Fixes issue 20183: gl journal is checked like posted when there is not lines.
authorIoritz Cia <ioritz.cia@openbravo.com>
Thu, 31 May 2012 17:35:55 +0200
changeset 16797 e1e23b382aa1
parent 16796 75bb6c439f80
child 16798 2b5a9e3d2afd
Fixes issue 20183: gl journal is checked like posted when there is not lines.
src-db/database/model/functions/GL_JOURNAL_POST.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/functions/GL_JOURNAL_POST.xml	Fri Jun 08 22:05:36 2012 +0200
+++ b/src-db/database/model/functions/GL_JOURNAL_POST.xml	Thu May 31 17:35:55 2012 +0200
@@ -22,7 +22,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SLU
-  * Contributions are Copyright (C) 2001-2011 Openbravo, S.L.U.
+  * Contributions are Copyright (C) 2012 Openbravo, S.L.U.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -58,11 +58,13 @@
     v_ControlAmt GL_Journal.ControlAmt%TYPE;
     FINISH_PROCESS BOOLEAN:=false;
     v_is_included NUMBER:=0;
+    v_has_lines NUMBER:=-1;
     v_available_period NUMBER:=0;
     v_is_ready AD_Org.IsReady%TYPE;
     v_is_tr_allow AD_OrgType.IsTransactionsAllowed%TYPE;
     v_isacctle AD_OrgType.IsAcctLegalEntity%TYPE;
     v_org_bule_id AD_Org.AD_Org_ID%TYPE;
+    v_documentNo GL_Journal.DocumentNo%TYPE;
     
   BEGIN
     --  Update AD_PInstance
@@ -203,6 +205,12 @@
       IF (v_is_tr_allow='N') THEN
         RAISE_APPLICATION_ERROR(-20000, '@OrgHeaderNotTransAllowed@');
       END IF;
+
+      -- Check if the gl journal has lines.
+      SELECT 1, documentNo INTO v_has_lines, v_documentNo FROM GL_Journal WHERE EXISTS (SELECT 1 FROM GL_JournalLine WHERE GL_JournalLine.GL_Journal_ID = v_Record_ID);
+      IF (v_has_lines=-1) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@GLJournalHasNoLines@' || ' ' || v_DocumentNo);
+      END IF;
       
       SELECT AD_ORG_CHK_DOCUMENTS('GL_JOURNAL', 'GL_JOURNALLINE', v_Record_ID, 'GL_JOURNAL_ID', 'GL_JOURNAL_ID') INTO v_is_included FROM dual;
       IF (v_is_included=-1) THEN
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jun 08 22:05:36 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Thu May 31 17:35:55 2012 +0200
@@ -19600,6 +19600,17 @@
 <!--CDC6BD44302C4CF2A44293957B34CB0F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--CDC6BD44302C4CF2A44293957B34CB0F--></AD_MESSAGE>
 
+<!--CE2380BA90DB49B682AF5B333EA8BFE9--><AD_MESSAGE>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <AD_MESSAGE_ID><![CDATA[CE2380BA90DB49B682AF5B333EA8BFE9]]></AD_MESSAGE_ID>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <VALUE><![CDATA[GLJournalHasNoLines]]></VALUE>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <MSGTEXT><![CDATA[G/L Journal cannot be processed/posted because it has no lines. Document no:]]></MSGTEXT>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--CE2380BA90DB49B682AF5B333EA8BFE9--></AD_MESSAGE>
+
 <!--CF72BCDFFF044C1D8007B907D8B64DF3--><AD_MESSAGE>
 <!--CF72BCDFFF044C1D8007B907D8B64DF3-->  <AD_MESSAGE_ID><![CDATA[CF72BCDFFF044C1D8007B907D8B64DF3]]></AD_MESSAGE_ID>
 <!--CF72BCDFFF044C1D8007B907D8B64DF3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>