Issue 12366: Recoded triggers to pass the JUnit tests
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Tue, 23 Feb 2010 17:50:44 +0100
changeset 6516 35dc05a84c8b
parent 6515 4e03817a571b
child 6517 efdbe4e29619
Issue 12366: Recoded triggers to pass the JUnit tests
src-db/database/model/triggers/C_INVOICELINE_TRG4.xml
src-db/database/model/triggers/C_ORDERLINE_TRG3.xml
--- a/src-db/database/model/triggers/C_INVOICELINE_TRG4.xml	Tue Feb 23 15:21:06 2010 +0100
+++ b/src-db/database/model/triggers/C_INVOICELINE_TRG4.xml	Tue Feb 23 17:50:44 2010 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
   <database name="TRIGGER C_INVOICELINE_TRG4">
-    <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="true" foreach="row">
+    <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="false" foreach="row">
       <body><![CDATA[
   /*************************************************************************
   * The contents of this file are subject to the Openbravo  Public  License
@@ -18,25 +18,22 @@
   * All Rights Reserved.
   * Contributor(s):  ______________________________________.
   ************************************************************************/
-  V_RATE NUMBER;
   V_PRECISION NUMBER;
 BEGIN
 
   IF AD_isTriggerEnabled()='N' THEN RETURN;
   END IF;
 
-  SELECT T.RATE INTO V_RATE FROM C_TAX T 
-  WHERE T.C_TAX_ID=:NEW.C_TAX_ID;
-
-  SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
-  WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
-  AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
-
   IF(INSERTING OR UPDATING) THEN
+    SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
+    WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
+    AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
+ 
     IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
       RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
     END IF;
   END IF;
-  END C_INVOICELINE_TRG4]]></body>
+  END C_INVOICELINE_TRG4
+]]></body>
     </trigger>
   </database>
--- a/src-db/database/model/triggers/C_ORDERLINE_TRG3.xml	Tue Feb 23 15:21:06 2010 +0100
+++ b/src-db/database/model/triggers/C_ORDERLINE_TRG3.xml	Tue Feb 23 17:50:44 2010 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
   <database name="TRIGGER C_ORDERLINE_TRG3">
-    <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="true" foreach="row">
+    <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
       <body><![CDATA[
 
 /*************************************************************************
@@ -19,24 +19,20 @@
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
-  V_RATE NUMBER;
   V_PRECISION NUMBER;
 BEGIN
   IF AD_isTriggerEnabled()='N' THEN RETURN;
   END IF;
 
-  SELECT T.RATE INTO V_RATE FROM C_TAX T 
-  WHERE T.C_TAX_ID=:NEW.C_TAX_ID;
-
-  SELECT C.STDPRECISION INTO V_PRECISION FROM C_CURRENCY C
-  WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
-
   IF(INSERTING OR UPDATING) THEN
+    SELECT C.STDPRECISION INTO V_PRECISION FROM C_CURRENCY C
+    WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
+  
     IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
       RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
     END IF;
   END IF;
   END C_ORDERLINE_TRG3
-  ]]></body>
+]]></body>
     </trigger>
   </database>