details: https://code.openbravo.com/erp/devel/pi/rev/29b1d32b4ac5 changeset: 27180:29b1d32b4ac5 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Tue Jul 07 16:04:14 2015 +0530 summary: Fixes Issue 30073:Different Alternate Tax Base Amount in a partial invoice from order depending on the process used
Fix takes care to copy proportionate alternate taxable amount as per qty being invoiced of the sales order line alternate tax amount. It applies for both Create Lines From process in Sales Invoice and Create Invoices >From Order process. Divide by zero is taken care of and cur precision is used while division operation for rounding purpose. details: https://code.openbravo.com/erp/devel/pi/rev/e830b43059bc changeset: 27181:e830b43059bc user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Tue Jul 07 18:49:21 2015 +0200 summary: Related to issue 30073: code review improvements CreateFrom.java: 1. Use admin mode to get order line 2. Avoid possible NPE when getting data[i].cOrderlineId C_INVOICE_CREATE: 1. Added rounding to currency precission 2. Tax Base Amount pro-rating support when running Generate Invoices and we select a partially shipped order diffstat: src-db/database/model/functions/C_INVOICE_CREATE.xml | 17 ++++++--- src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java | 22 ++++++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diffs (106 lines): diff -r f0e423d38532 -r e830b43059bc src-db/database/model/functions/C_INVOICE_CREATE.xml --- a/src-db/database/model/functions/C_INVOICE_CREATE.xml Wed Jul 08 08:49:34 2015 +0200 +++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml Tue Jul 07 18:49:21 2015 +0200 @@ -139,7 +139,8 @@ ol.A_Asset_ID, ol.C_Costcenter_ID, ol.User1_ID, - ol.User2_ID + ol.User2_ID, + ol.QtyOrdered FROM M_INOUT s, M_INOUTLINE sl RIGHT JOIN C_ORDERLINE ol ON sl.C_OrderLine_ID=ol.C_OrderLine_ID @@ -731,7 +732,8 @@ ChargeAmt, C_UOM_ID, C_Tax_ID, --MODIFIED BY F.IRIAZABAL QuantityOrder, M_Product_Uom_ID, PriceStd, - m_attributesetinstance_id, taxbaseamt, + m_attributesetinstance_id, + taxbaseamt, gross_unit_price, line_gross_amount, grosspricestd, grosspricelist, isdeferred, defplantype, periodnumber, c_period_id, @@ -749,7 +751,8 @@ ptr_sl.ChargeAmt, ptr_sl.C_UOM_ID, ptr_sl.C_Tax_ID, --MODIFIED BY F.IRIAZABAL ptr_sl.QuantityOrder, ptr_sl.M_Product_Uom_ID, ptr_sl.PriceStd, - ptr_sl.m_attributesetinstance_id, ptr_sl.taxbaseamt, + ptr_sl.m_attributesetinstance_id, + CASE WHEN ptr_sl.QtyOrdered != 0 THEN C_Currency_Round(ptr_sl.taxbaseamt*ptr_sl.MovementQty/ptr_sl.QtyOrdered, Cur_Order.C_Currency_ID, NULL) ELSE ptr_sl.taxbaseamt END, ptr_sl.gross_unit_price, C_Currency_Round(ptr_sl.MovementQty*ptr_sl.gross_unit_price, Cur_Order.C_Currency_ID, NULL), COALESCE(ptr_sl.grosspricestd,0), COALESCE(ptr_sl.grosspricelist,0), v_isdeferred_inv, v_defplantype_inv, v_periodnumber_inv, v_period_inv, @@ -911,7 +914,7 @@ pl.istaxincluded, ol.grosspricestd, ol.grosspricelist, - sl.explode, sl.bom_parent_id + sl.explode, sl.bom_parent_id, ol.qtyordered FROM M_INOUT sh, M_INOUTLINE sl, C_ORDER o, @@ -1283,7 +1286,8 @@ ChargeAmt, C_UOM_ID, C_Tax_ID, --MODIFIED BY F.IRIAZABAL QuantityOrder, M_Product_Uom_ID, PriceStd, - m_attributesetinstance_id, taxbaseamt, + m_attributesetinstance_id, + taxbaseamt, gross_unit_price, line_gross_amount, grosspricestd, grosspricelist, isdeferred, defplantype, periodnumber, c_period_id, @@ -1301,7 +1305,8 @@ Cur_InvoiceSchedule.Line_ChargeAmt, Cur_InvoiceSchedule.C_UOM_ID, Cur_InvoiceSchedule.C_Tax_ID, --MODIFIED BY F.IRIAZABAL Cur_InvoiceSchedule.QuantityOrder, Cur_InvoiceSchedule.M_Product_Uom_ID, Cur_InvoiceSchedule.PriceStd, - Cur_InvoiceSchedule.m_attributesetinstance_id, Cur_InvoiceSchedule.taxbaseamt, + Cur_InvoiceSchedule.m_attributesetinstance_id, + CASE WHEN Cur_InvoiceSchedule.QtyOrdered != 0 THEN C_Currency_Round(Cur_InvoiceSchedule.taxbaseamt*Cur_InvoiceSchedule.MovementQty/Cur_InvoiceSchedule.QtyOrdered, Cur_InvoiceSchedule.C_Currency_ID, NULL) ELSE Cur_InvoiceSchedule.taxbaseamt END, Cur_InvoiceSchedule.gross_unit_price, C_Currency_Round(Cur_InvoiceSchedule.MovementQty*Cur_InvoiceSchedule.gross_unit_price, Cur_InvoiceSchedule.C_Currency_ID, NULL), COALESCE(Cur_InvoiceSchedule.grosspricestd,0), COALESCE(Cur_InvoiceSchedule.grosspricelist,0), v_isdeferred_inv, v_defplantype_inv, v_periodnumber_inv, v_period_inv, diff -r f0e423d38532 -r e830b43059bc src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java --- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java Wed Jul 08 08:49:34 2015 +0200 +++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java Tue Jul 07 18:49:21 2015 +0200 @@ -47,6 +47,7 @@ import org.openbravo.erpCommon.utility.Utility; import org.openbravo.financial.FinancialUtils; import org.openbravo.model.common.invoice.Invoice; +import org.openbravo.model.common.order.OrderLine; import org.openbravo.model.materialmgmt.transaction.ShipmentInOut; import org.openbravo.model.pricing.pricelist.PriceList; import org.openbravo.utils.Replace; @@ -1618,12 +1619,31 @@ startingPeriodId = ""; } + // Alternate Tax Base Amount pro-rating + BigDecimal taxBaseAmt = lineNetAmt; + if (data[i].cOrderlineId != null && !data[i].cOrderlineId.isEmpty()) { + try { + OBContext.setAdminMode(true); + OrderLine ol = OBDal.getInstance().get(OrderLine.class, data[i].cOrderlineId); + if (ol != null) { + BigDecimal qtyOrdered = ol.getOrderedQuantity(); + taxBaseAmt = ol.getTaxableAmount(); + if (qtyOrdered.compareTo(ZERO) != 0) { + taxBaseAmt = (taxBaseAmt.multiply(qty)).divide(qtyOrdered, curPrecision, + BigDecimal.ROUND_HALF_UP); + } + } + } finally { + OBContext.restorePreviousMode(); + } + } + CreateFromInvoiceData.insert(conn, this, strSequence, strKey, vars.getClient(), data[i].adOrgId, vars.getUser(), data[i].cOrderlineId, data[i].mInoutlineId, data[i].description, data[i].mProductId, data[i].cUomId, data[i].id, priceList, priceActual, priceLimit, lineNetAmt.toString(), C_Tax_ID, taxAmt.toPlainString(), data[i].quantityorder, data[i].mProductUomId, data[i].mAttributesetinstanceId, - priceStd, lineNetAmt.toString(), priceGross, grossAmt.toString(), priceListGross + priceStd, taxBaseAmt.toString(), priceGross, grossAmt.toString(), priceListGross .toString(), priceStdGross.toString(), isDeferred, planType, periodNumber, startingPeriodId, data[i].aAssetId, data[i].cProjectId, data[i].cCostcenterId, data[i].user1Id, data[i].user2Id, data[i].explode, ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits