details:   https://code.openbravo.com/erp/devel/pi/rev/c6ab374457d8
changeset: 31745:c6ab374457d8
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Wed Mar 22 17:30:36 2017 -0400
summary:   Fixes issue 35514: Wrong Product Expense account used with tax not 
deductible

When posting a Purchase Invoice with lines that contains a not deductible tax
the query to get the tax amount by lines was failing, also in the facacct create
lines process always was get the first one ignoring the product account

Now the amount its get from the invoicelinetax and a new method was created to
get the product accounts in the purchase invoice filtered by the product_id

details:   https://code.openbravo.com/erp/devel/pi/rev/aceca41e08a1
changeset: 31746:aceca41e08a1
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Mar 28 11:21:34 2017 +0200
summary:   Related to issue 35514: Code review improvements

Remove duplicated DocInvoiceData.selectProductAcct method making productId 
parameter optional.
Update copyrights.

diffstat:

 src/org/openbravo/erpCommon/ad_forms/DocInvoice.java          |  9 +++++----
 src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql     |  8 +++++---
 src/org/openbravo/erpCommon/ad_forms/DocLineInvoice_data.xsql |  4 ++--
 3 files changed, 12 insertions(+), 9 deletions(-)

diffs (85 lines):

diff -r ca589943eb25 -r aceca41e08a1 
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java      Tue Mar 28 
11:09:21 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java      Tue Mar 28 
11:21:34 2017 +0200
@@ -11,7 +11,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 SLU
- * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2017 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -885,9 +885,9 @@
             String strtaxAmount = null;
 
             try {
-
               DocInvoiceData[] dataEx = DocInvoiceData.selectProductAcct(conn,
-                  as.getC_AcctSchema_ID(), m_taxes[i].m_C_Tax_ID, Record_ID);
+                  as.getC_AcctSchema_ID(), m_taxes[i].m_C_Tax_ID, Record_ID,
+                  docLine1.m_M_Product_ID);
               if (dataEx.length == 0) {
                 dataEx = DocInvoiceData.selectGLItemAcctForTaxLine(conn, 
as.getC_AcctSchema_ID(),
                     m_taxes[i].m_C_Tax_ID, Record_ID);
@@ -1539,7 +1539,8 @@
     try {
 
       // We can have some lines from product or some lines from general ledger
-      data = DocInvoiceData.selectProductAcct(conn, as.getC_AcctSchema_ID(), 
taxId, Record_ID);
+      data = DocInvoiceData
+          .selectProductAcct(conn, as.getC_AcctSchema_ID(), taxId, Record_ID, 
null);
       cumulativeTaxLineAmount = 
createLineForTaxUndeductable(invoiceLineTaxCount,
           totalInvoiceLineTax, cumulativeTaxLineAmount, taxAmount, data, conn, 
fact, docLine,
           Fact_Acct_Group_ID);
diff -r ca589943eb25 -r aceca41e08a1 
src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Tue Mar 28 
11:09:21 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Tue Mar 28 
11:21:34 2017 +0200
@@ -12,7 +12,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 SLU
- * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2017 Openbravo S.L.U.
  ******************************************************************************
 -->
 
@@ -133,13 +133,15 @@
         AND l.M_Product_Id = p.M_Product_Id
         AND p.M_Product_Id = a.M_Product_Id
         AND a.C_AcctSchema_Id = ?
-        AND t.C_Tax_Id= ?
-        AND t.C_Invoice_Id= ?
+        AND t.C_Tax_Id = ?
+        AND t.C_Invoice_Id = ?
+        AND 1=1
      ]]>
      </Sql>
      <Parameter name="acctSchemaId"/>
      <Parameter name="taxId"/>
      <Parameter name="invoiceId"/>
+     <Parameter name="productId" optional="true" after="AND 1=1"><![CDATA[ AND 
p.M_Product_Id = ?]]></Parameter>
     </SqlMethod>
   <SqlMethod name="updateProductPO" type="preparedStatement" connection="true" 
return="rowCount">
     <SqlMethodComment></SqlMethodComment>
diff -r ca589943eb25 -r aceca41e08a1 
src/org/openbravo/erpCommon/ad_forms/DocLineInvoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocLineInvoice_data.xsql     Tue Mar 
28 11:09:21 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocLineInvoice_data.xsql     Tue Mar 
28 11:21:34 2017 +0200
@@ -12,7 +12,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 SLU
- * Contributions are Copyright (C) 2001-2015 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2017 Openbravo S.L.U.
  ******************************************************************************
 -->
 
@@ -111,7 +111,7 @@
         C_INVOICELINE.PRICELIST, C_INVOICELINE.PRICEACTUAL, 
C_INVOICELINE.PRICELIMIT,
         COALESCE(C_INVOICELINE_ACCTDIMENSION.AMT, C_INVOICELINE.LINENETAMT) AS 
LINENETAMT,
         C_INVOICELINE.C_CHARGE_ID, C_INVOICELINE.CHARGEAMT, 
C_INVOICELINE.C_UOM_ID,  c_invoicelinetax.C_TAX_ID,
-        C_INVOICELINE.S_RESOURCEASSIGNMENT_ID, C_INVOICELINE.TAXAMT, 
C_INVOICELINE.M_ATTRIBUTESETINSTANCE_ID,
+        C_INVOICELINE.S_RESOURCEASSIGNMENT_ID, C_INVOICELINETAX.TAXAMT, 
C_INVOICELINE.M_ATTRIBUTESETINSTANCE_ID,
         C_INVOICELINE.ISDESCRIPTION, C_INVOICELINE.QUANTITYORDER, 
C_INVOICELINE.M_PRODUCT_UOM_ID,
         C_INVOICELINE_ACCTDIMENSION.C_CAMPAIGN_ID, 
COALESCE(C_INVOICELINE_ACCTDIMENSION.C_PROJECT_ID, C_INVOICELINE.C_PROJECT_ID) 
AS C_PROJECT_ID,
         COALESCE(C_INVOICELINE_ACCTDIMENSION.USER1_ID,C_INVOICELINE.USER1_ID) 
AS user1Id,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to