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

> From: "Adam Heath" <[email protected]>
>> [email protected] 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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to