Scott Gray wrote:
On 26/03/2010, at 8:53 AM, Jacques Le Roux wrote:

From: "Adam Heath" <doo...@brainfood.com>
jler...@apache.org wrote:
Author: jleroux
Date: Fri Mar 26 14:34:02 2010
New Revision: 927870

URL: http://svn.apache.org/viewvc?rev=927870&view=rev
Log:
Fix a NPE I got on actualCurrencyAmount while working with R9.04.
Since the files are identical I commit in trunk and will backport

Modified:
   
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy?rev=927870&r1=927869&r2=927870&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
 Fri Mar 26
14:34:02 2010
@@ -68,13 +68,19 @@ List getPayments(List payments, boolean
            if (actual) {
                paymentMap.amount = payment.actualCurrencyAmount;
                paymentMap.currencyUomId = payment.actualCurrencyUomId;
-                paymentToApply =
payment.getBigDecimal("actualCurrencyAmount").setScale(decimals,rounding).subtract(paymentApplied);
+                paymentToApply = payment.getBigDecimal("actualCurrencyAmount");
+                if (paymentToApply) {
+                    paymentToApply = 
paymentToApply.setScale(decimals,rounding).subtract(paymentApplied);
+                }

paymentToApply =
payment.getBigDecimal("actualCurrencyAmount")?.setScale(decimals,
rounding).subtract(paymentApplied);

That's better groovy syntax.

Right, I thought I was in java (I use it more in form snippets where place is 
scarce)
Feel free to improve :p

Jacques

It's also worth noting that numbers with a value of zero evaluate to false in 
groovy which may not be desirable.

Regards
Scott

Yes, I did no think about that. Fixed at r928180/928181. Note that what suggested Adam was not enough, the safe navigation needs to be extended to substract.

Thanks

Jacques

Reply via email to