You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2007/04/19 09:09:03 UTC

svn commit: r530293 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Author: lektran
Date: Thu Apr 19 00:09:02 2007
New Revision: 530293

URL: http://svn.apache.org/viewvc?view=rev&rev=530293
Log:
A couple more conversions to BigDecimal, OFBIZ-880

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=530293&r1=530292&r2=530293
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Thu Apr 19 00:09:02 2007
@@ -1456,20 +1456,21 @@
                 }
 
                 Map shippingEstMap = ShippingEvents.getShipEstimate(dispatcher, delegator, orh, shipGroupSeqId);
-                Double shippingTotal = null;
+                BigDecimal shippingTotal = null;
                 if (orh.getValidOrderItems(shipGroupSeqId) == null || orh.getValidOrderItems(shipGroupSeqId).size() == 0) {
-                    shippingTotal = new Double(0.00);
+                    shippingTotal = ZERO;
                     Debug.log("No valid order items found - " + shippingTotal, module);
                 } else {
-                    shippingTotal = (Double) shippingEstMap.get("shippingTotal");
+                    shippingTotal = new BigDecimal(((Double) shippingEstMap.get("shippingTotal")).doubleValue());
+                    shippingTotal = shippingTotal.setScale(orderDecimals, orderRounding);
                     Debug.log("Got new shipping estimate - " + shippingTotal, module);
                 }
                 if (Debug.infoOn()) {
                     Debug.log("New Shipping Total [" + orderId + " / " + shipGroupSeqId + "] : " + shippingTotal, module);
                 }
 
-                double currentShipping = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId), orh.getAdjustments(), false, false, true);
-                currentShipping += OrderReadHelper.calcOrderAdjustments(orh.getOrderHeaderAdjustments(shipGroupSeqId), orh.getOrderItemsSubTotal(), false, false, true);
+                BigDecimal currentShipping = OrderReadHelper.getAllOrderItemsAdjustmentsTotalBd(orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId), orh.getAdjustments(), false, false, true);
+                currentShipping = currentShipping.add(OrderReadHelper.calcOrderAdjustmentsBd(orh.getOrderHeaderAdjustments(shipGroupSeqId), orh.getOrderItemsSubTotalBd(), false, false, true));
 
                 if (Debug.infoOn()) {
                     Debug.log("Old Shipping Total [" + orderId + " / " + shipGroupSeqId + "] : " + currentShipping, module);
@@ -1481,9 +1482,9 @@
                     continue;
                 }
 
-                if ((shippingTotal != null) && (shippingTotal.doubleValue() != currentShipping)) {
+                if ((shippingTotal != null) && (shippingTotal.compareTo(currentShipping) != 0)) {
                     // place the difference as a new shipping adjustment
-                    Double adjustmentAmount = new Double(shippingTotal.doubleValue() - currentShipping);
+                    BigDecimal adjustmentAmount = shippingTotal.subtract(currentShipping);
                     String adjSeqId = delegator.getNextSeqId("OrderAdjustment");
                     GenericValue orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentId", adjSeqId));
                     orderAdjustment.set("orderAdjustmentTypeId", "SHIPPING_CHARGES");