src-db/database/model/triggers/C_ORDERLINE_TRG3.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_ORDERLINE_TRG3">
     2   <database name="TRIGGER C_ORDERLINE_TRG3">
     3     <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="true" foreach="row">
     3     <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
     4       <body><![CDATA[
     4       <body><![CDATA[
     5 
     5 
     6 /*************************************************************************
     6 /*************************************************************************
     7 * The contents of this file are subject to the Openbravo  Public  License
     7 * The contents of this file are subject to the Openbravo  Public  License
     8 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
     8 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
    17 * The Initial Developer of the Original Code is Openbravo SL
    17 * The Initial Developer of the Original Code is Openbravo SL
    18 * All portions are Copyright (C) 2010 Openbravo SL
    18 * All portions are Copyright (C) 2010 Openbravo SL
    19 * All Rights Reserved.
    19 * All Rights Reserved.
    20 * Contributor(s):  ______________________________________.
    20 * Contributor(s):  ______________________________________.
    21 ************************************************************************/
    21 ************************************************************************/
    22   V_RATE NUMBER;
       
    23   V_PRECISION NUMBER;
    22   V_PRECISION NUMBER;
    24 BEGIN
    23 BEGIN
    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_CURRENCY C
       
    32   WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
       
    33 
       
    34   IF(INSERTING OR UPDATING) THEN
    27   IF(INSERTING OR UPDATING) THEN
       
    28     SELECT C.STDPRECISION INTO V_PRECISION FROM C_CURRENCY C
       
    29     WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
       
    30   
    35     IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
    31     IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
    36       RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
    32       RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
    37     END IF;
    33     END IF;
    38   END IF;
    34   END IF;
    39   END C_ORDERLINE_TRG3
    35   END C_ORDERLINE_TRG3
    40   ]]></body>
    36 ]]></body>
    41     </trigger>
    37     </trigger>
    42   </database>
    38   </database>