Fixes Issue 39895: Simple G/L Journal line can be removed although
authoratul.gaware@openbravo.com <atul.gaware@openbravo.com>
Fri, 11 Jan 2019 18:18:40 +0530
changeset 35312 5aff6a4a578c
parent 35311 76e291866ae6
child 35313 b4c3e3431595
Fixes Issue 39895: Simple G/L Journal line can be removed although
it has related payment. Payment can be deleted although the journal
is processed

** Before deleting gj journal line check is done for linked payment
if payment is linked error message is shown else line can be deleted.
** Before reactivating payment check is whether it is linked with gl
journal line having processed flag = yes in its header gl journal.
modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_PMT_CHECK_TRG.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/model/triggers/GL_JL_CHK_RESTRICTIONS_TRG.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_PMT_CHECK_TRG.xml	Mon Jan 14 13:23:02 2019 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_PMT_CHECK_TRG.xml	Fri Jan 11 18:18:40 2019 +0530
@@ -15,12 +15,13 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2010-2016 Openbravo SLU
+* All portions are Copyright (C) 2010-2019 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 *************************************************************************/
 
 v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY');
+v_Count NUMBER:=0;
   
 BEGIN
    
@@ -51,6 +52,17 @@
       )) THEN
       RAISE_APPLICATION_ERROR(-20000, '@20501@');
     END IF;
+    IF(:OLD.PROCESSED='Y' AND :NEW.PROCESSED='N') THEN
+      SELECT COUNT(*)
+      INTO v_Count
+      FROM GL_JOURNALLINE
+      JOIN GL_JOURNAL ON GL_JOURNALLINE.GL_JOURNAL_ID = GL_JOURNAL.GL_JOURNAL_ID
+      WHERE GL_JOURNALLINE.FIN_PAYMENT_ID = :OLD.FIN_PAYMENT_ID
+      AND GL_JOURNAL.PROCESSED = 'Y';
+      IF(v_Count > 0) THEN
+        RAISE_APPLICATION_ERROR(-20000,'@APRM_ReactivatePaymentInGLJournalLine@');
+      END IF;
+    END IF;
   END IF;
   IF(INSERTING) THEN
    IF(:NEW.PROCESSED='Y') THEN
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Jan 14 13:23:02 2019 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jan 11 18:18:40 2019 +0530
@@ -1321,6 +1321,18 @@
 <!--C6F7E24F731242D49A73C8C1A835A252-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--C6F7E24F731242D49A73C8C1A835A252--></AD_MESSAGE>
 
+<!--C9AB6E0AB571407E89EBB4BF2A56188A--><AD_MESSAGE>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <AD_MESSAGE_ID><![CDATA[C9AB6E0AB571407E89EBB4BF2A56188A]]></AD_MESSAGE_ID>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <VALUE><![CDATA[APRM_ReactivatePaymentInGLJournalLine]]></VALUE>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <MSGTEXT><![CDATA[To reactivate the payment, Unpost and unprocess G/L Journal of the G/L Journal Line in which payment is linked.]]></MSGTEXT>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--C9AB6E0AB571407E89EBB4BF2A56188A--></AD_MESSAGE>
+
 <!--CAB70EC8598D40E0BFFD7F0FB8538080--><AD_MESSAGE>
 <!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_MESSAGE_ID><![CDATA[CAB70EC8598D40E0BFFD7F0FB8538080]]></AD_MESSAGE_ID>
 <!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/model/triggers/GL_JL_CHK_RESTRICTIONS_TRG.xml	Mon Jan 14 13:23:02 2019 +0100
+++ b/src-db/database/model/triggers/GL_JL_CHK_RESTRICTIONS_TRG.xml	Fri Jan 11 18:18:40 2019 +0530
@@ -19,7 +19,7 @@
     * under the License.
     * The Original Code is Openbravo ERP.
     * The Initial Developer of the Original Code is Openbravo SLU
-    * All portions are Copyright (C) 2001-2016 Openbravo SLU
+    * All portions are Copyright (C) 2001-2019 Openbravo SLU
     * All Rights Reserved.
     * Contributor(s):  ______________________________________.
     ************************************************************************/
@@ -82,6 +82,9 @@
     IF (v_Processed='Y') THEN
       RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
     END IF;
+    IF (:OLD.FIN_PAYMENT_ID IS NOT NULL) THEN
+      RAISE_APPLICATION_ERROR(-20000,'@DeleteGLJournalLine@');
+    END IF;
   END IF;
   IF(INSERTING) THEN
     SELECT PROCESSED,
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Jan 14 13:23:02 2019 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jan 11 18:18:40 2019 +0530
@@ -27284,6 +27284,18 @@
 <!--E2670BE243274B3CBAF627D17B0696D9-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--E2670BE243274B3CBAF627D17B0696D9--></AD_MESSAGE>
 
+<!--E26DEB9F99AE45948821C6A178C4FCD8--><AD_MESSAGE>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <AD_MESSAGE_ID><![CDATA[E26DEB9F99AE45948821C6A178C4FCD8]]></AD_MESSAGE_ID>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <VALUE><![CDATA[DeleteGLJournalLine]]></VALUE>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <MSGTEXT><![CDATA[If you want to delete G/L Journal Line, you must first reactivate and delete its related payment.]]></MSGTEXT>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E26DEB9F99AE45948821C6A178C4FCD8-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--E26DEB9F99AE45948821C6A178C4FCD8--></AD_MESSAGE>
+
 <!--E27550B361614883A233DEE26B471747--><AD_MESSAGE>
 <!--E27550B361614883A233DEE26B471747-->  <AD_MESSAGE_ID><![CDATA[E27550B361614883A233DEE26B471747]]></AD_MESSAGE_ID>
 <!--E27550B361614883A233DEE26B471747-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>