Fixes issue 25414, fixes issue 25415:
authorJavier Etxarri <javier.echarri@openbravo.com>
Tue, 31 Dec 2013 17:08:12 +0100
changeset 21737 fcb87e990fcd
parent 21736 9fe57239e6a9
child 21738 d2a6126e04e6
Fixes issue 25414, fixes issue 25415:
Wrong currency rate is applied when posting a GL Journal line
G/L Journal lines accounting amounts are not updated when changing the header rate
src-db/database/model/triggers/GL_JOURNALLINE2_TRG.xml
src-db/database/model/triggers/GL_JOURNALLINE_TRG.xml
src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
src-db/database/model/triggers/GL_JOURNAL_TRG.xml
src-db/database/sourcedata/AD_AUXILIARINPUT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
--- a/src-db/database/model/triggers/GL_JOURNALLINE2_TRG.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/model/triggers/GL_JOURNALLINE2_TRG.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -34,10 +34,9 @@
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
     END IF;
-
-
   IF(UPDATING) THEN
-    IF NOT((COALESCE(:old.AMTSOURCEDR, 0) <> COALESCE(:NEW.AMTSOURCEDR, 0) OR COALESCE(:old.AMTSOURCECR, 0) <> COALESCE(:NEW.AMTSOURCECR, 0) OR COALESCE(:old.C_CURRENCY_ID, '0') <> COALESCE(:NEW.C_CURRENCY_ID, '0'))) THEN
+    IF NOT((COALESCE(:old.AMTSOURCEDR, 0) <> COALESCE(:NEW.AMTSOURCEDR, 0) OR COALESCE(:old.AMTSOURCECR, 0) <> COALESCE(:NEW.AMTSOURCECR, 0) 
+            OR COALESCE(:old.C_CURRENCY_ID, '0') <> COALESCE(:NEW.C_CURRENCY_ID, '0') OR  COALESCE(:old.currencyrate, '0') <> COALESCE(:NEW.currencyrate, '0'))) THEN
       RETURN;
     END IF;
   END IF;
--- a/src-db/database/model/triggers/GL_JOURNALLINE_TRG.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/model/triggers/GL_JOURNALLINE_TRG.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -36,7 +36,7 @@
 
   --Check if it is necessary to substract old amount and add new amount when you are updating but not the currency (issue 24755)  
   IF(UPDATING) THEN
-    IF (:old.c_currency_id=:new.c_currency_id) THEN
+    IF (:old.c_currency_id=:new.c_currency_id and :old.currencyrate=:new.currencyrate) THEN
       IF(:old.IsActive='Y') THEN
         UPDATE GL_Journal
           SET TotalDr=TotalDr - :old.AmtSourceDr,
--- a/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -58,11 +58,7 @@
         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;    
     END IF;
     IF(DELETING) THEN
       IF(:old.Processed='Y') THEN
--- a/src-db/database/model/triggers/GL_JOURNAL_TRG.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/model/triggers/GL_JOURNAL_TRG.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -34,6 +34,12 @@
 
     -- Subtract Old Amount
     IF(UPDATING) THEN
+      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;
+      IF (:old.currencyrate <> :new.currencyrate) THEN
+        UPDATE gl_journalline SET currencyrate = :new.currencyrate where gl_journal_id = :old.gl_journal_id;
+      END IF;
       IF(:old.TotalDr <> :NEW.TotalDr OR :OLD.TotalCr <> :NEW.TotalCr) THEN  
       IF(:old.GL_JournalBatch_ID IS NOT NULL AND :old.IsActive='Y') THEN
 	  UPDATE GL_JournalBatch
--- a/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -2458,6 +2458,17 @@
 <!--9EC3A191A6D84253A26520E4849B73EF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--9EC3A191A6D84253A26520E4849B73EF--></AD_AUXILIARINPUT>
 
+<!--9F7DE5D4045A4391A93E1444C6D921C7--><AD_AUXILIARINPUT>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <AD_AUXILIARINPUT_ID><![CDATA[9F7DE5D4045A4391A93E1444C6D921C7]]></AD_AUXILIARINPUT_ID>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <AD_TAB_ID><![CDATA[160]]></AD_TAB_ID>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <NAME><![CDATA[generalLedgerCurrency]]></NAME>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <CODE><![CDATA[@SQL=select c_currency_id from C_AcctSchema where C_AcctSchema_id=@c_acctschema_id@]]></CODE>
+<!--9F7DE5D4045A4391A93E1444C6D921C7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--9F7DE5D4045A4391A93E1444C6D921C7--></AD_AUXILIARINPUT>
+
 <!--A00393E2985B483DA01D3442B182AF80--><AD_AUXILIARINPUT>
 <!--A00393E2985B483DA01D3442B182AF80-->  <AD_AUXILIARINPUT_ID><![CDATA[A00393E2985B483DA01D3442B182AF80]]></AD_AUXILIARINPUT_ID>
 <!--A00393E2985B483DA01D3442B182AF80-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -22676,6 +22676,7 @@
 <!--1632-->  <ISSESSIONATTR><![CDATA[Y]]></ISSESSIONATTR>
 <!--1632-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--1632-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--1632-->  <AD_CALLOUT_ID><![CDATA[134]]></AD_CALLOUT_ID>
 <!--1632-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--1632-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1632-->  <POSITION><![CDATA[13]]></POSITION>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Fri Dec 27 14:31:41 2013 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Tue Dec 31 17:08:12 2013 +0100
@@ -11041,7 +11041,7 @@
 <!--883-->  <AD_COLUMN_ID><![CDATA[1792]]></AD_COLUMN_ID>
 <!--883-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--883-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--883-->  <DISPLAYLOGIC><![CDATA[@C_Currency_ID@!@batchCurrency@]]></DISPLAYLOGIC>
+<!--883-->  <DISPLAYLOGIC><![CDATA[@C_Currency_ID@!@generalLedgerCurrency@]]></DISPLAYLOGIC>
 <!--883-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--883-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--883-->  <SEQNO><![CDATA[100]]></SEQNO>