You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2014/07/30 08:40:50 UTC

svn commit: r1614557 - in /ofbiz/branches/release13.07: ./ applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java

Author: jleroux
Date: Wed Jul 30 06:40:49 2014
New Revision: 1614557

URL: http://svn.apache.org/r1614557
Log:
"Applied fix from trunk for revision: 1614556" 
------------------------------------------------------------------------
r1614556 | jleroux | 2014-07-30 08:40:23 +0200 (mer. 30 juil. 2014) | 1 ligne

Fixes a possible ArithmeticException: Division undefined
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1614556

Modified: ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=1614557&r1=1614556&r2=1614557&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java (original)
+++ ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java Wed Jul 30 06:40:49 2014
@@ -515,7 +515,10 @@ public class InvoiceWorker {
             List<GenericValue> acctgTransEntries = invoice.getRelated("AcctgTrans", null, null, false);
             if (UtilValidate.isNotEmpty(acctgTransEntries)) {
                 GenericValue acctgTransEntry = (acctgTransEntries.get(0)).getRelated("AcctgTransEntry", null, null, false).get(0);
-                conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
+                BigDecimal origAmount = acctgTransEntry.getBigDecimal("origAmount");
+                if (origAmount.compareTo(ZERO) == 1) {
+                    conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
+                }
             }
             // check if a payment is applied and use the currency conversion from there
             if (UtilValidate.isEmpty(conversionRate)) {