src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
changeset 21682 337545057885
parent 18880 aa594e52b24d
child 21737 fcb87e990fcd
--- a/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Fri Dec 20 11:02:21 2013 +0100
+++ b/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Fri Dec 20 13:03:18 2013 +0100
@@ -31,47 +31,50 @@
     END IF;
 
 
-    IF UPDATING
-    THEN  IF(:old.Processed='Y'
-    AND ((COALESCE(:old.DATEDOC, v_DateNull) <> COALESCE(:new.DATEDOC, v_DateNull))
-    OR(COALESCE(:old.C_PERIOD_ID, '0') <> COALESCE(:new.C_PERIOD_ID, '0'))
-    OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
-    OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
-    OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))
-    OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
-    OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0'))))
-    THEN  RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    IF UPDATING THEN  
+      IF(:old.Processed='Y'
+        AND ((COALESCE(:old.DATEDOC, v_DateNull) <> COALESCE(:new.DATEDOC, v_DateNull))
+        OR(COALESCE(:old.C_PERIOD_ID, '0') <> COALESCE(:new.C_PERIOD_ID, '0'))
+        OR(COALESCE(:old.CURRENCYRATE, 0) <> COALESCE(:new.CURRENCYRATE, 0))
+        OR(COALESCE(:old.CURRENCYRATETYPE, '.') <> COALESCE(:new.CURRENCYRATETYPE, '.'))
+        OR(COALESCE(:old.CONTROLAMT, 0) <> COALESCE(:new.CONTROLAMT, 0))
+        OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
+        OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0'))))
+        THEN  RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+      END IF;
+    
+      IF(:old.Posted='Y' 
+        AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull)) 
+        OR(COALESCE(:old.C_ACCTSCHEMA_ID, '0') <> COALESCE(:new.C_ACCTSCHEMA_ID, '0')) 
+        OR(COALESCE(:old.GL_CATEGORY_ID, '0') <> COALESCE(:new.GL_CATEGORY_ID, '0')) 
+        OR(COALESCE(:old.POSTINGTYPE, '.') <> COALESCE(:new.POSTINGTYPE, '.'))
+        OR(COALESCE(:OLD.User1_ID, '0') <> COALESCE(:NEW.User1_ID, '0'))
+        OR(COALESCE(:OLD.User2_ID, '0') <> COALESCE(:NEW.User2_ID, '0'))
+        OR(COALESCE(:OLD.C_Campaign_ID, '0') <> COALESCE(:NEW.C_Campaign_ID, '0'))
+        OR(COALESCE(:OLD.C_Project_ID, '0') <> COALESCE(:NEW.C_Project_ID, '0'))
+        OR(COALESCE(:OLD.A_Asset_ID, '0') <> COALESCE(:NEW.A_Asset_ID, '0'))
+        OR(COALESCE(:OLD.C_Costcenter_ID, '0') <> COALESCE(:NEW.C_Costcenter_ID, '0'))
+        OR(COALESCE(:OLD.C_BPartner_ID, '0') <> COALESCE(:NEW.C_BPartner_ID, '0'))
+        OR(COALESCE(:OLD.M_Product_ID, '0') <> COALESCE(:NEW.M_Product_ID, '0'))
+        )) 
+        THEN RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+      END IF;
+    
+      IF (:old.c_currency_id <> :new.c_currency_id) THEN
+        UPDATE gl_journalline SET c_currency_id = :new.c_currency_id where gl_journal_id = :old.gl_journal_id;
+      END IF;
     END IF;
-    
-    IF(:old.Posted='Y' 
-      AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull)) 
-      OR(COALESCE(:old.C_ACCTSCHEMA_ID, '0') <> COALESCE(:new.C_ACCTSCHEMA_ID, '0')) 
-      OR(COALESCE(:old.GL_CATEGORY_ID, '0') <> COALESCE(:new.GL_CATEGORY_ID, '0')) 
-      OR(COALESCE(:old.POSTINGTYPE, '.') <> COALESCE(:new.POSTINGTYPE, '.'))
-      OR(COALESCE(:OLD.User1_ID, '0') <> COALESCE(:NEW.User1_ID, '0'))
-      OR(COALESCE(:OLD.User2_ID, '0') <> COALESCE(:NEW.User2_ID, '0'))
-      OR(COALESCE(:OLD.C_Campaign_ID, '0') <> COALESCE(:NEW.C_Campaign_ID, '0'))
-      OR(COALESCE(:OLD.C_Project_ID, '0') <> COALESCE(:NEW.C_Project_ID, '0'))
-      OR(COALESCE(:OLD.A_Asset_ID, '0') <> COALESCE(:NEW.A_Asset_ID, '0'))
-      OR(COALESCE(:OLD.C_Costcenter_ID, '0') <> COALESCE(:NEW.C_Costcenter_ID, '0'))
-      OR(COALESCE(:OLD.C_BPartner_ID, '0') <> COALESCE(:NEW.C_BPartner_ID, '0'))
-      OR(COALESCE(:OLD.M_Product_ID, '0') <> COALESCE(:NEW.M_Product_ID, '0'))
-      )) 
-    THEN
-      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    IF(DELETING) THEN
+      IF(:old.Processed='Y') THEN
+        RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+      END IF;
     END IF;
- END IF;
- IF(DELETING) THEN
-  IF(:old.Processed='Y') THEN
-    RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
-  END IF;
- END IF;
- IF(INSERTING) THEN
-  IF(:NEW.Processed='Y') THEN
-    RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
-  END IF;
- END IF;
-END GL_JOURNAL_CHK_RESTRICT_TRG
+    IF(INSERTING) THEN
+      IF(:NEW.Processed='Y') THEN
+        RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+      END IF;
+    END IF;
+    END GL_JOURNAL_CHK_RESTRICT_TRG
 ]]></body>
     </trigger>
   </database>