Author: jleroux
Date: Tue Feb 13 12:29:42 2018
New Revision: 1824120

URL: http://svn.apache.org/viewvc?rev=1824120&view=rev
Log:
Improved: [DEPRECATION] Replace BigDecimal.ROUND_* by RoundingMode.*
(OFBIZ-9571)

Replaces both getBigDecimalRoundingMode() by getRoundingMode()

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java?rev=1824120&r1=1824119&r2=1824120&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
 Tue Feb 13 12:29:42 2018
@@ -36,7 +36,7 @@ import org.apache.ofbiz.entity.util.Enti
 
 
 public final class UtilAccounting {
-       
+    
     public static final String module = UtilAccounting.class.getName();
 
     private UtilAccounting() {}
@@ -311,7 +311,7 @@ public final class UtilAccounting {
         BigDecimal origAmount = amounts.getBigDecimal("origAmount");
         BigDecimal amount = amounts.getBigDecimal("amount");
         if (origAmount != null && amount != null && 
BigDecimal.ZERO.compareTo(origAmount) != 0 && BigDecimal.ZERO.compareTo(amount) 
!= 0 && amount.compareTo(origAmount) != 0) {
-            exchangeRate = amount.divide(origAmount, 
UtilNumber.getBigDecimalScale("ledger.decimals"), 
UtilNumber.getBigDecimalRoundingMode("invoice.rounding"));
+            exchangeRate = amount.divide(origAmount, 
UtilNumber.getBigDecimalScale("ledger.decimals"), 
UtilNumber.getRoundingMode("invoice.rounding"));
         }
         return exchangeRate;
     }
@@ -332,7 +332,7 @@ public final class UtilAccounting {
         BigDecimal origAmount = amounts.getBigDecimal("origAmount");
         BigDecimal amount = amounts.getBigDecimal("amount");
         if (origAmount != null && amount != null && 
BigDecimal.ZERO.compareTo(origAmount) != 0 && BigDecimal.ZERO.compareTo(amount) 
!= 0 && amount.compareTo(origAmount) != 0) {
-            exchangeRate = amount.divide(origAmount, 
UtilNumber.getBigDecimalScale("ledger.decimals"), 
UtilNumber.getBigDecimalRoundingMode("invoice.rounding"));
+            exchangeRate = amount.divide(origAmount, 
UtilNumber.getBigDecimalScale("ledger.decimals"), 
UtilNumber.getRoundingMode("invoice.rounding"));
         }
         return exchangeRate;
     }

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1824120&r1=1824119&r2=1824120&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
 Tue Feb 13 12:29:42 2018
@@ -3550,9 +3550,9 @@ public class OrderServices {
                 if (remainder.compareTo(BigDecimal.ZERO) != 0) {
                     return 
ServiceUtil.returnError(UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", locale));
                 }
-                quantity = quantity.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                quantity = quantity.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
             } else {
-                quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
             }
         } catch(GenericEntityException e) {
             Debug.logError(e.getMessage(), module);
@@ -3721,9 +3721,9 @@ public class OrderServices {
                         if (remainder.compareTo(BigDecimal.ZERO) != 0) {
                             return 
ServiceUtil.returnError(UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", locale));
                         }
-                        qty = qty.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        qty = qty.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                     } else {
-                        qty = 
qty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        qty = 
qty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                     }
                 } catch(GenericEntityException e) {
                     Debug.logError(e.getMessage(), module);
@@ -3870,9 +3870,9 @@ public class OrderServices {
                         if (remainder.compareTo(BigDecimal.ZERO) != 0) {
                             return 
ServiceUtil.returnError(UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", locale));
                         }
-                        groupQty = groupQty.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        groupQty = groupQty.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                     } else {
-                        groupQty = 
groupQty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        groupQty = 
groupQty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                     }
                 } catch(GenericEntityException e) {
                     Debug.logError(e.getMessage(), module);

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1824120&r1=1824119&r2=1824120&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
 Tue Feb 13 12:29:42 2018
@@ -476,10 +476,10 @@ public class ShoppingCartEvents {
                     request.setAttribute("_ERROR_MESSAGE_", 
UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", locale));
                     return "error";
                 }
-                quantity = quantity.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                quantity = quantity.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
             }
             else {
-                quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
             }
         } catch (Exception e) {
             Debug.logWarning(e, "Problems parsing quantity string: " + 
quantityStr, module);
@@ -1836,10 +1836,10 @@ public class ShoppingCartEvents {
                             request.setAttribute("_ERROR_MESSAGE_", 
UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", cart.getLocale()));
                             return "error";
                         }
-                        quantity = quantity.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        quantity = quantity.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                     }
                     else {
-                        quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                        quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                     }
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e.getMessage(), module);

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=1824120&r1=1824119&r2=1824120&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
 Tue Feb 13 12:29:42 2018
@@ -447,9 +447,9 @@ public class ShoppingCartHelper {
                             if (remainder.compareTo(BigDecimal.ZERO) != 0) {
                                 return 
ServiceUtil.returnError(UtilProperties.getMessage(resource_error, 
"cart.addToCart.quantityInDecimalNotAllowed", this.cart.getLocale()));
                             }
-                            quantity = quantity.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                            quantity = quantity.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                         } else {
-                            quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                            quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                         }
                     } catch(GenericEntityException e) {
                         Debug.logError(e.getMessage(), module);
@@ -779,10 +779,10 @@ public class ShoppingCartHelper {
                                 result = ServiceUtil.returnError(errorMsgs);
                                 return result;
                             }
-                            quantity = quantity.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                            quantity = quantity.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                         }
                         else {
-                            quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                            quantity = 
quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                         }
                         if (quantity.compareTo(BigDecimal.ZERO) < 0) {
                             String errMsg = 
UtilProperties.getMessage(resource_error, "cart.quantity_not_positive_number", 
this.cart.getLocale());

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java?rev=1824120&r1=1824119&r2=1824120&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java
 Tue Feb 13 12:29:42 2018
@@ -272,10 +272,10 @@ public final class ProductDisplayWorker
                 BigDecimal occs = productQuantities.get(prodId);
                 //For quantity we should test if we allow to add decimal 
quantity for this product an productStore : if not then round to 0
                 if(! ProductWorker.isDecimalQuantityOrderAllowed(delegator, 
prodId, cart.getProductStoreId())){
-                    occs = occs.setScale(0, 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                    occs = occs.setScale(0, 
UtilNumber.getRoundingMode("order.rounding"));
                 }
                 else {
-                    occs = 
occs.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getBigDecimalRoundingMode("order.rounding"));
+                    occs = 
occs.setScale(UtilNumber.getBigDecimalScale("order.decimals"), 
UtilNumber.getRoundingMode("order.rounding"));
                 }
                 productQuantities.put(prodId, occs);
                 BigDecimal nqdbl = quantityModifier.multiply(new 
BigDecimal(quantity)).add(occs.multiply(occurancesModifier));


Reply via email to