Fixes Issue 26542: Currency conversion can be deleted although it is used
authorAtul Gaware <atul.gaware@openbravo.com>
Wed, 30 Jul 2014 13:40:16 +0530
changeset 24138 67abd792f3d3
parent 24137 bb28d03a69b5
child 24139 a496e0ae760c
Fixes Issue 26542: Currency conversion can be deleted although it is used
when posting a document
src-db/database/model/triggers/C_CONVERSION_RATE_TRG.xml
--- a/src-db/database/model/triggers/C_CONVERSION_RATE_TRG.xml	Wed Jul 30 09:35:31 2014 +0200
+++ b/src-db/database/model/triggers/C_CONVERSION_RATE_TRG.xml	Wed Jul 30 13:40:16 2014 +0530
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
   <database name="TRIGGER C_CONVERSION_RATE_TRG">
-    <trigger name="C_CONVERSION_RATE_TRG" table="C_CONVERSION_RATE" fires="before" insert="true" update="true" delete="false" foreach="row">
+    <trigger name="C_CONVERSION_RATE_TRG" table="C_CONVERSION_RATE" fires="before" insert="true" update="true" delete="true" foreach="row">
       <body><![CDATA[
     /*************************************************************************
     * The contents of this file are subject to the Compiere Public
@@ -17,7 +17,7 @@
     * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
     * All Rights Reserved.
     * Contributor(s): Openbravo SLU
-    * Contributions are Copyright (C) 2001-2012 Openbravo, S.L.U.
+    * Contributions are Copyright (C) 2001-2014 Openbravo, S.L.U.
     *
     * Specifically, this derivative work is based upon the following Compiere
     * file and version.
@@ -35,15 +35,16 @@
     IF AD_isTriggerEnabled()='N' THEN RETURN;
     END IF;
 
-
-  --RAISE_APPLICATION_ERROR (-20000, '@20506@');
-  IF(:new.ValidTo IS NULL) THEN
-    -- If there is no end date, set it to X
-      :new.ValidTo:=TO_DATE('31-12-9999', 'DD-MM-YYYY') ;
-  END IF;
-  --Check for invalid dates
-  IF :new.ValidTo < :new.ValidFrom THEN
-    RAISE_APPLICATION_ERROR(-20000, '@20505@');
+  IF (INSERTING OR UPDATING) THEN
+	  --RAISE_APPLICATION_ERROR (-20000, '@20506@');
+	  IF(:new.ValidTo IS NULL) THEN
+	    -- If there is no end date, set it to X
+	      :new.ValidTo:=TO_DATE('31-12-9999', 'DD-MM-YYYY') ;
+	  END IF;
+	  --Check for invalid dates
+	  IF :new.ValidTo < :new.ValidFrom THEN
+	    RAISE_APPLICATION_ERROR(-20000, '@20505@');
+	  END IF;
   END IF;
 
   IF UPDATING THEN