Fixes issue 12857: It is possible to generate an invoice with a Transaction Document disabled
authorSivaraman Rajagopal <sivaraman.rajagopal@openbravo.com>
Fri, 23 Apr 2010 15:50:49 +0530
changeset 7125 f416696344a6
parent 7124 919cfa2a9e68
child 7126 aeacb7e398a6
Fixes issue 12857: It is possible to generate an invoice with a Transaction Document disabled
src-db/database/model/functions/C_INVOICE_CREATE.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/erpCommon/ad_forms/GenerateInvoicesmanual.java
--- a/src-db/database/model/functions/C_INVOICE_CREATE.xml	Fri Apr 23 15:40:23 2010 +0530
+++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml	Fri Apr 23 15:50:49 2010 +0530
@@ -372,6 +372,7 @@
               * Create Invoice Header ---------------------------------------
               */
               -- Get Order DocType Info - approved from Invoice DocType
+              BEGIN
               v_ResultStr:='GetDocTypeInfo - ' || Cur_Order.C_DocType_ID;  SELECT od.C_DocTypeInvoice_ID,
                 od.DocSubTypeSO
               INTO v_DocType_ID,
@@ -379,7 +380,12 @@
               FROM C_DOCTYPE od,
                 C_DOCTYPE ID
               WHERE od.C_DocType_ID=Cur_Order.C_DocType_ID
-                AND od.C_DocTypeInvoice_ID=ID.C_DocType_ID;
+                AND od.C_DocTypeInvoice_ID=ID.C_DocType_ID
+                AND ID.IsActive='Y';
+              EXCEPTION
+              WHEN OTHERS THEN
+                RAISE_APPLICATION_ERROR(-20000, '@NoDocumentTypeFound@') ;
+              END;
               --
               Ad_Sequence_Next('C_Invoice', Cur_Order.AD_Client_ID, p_Invoice_ID) ;
               Ad_Sequence_Doctype(v_DocType_ID, Cur_Order.AD_Client_ID, 'Y', v_DocumentNo) ;
@@ -890,6 +896,7 @@
                     RAISE_APPLICATION_ERROR(-20000, '@NoDefaultInvoice@') ;
                   END;
                 ELSE
+                  BEGIN
                   SELECT od.C_DocTypeInvoice_ID
                   INTO v_DocType_ID
                   FROM C_DOCTYPE od,
@@ -897,7 +904,12 @@
                     C_ORDER o
                   WHERE od.C_DocType_ID=o.C_DocType_ID
                     AND od.C_DocTypeInvoice_ID=ID.C_DocType_ID
-                    AND o.C_Order_ID=Cur_InvoiceSchedule.C_Order_ID;
+                    AND o.C_Order_ID=Cur_InvoiceSchedule.C_Order_ID
+                    AND ID.IsActive='Y';
+                  EXCEPTION
+                  WHEN OTHERS THEN
+                    RAISE_APPLICATION_ERROR(-20000, '@NoDocumentTypeFound@') ;
+                  END;
                 END IF;
                 IF(NOT FINISH_PROCESS) THEN
                   -- Get other defaults
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Apr 23 15:40:23 2010 +0530
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Apr 23 15:50:49 2010 +0530
@@ -30783,6 +30783,17 @@
 <!--51AF5F10036A4B14A54EC2DF10A94B7C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--51AF5F10036A4B14A54EC2DF10A94B7C--></AD_MESSAGE>
 
+<!--5383FDEB68134637A9344226B026533A--><AD_MESSAGE>
+<!--5383FDEB68134637A9344226B026533A-->  <AD_MESSAGE_ID><![CDATA[5383FDEB68134637A9344226B026533A]]></AD_MESSAGE_ID>
+<!--5383FDEB68134637A9344226B026533A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5383FDEB68134637A9344226B026533A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5383FDEB68134637A9344226B026533A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5383FDEB68134637A9344226B026533A-->  <VALUE><![CDATA[NoDocumentTypeFound]]></VALUE>
+<!--5383FDEB68134637A9344226B026533A-->  <MSGTEXT><![CDATA[No document type found for invoice]]></MSGTEXT>
+<!--5383FDEB68134637A9344226B026533A-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--5383FDEB68134637A9344226B026533A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--5383FDEB68134637A9344226B026533A--></AD_MESSAGE>
+
 <!--548069F5D9E04ECF80B3EA2EA7218036--><AD_MESSAGE>
 <!--548069F5D9E04ECF80B3EA2EA7218036-->  <AD_MESSAGE_ID><![CDATA[548069F5D9E04ECF80B3EA2EA7218036]]></AD_MESSAGE_ID>
 <!--548069F5D9E04ECF80B3EA2EA7218036-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_forms/GenerateInvoicesmanual.java	Fri Apr 23 15:40:23 2010 +0530
+++ b/src/org/openbravo/erpCommon/ad_forms/GenerateInvoicesmanual.java	Fri Apr 23 15:50:49 2010 +0530
@@ -92,35 +92,7 @@
       OBError myMessage = new OBError();
       String message = "";
       myMessage.setTitle("");
-      if (pinstanceData != null && pinstanceData.length > 0) {
-        if (!pinstanceData[0].errormsg.equals("")) {
-          message = pinstanceData[0].errormsg;
-          myMessage.setType("Success");
-          myMessage.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
-          if (message.startsWith("@") && message.endsWith("@")) {
-            myMessage.setMessage(message.substring(1, message.length() - 1));
-            if (message.indexOf("@") == -1)
-              myMessage.setMessage(Utility.messageBD(this, message, vars.getLanguage()));
-            else
-              myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), "@"
-                  + message + "@"));
-          } else
-            myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), message));
-        } else if (!pinstanceData[0].pMsg.equals("")) {
-          myMessage.setType("Success");
-          myMessage.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
-          message = pinstanceData[0].pMsg;
-          myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), message));
-        } else if (pinstanceData[0].result.equals("1")) {
-          myMessage.setType("Success");
-          myMessage.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
-          myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
-        } else {
-          myMessage.setType("Error");
-          myMessage.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
-          myMessage.setMessage(Utility.messageBD(this, "Error", vars.getLanguage()));
-        }
-      }
+      myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
       vars.setMessage("GenerateInvoicesmanual", myMessage);
       GenerateInvoicesmanualData.resetSelection(this, strCOrderId);
       if (log4j.isDebugEnabled())