src-db/database/model/triggers/C_CASH_CHK_RESTRICTIONS_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 756 ae11e4610537
child 1605 8a0fe0193bef
permissions -rw-r--r--
Fix last update of copyright years in database files
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER C_CASH_CHK_RESTRICTIONS_TRG">
adrian@94
     3
    <trigger name="C_CASH_CHK_RESTRICTIONS_TRG" table="C_CASH" fires="before" insert="true" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
gorka@401
     9
adrian@94
    10
    /*************************************************************************
adrian@94
    11
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
    12
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    13
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    14
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    15
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    16
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    17
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    18
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    19
    * under the License.
adrian@94
    20
    * The Original Code is Openbravo ERP.
adrian@94
    21
    * The Initial Developer of the Original Code is Openbravo SL
adrian@94
    22
    * All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    23
    * All Rights Reserved.
adrian@94
    24
    * Contributor(s):  ______________________________________.
adrian@94
    25
    ************************************************************************/
gorkaion@280
    26
    v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY');
adrian@94
    27
    BEGIN  IF UPDATING
gorka@401
    28
      THEN  IF(:old.Processed='Y'
gorka@401
    29
        AND ((COALESCE(:old.STATEMENTDATE, v_DateNull) <> COALESCE(:new.STATEMENTDATE, v_DateNull))
gorka@401
    30
        OR(COALESCE(:old.AD_ORGTRX_ID, 0) <> COALESCE(:new.AD_ORGTRX_ID, 0))
gorka@401
    31
        OR(COALESCE(:old.USER1_ID, 0) <> COALESCE(:new.USER1_ID, 0))
gorka@401
    32
        OR(COALESCE(:old.USER2_ID, 0) <> COALESCE(:new.USER2_ID, 0))
gorka@401
    33
        OR(COALESCE(:old.AD_ORG_ID, 0) <> COALESCE(:new.AD_ORG_ID, 0))
antonio@737
    34
        OR(COALESCE(:old.AD_CLIENT_ID, 0) <> COALESCE(:new.AD_CLIENT_ID, 0)))) THEN
gorka@401
    35
          RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
gorka@401
    36
      END IF;
antonio@737
    37
      IF(:old.Posted='Y'
gorka@401
    38
        AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull))
gorka@401
    39
        OR(COALESCE(:old.C_CAMPAIGN_ID, 0) <> COALESCE(:new.C_CAMPAIGN_ID, 0))
gorka@401
    40
        OR(COALESCE(:old.C_PROJECT_ID, 0) <> COALESCE(:new.C_PROJECT_ID, 0))
gorka@401
    41
        OR(COALESCE(:old.C_ACTIVITY_ID, 0) <> COALESCE(:new.C_ACTIVITY_ID, 0)))) THEN
gorka@401
    42
          RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
gorka@401
    43
      END IF;
gorka@401
    44
    END IF;
antonio@737
    45
gorka@401
    46
   IF(DELETING) THEN
gorka@401
    47
    IF(:old.Processed='Y') THEN
gorka@401
    48
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
gorka@401
    49
    END IF;
gorka@401
    50
   END IF;
gorka@401
    51
   IF(INSERTING) THEN
gorka@401
    52
    IF(:NEW.Processed='Y') THEN
gorka@401
    53
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
gorka@401
    54
    END IF;
gorka@401
    55
   END IF;
antonio@735
    56
  END C_CASH_CHK_RESTRICTIONS_TRG
gorkaion@239
    57
]]></body>
adrian@94
    58
    </trigger>
adrian@94
    59
  </database>