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:52 UTC

svn commit: r1614558 - in /ofbiz/branches/release12.04: ./ applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java

Author: jleroux
Date: Wed Jul 30 06:40:52 2014
New Revision: 1614558

URL: http://svn.apache.org/r1614558
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/release12.04/   (props changed)
    ofbiz/branches/release12.04/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java

Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1614556

Modified: ofbiz/branches/release12.04/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=1614558&r1=1614557&r2=1614558&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java (original)
+++ ofbiz/branches/release12.04/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java Wed Jul 30 06:40:52 2014
@@ -517,7 +517,10 @@ public class InvoiceWorker {
             List<GenericValue> acctgTransEntries = invoice.getRelated("AcctgTrans");
             if (UtilValidate.isNotEmpty(acctgTransEntries)) {
                 GenericValue acctgTransEntry = (acctgTransEntries.get(0)).getRelated("AcctgTransEntry").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)) {