details: https://code.openbravo.com/erp/devel/pi/rev/fec735938d2b changeset: 31613:fec735938d2b user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Tue Mar 07 19:27:58 2017 +0100 summary: Fixes issue 35429: Error when creating a PIT invoice line with empty tax in Oracle
Do not run C_INVOICELINE_BEFORE_TRG trigger in case tax is null. details: https://code.openbravo.com/erp/devel/pi/rev/2d002737ee99 changeset: 31614:2d002737ee99 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Wed Mar 08 10:08:26 2017 +0100 summary: Fixes issue 35428: Do not use C_GET_NET_PRICE_FROM_GROSS function We avoid Net Price and Net Amount calculation outside triggers when creating new Order/Invoice lines with Price Including Taxes. Also, we change use of C_GET_NET_PRICE_FROM_GROSS function with C_GET_NET_AMOUNT_FROM_GROSS in Order and Invoice callouts. Now, we get line net amount from line gross amount instead of getting line net price from line gross amount and then line net amount from line net price. Thus, we avoid precision loss. diffstat: src-db/database/model/functions/C_INVOICE_POST.xml | 2 +- src-db/database/model/functions/C_ORDER_POST1.xml | 2 +- src-db/database/model/functions/MRP_PURCHASEORDER.xml | 21 +-- src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml | 6 +- src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml | 16 +- src-db/database/model/functions/M_PROMOTION_ADJUSTMENT.xml | 6 +- src-db/database/model/functions/M_REQUISITION_CREATEPO.xml | 6 +- src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml | 2 +- src/org/openbravo/common/actionhandler/OrderCreatePOLines.java | 9 +- src/org/openbravo/common/actionhandler/SRMOPickEditLines.java | 7 +- src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java | 5 +- src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java | 9 +- src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder.java | 6 +- src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java | 8 +- src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java | 16 +-- src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java | 33 +++++- src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java | 52 +++++++-- src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java | 17 +-- src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql | 18 +--- src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java | 43 +------ src/org/openbravo/financial/FinancialUtils.java | 35 ++++++- 21 files changed, 160 insertions(+), 159 deletions(-) diffs (truncated from 828 to 300 lines): diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/C_INVOICE_POST.xml --- a/src-db/database/model/functions/C_INVOICE_POST.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/C_INVOICE_POST.xml Wed Mar 08 10:08:26 2017 +0100 @@ -1388,7 +1388,7 @@ ELSE v_line_gross_amount:=(-1) * Cur_TaxDiscount.LINEGROSSAMT * Cur_CInvoiceDiscount.Discount/100; END IF; - v_Discount:= C_GET_NET_PRICE_FROM_GROSS(Cur_TaxDiscount.C_TAX_ID, v_line_gross_amount, 0, v_pricePrecision, 1); + v_Discount:= C_GET_NET_AMOUNT_FROM_GROSS(Cur_TaxDiscount.C_TAX_ID, v_line_gross_amount, 0, v_stdPrecision); v_gross_unit_price:= v_line_gross_amount; ELSE IF (Cur_CInvoiceDiscount.CASCADE='Y') THEN diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/C_ORDER_POST1.xml --- a/src-db/database/model/functions/C_ORDER_POST1.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/C_ORDER_POST1.xml Wed Mar 08 10:08:26 2017 +0100 @@ -1120,7 +1120,7 @@ ELSE v_line_gross_amount:=(-1) * Cur_TaxDiscount.LINEGROSSAMT * Cur_COrderDiscount.Discount/100; END IF; - v_Discount:= C_GET_NET_PRICE_FROM_GROSS(Cur_TaxDiscount.C_TAX_ID, v_line_gross_amount, 0, v_pricePrecision, 1); + v_Discount:= C_GET_NET_AMOUNT_FROM_GROSS(Cur_TaxDiscount.C_TAX_ID, v_line_gross_amount, 0, v_stdPrecision); v_gross_unit_price:= v_line_gross_amount; ELSE IF (Cur_COrderDiscount.CASCADE='Y') THEN diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/MRP_PURCHASEORDER.xml --- a/src-db/database/model/functions/MRP_PURCHASEORDER.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/MRP_PURCHASEORDER.xml Wed Mar 08 10:08:26 2017 +0100 @@ -16,7 +16,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2001-2016 Openbravo SLU +* All portions are Copyright (C) 2001-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -55,7 +55,6 @@ v_LineNetAmt NUMBER:=0; v_gross_unit_price NUMBER:=0; v_stdprecision NUMBER:=0; - v_priceprecision NUMBER:=0; v_line_gross_amount NUMBER:=0; v_gross_price_std NUMBER:=0; v_gross_price_list NUMBER:=0; @@ -236,20 +235,20 @@ v_TaxID := C_GetTax(Cur_workproposal.M_Product_ID, v_DateDoc, v_Org_ID, v_M_Warehouse_ID, v_BillTo_ID, v_BPartner_Location_ID, null, 'N'); v_LineNetAmt:= v_PriceActual*Cur_workproposal.QTY; IF (v_istaxincluded = 'Y') THEN - SELECT PricePrecision, stdprecision - INTO v_priceprecision, v_stdprecision - FROM C_CURRENCY - WHERE C_CURRENCY_ID = Cur_workproposal.C_Currency_ID; + SELECT stdprecision + INTO v_stdprecision + FROM C_CURRENCY + WHERE C_CURRENCY_ID = Cur_workproposal.C_Currency_ID; v_gross_unit_price:= v_PriceActual; v_gross_price_std:= v_PriceStd; v_gross_price_list:= v_PriceList; v_line_gross_amount:= ROUND(v_gross_unit_price * Cur_workproposal.QTY, v_stdprecision); - v_PriceActual:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceActual, 0, v_priceprecision, 1); - v_PriceStd:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceStd, 0, v_priceprecision, 1); - v_PriceList:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceList, 0, v_priceprecision, 1); - v_PriceLimit:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceLimit, 0, v_priceprecision, 1); - v_LineNetAmt:= ROUND(v_PriceActual * Cur_workproposal.QTY, v_stdprecision); + v_PriceActual:= 0; + v_PriceStd:= 0; + v_PriceList:= 0; + v_PriceLimit:= 0; + v_LineNetAmt:= 0; UPDATE C_ORDER SET ISTAXINCLUDED='Y' WHERE C_ORDER_ID = v_COrder_ID; diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml --- a/src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml Wed Mar 08 10:08:26 2017 +0100 @@ -19,7 +19,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2013-2016 Openbravo SLU +* All portions are Copyright (C) 2013-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -159,8 +159,8 @@ v_gross_unit_price:=M_Get_Offers_Price(CUR_BOM_Line.DateOrdered, v_CBPartner_ID, CUR_BOM.M_ProductBOM_ID, M_BOM_PriceStd(CUR_BOM.M_ProductBOM_ID, v_PriceList_Version_ID), CUR_BOM_Line.QtyInvoiced*CUR_BOM.BOMQty, v_PriceList_ID); v_gross_price_list:=M_Get_Offers_Price(CUR_BOM_Line.DateOrdered, v_CBPartner_ID, CUR_BOM.M_ProductBOM_ID, M_BOM_PriceList(CUR_BOM.M_ProductBOM_ID, v_PriceList_Version_ID), CUR_BOM_Line.QtyInvoiced*CUR_BOM.BOMQty, v_PriceList_ID); v_line_gross_amount:=ROUND(CUR_BOM_Line.QtyOrdered*CUR_BOM.BOMQty*v_gross_unit_price, v_Precision); - v_price_actual:=ROUND(C_GET_NET_PRICE_FROM_GROSS(V_C_Tax_Id, M_Get_Offers_Price(CUR_BOM_Line.DateOrdered, v_CBPartner_ID, CUR_BOM.M_ProductBOM_ID, M_BOM_PriceStd(CUR_BOM.M_ProductBOM_ID, v_PriceList_Version_ID), CUR_BOM_Line.QtyInvoiced*CUR_BOM.BOMQty, v_PriceList_ID), 0, v_Precision, 1),v_Precision); - v_line_net_amt:=ROUND(CUR_BOM_Line.QtyOrdered*CUR_BOM.BOMQty*v_price_actual, v_Precision); + v_price_actual:=0; + v_line_net_amt:=0; ELSE v_gross_unit_price:=0; v_line_gross_amount:=0; diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml --- a/src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml Wed Mar 08 10:08:26 2017 +0100 @@ -19,7 +19,7 @@ * 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. * * Specifically, this derivative work is based upon the following Compiere * file and version. @@ -113,7 +113,6 @@ -- v_taxBaseAmt NUMBER; v_LineNetAmt NUMBER; - v_TotalNet NUMBER; -- v_Offer_ID varchar2(32); BEGIN FOR CUR_Shipment IN @@ -265,7 +264,6 @@ ) ; -- Lines - v_TotalNet:=0; FOR CUR_ShipmentLines IN (SELECT * FROM M_INOUTLINE WHERE M_InOut_ID=v_Record_ID) LOOP @@ -318,10 +316,10 @@ v_grosspricestd:= v_PriceActual; v_grosspricelist:= v_PriceList; v_line_gross_amount:= ROUND(v_gross_unit_price * CUR_ShipmentLines.MovementQty, v_stdprecision); - v_PriceActual:= C_GET_NET_PRICE_FROM_GROSS(v_C_Tax_ID, v_PriceActual, 0, v_priceprecision, 1); - v_PriceList:= C_GET_NET_PRICE_FROM_GROSS(v_C_Tax_ID, v_PriceList, 0, v_priceprecision, 1); - v_PriceLimit:= C_GET_NET_PRICE_FROM_GROSS(v_C_Tax_ID, v_PriceLimit, 0, v_priceprecision, 1); - v_LineNetAmt:= ROUND(v_PriceActual * CUR_ShipmentLines.MovementQty, v_stdprecision); + v_PriceActual:= 0; + v_PriceList:= 0; + v_PriceLimit:= 0; + v_LineNetAmt:= 0; ELSE v_PriceActual:=M_Get_Offers_Price(now(), CUR_Shipment.C_BPartner_ID, CUR_ShipmentLines.M_Product_ID, v_PriceActual, CUR_ShipmentLines.MovementQty, v_M_PriceList_ID); v_LineNetAmt:=ROUND(M_Get_Offers_Price(now(), CUR_Shipment.C_BPartner_ID, CUR_ShipmentLines.M_Product_ID, v_PriceActual, CUR_ShipmentLines.MovementQty, v_M_PriceList_ID) *CUR_ShipmentLines.MovementQty, v_stdprecision) ; @@ -384,9 +382,7 @@ coalesce(CUR_ShipmentLines.c_costcenter_id, CUR_Shipment.c_costcenter_id), coalesce(CUR_ShipmentLines.a_asset_id, CUR_Shipment.a_asset_id), CUR_ShipmentLines.c_aum, CUR_ShipmentLines.aumqty - ) - ; - v_TotalNet:=v_TotalNet + v_LineNetAmt; + ); END LOOP; -- ShipLines END IF; END LOOP; -- All Shipments diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/M_PROMOTION_ADJUSTMENT.xml --- a/src-db/database/model/functions/M_PROMOTION_ADJUSTMENT.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/M_PROMOTION_ADJUSTMENT.xml Wed Mar 08 10:08:26 2017 +0100 @@ -34,7 +34,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2014 Openbravo SLU +* All portions are Copyright (C) 2014-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -97,8 +97,8 @@ v_newGrossAmt := round(v_newUnitPrice * v_qty, p_stdprecision); v_totalPromotion := v_origGrossAmt - v_newGrossAmt; - v_newNetPrice := c_get_net_price_from_gross(v_tax, v_newGrossAmt, v_newGrossAmt, p_priceprecision, v_qty); - v_newNetAmt := round(v_newNetPrice * v_qty, p_stdprecision); + v_newNetPrice := 0; + v_newNetAmt := 0; v_basePrice := v_unitprice; else if (v_fixed is not null) then diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/functions/M_REQUISITION_CREATEPO.xml --- a/src-db/database/model/functions/M_REQUISITION_CREATEPO.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/functions/M_REQUISITION_CREATEPO.xml Wed Mar 08 10:08:26 2017 +0100 @@ -16,7 +16,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2008-2016 Openbravo SLU +* All portions are Copyright (C) 2008-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -264,8 +264,8 @@ IF (Cur_Lines.istaxincluded = 'Y') THEN v_gross_unit_price:= v_Gross; v_line_gross_amount:= ROUND(v_gross_unit_price * (Cur_Lines.QTY - Cur_Lines.ORDEREDQTY), v_stdPre); - v_PriceActual:= C_GET_NET_PRICE_FROM_GROSS(v_Tax_ID, v_line_gross_amount, v_line_gross_amount, v_priPre, (Cur_Lines.QTY - Cur_Lines.ORDEREDQTY)); - v_LineNetAmt:= ROUND(v_PriceActual * (Cur_Lines.QTY - Cur_Lines.ORDEREDQTY), v_stdPre); + v_PriceActual:= 0; + v_LineNetAmt:= 0; IF (v_PriceList = 0) THEN v_Discount := 0 ; ELSE diff -r e6809c9c722b -r 2d002737ee99 src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml --- a/src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml Thu Mar 02 14:02:04 2017 +0100 +++ b/src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml Wed Mar 08 10:08:26 2017 +0100 @@ -64,7 +64,7 @@ JOIN m_pricelist ON i.m_pricelist_id = m_pricelist.m_pricelist_id WHERE i.c_invoice_id = v_invoice_id; - IF (v_istaxincluded = 'Y') THEN + IF (v_istaxincluded = 'Y' AND :new.c_tax_id IS NOT NULL) THEN IF (INSERTING) THEN v_execute:='Y'; ELSIF(UPDATING) THEN diff -r e6809c9c722b -r 2d002737ee99 src/org/openbravo/common/actionhandler/OrderCreatePOLines.java --- a/src/org/openbravo/common/actionhandler/OrderCreatePOLines.java Thu Mar 02 14:02:04 2017 +0100 +++ b/src/org/openbravo/common/actionhandler/OrderCreatePOLines.java Wed Mar 08 10:08:26 2017 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2013-2016 Openbravo SLU + * All portions are Copyright (C) 2013-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -36,7 +36,6 @@ import org.openbravo.dal.service.OBCriteria; import org.openbravo.dal.service.OBDal; import org.openbravo.erpCommon.utility.OBMessageUtils; -import org.openbravo.financial.FinancialUtils; import org.openbravo.model.common.order.Order; import org.openbravo.model.common.order.OrderLine; import org.openbravo.model.common.plm.Product; @@ -165,7 +164,6 @@ // Price BigDecimal unitPrice, netPrice, grossPrice, stdPrice, limitPrice, grossAmt, netListPrice, grossListPrice, grossStdPrice; stdPrice = BigDecimal.ZERO; - final int pricePrecision = order.getCurrency().getPricePrecision().intValue(); final int stdPrecision = order.getCurrency().getStandardPrecision().intValue(); unitPrice = new BigDecimal(selectedLine.getString("standardPrice")); @@ -174,12 +172,9 @@ if (order.getPriceList().isPriceIncludesTax()) { grossPrice = unitPrice; grossAmt = grossPrice.multiply(qtyOrdered).setScale(stdPrecision, BigDecimal.ROUND_HALF_UP); - netPrice = FinancialUtils.calculateNetFromGross(tax.getId(), grossAmt, pricePrecision, - grossAmt, qtyOrdered); - limitPrice = netPrice; + netPrice = limitPrice = netListPrice = BigDecimal.ZERO; // selected line standard price is Gross Std Price in this case grossStdPrice = unitPrice; - netListPrice = netPrice; } else { netPrice = unitPrice; grossListPrice = grossAmt = grossPrice = grossStdPrice = BigDecimal.ZERO; diff -r e6809c9c722b -r 2d002737ee99 src/org/openbravo/common/actionhandler/SRMOPickEditLines.java --- a/src/org/openbravo/common/actionhandler/SRMOPickEditLines.java Thu Mar 02 14:02:04 2017 +0100 +++ b/src/org/openbravo/common/actionhandler/SRMOPickEditLines.java Wed Mar 08 10:08:26 2017 +0100 @@ -250,7 +250,6 @@ // Price BigDecimal unitPrice, netPrice, grossPrice, stdPrice, limitPrice, grossAmt, netListPrice, grossListPrice; stdPrice = BigDecimal.ZERO; - final int pricePrecision = order.getCurrency().getPricePrecision().intValue(); final int stdPrecision = order.getCurrency().getStandardPrecision().intValue(); if (selectedLine.get("unitPrice").equals(null) || "".equals(selectedLine.get("unitPrice"))) { @@ -282,11 +281,7 @@ grossPrice = unitPrice; grossAmt = grossPrice.multiply(qtyReturned) .setScale(stdPrecision, BigDecimal.ROUND_HALF_UP); - netPrice = FinancialUtils.calculateNetFromGross(tax.getId(), grossAmt, pricePrecision, - grossAmt, qtyReturned); - limitPrice = netPrice; - stdPrice = netPrice; - netListPrice = netPrice; + netPrice = limitPrice = stdPrice = netListPrice = BigDecimal.ZERO; } else { netPrice = unitPrice; grossListPrice = grossAmt = grossPrice = BigDecimal.ZERO; diff -r e6809c9c722b -r 2d002737ee99 src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java --- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Thu Mar 02 14:02:04 2017 +0100 +++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Wed Mar 08 10:08:26 2017 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2001-2016 Openbravo SLU + * All portions are Copyright (C) 2001-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -176,8 +176,7 @@ priceGross = priceStd; lineGrossAmt = priceGross.multiply(invLine.getInvoicedQuantity()).setScale( stdPrecision, BigDecimal.ROUND_HALF_UP); - priceActual = FinancialUtils.calculateNetFromGross(strCTaxID, lineGrossAmt, - pricePrecision, lineGrossAmt, invLine.getInvoicedQuantity()); + priceActual = BigDecimal.ZERO; ProductPrice prices = FinancialUtils.getProductPrice( OBDal.getInstance().get(Product.class, strmProductId), invoice.getInvoiceDate(), invoice.isSalesTransaction(), diff -r e6809c9c722b -r 2d002737ee99 src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java --- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java Thu Mar 02 14:02:04 2017 +0100 +++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java Wed Mar 08 10:08:26 2017 +0100 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits