details: https://code.openbravo.com/erp/devel/pi/rev/fc24781d4355 changeset: 29663:fc24781d4355 user: Mark <markmm82 <at> gmail.com> date: Sat Jun 11 18:58:10 2016 -0400 summary: Fixes issue 33197: Avoided / by zero error when processing a landed cost
Avoided / by zero error when processing a landed cost details: https://code.openbravo.com/erp/devel/pi/rev/a4b0ffea953b changeset: 29664:a4b0ffea953b user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Fri Jun 17 14:03:50 2016 +0200 summary: Related to issue 33197: Code review improvements Take receipt line amount and receipt amount as absolute values to calculate correct landed cost receipt amount in case we have one receipt with two lines with the same amount but one positive and the other negative. diffstat: src/org/openbravo/costing/LandedCostDistributionByAmount.java | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (33 lines): diff -r 3383c34486c2 -r a4b0ffea953b src/org/openbravo/costing/LandedCostDistributionByAmount.java --- a/src/org/openbravo/costing/LandedCostDistributionByAmount.java Wed Jun 15 18:26:36 2016 +0530 +++ b/src/org/openbravo/costing/LandedCostDistributionByAmount.java Fri Jun 17 14:03:50 2016 +0200 @@ -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) 2014-2015 Openbravo SLU + * All portions are Copyright (C) 2014-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -76,7 +76,7 @@ trxAmt = getConvertedAmount(trxAmt, strTrxCur, strCurId, dateReference, strOrgId); } - totalAmt = totalAmt.add(trxAmt); + totalAmt = totalAmt.add(trxAmt.abs()); if (i % 100 == 0) { OBDal.getInstance().flush(); @@ -107,7 +107,10 @@ // Insert pending amount on receipt with higher cost to avoid rounding issues. receiptAmt = pendingAmt; } else { - receiptAmt = baseAmt.multiply(trxAmt).divide(totalAmt, precission, RoundingMode.HALF_UP); + receiptAmt = baseAmt.multiply(trxAmt.abs()); + if (totalAmt.compareTo(BigDecimal.ZERO) != 0) { + receiptAmt = receiptAmt.divide(totalAmt, precission, RoundingMode.HALF_UP); + } } pendingAmt = pendingAmt.subtract(receiptAmt); LCReceipt lcrl = (LCReceipt) OBDal.getInstance().getProxy(LCReceipt.ENTITY_NAME, ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohomanageengine _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits