Author: jleroux
Date: Sat Nov 14 11:01:08 2009
New Revision: 836153

URL: http://svn.apache.org/viewvc?rev=836153&view=rev
Log:
Close "Replace all "0.00" in java code, notably to allow passing different 
decimals lenghtes" (https://issues.apache.org/jira/browse/OFBIZ-3200) - 
OFBIZ-3200

Modified:
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Operator.java
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Receipt.java

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
 Sat Nov 14 11:01:08 2009
@@ -557,7 +557,7 @@
             results.put("processAmount", new 
BigDecimal(ar.getResponseField(AuthorizeResponse.AMOUNT)));
         } else {
             results.put("authCode", ar.getResponseCode());
-            results.put("processAmount", new BigDecimal("0.00"));
+            results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", AuthorizeResponse.ERROR);
         }
         Debug.logInfo("processAuthTransResult: " + results.toString(),module);
@@ -574,7 +574,7 @@
             results.put("captureCode", 
ar.getResponseField(AuthorizeResponse.AUTHORIZATION_CODE));
             results.put("captureAmount", new 
BigDecimal(ar.getResponseField(AuthorizeResponse.AMOUNT)));
         } else {
-            results.put("captureAmount", new BigDecimal("0.00"));
+            results.put("captureAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processCaptureTransResult: " + 
results.toString(),module);
     }
@@ -591,7 +591,7 @@
             results.put("refundCode", 
ar.getResponseField(AuthorizeResponse.AUTHORIZATION_CODE));
             results.put("refundAmount", new 
BigDecimal(ar.getResponseField(AuthorizeResponse.AMOUNT)));
         } else {
-            results.put("refundAmount", new BigDecimal("0.00"));
+            results.put("refundAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processRefundTransResult: " + 
results.toString(),module);
         return results;
@@ -609,7 +609,7 @@
             results.put("releaseCode", 
ar.getResponseField(AuthorizeResponse.AUTHORIZATION_CODE));
             results.put("releaseAmount", new 
BigDecimal(ar.getResponseField(AuthorizeResponse.AMOUNT)));
         } else {
-            results.put("releaseAmount", new BigDecimal("0.00"));
+            results.put("releaseAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processReleaseTransResult: " + 
results.toString(),module);
         return results;
@@ -633,7 +633,7 @@
             results.put("processAmount", new 
BigDecimal(ar.getResponseField(AuthorizeResponse.AMOUNT)));
         } else {
             results.put("authCode", ar.getResponseCode());
-            results.put("processAmount", new BigDecimal("0.00"));
+            results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", AuthorizeResponse.ERROR);
         }
         Debug.logInfo("processAuthTransResult: " + results.toString(),module);

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
 Sat Nov 14 11:01:08 2009
@@ -75,7 +75,7 @@
         if (getMessageListMaxSev(authResponseDoc) > 4) {  // 5 and higher, 
process error from HSBC
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("authResult", new Boolean(false));
-            result.put("processAmount", new BigDecimal("0.00"));
+            result.put("processAmount", BigDecimal.ZERO);
             result.put("authRefNum", getReferenceNum(authResponseDoc));
             List<String> messages = getMessageList(authResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -105,7 +105,7 @@
         if (getMessageListMaxSev(creditResponseDoc) > 4) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("creditResult", new Boolean(false));
-            result.put("creditAmount", new BigDecimal("0.00"));
+            result.put("creditAmount", BigDecimal.ZERO);
             result.put("creditRefNum", getReferenceNum(creditResponseDoc));
             List<String> messages = getMessageList(creditResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -138,7 +138,7 @@
         if (getMessageListMaxSev(captureResponseDoc) > 4) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("captureResult", new Boolean(false));
-            result.put("captureAmount", new BigDecimal("0.00"));
+            result.put("captureAmount", BigDecimal.ZERO);
             result.put("captureRefNum", getReferenceNum(captureResponseDoc));
             List<String> messages = getMessageList(captureResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -170,7 +170,7 @@
         if (getMessageListMaxSev(releaseResponseDoc) > 4) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("releaseResult", new Boolean(false));
-            result.put("releaseAmount", new BigDecimal("0.00"));
+            result.put("releaseAmount", BigDecimal.ZERO);
             result.put("releaseRefNum", getReferenceNum(releaseResponseDoc));
             List<String> messages = getMessageList(releaseResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -224,7 +224,7 @@
         if (getMessageListMaxSev(refundResponseDoc) > 4) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("refundResult", new Boolean(false));
-            result.put("refundAmount", new BigDecimal("0.00"));
+            result.put("refundAmount", BigDecimal.ZERO);
             result.put("refundRefNum", getReferenceNum(refundResponseDoc));
             List<String> messages = getMessageList(refundResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -257,7 +257,7 @@
         if (getMessageListMaxSev(reauthResponseDoc) > 4) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("reauthResult", new Boolean(false));
-            result.put("reauthAmount", new BigDecimal("0.00"));
+            result.put("reauthAmount", BigDecimal.ZERO);
             result.put("reauthRefNum", getReferenceNum(reauthResponseDoc));
             List<String> messages = getMessageList(reauthResponseDoc);
             if (UtilValidate.isNotEmpty(messages)) {
@@ -386,7 +386,7 @@
             result.put("processAmount", new 
BigDecimal(authAmountStr).movePointLeft(2));
         } else {
             result.put("authResult", Boolean.valueOf(false));
-            result.put("processAmount", new BigDecimal("0.00"));
+            result.put("processAmount", BigDecimal.ZERO);
         }
 
         result.put("authRefNum", UtilXml.childElementValue(orderFormElement, 
"Id"));
@@ -432,7 +432,7 @@
             result.put("creditAmount", new 
BigDecimal(creditAmountStr).movePointLeft(2));
         } else {
             result.put("creditResult", Boolean.valueOf(false));
-            result.put("creditAmount", new BigDecimal("0.00"));
+            result.put("creditAmount", BigDecimal.ZERO);
         }
 
         result.put("creditRefNum", UtilXml.childElementValue(orderFormElement, 
"Id"));
@@ -466,7 +466,7 @@
             result.put("captureAmount", new 
BigDecimal(captureAmountStr).movePointLeft(2));
         } else {
             result.put("captureResult", Boolean.valueOf(false));
-            result.put("captureAmount", new BigDecimal("0.00"));
+            result.put("captureAmount", BigDecimal.ZERO);
         }
 
         result.put("captureRefNum", 
UtilXml.childElementValue(orderFormElement, "Id"));
@@ -500,7 +500,7 @@
             result.put("releaseAmount", new 
BigDecimal(releaseAmountStr).movePointLeft(2));
         } else {
             result.put("releaseResult", Boolean.valueOf(false));
-            result.put("releaseAmount", new BigDecimal("0.00"));
+            result.put("releaseAmount", BigDecimal.ZERO);
         }
 
         result.put("releaseRefNum", 
UtilXml.childElementValue(orderFormElement, "Id"));
@@ -534,7 +534,7 @@
             result.put("refundAmount", new 
BigDecimal(refundAmountStr).movePointLeft(2));
         } else {
             result.put("refundResult", Boolean.valueOf(false));
-            result.put("refundAmount", new BigDecimal("0.00"));
+            result.put("refundAmount", BigDecimal.ZERO);
         }
 
         result.put("refundRefNum", UtilXml.childElementValue(orderFormElement, 
"Id"));
@@ -568,7 +568,7 @@
             result.put("reauthAmount", new 
BigDecimal(reauthAmountStr).movePointLeft(2));
         } else {
             result.put("reauthResult", Boolean.valueOf(false));
-            result.put("reauthAmount", new BigDecimal("0.00"));
+            result.put("reauthAmount", BigDecimal.ZERO);
         }
 
         result.put("reauthRefNum", UtilXml.childElementValue(orderFormElement, 
"Id"));

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
 Sat Nov 14 11:01:08 2009
@@ -516,7 +516,7 @@
             results.put("processAmount", new 
BigDecimal(results.get("processAmount").toString()));
         } else {
             results.put("authCode", response.getAuthCode());
-            results.put("processAmount", new BigDecimal("0.00"));
+            results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", OrbitalPaymentServices.ERROR);
         }
         Debug.logInfo("processAuthTransResult: " + results.toString(),module);
@@ -540,7 +540,7 @@
             results.put("processAmount", new 
BigDecimal(results.get("processAmount").toString()));
         } else {
             results.put("authCode", response.getAuthCode());
-            results.put("processAmount", new BigDecimal("0.00"));
+            results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", OrbitalPaymentServices.ERROR);
         }
         Debug.logInfo("processAuthCaptureTransResult: " + 
results.toString(),module);
@@ -557,7 +557,7 @@
             results.put("captureCode", response.getAuthCode());
             results.put("captureAmount", new 
BigDecimal(results.get("captureAmount").toString()));
         } else {
-            results.put("captureAmount", new BigDecimal("0.00"));
+            results.put("captureAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processCaptureTransResult: " + 
results.toString(),module);
     }
@@ -573,7 +573,7 @@
             results.put("refundCode", response.getAuthCode());
             results.put("refundAmount", new 
BigDecimal(results.get("refundAmount").toString()));
         } else {
-            results.put("refundAmount", new BigDecimal("0.00"));
+            results.put("refundAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processRefundTransResult: " + 
results.toString(),module);
     }
@@ -589,7 +589,7 @@
             results.put("releaseCode", response.getAuthCode());
             results.put("releaseAmount", new 
BigDecimal(results.get("releaseAmount").toString()));
         } else {
-            results.put("releaseAmount", new BigDecimal("0.00"));
+            results.put("releaseAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processReleaseTransResult: " + 
results.toString(),module);
     }

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
 Sat Nov 14 11:01:08 2009
@@ -682,7 +682,7 @@
      */
     public BigDecimal getAmount(String amount) {
         if (amount == null) {
-            return new BigDecimal("0.00");
+            return BigDecimal.ZERO;
         }
         BigDecimal amountBd = new BigDecimal(amount);
         return amountBd.movePointLeft(2);

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java 
(original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java 
Sat Nov 14 11:01:08 2009
@@ -1013,7 +1013,7 @@
             product = item.getRelatedOne("Product");
         } catch (GenericEntityException e) {
             Debug.logError(e, "Problem getting Product from OrderItem; 
returning 0", module);
-            return new BigDecimal ("0.00");
+            return BigDecimal.ZERO;
         }
         if (product != null) {
             if (ProductWorker.shippingApplies(product)) {

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=836153&r1=836152&r2=836153&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
 Sat Nov 14 11:01:08 2009
@@ -1634,20 +1634,22 @@
                 }
 
                 // get the selected amount
-                String selectedAmountStr = "0.00";
+                String selectedAmountStr = null;
                 if (paramMap.containsKey("amount" + thisSuffix)) {
                     selectedAmountStr = (String) paramMap.remove("amount" + 
thisSuffix);
                 }
 
                 // parse the amount
                 BigDecimal amount = null;
-                if (selectedAmountStr != null && selectedAmountStr.length() > 
0) {
+                if (UtilValidate.isNotEmpty(selectedAmountStr)) {
                     try {
                         amount = new BigDecimal(selectedAmountStr);
                     } catch (Exception e) {
                         Debug.logWarning(e, "Problem parsing amount string: " 
+ selectedAmountStr, module);
                         amount = null;
                     }
+                } else {
+                    amount = BigDecimal.ZERO;
                 }
 
                 if (paramMap.containsKey("itemDesiredDeliveryDate" + 
thisSuffix)) {
@@ -1818,18 +1820,20 @@
                     Debug.logWarning(e, "Problems parsing quantity string: " + 
quantityStr, module);
                     quantity = BigDecimal.ZERO;
                 }
-                String selectedAmountStr = "0.00";
+                String selectedAmountStr = null;
                 if (paramMap.containsKey("amount" + thisSuffix)) {
                     selectedAmountStr = (String) paramMap.remove("amount" + 
thisSuffix);
                 }
                 BigDecimal amount = null;
-                if (selectedAmountStr != null && selectedAmountStr.length() > 
0) {
+                if (UtilValidate.isNotEmpty(selectedAmountStr)) {
                     try {
                         amount = new BigDecimal(selectedAmountStr);
                     } catch (Exception e) {
                         Debug.logWarning(e, "Problem parsing amount string: " 
+ selectedAmountStr, module);
                         amount = null;
                     }
+                } else {
+                    amount = BigDecimal.ZERO;
                 }
                 if (paramMap.containsKey("itemDesiredDeliveryDate" + 
thisSuffix)) {
                     itemDesiredDeliveryDateStr = (String) 
paramMap.remove("itemDesiredDeliveryDate" + thisSuffix);

Modified: 
ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Operator.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Operator.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Operator.java 
(original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/Operator.java 
Sat Nov 14 11:01:08 2009
@@ -21,6 +21,7 @@
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.Component;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import javax.swing.BorderFactory;
@@ -101,11 +102,11 @@
 
         String fieldName = field.getName();
         if (OPER_TOTAL[0].equals(fieldName)) {
-            String total = "0.00";
+            BigDecimal total = BigDecimal.ZERO;
             if (trans != null) {
-                total = UtilFormatOut.formatPrice(trans.getTotalDue());
+                total = trans.getTotalDue();
             }
-            field.setText(total);
+            field.setText(UtilFormatOut.formatPrice(total));
         } else if (OPER_DATE[0].equals(fieldName)) {
             field.setText(sdf.format(new Date()));
         } else if (OPER_EMPL[0].equals(fieldName)) {

Modified: 
ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Receipt.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Receipt.java?rev=836153&r1=836152&r2=836153&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Receipt.java 
(original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Receipt.java 
Sat Nov 14 11:01:08 2009
@@ -476,11 +476,8 @@
         expandMap.put("taxTotal", 
UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getTaxTotal()), 
priceLength[type], false, ' '));
         expandMap.put("grandTotal", 
UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getGrandTotal()), 
priceLength[type], false, ' '));
         expandMap.put("totalPayments", 
UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getPaymentTotal()), 
priceLength[type], false, ' '));
-        expandMap.put("change", 
UtilFormatOut.padString((trans.getTotalDue().compareTo(BigDecimal.ZERO) < 0 ?
-                UtilFormatOut.formatPrice(trans.getTotalDue().negate()) : 
"0.00"), priceLength[type], false, ' '));
-        expandMap.put("saleDiscount", 
UtilFormatOut.padString((trans.GetTotalDiscount().compareTo(BigDecimal.ZERO) != 
0 ?
-                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, 
' '));
         return expandMap;
     }
 


Reply via email to