Fixed bug 4002: Review processes that create Invoices because of Tax Date
authorCarlos Romero <carlos.romero@openbravo.com>
Tue, 17 Jun 2008 17:04:30 +0000
changeset 1259 aa36b7150211
parent 1258 ff6c6de71714
child 1260 e5cabe59d09e
Fixed bug 4002: Review processes that create Invoices because of Tax Date
Functions and inserts modified in order to include TaxDate with the same value that DateAcct
* C_COMMISSIONRUN_PROCESS.xml
* C_CREATE_PINVOICE_FROM_OUTS.xml
* C_INVOICE_CREATE.xml
* C_INVOICE_POST.xml
* M_INOUT_CREATEINVOICE.xml
* M_RAPPEL_INVOICE_CREATE.xml
* C_INVOICE_TRG.xml
* ad_forms/InvoiceVendorMultiline_data.xsql
* ad_process/ExpenseAPInvoice_data.xsql
src-db/database/model/functions/C_COMMISSIONRUN_PROCESS.xml
src-db/database/model/functions/C_CREATE_PINVOICE_FROM_OUTS.xml
src-db/database/model/functions/C_INVOICE_CREATE.xml
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml
src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml
src-db/database/model/triggers/C_INVOICE_TRG.xml
src/org/openbravo/erpCommon/ad_forms/InvoiceVendorMultiline_data.xsql
src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice_data.xsql
--- a/src-db/database/model/functions/C_COMMISSIONRUN_PROCESS.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/C_COMMISSIONRUN_PROCESS.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -16,7 +16,7 @@
   * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
   * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
   * Contributor(s): Openbravo SL
-  * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
+  * Contributions are Copyright (C) 2001-2008 Openbravo S.L.
   ******************************************************************************/
  -- Logistice
  v_ResultStr     VARCHAR2(2000) := '';
@@ -143,7 +143,7 @@
    IsSOTrx, DocumentNo, DocStatus, DocAction, Processing, Processed,
    C_DocType_ID, C_DocTypeTarget_ID, Description,
    SalesRep_ID,
-   DateInvoiced, DatePrinted, IsPrinted, DateAcct,
+   DateInvoiced, DatePrinted, IsPrinted, DateAcct, TaxDate,
    C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID,
    POReference, DateOrdered, IsDiscountPrinted,
    C_Currency_ID, PaymentRule, C_Charge_ID, ChargeAmt,
@@ -155,7 +155,7 @@
    'N', v_DocumentNo, 'DR', 'CO', 'N', 'N',
    v_C_DocType_ID, v_C_DocType_ID, CUR_ComRun.Description,
    v_SalesRep_ID,
-   CUR_ComRun.Updated, NULL, 'N', CUR_ComRun.Updated, -- DateInvoiced=DateAcct
+   CUR_ComRun.Updated, NULL, 'N', CUR_ComRun.Updated, CUR_ComRun.Updated, -- DateInvoiced=DateAcct
    v_C_PaymentTerm_ID, v_C_BPartner_ID, v_C_BPartner_Location_ID, NULL,
    v_POReference, CUR_ComRun.Updated, v_IsDiscountPrinted,
    v_C_Currency_ID, v_PaymentRule, NULL, 0,
--- a/src-db/database/model/functions/C_CREATE_PINVOICE_FROM_OUTS.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/C_CREATE_PINVOICE_FROM_OUTS.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -16,7 +16,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SL
-* All portions are Copyright (C) 2001-2006 Openbravo SL
+* All portions are Copyright (C) 2001-2008 Openbravo SL
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -197,7 +197,7 @@
             ISSOTRX, DOCUMENTNO, DOCSTATUS, DOCACTION,
             PROCESSING, PROCESSED, POSTED, C_DOCTYPE_ID,
             C_DOCTYPETARGET_ID, C_ORDER_ID, DESCRIPTION,
-            ISPRINTED, SALESREP_ID, DATEINVOICED,
+            ISPRINTED, SALESREP_ID, DATEINVOICED, TAXDATE,
             DATEPRINTED, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
             POREFERENCE, ISDISCOUNTPRINTED, DATEORDERED, C_CURRENCY_ID,
             PAYMENTRULE, C_PAYMENTTERM_ID, C_CHARGE_ID, CHARGEAMT,
@@ -213,7 +213,7 @@
              'N', v_DocumentNo, 'DR', 'CO',
              'N', 'N', 'N', 0,
             v_DocType_ID, NULL, NULL,
-            'N', NULL, v_DateInvoiced,
+            'N', NULL, v_DateInvoiced, v_DateInvoiced,
             NULL, v_DateInvoiced, v_BPartner_ID, v_BPLocation_ID,
             v_ReferenceNo, 'Y', NULL, v_Currency_ID,
             v_PaymentRule, v_PaymentTerm_ID, NULL, 0,
--- a/src-db/database/model/functions/C_INVOICE_CREATE.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -390,7 +390,8 @@
                   Processing, Processed, C_DocType_ID, C_DocTypeTarget_ID,
                   Description, SalesRep_ID,
                   DateInvoiced,
-                  DatePrinted, IsPrinted, DateAcct, C_PaymentTerm_ID,
+                  DatePrinted, IsPrinted, DateAcct, TaxDate, 
+                  C_PaymentTerm_ID,
                   C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID, POReference,
                   DateOrdered, IsDiscountPrinted, C_Currency_ID, PaymentRule,
                   C_Charge_ID, ChargeAmt, IsSelfService, TotalLines,
@@ -400,12 +401,12 @@
                 VALUES
                 (
                   p_Invoice_ID, Cur_Order.C_Order_ID, Cur_Order.AD_Client_ID, Cur_Order.AD_Org_ID,
-                   'Y', now(), 0, now(),
-                  0, Cur_Order.IsSOTrx, v_DocumentNo, 'DR',
-                   'CO', 'N', 'N', v_DocType_ID,
-                  v_DocType_ID, Cur_Order.Description,
-                  Cur_Order.SalesRep_ID, v_DateInvoiced, NULL, 'N',
-                  v_DateInvoiced, -- DateInvoiced=DateAcct
+                  'Y', now(), 0, now(),0, 
+                  Cur_Order.IsSOTrx, v_DocumentNo, 'DR', 'CO', 
+                  'N', 'N', v_DocType_ID, v_DocType_ID, 
+                  Cur_Order.Description, Cur_Order.SalesRep_ID, 
+                  v_DateInvoiced, 
+                  NULL, 'N', v_DateInvoiced, v_DateInvoiced, -- DateInvoiced=DateAcct
                   Cur_Order.C_PaymentTerm_ID, Cur_Order.C_BPartner_ID, Cur_Order.BillTo_ID, Cur_Order.AD_User_ID,
                   Cur_Order.POReference, Cur_Order.DateOrdered, Cur_Order.IsDiscountPrinted, Cur_Order.C_Currency_ID,
                   Cur_Order.PaymentRule, Cur_Order.C_Charge_ID, Cur_Order.ChargeAmt, Cur_Order.IsSelfService,
@@ -902,7 +903,7 @@
                       DocAction, Processing, Processed, C_DocType_ID,
                       C_DocTypeTarget_ID, Description,
                       SalesRep_ID, DateInvoiced, DatePrinted, IsPrinted,
-                      DateAcct,
+                      DateAcct, TaxDate,
                       C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID,
                       POReference, DateOrdered, IsDiscountPrinted, C_Currency_ID,
                       PaymentRule, C_Charge_ID, ChargeAmt, IsSelfService,
@@ -918,7 +919,7 @@
                        'CO', 'N', 'N', v_DocType_ID,
                       v_DocType_ID, v_description,
                       Cur_InvoiceSchedule.SalesRep_ID, v_DateInvoiced, NULL, 'N',
-                      v_DateInvoiced, -- DateInvoiced=DateAcct
+                      v_DateInvoiced, v_DateInvoiced, -- DateInvoiced=DateAcct
                       Cur_InvoiceSchedule.C_PaymentTerm_ID, Cur_InvoiceSchedule.C_BPartner_ID, Cur_InvoiceSchedule.BillTo_ID, Cur_InvoiceSchedule.AD_User_ID,
                       Cur_InvoiceSchedule.POReference, Cur_InvoiceSchedule.DateOrdered, Cur_InvoiceSchedule.IsDiscountPrinted, Cur_InvoiceSchedule.C_Currency_ID,
                       Cur_InvoiceSchedule.PaymentRule, NULL, 0, 'N',
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -361,8 +361,8 @@
               IsActive, Created, CreatedBy, Updated,
               UpdatedBy, IsSOTrx, DocumentNo, DocStatus,
               DocAction, Processing, Processed, C_DocType_ID,
-              C_DocTypeTarget_ID, Description,
-              SalesRep_ID, DateInvoiced, DatePrinted, IsPrinted,
+              C_DocTypeTarget_ID, Description, SalesRep_ID, 
+              DateInvoiced, DatePrinted, IsPrinted, TaxDate,
               DateAcct, C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID,
               AD_User_ID, POReference, DateOrdered, IsDiscountPrinted,
               C_Currency_ID, PaymentRule, C_Charge_ID, ChargeAmt,
@@ -374,8 +374,8 @@
             IsActive, now(), UpdatedBy, now(),
             UpdatedBy, IsSOTrx, v_RDocumentNo, 'DR',
              'CO', 'N', 'N', v_DoctypeReversed_ID,
-            v_DoctypeReversed_ID, '(*R*: ' || DocumentNo || ') ' || Description,
-            SalesRep_ID, DateInvoiced, NULL, 'N',
+            v_DoctypeReversed_ID, '(*R*: ' || DocumentNo || ') ' || Description, SalesRep_ID, 
+            DateInvoiced, NULL, 'N', TaxDate, DateAcct
             DateAcct, C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID,
             AD_User_ID, POReference, DateOrdered, IsDiscountPrinted,
             C_Currency_ID, PaymentRule, C_Charge_ID, ChargeAmt * -1,
--- a/src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -203,8 +203,8 @@
               IsActive, Created, CreatedBy, Updated,
               UpdatedBy, IsSOTrx, DocumentNo, DocStatus,
               DocAction, Processing, Processed, C_DocType_ID,
-              C_DocTypeTarget_ID, Description,
-              SalesRep_ID, DateInvoiced, DatePrinted, IsPrinted,
+              C_DocTypeTarget_ID, Description, SalesRep_ID, 
+              DateInvoiced, DatePrinted, IsPrinted, TaxDate,
               DateAcct, C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID,
               AD_User_ID, POReference, DateOrdered, IsDiscountPrinted,
               C_Currency_ID, PaymentRule, C_Charge_ID, ChargeAmt,
@@ -218,8 +218,8 @@
                'Y', now(), 0, now(),
               0, 'N', v_DocumentNo, 'DR',
                'CO', 'N', 'N', v_DocType_ID,
-              v_DocType_ID, CUR_Shipment.Description,
-              NULL, now(), NULL, 'N',
+              v_DocType_ID, CUR_Shipment.Description, NULL, 
+              now(), NULL, 'N', now(),
               now(), v_C_PaymentTerm_ID, CUR_Shipment.C_BPartner_ID, CUR_Shipment.C_BPartner_Location_ID,
               CUR_Shipment.AD_User_ID, NULL, CUR_Shipment.DateOrdered, v_IsDiscountPrinted,
               v_C_Currency_ID, v_PaymentRule, NULL, 0,
--- a/src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -16,7 +16,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SL
-* All portions are Copyright (C) 2001-2006 Openbravo SL
+* All portions are Copyright (C) 2001-2008 Openbravo SL
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -340,8 +340,8 @@
             ISSOTRX, DOCUMENTNO, DOCSTATUS, DOCACTION,
             PROCESSING, PROCESSED, POSTED, C_DOCTYPE_ID,
             C_DOCTYPETARGET_ID, C_ORDER_ID, DESCRIPTION,
-            ISPRINTED, SALESREP_ID, DATEINVOICED,
-            DATEPRINTED, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
+            ISPRINTED, SALESREP_ID, DATEINVOICED, DATEPRINTED, 
+            TAXDATE, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID,
             POREFERENCE, ISDISCOUNTPRINTED, DATEORDERED, C_CURRENCY_ID,
             PAYMENTRULE, C_PAYMENTTERM_ID, C_CHARGE_ID, CHARGEAMT,
             TOTALLINES, GRANDTOTAL, M_PRICELIST_ID, ISTAXINCLUDED,
@@ -357,8 +357,8 @@
             CUR_INVOICE.ISSOTRX, v_DocumentNo, 'DR', 'CO',
              'N', 'N', 'N', CUR_INVOICE.C_DOCTYPE_ID,
             CUR_INVOICE.C_DOCTYPETARGET_ID, NULL, NULL,
-            'N', NULL, now(),
-            NULL, now(), CUR_INVOICE.C_BPARTNER_ID, CUR_INVOICE.C_BPARTNER_LOCATION_ID,
+            'N', NULL, now(), NULL, 
+            now(), now(), CUR_INVOICE.C_BPARTNER_ID, CUR_INVOICE.C_BPARTNER_LOCATION_ID,
             NULL, 'N', NULL, CUR_INVOICE.C_CURRENCY_ID,
             v_paymentRule, v_paymenttermId, NULL, 0,
             0, 0, v_pricelistId, 'N',
--- a/src-db/database/model/triggers/C_INVOICE_TRG.xml	Tue Jun 17 16:52:56 2008 +0000
+++ b/src-db/database/model/triggers/C_INVOICE_TRG.xml	Tue Jun 17 17:04:30 2008 +0000
@@ -19,7 +19,7 @@
     * under the License.
     * The Original Code is Openbravo ERP.
     * The Initial Developer of the Original Code is Openbravo SL
-    * All portions are Copyright (C) 2001-2006 Openbravo SL
+    * All portions are Copyright (C) 2001-2008 Openbravo SL
     * All Rights Reserved.
     * Contributor(s):  ______________________________________.
     ************************************************************************/
@@ -72,9 +72,6 @@
    IF(:NEW.PROCESSED='Y') THEN
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
    END IF;
-   IF(:NEW.TAXDATE IS NULL) THEN
-     :NEW.TAXDATE := :NEW.DATEINVOICED ;
-   END IF;
   END IF;
   IF(DELETING) THEN
    IF(:OLD.PROCESSED='Y') THEN
--- a/src/org/openbravo/erpCommon/ad_forms/InvoiceVendorMultiline_data.xsql	Tue Jun 17 16:52:56 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/InvoiceVendorMultiline_data.xsql	Tue Jun 17 17:04:30 2008 +0000
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -267,12 +267,12 @@
     <Sql><![CDATA[
         INSERT INTO C_Invoice (Processing, IsTaxIncluded, IsSOTrx, IsPrinted, 
         Processed, IsSelfService, C_Invoice_ID, DatePrinted, AD_Client_ID, AD_Org_ID, C_Order_ID, DateOrdered, 
-        DocumentNo, POReference, Description, IsActive, C_DocTypeTarget_ID, DateInvoiced, DateAcct, C_BPartner_ID, 
+        DocumentNo, POReference, Description, IsActive, C_DocTypeTarget_ID, DateInvoiced, DateAcct, TaxDate, C_BPartner_ID, 
         C_BPartner_Location_ID, AD_User_ID, M_PriceList_ID, C_Currency_ID, SalesRep_ID, IsDiscountPrinted, C_Charge_ID, 
         ChargeAmt, PaymentRule, C_PaymentTerm_ID, CreateFrom, GenerateTo, C_Project_ID, C_Activity_ID, C_Campaign_ID, 
         AD_OrgTrx_ID, User1_ID, User2_ID, DocStatus, C_DocType_ID, CopyFrom, DocAction, Posted, 
         created, createdby, updated, updatedBy)
-        VALUES (?, ?, ?, ?, ?, ?, ?, TO_NUMBER(?), TO_DATE(?), ?, TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_DATE(?), ?, ?, ?, ?, TO_NUMBER(?), TO_DATE(?), TO_DATE(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), ?, TO_NUMBER(?), TO_NUMBER(?), ?, TO_NUMBER(?), ?, ?, 
+        VALUES (?, ?, ?, ?, ?, ?, ?, TO_NUMBER(?), TO_DATE(?), ?, TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_DATE(?), ?, ?, ?, ?, TO_NUMBER(?), TO_DATE(?), TO_DATE(?), TO_DATE(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), ?, TO_NUMBER(?), TO_NUMBER(?), ?, TO_NUMBER(?), ?, ?, 
         TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), ?, TO_NUMBER(?), ?, ?, ?, now(), TO_NUMBER(?), now(), TO_NUMBER(?))
     ]]></Sql>
     <Parameter name="processing"></Parameter> 
@@ -294,6 +294,7 @@
     <Parameter name="cDoctypetargetId"></Parameter> 
     <Parameter name="dateinvoiced"></Parameter> 
     <Parameter name="dateacct"></Parameter> 
+    <Parameter name="dateacct"></Parameter> 
     <Parameter name="cBpartnerId"></Parameter> 
     <Parameter name="cBpartnerLocationId"></Parameter> 
     <Parameter name="adUserId"></Parameter> 
--- a/src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice_data.xsql	Tue Jun 17 16:52:56 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice_data.xsql	Tue Jun 17 17:04:30 2008 +0000
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2007 Openbravo SL 
+ * All portions are Copyright (C) 2001-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -302,6 +302,7 @@
 , C_DocTypeTarget_ID
 , DateInvoiced
 , DateAcct
+, TaxDate
 , C_BPartner_ID
 , C_BPartner_Location_ID
 , AD_User_ID
@@ -350,6 +351,7 @@
 , TO_NUMBER(?)
 , TO_DATE(?) 
 , TO_DATE(?) 
+, TO_DATE(?)
 , TO_NUMBER(?)
 , TO_NUMBER(?)
 , TO_NUMBER(?)
@@ -399,6 +401,7 @@
 <Parameter name="cDoctypetargetId"/>
 <Parameter name="dateinvoiced"/>
 <Parameter name="dateacct"/>
+<Parameter name="dateacct"/>
 <Parameter name="cBpartnerId"/>
 <Parameter name="cBpartnerLocationId"/>
 <Parameter name="adUserId"/>