Fixes issue 21876: ignore temporal sales/purchase invoices.
authorMikel Irurita <mikel.irurita@openbravo.com>
Mon, 04 Feb 2013 11:07:21 +0100
changeset 19554 0de5dae02dec
parent 19553 6aa13988eec1
child 19585 b32c54841890
Fixes issue 21876: ignore temporal sales/purchase invoices.
In a invoicing process where the user should be able to preview/validate/update the invoices
that are going to be generated (there is a validation step) it is very useful to use c_invoice
table to store these temporal invoices (you take advantage of all the trigger, tax calculation,
gross amount calculation...).

New document status created: TEMP
Modified sales/purchase invoice tab where clauses
Modified Business Partner Info >> Partner Invoices tab where clause
Temporal invoices filtered out in Invoice Detail report
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_TAB.xml
src/org/openbravo/erpCommon/ad_reports/ReportInvoices_data.xsql
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Feb 04 10:52:04 2013 +0100
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Feb 04 11:07:21 2013 +0100
@@ -10092,6 +10092,18 @@
 <!--8DD863CADC734203914EFC5AAFEF0BDA-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--8DD863CADC734203914EFC5AAFEF0BDA--></AD_REF_LIST>
 
+<!--8DE76CF570B942F49F18CBAB0A5C65D9--><AD_REF_LIST>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <AD_REF_LIST_ID><![CDATA[8DE76CF570B942F49F18CBAB0A5C65D9]]></AD_REF_LIST_ID>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <VALUE><![CDATA[TEMP]]></VALUE>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <NAME><![CDATA[Temporal]]></NAME>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <DESCRIPTION><![CDATA[A temporal invoice is not available (not visible) in the system. This kind of invoices are ignored by standard processes.]]></DESCRIPTION>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <AD_REFERENCE_ID><![CDATA[131]]></AD_REFERENCE_ID>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8DE76CF570B942F49F18CBAB0A5C65D9--></AD_REF_LIST>
+
 <!--8F3A063A37CA4FFD8CD13D9CEE135085--><AD_REF_LIST>
 <!--8F3A063A37CA4FFD8CD13D9CEE135085-->  <AD_REF_LIST_ID><![CDATA[8F3A063A37CA4FFD8CD13D9CEE135085]]></AD_REF_LIST_ID>
 <!--8F3A063A37CA4FFD8CD13D9CEE135085-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TAB.xml	Mon Feb 04 10:52:04 2013 +0100
+++ b/src-db/database/sourcedata/AD_TAB.xml	Mon Feb 04 11:07:21 2013 +0100
@@ -3134,7 +3134,7 @@
 <!--263-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--263-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--263-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
-<!--263-->  <HQLWHERECLAUSE><![CDATA[e.salesTransaction=true]]></HQLWHERECLAUSE>
+<!--263-->  <HQLWHERECLAUSE><![CDATA[e.salesTransaction=true and e.documentStatus <> 'TEMP']]></HQLWHERECLAUSE>
 <!--263-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--263-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--263-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
@@ -3353,7 +3353,7 @@
 <!--290-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--290-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--290-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
-<!--290-->  <HQLWHERECLAUSE><![CDATA[e.salesTransaction=false]]></HQLWHERECLAUSE>
+<!--290-->  <HQLWHERECLAUSE><![CDATA[e.salesTransaction=false and e.documentStatus <> 'TEMP']]></HQLWHERECLAUSE>
 <!--290-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--290-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--290-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
@@ -6086,7 +6086,7 @@
 <!--553-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--553-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--553-->  <UIPATTERN><![CDATA[RO]]></UIPATTERN>
-<!--553-->  <HQLWHERECLAUSE><![CDATA[e.businessPartner.id=@BusinessPartner.id@]]></HQLWHERECLAUSE>
+<!--553-->  <HQLWHERECLAUSE><![CDATA[e.businessPartner.id=@BusinessPartner.id@ and e.documentStatus <> 'TEMP']]></HQLWHERECLAUSE>
 <!--553-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--553-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--553-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportInvoices_data.xsql	Mon Feb 04 10:52:04 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportInvoices_data.xsql	Mon Feb 04 11:07:21 2013 +0100
@@ -56,6 +56,7 @@
       AND (C_INVOICELINE.M_PRODUCT_ID IS NOT NULL OR C_INVOICELINE.ACCOUNT_ID IS NOT NULL)
       AND C_INVOICELINE.C_UOM_ID = C_UOM.C_UOM_ID
       AND C_INVOICELINE.C_TAX_ID = C_TAX.C_TAX_ID
+      AND I.DOCSTATUS <> 'TEMP'
       AND I.AD_Client_ID IN ('1')
       AND I.AD_ORG_ID IN ('1')
       AND 1=1
@@ -80,6 +81,7 @@
       AND C_INVOICETAX.C_INVOICE_ID= I2.C_INVOICE_ID
       AND (IL.M_PRODUCT_ID IS NOT NULL OR IL.ACCOUNT_ID IS NOT NULL)
       AND C_INVOICETAX.C_TAX_ID = C_TAX.C_TAX_ID
+      AND I2.DOCSTATUS <> 'TEMP'
       AND I2.AD_Client_ID IN ('2')
       AND I2.AD_ORG_ID IN ('2')
       AND 2=2) A