modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_PMT_CHECK_TRG.xml
changeset 9076 c4f1a5c7d7c2
child 12911 195b478bc8df
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER APRM_FIN_PMT_CHECK_TRG">
       
     3     <trigger name="APRM_FIN_PMT_CHECK_TRG" table="FIN_PAYMENT" fires="before" insert="true" update="true" delete="true" foreach="row">
       
     4       <body><![CDATA[
       
     5 
       
     6 /************************************************************************
       
     7 * The contents of this file are subject to the Openbravo  Public  License
       
     8 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
       
     9 * Version 1.1  with a permitted attribution clause; you may not  use this
       
    10 * file except in compliance with the License. You  may  obtain  a copy of
       
    11 * the License at http://www.openbravo.com/legal/license.html
       
    12 * Software distributed under the License  is  distributed  on  an "AS IS"
       
    13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
       
    14 * License for the specific  language  governing  rights  and  limitations
       
    15 * under the License.
       
    16 * The Original Code is Openbravo ERP.
       
    17 * The Initial Developer of the Original Code is Openbravo SLU
       
    18 * All portions are Copyright (C) 2010 Openbravo SLU
       
    19 * All Rights Reserved.
       
    20 * Contributor(s):  ______________________________________.
       
    21 *************************************************************************/
       
    22 
       
    23 v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY');
       
    24   
       
    25 BEGIN
       
    26    
       
    27   IF AD_isTriggerEnabled()='N' THEN RETURN;
       
    28   END IF;
       
    29 
       
    30   IF (UPDATING) THEN
       
    31     IF(:OLD.PROCESSED='Y' AND ((COALESCE(:OLD.AD_ORG_ID, '0') <> COALESCE(:NEW.AD_ORG_ID, '0'))
       
    32       OR(COALESCE(:OLD.DOCUMENTNO, '0') <> COALESCE(:NEW.DOCUMENTNO, '0'))
       
    33       OR(COALESCE(:OLD.C_CURRENCY_ID, '0') <> COALESCE(:NEW.C_CURRENCY_ID, '0'))
       
    34       OR(COALESCE(:OLD.C_BPARTNER_ID, '0') <> COALESCE(:NEW.C_BPARTNER_ID, '0'))
       
    35       OR(COALESCE(:OLD.FIN_PAYMENTMETHOD_ID, '0') <> COALESCE(:NEW.FIN_PAYMENTMETHOD_ID, '0'))
       
    36       OR(COALESCE(:OLD.FIN_FINANCIAL_ACCOUNT_ID, '0') <> COALESCE(:NEW.FIN_FINANCIAL_ACCOUNT_ID, '0'))
       
    37       OR(COALESCE(:OLD.AMOUNT, 0) <> COALESCE(:NEW.AMOUNT, 0))
       
    38       OR(COALESCE(:OLD.WRITEOFFAMT, 0) <> COALESCE(:NEW.WRITEOFFAMT, 0))
       
    39       OR(COALESCE(:OLD.PAYMENTDATE, v_DateNull) <> COALESCE(:NEW.PAYMENTDATE, v_DateNull)))) THEN
       
    40       RAISE_APPLICATION_ERROR(-20000, '@20501@');
       
    41     END IF;
       
    42   END IF;
       
    43   IF(INSERTING) THEN
       
    44    IF(:NEW.PROCESSED='Y') THEN
       
    45      RAISE_APPLICATION_ERROR(-20000, '@20501@');
       
    46    END IF;
       
    47   END IF;
       
    48   IF(DELETING) THEN
       
    49    IF(:OLD.PROCESSED='Y') THEN
       
    50      RAISE_APPLICATION_ERROR(-20000, '@20501@');
       
    51    END IF;
       
    52   END IF;
       
    53 END APRM_FIN_PMT_CHECK_TRG
       
    54 ]]></body>
       
    55     </trigger>
       
    56   </database>