src-db/database/model/triggers/C_INVOICELINE_TRG4.xml
changeset 6475 35dc05a84c8b
parent 6474 4e03817a571b
child 6701 690d2af86089
equal deleted inserted replaced
6474:4e03817a571b 6475:35dc05a84c8b
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="TRIGGER C_INVOICELINE_TRG4">
     2   <database name="TRIGGER C_INVOICELINE_TRG4">
     3     <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="true" foreach="row">
     3     <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="false" foreach="row">
     4       <body><![CDATA[
     4       <body><![CDATA[
     5   /*************************************************************************
     5   /*************************************************************************
     6   * The contents of this file are subject to the Openbravo  Public  License
     6   * The contents of this file are subject to the Openbravo  Public  License
     7   * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
     7   * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
     8   * Version 1.1  with a permitted attribution clause; you may not  use this
     8   * Version 1.1  with a permitted attribution clause; you may not  use this
    16   * The Initial Developer of the Original Code is Openbravo SL
    16   * The Initial Developer of the Original Code is Openbravo SL
    17   * All portions are Copyright (C) 2010 Openbravo SL
    17   * All portions are Copyright (C) 2010 Openbravo SL
    18   * All Rights Reserved.
    18   * All Rights Reserved.
    19   * Contributor(s):  ______________________________________.
    19   * Contributor(s):  ______________________________________.
    20   ************************************************************************/
    20   ************************************************************************/
    21   V_RATE NUMBER;
       
    22   V_PRECISION NUMBER;
    21   V_PRECISION NUMBER;
    23 BEGIN
    22 BEGIN
    24 
    23 
    25   IF AD_isTriggerEnabled()='N' THEN RETURN;
    24   IF AD_isTriggerEnabled()='N' THEN RETURN;
    26   END IF;
    25   END IF;
    27 
    26 
    28   SELECT T.RATE INTO V_RATE FROM C_TAX T 
       
    29   WHERE T.C_TAX_ID=:NEW.C_TAX_ID;
       
    30 
       
    31   SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
       
    32   WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
       
    33   AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
       
    34 
       
    35   IF(INSERTING OR UPDATING) THEN
    27   IF(INSERTING OR UPDATING) THEN
       
    28     SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
       
    29     WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
       
    30     AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
       
    31  
    36     IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
    32     IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
    37       RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
    33       RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
    38     END IF;
    34     END IF;
    39   END IF;
    35   END IF;
    40   END C_INVOICELINE_TRG4]]></body>
    36   END C_INVOICELINE_TRG4
       
    37 ]]></body>
    41     </trigger>
    38     </trigger>
    42   </database>
    39   </database>