You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2009/11/14 10:32:04 UTC
Re: svn commit: r834274 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
Hi Scott,
I continue on this, I have created a Jira https://issues.apache.org/jira/browse/OFBIZ-3200
I have replaced all new BigDecimal("0.00") by BigDecimal.ZERO in OFBIZ-3200.patch + some changes copied on this commit.
But I'd like to have your opinion on that. There are still these cases. I will handle the POS ones, could you take care of the
others or at least guide me
PayPalServices.java (3 matches)
127: encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00");
338: encoder.add("SHIPPINGAMT", "0.00");
339: encoder.add("TAXAMT", "0.00");
ValueLinkApi.java
673: return "0.00";
POS
Operator.java
104: String total = "0.00";
Receipt.java (2 matches)
480: UtilFormatOut.formatPrice(trans.getTotalDue().negate()) : "0.00"), priceLength[type], false, ' '));
482: UtilFormatOut.formatPrice(trans.GetTotalDiscount()) : "0.00"), priceLength[type], false, ' '));
Thanks
Jacques
> Author: lektran
> Date: Mon Nov 9 23:01:34 2009
> New Revision: 834274
>
> URL: http://svn.apache.org/viewvc?rev=834274&view=rev
> Log:
> Instead of parsing a default string of "0.00" into a BigDecimal just assign BigDecimal.ZERO
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
>
> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=834274&r1=834273&r2=834274&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Mon Nov 9 23:01:34 2009
> @@ -400,7 +400,7 @@
> }
>
> // get the selected amount
> - String selectedAmountStr = "0.00";
> + String selectedAmountStr = null;
> if (paramMap.containsKey("ADD_AMOUNT")) {
> selectedAmountStr = (String) paramMap.remove("ADD_AMOUNT");
> } else if (paramMap.containsKey("add_amount")) {
> @@ -409,13 +409,15 @@
>
> // parse the amount
> BigDecimal amount = null;
> - if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
> + if (UtilValidate.isNotEmpty(selectedAmountStr)) {
> try {
> amount = new BigDecimal(nf.parse(selectedAmountStr).doubleValue());
> } catch (Exception e) {
> Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
> amount = null;
> }
> + } else {
> + amount = BigDecimal.ZERO;
> }
>
> // check for required amount
>
>
Re: svn commit: r834274 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
Posted by Jacques Le Roux <ja...@les7arts.com>.
Thanks Scott!
Jacques
From: "Scott Gray" <sc...@hotwaxmedia.com>
> Hi Jacques,
>
> I'll look at the patch and comment in the issue, inline for the questions below.
>
> Regards
> Scott
>
> On 14/11/2009, at 10:32 PM, Jacques Le Roux wrote:
>
>> Hi Scott,
>>
>> I continue on this, I have created a Jira https://issues.apache.org/jira/browse/OFBIZ-3200
>>
>> I have replaced all new BigDecimal("0.00") by BigDecimal.ZERO in OFBIZ-3200.patch + some changes copied on this commit.
>>
>> But I'd like to have your opinion on that. There are still these cases. I will handle the POS ones, could you take care of the
>> others or at least guide me
>>
>> PayPalServices.java (3 matches)
>> 127: encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00");
>> 338: encoder.add("SHIPPINGAMT", "0.00");
>> 339: encoder.add("TAXAMT", "0.00");
>
> Leave these as is, they're being sent to PayPal and not dealt with by us
>
>> ValueLinkApi.java
>> 673: return "0.00";
>
> I have no idea what ValueLink is, I would leave it alone for now.
>
>> POS
>> Operator.java
>> 104: String total = "0.00";
> BigDecimal total = BigDecimal.ZERO;
> if (trans != null) {
> total = trans.getTotalDue();
> }
> field.setText(UtilFormatOut.formatPrice(total));
>
>> Receipt.java (2 matches)
>> 480: UtilFormatOut.formatPrice(trans.getTotalDue().negate()) : "0.00"), priceLength[type], false, ' '));
>> 482: UtilFormatOut.formatPrice(trans.GetTotalDiscount()) : "0.00"), priceLength[type], false, ' '));
>
> expandMap.put("change", UtilFormatOut .padString (UtilFormatOut
> .formatPrice(trans.getTotalDue().compareTo(BigDecimal.ZERO) < 0 ?
> trans.getTotalDue().negate() : BigDecimal.ZERO), priceLength[type], false, ' '));
> expandMap.put("saleDiscount", UtilFormatOut .padString (UtilFormatOut
> .formatPrice(trans.GetTotalDiscount().compareTo(BigDecimal.ZERO) != 0 ?
> trans.GetTotalDiscount() : BigDecimal.ZERO), priceLength[type], false, ' '));
> (Just move the formatPrice call out so that it wraps the ternary then replace 0.00 with BigDecimal.ZERO)
>
>> Thanks
>>
>> Jacques
>>
>>
>>> Author: lektran
>>> Date: Mon Nov 9 23:01:34 2009
>>> New Revision: 834274
>>>
>>> URL: http://svn.apache.org/viewvc?rev=834274&view=rev
>>> Log:
>>> Instead of parsing a default string of "0.00" into a BigDecimal just assign BigDecimal.ZERO
>>>
>>> Modified:
>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java
>>>
>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartEvents.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=834274&r1=834273&r2=834274&view=diff
>>> = = = = = = = = = =====================================================================
>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java (original)
>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java Mon Nov 9 23:01:34 2009
>>> @@ -400,7 +400,7 @@
>>> }
>>>
>>> // get the selected amount
>>> - String selectedAmountStr = "0.00";
>>> + String selectedAmountStr = null;
>>> if (paramMap.containsKey("ADD_AMOUNT")) {
>>> selectedAmountStr = (String) paramMap.remove("ADD_AMOUNT");
>>> } else if (paramMap.containsKey("add_amount")) {
>>> @@ -409,13 +409,15 @@
>>>
>>> // parse the amount
>>> BigDecimal amount = null;
>>> - if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
>>> + if (UtilValidate.isNotEmpty(selectedAmountStr)) {
>>> try {
>>> amount = new BigDecimal(nf.parse(selectedAmountStr).doubleValue());
>>> } catch (Exception e) {
>>> Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
>>> amount = null;
>>> }
>>> + } else {
>>> + amount = BigDecimal.ZERO;
>>> }
>>>
>>> // check for required amount
>>>
>>
>>
>
>
Re: svn commit: r834274 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Jacques,
I'll look at the patch and comment in the issue, inline for the
questions below.
Regards
Scott
On 14/11/2009, at 10:32 PM, Jacques Le Roux wrote:
> Hi Scott,
>
> I continue on this, I have created a Jira https://issues.apache.org/jira/browse/OFBIZ-3200
>
> I have replaced all new BigDecimal("0.00") by BigDecimal.ZERO in
> OFBIZ-3200.patch + some changes copied on this commit.
>
> But I'd like to have your opinion on that. There are still these
> cases. I will handle the POS ones, could you take care of the others
> or at least guide me
>
> PayPalServices.java (3 matches)
> 127: encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00");
> 338: encoder.add("SHIPPINGAMT", "0.00");
> 339: encoder.add("TAXAMT", "0.00");
Leave these as is, they're being sent to PayPal and not dealt with by us
> ValueLinkApi.java
> 673: return "0.00";
I have no idea what ValueLink is, I would leave it alone for now.
> POS
> Operator.java
> 104: String total = "0.00";
BigDecimal total = BigDecimal.ZERO;
if (trans != null) {
total = trans.getTotalDue();
}
field.setText(UtilFormatOut.formatPrice(total));
> Receipt.java (2 matches)
> 480: UtilFormatOut.formatPrice(trans.getTotalDue().negate()) :
> "0.00"), priceLength[type], false, ' '));
> 482: UtilFormatOut.formatPrice(trans.GetTotalDiscount()) : "0.00"),
> priceLength[type], false, ' '));
expandMap.put("change",
UtilFormatOut
.padString
(UtilFormatOut
.formatPrice(trans.getTotalDue().compareTo(BigDecimal.ZERO) < 0 ?
trans.getTotalDue().negate() : BigDecimal.ZERO),
priceLength[type], false, ' '));
expandMap.put("saleDiscount",
UtilFormatOut
.padString
(UtilFormatOut
.formatPrice(trans.GetTotalDiscount().compareTo(BigDecimal.ZERO) != 0 ?
trans.GetTotalDiscount() : BigDecimal.ZERO),
priceLength[type], false, ' '));
(Just move the formatPrice call out so that it wraps the ternary then
replace 0.00 with BigDecimal.ZERO)
> Thanks
>
> Jacques
>
>
>> Author: lektran
>> Date: Mon Nov 9 23:01:34 2009
>> New Revision: 834274
>>
>> URL: http://svn.apache.org/viewvc?rev=834274&view=rev
>> Log:
>> Instead of parsing a default string of "0.00" into a BigDecimal
>> just assign BigDecimal.ZERO
>>
>> Modified:
>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> ShoppingCartEvents.java
>>
>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/
>> shoppingcart/ShoppingCartEvents.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=834274&r1=834273&r2=834274&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> ShoppingCartEvents.java (original)
>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> ShoppingCartEvents.java Mon Nov 9 23:01:34 2009
>> @@ -400,7 +400,7 @@
>> }
>>
>> // get the selected amount
>> - String selectedAmountStr = "0.00";
>> + String selectedAmountStr = null;
>> if (paramMap.containsKey("ADD_AMOUNT")) {
>> selectedAmountStr = (String)
>> paramMap.remove("ADD_AMOUNT");
>> } else if (paramMap.containsKey("add_amount")) {
>> @@ -409,13 +409,15 @@
>>
>> // parse the amount
>> BigDecimal amount = null;
>> - if (selectedAmountStr != null &&
>> selectedAmountStr.length() > 0) {
>> + if (UtilValidate.isNotEmpty(selectedAmountStr)) {
>> try {
>> amount = new
>> BigDecimal(nf.parse(selectedAmountStr).doubleValue());
>> } catch (Exception e) {
>> Debug.logWarning(e, "Problem parsing amount string:
>> " + selectedAmountStr, module);
>> amount = null;
>> }
>> + } else {
>> + amount = BigDecimal.ZERO;
>> }
>>
>> // check for required amount
>>
>
>