Fixed bug 9325. The invoices without lines are not posted.
authorAreef Basha <areef.basha@openbravo.com>
Fri, 26 Jun 2009 11:06:39 +0530
changeset 4067 c514d884966b
parent 4066 61cc1788805c
child 4068 ed12d262cab5
Fixed bug 9325. The invoices without lines are not posted.
Now the invoice has been made to complete only if it has line(s).
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Fri Jun 26 00:12:18 2009 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Fri Jun 26 11:06:39 2009 +0530
@@ -100,6 +100,7 @@
     v_RDocumentNo C_INVOICE.DocumentNo%TYPE;
     v_NextNo VARCHAR2(32);
     v_count NUMBER;
+    V_InvoiceLines_count NUMBER;
     v_AD_Org_ID VARCHAR2(32);
     v_POReference NVARCHAR2(40) ;
     --
@@ -221,6 +222,27 @@
     IF(v_DocStatus IN('VO', 'CL', 'RE')) THEN
       RAISE_APPLICATION_ERROR(-20000, '@AlreadyPosted@');
     END IF;
+    --Allow to complete an invoice only in these cases:
+    --* There are invoice lines
+    --* There are tax lines
+    --* There are both invoice and tax lines 
+    IF((v_DocStatus='DR' AND v_DocAction='CO')
+       OR (v_DocStatus='CO' AND v_DocAction='RE')) THEN
+          SELECT COUNT(*)
+          INTO V_InvoiceLines_count
+          FROM C_INVOICE
+          WHERE C_INVOICE_ID=v_Record_ID 
+          AND (EXISTS (SELECT 1
+                        FROM C_INVOICELINE
+                       WHERE C_INVOICE_ID=v_Record_ID)
+          OR EXISTS (SELECT 1
+                           FROM C_INVOICETAX
+                          WHERE C_INVOICE_ID=v_Record_ID));
+
+          IF V_InvoiceLines_count=0 THEN
+            RAISE_APPLICATION_ERROR(-20000, '@InvoicesNeedLines@');
+          END IF;
+    END IF;    
     IF(NOT FINISH_PROCESS) THEN
       /**
       * Unlock
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jun 26 00:12:18 2009 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jun 26 11:06:39 2009 +0530
@@ -63636,6 +63636,17 @@
 <!--467F2D9DFA8E4254B205D872DC75193C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--467F2D9DFA8E4254B205D872DC75193C--></AD_MESSAGE>
 
+<!--47409688AF1E4A698F396E8FFCF01CBE--><AD_MESSAGE>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <AD_MESSAGE_ID><![CDATA[47409688AF1E4A698F396E8FFCF01CBE]]></AD_MESSAGE_ID>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <VALUE><![CDATA[InvoicesNeedLines]]></VALUE>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <MSGTEXT><![CDATA[Invoices need product lines or tax lines to be completed]]></MSGTEXT>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--47409688AF1E4A698F396E8FFCF01CBE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--47409688AF1E4A698F396E8FFCF01CBE--></AD_MESSAGE>
+
 <!--4D4E566D206546908DB84B065999789C--><AD_MESSAGE>
 <!--4D4E566D206546908DB84B065999789C-->  <AD_MESSAGE_ID><![CDATA[4D4E566D206546908DB84B065999789C]]></AD_MESSAGE_ID>
 <!--4D4E566D206546908DB84B065999789C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>