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 2010/03/26 15:34:02 UTC
svn commit: r927870 -
/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
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);
+ }
} else {
paymentMap.amount = payment.amount;
paymentMap.currencyUomId = payment.currencyUomId;
- paymentToApply = payment.getBigDecimal("amount").setScale(decimals,rounding).subtract(paymentApplied);
+ paymentToApply = payment.getBigDecimal("amount");
+ if (paymentToApply) {
+ paymentToApply = paymentToApply.setScale(decimals,rounding).subtract(paymentApplied);
+ }
}
- if (paymentToApply.signum() == 1) {
+ if (paymentToApply && paymentToApply.signum() == 1) {
paymentMap.paymentId = payment.paymentId;
paymentMap.effectiveDate = payment.effectiveDate;
if (paymentToApply.compareTo(invoiceToApply) < 0 ) {
Re: svn commit: r927870 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
Posted by Jacques Le Roux <ja...@les7arts.com>.
Scott Gray wrote:
> On 26/03/2010, at 8:53 AM, Jacques Le Roux wrote:
>
>> From: "Adam Heath" <do...@brainfood.com>
>>> jleroux@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
Re: svn commit: r927870 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
Posted by Scott Gray <sc...@hotwaxmedia.com>.
On 26/03/2010, at 8:53 AM, Jacques Le Roux wrote:
> From: "Adam Heath" <do...@brainfood.com>
>> jleroux@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
Re: svn commit: r927870 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
Posted by Jacques Le Roux <ja...@les7arts.com>.
From: "Adam Heath" <do...@brainfood.com>
> jleroux@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
Re: svn commit: r927870 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
Posted by Adam Heath <do...@brainfood.com>.
jleroux@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.