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 2008/12/01 07:51:15 UTC
svn commit: r721986 [11/13] - in /ofbiz/branches/typecheckcleanup200810:
applications/accounting/script/org/ofbiz/accounting/olap/
applications/order/entitydef/
applications/order/script/org/ofbiz/order/order/
applications/order/script/org/ofbiz/order/...
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductEvents.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductEvents.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductEvents.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.product.product;
+import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Iterator;
@@ -304,7 +305,7 @@
String quantityStr = request.getParameter("QUANTITY");
String sequenceNumStr = request.getParameter("SEQUENCE_NUM");
Timestamp thruDate = null;
- Double quantity = null;
+ BigDecimal quantity = null;
Long sequenceNum = null;
if (UtilValidate.isNotEmpty(thruDateStr)) {
@@ -316,8 +317,8 @@
}
if (UtilValidate.isNotEmpty(quantityStr)) {
try {
- quantity = Double.valueOf(quantityStr);
- } catch (Exception e) {
+ quantity = new BigDecimal(quantityStr);
+ } catch (NumberFormatException e) {
errMsgList.add(UtilProperties.getMessage(resource,"productevents.quantity_not_formatted_correctly", UtilHttp.getLocale(request)));
}
}
@@ -434,10 +435,10 @@
product.set("lastModifiedDate", nowTimestamp);
product.setString("lastModifiedByUserLogin", userLogin.getString("userLoginId"));
try {
- product.set("productHeight", UtilParse.parseDoubleForEntity(request.getParameter("productHeight")));
- product.set("productWidth", UtilParse.parseDoubleForEntity(request.getParameter("productWidth")));
- product.set("productDepth", UtilParse.parseDoubleForEntity(request.getParameter("productDepth")));
- product.set("weight", UtilParse.parseDoubleForEntity(request.getParameter("weight")));
+ product.set("productHeight", UtilParse.parseBigDecimalForEntity(request.getParameter("productHeight")));
+ product.set("productWidth", UtilParse.parseBigDecimalForEntity(request.getParameter("productWidth")));
+ product.set("productDepth", UtilParse.parseBigDecimalForEntity(request.getParameter("productDepth")));
+ product.set("weight", UtilParse.parseBigDecimalForEntity(request.getParameter("weight")));
// default unit settings for shipping parameters
product.set("heightUomId", "LEN_in");
@@ -445,10 +446,10 @@
product.set("depthUomId", "LEN_in");
product.set("weightUomId", "WT_oz");
- Double floz = UtilParse.parseDoubleForEntity(request.getParameter("~floz"));
- Double ml = UtilParse.parseDoubleForEntity(request.getParameter("~ml"));
- Double ntwt = UtilParse.parseDoubleForEntity(request.getParameter("~ntwt"));
- Double grams = UtilParse.parseDoubleForEntity(request.getParameter("~grams"));
+ BigDecimal floz = UtilParse.parseBigDecimalForEntity(request.getParameter("~floz"));
+ BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml"));
+ BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt"));
+ BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams"));
List currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
@@ -471,14 +472,14 @@
do {
GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
try {
- product.set("productHeight", UtilParse.parseDoubleForEntity(request.getParameter("productHeight" + attribIdx)));
- product.set("productWidth", UtilParse.parseDoubleForEntity(request.getParameter("productWidth" + attribIdx)));
- product.set("productDepth", UtilParse.parseDoubleForEntity(request.getParameter("productDepth" + attribIdx)));
- product.set("weight", UtilParse.parseDoubleForEntity(request.getParameter("weight" + attribIdx)));
- Double floz = UtilParse.parseDoubleForEntity(request.getParameter("~floz" + attribIdx));
- Double ml = UtilParse.parseDoubleForEntity(request.getParameter("~ml" + attribIdx));
- Double ntwt = UtilParse.parseDoubleForEntity(request.getParameter("~ntwt" + attribIdx));
- Double grams = UtilParse.parseDoubleForEntity(request.getParameter("~grams" + attribIdx));
+ product.set("productHeight", UtilParse.parseBigDecimalForEntity(request.getParameter("productHeight" + attribIdx)));
+ product.set("productWidth", UtilParse.parseBigDecimalForEntity(request.getParameter("productWidth" + attribIdx)));
+ product.set("productDepth", UtilParse.parseBigDecimalForEntity(request.getParameter("productDepth" + attribIdx)));
+ product.set("weight", UtilParse.parseBigDecimalForEntity(request.getParameter("weight" + attribIdx)));
+ BigDecimal floz = UtilParse.parseBigDecimalForEntity(request.getParameter("~floz" + attribIdx));
+ BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml" + attribIdx));
+ BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt" + attribIdx));
+ BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams" + attribIdx));
List currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
@@ -528,7 +529,7 @@
* @throws GenericEntityException
*/
private static void setOrCreateProdFeature(GenericDelegator delegator, String productId, List currentProductFeatureAndAppls,
- String uomId, String productFeatureTypeId, Double numberSpecified) throws GenericEntityException {
+ String uomId, String productFeatureTypeId, BigDecimal numberSpecified) throws GenericEntityException {
GenericValue productFeatureType = delegator.findByPrimaryKey("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId));
GenericValue uom = delegator.findByPrimaryKey("Uom", UtilMisc.toMap("uomId", uomId));
@@ -543,7 +544,7 @@
boolean foundOneEqual = false;
while (typeUomProductFeatureAndApplIter.hasNext()) {
GenericValue typeUomProductFeatureAndAppl = (GenericValue) typeUomProductFeatureAndApplIter.next();
- if ((numberSpecified != null) && (numberSpecified.equals(typeUomProductFeatureAndAppl.getDouble("numberSpecified")))) {
+ if ((numberSpecified != null) && (numberSpecified.equals(typeUomProductFeatureAndAppl.getBigDecimal("numberSpecified")))) {
foundOneEqual = true;
} else {
// remove the PFA...
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearch.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*/
package org.ofbiz.product.product;
+import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
@@ -1575,11 +1576,11 @@
public static class ListPriceRangeConstraint extends ProductSearchConstraint {
public static final String constraintName = "ListPriceRange";
- protected Double lowPrice;
- protected Double highPrice;
+ protected BigDecimal lowPrice;
+ protected BigDecimal highPrice;
protected String currencyUomId;
- public ListPriceRangeConstraint(Double lowPrice, Double highPrice, String currencyUomId) {
+ public ListPriceRangeConstraint(BigDecimal lowPrice, BigDecimal highPrice, String currencyUomId) {
this.lowPrice = lowPrice;
this.highPrice = highPrice;
this.currencyUomId = UtilValidate.isNotEmpty(currencyUomId) ? currencyUomId : "USD";
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.product.product;
+import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
@@ -273,7 +274,7 @@
Timestamp thruDate = null;
Timestamp fromDate = null;
- Double amount = null;
+ BigDecimal amount = null;
Long sequenceNum = null;
try {
@@ -284,7 +285,7 @@
thruDate = Timestamp.valueOf(thruDateStr);
}
if (UtilValidate.isNotEmpty(amountStr)) {
- amount = Double.valueOf(amountStr);
+ amount = new BigDecimal(amountStr);
}
if (UtilValidate.isNotEmpty(sequenceNumStr)) {
sequenceNum= Long.valueOf(sequenceNumStr);
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Sun Nov 30 22:51:11 2008
@@ -19,6 +19,7 @@
package org.ofbiz.product.product;
import java.io.IOException;
+import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
@@ -702,19 +703,19 @@
// add a list price range to the search
if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW")) || UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
- Double listPriceLow = null;
- Double listPriceHigh = null;
+ BigDecimal listPriceLow = null;
+ BigDecimal listPriceHigh = null;
String listPriceCurrency = UtilHttp.getCurrencyUom(request);
if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW"))) {
try {
- listPriceLow = Double.valueOf((String) parameters.get("LIST_PRICE_LOW"));
+ listPriceLow = new BigDecimal((String) parameters.get("LIST_PRICE_LOW"));
} catch (NumberFormatException e) {
Debug.logError("Error parsing LIST_PRICE_LOW parameter [" + (String) parameters.get("LIST_PRICE_LOW") + "]: " + e.toString(), module);
}
}
if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
try {
- listPriceHigh = Double.valueOf((String) parameters.get("LIST_PRICE_HIGH"));
+ listPriceHigh = new BigDecimal((String) parameters.get("LIST_PRICE_HIGH"));
} catch (NumberFormatException e) {
Debug.logError("Error parsing LIST_PRICE_HIGH parameter [" + (String) parameters.get("LIST_PRICE_HIGH") + "]: " + e.toString(), module);
}
@@ -737,19 +738,19 @@
listPriceHighStr = null;
}
- Double listPriceLow = null;
- Double listPriceHigh = null;
+ BigDecimal listPriceLow = null;
+ BigDecimal listPriceHigh = null;
String listPriceCurrency = UtilHttp.getCurrencyUom(request);
if (UtilValidate.isNotEmpty(listPriceLowStr)) {
try {
- listPriceLow = Double.valueOf(listPriceLowStr);
+ listPriceLow = new BigDecimal(listPriceLowStr);
} catch (NumberFormatException e) {
Debug.logError("Error parsing low part of LIST_PRICE_RANGE parameter [" + listPriceLowStr + "]: " + e.toString(), module);
}
}
if (UtilValidate.isNotEmpty(listPriceHighStr)) {
try {
- listPriceHigh = Double.valueOf(listPriceHighStr);
+ listPriceHigh = new BigDecimal(listPriceHighStr);
} catch (NumberFormatException e) {
Debug.logError("Error parsing high part of LIST_PRICE_RANGE parameter [" + listPriceHighStr + "]: " + e.toString(), module);
}
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductServices.java Sun Nov 30 22:51:11 2008
@@ -22,6 +22,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.util.*;
@@ -248,7 +249,7 @@
// next check inventory for each item: if inventory is not required or is available
try {
- Map invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productIdTo, "quantity", new Double(1.0)));
+ Map invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productIdTo, "quantity", BigDecimal.ONE));
if (ServiceUtil.isError(invReqResult)) {
return ServiceUtil.returnError("Error calling the isStoreInventoryRequired when building the variant product tree.", null, null, invReqResult);
} else if ("Y".equals((String) invReqResult.get("availableOrNotRequired"))) {
@@ -916,8 +917,8 @@
return ServiceUtil.returnError(e.getMessage());
}
- Double availableToPromiseTotal = (Double) invRes.get("availableToPromiseTotal");
- if (availableToPromiseTotal != null && availableToPromiseTotal.doubleValue() > 0) {
+ BigDecimal availableToPromiseTotal = (BigDecimal) invRes.get("availableToPromiseTotal");
+ if (availableToPromiseTotal != null && availableToPromiseTotal.compareTo(BigDecimal.ZERO) > 0) {
// refresh the product so we can update it
GenericValue productToUpdate = null;
try {
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/product/ProductWorker.java Sun Nov 30 22:51:11 2008
@@ -27,6 +27,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.math.BigDecimal;
+import java.math.MathContext;
import java.sql.Timestamp;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.PageContext;
@@ -42,6 +44,7 @@
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ModelService;
+
import javolution.util.FastList;
import javolution.util.FastSet;
@@ -53,6 +56,8 @@
public static final String module = ProductWorker.class.getName();
public static final String resource = "ProductUiLabels";
+ public static final MathContext generalRounding = new MathContext(10);
+
/** @deprecated */
public static void getProduct(PageContext pageContext, String attributeName) {
getProduct(pageContext, attributeName, null);
@@ -240,14 +245,14 @@
* invokes the getInventoryAvailableByFacility service, returns true if specified quantity is available, else false
* this is only used in the related method that uses a ProductConfigWrapper, until that is refactored into a service as well...
*/
- private static boolean isProductInventoryAvailableByFacility(String productId, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException {
- Double availableToPromise = null;
+ private static boolean isProductInventoryAvailableByFacility(String productId, String inventoryFacilityId, BigDecimal quantity, LocalDispatcher dispatcher) throws GenericServiceException {
+ BigDecimal availableToPromise = null;
try {
Map result = dispatcher.runSync("getInventoryAvailableByFacility",
UtilMisc.toMap("productId", productId, "facilityId", inventoryFacilityId));
- availableToPromise = (Double) result.get("availableToPromiseTotal");
+ availableToPromise = (BigDecimal) result.get("availableToPromiseTotal");
if (availableToPromise == null) {
Debug.logWarning("The getInventoryAvailableByFacility service returned a null availableToPromise, the error message was:\n" + result.get(ModelService.ERROR_MESSAGE), module);
@@ -259,7 +264,7 @@
}
// check to see if we got enough back...
- if (availableToPromise.doubleValue() >= quantity) {
+ if (availableToPromise.compareTo(quantity) >= 0) {
if (Debug.infoOn()) Debug.logInfo("Inventory IS available in facility with id " + inventoryFacilityId + " for product id " + productId + "; desired quantity is " + quantity + ", available quantity is " + availableToPromise, module);
return true;
} else {
@@ -272,7 +277,7 @@
* Invokes the getInventoryAvailableByFacility service, returns true if specified quantity is available for all the selected parts, else false.
* Also, set the available flag for all the product configuration's options.
**/
- public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException {
+ public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, BigDecimal quantity, LocalDispatcher dispatcher) throws GenericServiceException {
boolean available = true;
List options = productConfig.getSelectedOptions();
Iterator optionsIt = options.iterator();
@@ -283,10 +288,10 @@
while (productsIt.hasNext()) {
GenericValue product = (GenericValue)productsIt.next();
String productId = product.getString("productId");
- Double cmpQuantity = product.getDouble("quantity");
- double neededQty = 1.0;
+ BigDecimal cmpQuantity = product.getBigDecimal("quantity");
+ BigDecimal neededQty = BigDecimal.ZERO;
if (cmpQuantity != null) {
- neededQty = quantity * cmpQuantity.doubleValue();
+ neededQty = quantity.multiply(cmpQuantity);
}
if (!isProductInventoryAvailableByFacility(productId, inventoryFacilityId, neededQty, dispatcher)) {
ci.setAvailable(false);
@@ -590,8 +595,8 @@
// product calc methods
- public static double calcOrderAdjustments(List orderHeaderAdjustments, double subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
- double adjTotal = 0.0;
+ public static BigDecimal calcOrderAdjustments(List orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
+ BigDecimal adjTotal = BigDecimal.ZERO;
if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) {
List filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false);
@@ -600,20 +605,20 @@
while (adjIt.hasNext()) {
GenericValue orderAdjustment = (GenericValue) adjIt.next();
- adjTotal += calcOrderAdjustment(orderAdjustment, subTotal);
+ adjTotal = adjTotal.add(calcOrderAdjustment(orderAdjustment, subTotal));
}
}
return adjTotal;
}
- public static double calcOrderAdjustment(GenericValue orderAdjustment, double orderSubTotal) {
- double adjustment = 0.0;
+ public static BigDecimal calcOrderAdjustment(GenericValue orderAdjustment, BigDecimal orderSubTotal) {
+ BigDecimal adjustment = BigDecimal.ZERO;
if (orderAdjustment.get("amount") != null) {
- adjustment += orderAdjustment.getDouble("amount").doubleValue();
+ adjustment = adjustment.add(orderAdjustment.getBigDecimal("amount"));
}
else if (orderAdjustment.get("sourcePercentage") != null) {
- adjustment += (orderAdjustment.getDouble("sourcePercentage").doubleValue() * orderSubTotal);
+ adjustment = adjustment.add(orderAdjustment.getBigDecimal("sourcePercentage").multiply(orderSubTotal));
}
return adjustment;
}
@@ -655,11 +660,11 @@
return newOrderAdjustmentsList;
}
- public static double getAverageProductRating(GenericDelegator delegator, String productId) {
+ public static BigDecimal getAverageProductRating(GenericDelegator delegator, String productId) {
return getAverageProductRating(delegator, productId, null);
}
- public static double getAverageProductRating(GenericDelegator delegator, String productId, String productStoreId) {
+ public static BigDecimal getAverageProductRating(GenericDelegator delegator, String productId, String productStoreId) {
GenericValue product = null;
try {
product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
@@ -669,30 +674,30 @@
return ProductWorker.getAverageProductRating(product, productStoreId);
}
- public static double getAverageProductRating(GenericValue product, String productStoreId) {
+ public static BigDecimal getAverageProductRating(GenericValue product, String productStoreId) {
return getAverageProductRating(product, null, productStoreId);
}
- public static double getAverageProductRating(GenericValue product, List reviews, String productStoreId) {
+ public static BigDecimal getAverageProductRating(GenericValue product, List reviews, String productStoreId) {
if (product == null) {
Debug.logWarning("Invalid product entity passed; unable to obtain valid product rating", module);
- return 0.00;
+ return BigDecimal.ZERO;
}
- double productRating = 0.00;
- Double productEntityRating = product.getDouble("productRating");
+ BigDecimal productRating = BigDecimal.ZERO;
+ BigDecimal productEntityRating = product.getBigDecimal("productRating");
String entityFieldType = product.getString("ratingTypeEnum");
// null check
if (productEntityRating == null) {
- productEntityRating = new Double(0);
+ productEntityRating = BigDecimal.ZERO;
}
if (entityFieldType == null) {
entityFieldType = new String();
}
if ("PRDR_FLAT".equals(entityFieldType)) {
- productRating = productEntityRating.doubleValue();
+ productRating = productEntityRating;
} else {
// get the product rating from the ProductReview entity; limit by product store if ID is passed
Map reviewByAnd = UtilMisc.toMap("statusId", "PRR_APPROVED");
@@ -710,32 +715,32 @@
}
// tally the average
- double ratingTally = 0;
- double numRatings = 0;
+ BigDecimal ratingTally = BigDecimal.ZERO;
+ BigDecimal numRatings = BigDecimal.ZERO;
if (reviews != null) {
Iterator i = reviews.iterator();
while (i.hasNext()) {
GenericValue productReview = (GenericValue) i.next();
- Double rating = productReview.getDouble("productRating");
+ BigDecimal rating = productReview.getBigDecimal("productRating");
if (rating != null) {
- ratingTally += rating.doubleValue();
- numRatings++;
+ ratingTally = ratingTally.add(rating);
+ numRatings.add(BigDecimal.ONE);
}
}
}
- if (ratingTally > 0 && numRatings > 0) {
- productRating = ratingTally / numRatings;
+ if (ratingTally.compareTo(BigDecimal.ZERO) > 0 && numRatings.compareTo(BigDecimal.ZERO) > 0) {
+ productRating = ratingTally.divide(numRatings, generalRounding);
}
if ("PRDR_MIN".equals(entityFieldType)) {
// check for min
- if (productEntityRating.doubleValue() > productRating) {
- productRating = productEntityRating.doubleValue();
+ if (productEntityRating.compareTo(productRating) > 0) {
+ productRating = productEntityRating;
}
} else if ("PRDR_MAX".equals(entityFieldType)) {
// check for max
- if (productRating > productEntityRating.doubleValue()) {
- productRating = productEntityRating.doubleValue();
+ if (productRating.compareTo(productEntityRating) > 0) {
+ productRating = productEntityRating;
}
}
}
@@ -1121,12 +1126,12 @@
if (UtilValidate.isNotEmpty(productFeaturePrices)) {
GenericValue productFeaturePrice = productFeaturePrices.get(0);
if (UtilValidate.isNotEmpty(productFeaturePrice)) {
- productPrice.put("price", productPrice.getDouble("price").doubleValue() + productFeaturePrice.getDouble("price").doubleValue());
+ productPrice.put("price", productPrice.getBigDecimal("price").add(productFeaturePrice.getBigDecimal("price")));
}
}
}
if (productPrice.get("price") == null) {
- productPrice.put("price", productPrice.getDouble("price").doubleValue());
+ productPrice.put("price", productPrice.getBigDecimal("price"));
}
productPrice.put("productId", product.getString("productId"));
productPrice.create();
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java Sun Nov 30 22:51:11 2008
@@ -19,6 +19,7 @@
package org.ofbiz.product.spreadsheetimport;
+import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@@ -45,15 +46,15 @@
// prepare the inventoryItem map
public static Map prepareInventoryItem(String productId,
- double quantityOnHand, String inventoryItemId) {
+ BigDecimal quantityOnHand, String inventoryItemId) {
Map fields = new HashMap();
fields.put("inventoryItemId", inventoryItemId);
fields.put("inventoryItemTypeId", "NON_SERIAL_INV_ITEM");
fields.put("productId", productId);
fields.put("ownerPartyId", "Company");
fields.put("facilityId", "WebStoreWarehouse");
- fields.put("quantityOnHandTotal", new Double(quantityOnHand));
- fields.put("availableToPromiseTotal", new Double(quantityOnHand));
+ fields.put("quantityOnHandTotal", quantityOnHand);
+ fields.put("availableToPromiseTotal", quantityOnHand);
return fields;
}
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java Sun Nov 30 22:51:11 2008
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -117,9 +118,9 @@
String productId = cell1.getStringCellValue();
// read QOH from ninth column
HSSFCell cell8 = row.getCell((short) 8);
- double quantityOnHand = 0.0;
+ BigDecimal quantityOnHand = BigDecimal.ZERO;
if (cell8 != null && cell8.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
- quantityOnHand = cell8.getNumericCellValue();
+ quantityOnHand = new BigDecimal(cell8.getNumericCellValue());
// check productId if null then skip creating inventory item
// too.
@@ -128,11 +129,11 @@
if (productId != null && !productId.trim().equalsIgnoreCase("") && !productExists) {
products.add(ImportProductHelper.prepareProduct(productId));
- if (quantityOnHand >= 0.0)
+ if (quantityOnHand.compareTo(BigDecimal.ZERO) >= 0)
inventoryItems.add(ImportProductHelper.prepareInventoryItem(productId, quantityOnHand,
delegator.getNextSeqId("InventoryItem")));
else
- inventoryItems.add(ImportProductHelper.prepareInventoryItem(productId, 0.0, delegator
+ inventoryItems.add(ImportProductHelper.prepareInventoryItem(productId, BigDecimal.ZERO, delegator
.getNextSeqId("InventoryItem")));
}
int rowNum = row.getRowNum() + 1;
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.product.store;
+import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -210,7 +211,7 @@
return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId));
}
- public static List getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List itemSizes, Map featureIdMap, double weight, double orderTotal) {
+ public static List getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List itemSizes, Map featureIdMap, BigDecimal weight, BigDecimal orderTotal) {
if (featureIdMap == null) {
featureIdMap = new HashMap();
}
@@ -232,44 +233,44 @@
//Debug.logInfo("Checking Shipping Method : " + method.getString("shipmentMethodTypeId"), module);
// test min/max weight first
- Double minWeight = method.getDouble("minWeight");
- Double maxWeight = method.getDouble("maxWeight");
- if (minWeight != null && minWeight.doubleValue() > 0 && minWeight.doubleValue() > weight) {
+ BigDecimal minWeight = method.getBigDecimal("minWeight");
+ BigDecimal maxWeight = method.getBigDecimal("maxWeight");
+ if (minWeight != null && minWeight.compareTo(BigDecimal.ZERO) > 0 && minWeight.compareTo(weight) > 0) {
returnShippingMethods.remove(method);
//Debug.logInfo("Removed shipping method due to not enough weight", module);
continue;
}
- if (maxWeight != null && maxWeight.doubleValue() > 0 && maxWeight.doubleValue() < weight) {
+ if (maxWeight != null && maxWeight.compareTo(BigDecimal.ZERO) > 0 && maxWeight.compareTo(weight) < 0) {
returnShippingMethods.remove(method);
//Debug.logInfo("Removed shipping method due to too much weight", module);
continue;
}
// test order total
- Double minTotal = method.getDouble("minTotal");
- Double maxTotal = method.getDouble("maxTotal");
- if (minTotal != null && minTotal.doubleValue() > 0 && minTotal.doubleValue() > orderTotal) {
+ BigDecimal minTotal = method.getBigDecimal("minTotal");
+ BigDecimal maxTotal = method.getBigDecimal("maxTotal");
+ if (minTotal != null && minTotal.compareTo(BigDecimal.ZERO) > 0 && minTotal.compareTo(orderTotal) > 0) {
returnShippingMethods.remove(method);
//Debug.logInfo("Removed shipping method due to not enough order total", module);
continue;
}
- if (maxTotal != null && maxTotal.doubleValue() > 0 && maxTotal.doubleValue() < orderTotal) {
+ if (maxTotal != null && maxTotal.compareTo(BigDecimal.ZERO) > 0 && maxTotal.compareTo(orderTotal) < 0) {
returnShippingMethods.remove(method);
//Debug.logInfo("Removed shipping method due to too much shipping total", module);
continue;
}
// test product sizes
- Double minSize = method.getDouble("minSize");
- Double maxSize = method.getDouble("maxSize");
- if (minSize != null && minSize.doubleValue() > 0) {
+ BigDecimal minSize = method.getBigDecimal("minSize");
+ BigDecimal maxSize = method.getBigDecimal("maxSize");
+ if (minSize != null && minSize.compareTo(BigDecimal.ZERO) > 0) {
boolean allMatch = false;
if (itemSizes != null) {
allMatch = true;
Iterator isi = itemSizes.iterator();
while (isi.hasNext()) {
- Double size = (Double) isi.next();
- if (size.doubleValue() < minSize.doubleValue()) {
+ BigDecimal size = (BigDecimal) isi.next();
+ if (size.compareTo(minSize) < 0) {
allMatch = false;
}
}
@@ -280,14 +281,14 @@
continue;
}
}
- if (maxSize != null && maxSize.doubleValue() > 0) {
+ if (maxSize != null && maxSize.compareTo(BigDecimal.ZERO) > 0) {
boolean allMatch = false;
if (itemSizes != null) {
allMatch = true;
Iterator isi = itemSizes.iterator();
while (isi.hasNext()) {
- Double size = (Double) isi.next();
- if (size.doubleValue() > maxSize.doubleValue()) {
+ BigDecimal size = (BigDecimal) isi.next();
+ if (size.compareTo(maxSize) > 0) {
allMatch = false;
}
}
@@ -333,7 +334,7 @@
// check the items excluded from shipping
String includeFreeShipping = method.getString("includeNoChargeItems");
if (includeFreeShipping != null && "N".equalsIgnoreCase(includeFreeShipping)) {
- if ((itemSizes == null || itemSizes.size() == 0) && orderTotal == 0) {
+ if ((itemSizes == null || itemSizes.size() == 0) && orderTotal.compareTo(BigDecimal.ZERO) == 0) {
returnShippingMethods.remove(method);
//Debug.logInfo("Removed shipping method due to all items being exempt from shipping", module);
continue;
@@ -579,7 +580,7 @@
return isStoreInventoryRequiredAndAvailable(request, product, null, Boolean.TRUE, null);
}
- public static boolean isStoreInventoryAvailable(ServletRequest request, GenericValue product, Double quantity) {
+ public static boolean isStoreInventoryAvailable(ServletRequest request, GenericValue product, BigDecimal quantity) {
return isStoreInventoryRequiredAndAvailable(request, product, quantity, null, Boolean.TRUE);
}
@@ -593,7 +594,7 @@
* @param wantRequired If true then inventory required must be true for the result to be true, if false must be false; if null don't care
* @param wantAvailable If true then inventory avilable must be true for the result to be true, if false must be false; if null don't care
*/
- public static boolean isStoreInventoryRequiredAndAvailable(ServletRequest request, GenericValue product, Double quantity, Boolean wantRequired, Boolean wantAvailable) {
+ public static boolean isStoreInventoryRequiredAndAvailable(ServletRequest request, GenericValue product, BigDecimal quantity, Boolean wantRequired, Boolean wantAvailable) {
GenericValue productStore = getProductStore(request);
if (productStore == null) {
Debug.logWarning("No ProductStore found, return false for inventory check", module);
@@ -604,7 +605,7 @@
return false;
}
- if (quantity == null) quantity = new Double(1);
+ if (quantity == null) quantity = BigDecimal.ONE;
String productStoreId = productStore.getString("productStoreId");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
@@ -642,7 +643,7 @@
}
}
- public static boolean isStoreInventoryAvailable(ServletRequest request, ProductConfigWrapper productConfig, double quantity) {
+ public static boolean isStoreInventoryAvailable(ServletRequest request, ProductConfigWrapper productConfig, BigDecimal quantity) {
GenericValue productStore = getProductStore(request);
if (productStore == null) {
@@ -657,7 +658,7 @@
}
/** check inventory availability for the given catalog, product, quantity, etc */
- public static boolean isStoreInventoryAvailable(String productStoreId, ProductConfigWrapper productConfig, double quantity, GenericDelegator delegator, LocalDispatcher dispatcher) {
+ public static boolean isStoreInventoryAvailable(String productStoreId, ProductConfigWrapper productConfig, BigDecimal quantity, GenericDelegator delegator, LocalDispatcher dispatcher) {
GenericValue productStore = getProductStore(productStoreId, delegator);
if (productStore == null) {
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java Sun Nov 30 22:51:11 2008
@@ -19,6 +19,7 @@
package org.ofbiz.product.supplier;
+import java.math.BigDecimal;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -60,7 +61,7 @@
String productId = (String) context.get("productId");
String partyId = (String) context.get("partyId");
String currencyUomId = (String) context.get("currencyUomId");
- Double quantity =(Double) context.get("quantity");
+ BigDecimal quantity =(BigDecimal) context.get("quantity");
String canDropShip = (String) context.get("canDropShip");
try {
product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java Sun Nov 30 22:51:11 2008
@@ -28,6 +28,7 @@
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilDateTime;
+import java.math.BigDecimal;
import java.util.Map;
import javolution.util.FastMap;
@@ -37,7 +38,7 @@
protected GenericDelegator delegator = null;
protected GenericValue userLogin = null;
protected static String inventoryTransferId = null;
- protected double transferQty = 1;
+ protected BigDecimal transferQty = BigDecimal.ONE;
public InventoryItemTransferTest(String name) {
super(name);
@@ -61,7 +62,7 @@
ctx.put("facilityId", "WebStoreWarehouse");
ctx.put("facilityIdTo", "WebStoreWarehouse");
ctx.put("receiveDate", UtilDateTime.nowTimestamp());
- ctx.put("xferQty", new Double (transferQty));
+ ctx.put("xferQty", transferQty);
ctx.put("userLogin", userLogin);
Map resp = dispatcher.runSync("createInventoryTransfer", ctx);
inventoryTransferId = (String) resp.get("inventoryTransferId");
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/StockMovesTest.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/StockMovesTest.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/StockMovesTest.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/product/test/StockMovesTest.java Sun Nov 30 22:51:11 2008
@@ -27,6 +27,7 @@
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.base.util.UtilMisc;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;
@@ -78,7 +79,7 @@
ppsmCtx.put("facilityId", "WebStoreWarehouse");
ppsmCtx.put("locationSeqId","TLTLTLUL01" );
ppsmCtx.put("targetLocationSeqId", "TLTLTLLL01");
- ppsmCtx.put("quantityMoved", new Double(5));
+ ppsmCtx.put("quantityMoved", new BigDecimal("5"));
ppsmCtx.put("userLogin", userLogin);
Map respMap3 = dispatcher.runSync("processPhysicalStockMove", ppsmCtx);
}
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.shipment.packing;
+import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;
@@ -37,8 +38,8 @@
String shipGroupSeqId = (String) context.get("shipGroupSeqId");
String orderId = (String) context.get("orderId");
String productId = (String) context.get("productId");
- Double quantity = (Double) context.get("quantity");
- Double weight = (Double) context.get("weight");
+ BigDecimal quantity = (BigDecimal) context.get("quantity");
+ BigDecimal weight = (BigDecimal) context.get("weight");
Integer packageSeq = (Integer) context.get("packageSeq");
// set the instructions -- will clear out previous if now null
@@ -50,18 +51,18 @@
session.setPickerPartyId(pickerPartyId);
if (quantity == null) {
- quantity = new Double(1);
+ quantity = BigDecimal.ONE;
}
Debug.log("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] Pack input [" + productId + "] @ [" + quantity + "] packageSeq [" + packageSeq + "] weight [" + weight +"]", module);
if (weight == null) {
Debug.logWarning("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] product [" + productId + "] being packed without a weight, assuming 0", module);
- weight = new Double(0.0);
+ weight = BigDecimal.ZERO;
}
try {
- session.addOrIncreaseLine(orderId, null, shipGroupSeqId, productId, quantity.doubleValue(), packageSeq.intValue(), weight.doubleValue(), false);
+ session.addOrIncreaseLine(orderId, null, shipGroupSeqId, productId, quantity, packageSeq.intValue(), weight, false);
} catch (GeneralException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -148,13 +149,13 @@
weights = new String[] { wgtStr };
for (int p = 0; p < packages.length; p++) {
- double quantity;
+ BigDecimal quantity;
int packageSeq;
- double weightSeq;
+ BigDecimal weightSeq;
try {
- quantity = Double.parseDouble(quantities[p]);
+ quantity = new BigDecimal(quantities[p]);
packageSeq = Integer.parseInt(packages[p]);
- weightSeq = Double.parseDouble(weights[p]);
+ weightSeq = new BigDecimal(weights[p]);
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
@@ -227,8 +228,8 @@
String carrierRoleTypeId = (String) context.get("carrierRoleTypeId");
String productStoreId = (String) context.get("productStoreId");
- double shippableWeight = setSessionPackageWeights(session, packageWeights);
- Double estimatedShipCost = session.getShipmentCostEstimate(shippingContactMechId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, productStoreId, null, null, new Double(shippableWeight), null);
+ BigDecimal shippableWeight = setSessionPackageWeights(session, packageWeights);
+ BigDecimal estimatedShipCost = session.getShipmentCostEstimate(shippingContactMechId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, productStoreId, null, null, shippableWeight, null);
session.setAdditionalShippingCharge(estimatedShipCost);
session.setWeightUomId(weightUomId);
@@ -244,7 +245,7 @@
// set the instructions -- will clear out previous if now null
String instructions = (String) context.get("handlingInstructions");
String pickerPartyId = (String) context.get("pickerPartyId");
- Double additionalShippingCharge = (Double) context.get("additionalShippingCharge");
+ BigDecimal additionalShippingCharge = (BigDecimal) context.get("additionalShippingCharge");
Map packageWeights = (Map) context.get("packageWeights");
String weightUomId = (String) context.get("weightUomId");
session.setHandlingInstructions(instructions);
@@ -277,17 +278,17 @@
return resp;
}
- public static double setSessionPackageWeights(PackingSession session, Map packageWeights) {
- double shippableWeight = 0;
+ public static BigDecimal setSessionPackageWeights(PackingSession session, Map packageWeights) {
+ BigDecimal shippableWeight = BigDecimal.ZERO;
if (! UtilValidate.isEmpty(packageWeights)) {
Iterator pwit = packageWeights.keySet().iterator();
while (pwit.hasNext()) {
String packageSeqId = (String) pwit.next();
String packageWeightStr = (String) packageWeights.get(packageSeqId);
if (UtilValidate.isNotEmpty(packageWeightStr)) {
- double packageWeight = UtilMisc.toDouble(packageWeights.get(packageSeqId));
- session.setPackageWeight(Integer.parseInt(packageSeqId), new Double(packageWeight));
- shippableWeight += packageWeight;
+ BigDecimal packageWeight = new BigDecimal((String)packageWeights.get(packageSeqId));
+ session.setPackageWeight(Integer.parseInt(packageSeqId), packageWeight);
+ shippableWeight = shippableWeight.add(packageWeight);
} else {
session.setPackageWeight(Integer.parseInt(packageSeqId), null);
}
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Sun Nov 30 22:51:11 2008
@@ -55,7 +55,7 @@
protected String shipmentId = null;
protected String instructions = null;
protected String weightUomId = null;
- protected Double additionalShippingCharge = null;
+ protected BigDecimal additionalShippingCharge = null;
protected Map packageWeights = null;
protected List packEvents = null;
protected List packLines = null;
@@ -93,14 +93,14 @@
this(dispatcher, userLogin, null, null, null, null);
}
- public void addOrIncreaseLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, double quantity, int packageSeqId, double weight, boolean update) throws GeneralException {
+ public void addOrIncreaseLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, int packageSeqId, BigDecimal weight, boolean update) throws GeneralException {
// reset the session if we just completed
if (status == 0) {
throw new GeneralException("Packing session has been completed; be sure to CLEAR before packing a new order! [000]");
}
// do nothing if we are trying to add a quantity of 0
- if (!update && quantity == 0) {
+ if (!update && quantity.compareTo(BigDecimal.ZERO) == 0) {
return;
}
@@ -139,9 +139,9 @@
// more than one reservation found
Map toCreateMap = FastMap.newInstance();
Iterator i = reservations.iterator();
- double qtyRemain = quantity;
+ BigDecimal qtyRemain = quantity;
- while (i.hasNext() && qtyRemain > 0) {
+ while (i.hasNext() && qtyRemain.compareTo(BigDecimal.ZERO) > 0) {
GenericValue res = (GenericValue) i.next();
// Check that the inventory item product match with the current product to pack
@@ -149,26 +149,26 @@
continue;
}
- double resQty = res.getDouble("quantity").doubleValue();
- double resPackedQty = this.getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, res.getString("inventoryItemId"), -1);
- if (resPackedQty >= resQty) {
+ BigDecimal resQty = res.getBigDecimal("quantity");
+ BigDecimal resPackedQty = this.getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, res.getString("inventoryItemId"), -1);
+ if (resPackedQty.compareTo(resQty) >= 0) {
continue;
} else if (!update) {
- resQty -= resPackedQty;
+ resQty = resQty.subtract(resPackedQty);
}
- double thisQty = resQty > qtyRemain ? qtyRemain : resQty;
+ BigDecimal thisQty = resQty.compareTo(qtyRemain) > 0 ? qtyRemain : resQty;
int thisCheck = this.checkLineForAdd(res, orderId, orderItemSeqId, shipGroupSeqId, productId, thisQty, packageSeqId, update);
switch (thisCheck) {
case 2:
Debug.log("Packing check returned '2' - new pack line will be created!", module);
- toCreateMap.put(res, new Double(thisQty));
- qtyRemain -= thisQty;
+ toCreateMap.put(res, thisQty);
+ qtyRemain = qtyRemain.subtract(thisQty);
break;
case 1:
Debug.log("Packing check returned '1' - existing pack line has been updated!", module);
- qtyRemain -= thisQty;
+ qtyRemain = qtyRemain.subtract(thisQty);
break;
case 0:
Debug.log("Packing check returned '0' - doing nothing.", module);
@@ -176,12 +176,12 @@
}
}
- if (qtyRemain == 0) {
+ if (qtyRemain.compareTo(BigDecimal.ZERO) == 0) {
Iterator x = toCreateMap.keySet().iterator();
while (x.hasNext()) {
GenericValue res = (GenericValue) x.next();
- Double qty = (Double) toCreateMap.get(res);
- this.createPackLineItem(2, res, orderId, orderItemSeqId, shipGroupSeqId, productId, qty.doubleValue(), weight, packageSeqId);
+ BigDecimal qty = (BigDecimal) toCreateMap.get(res);
+ this.createPackLineItem(2, res, orderId, orderItemSeqId, shipGroupSeqId, productId, qty, weight, packageSeqId);
}
} else {
throw new GeneralException("Not enough inventory reservation available; cannot pack the item! [103]");
@@ -192,12 +192,12 @@
this.runEvents(PackingEvent.EVENT_CODE_ADD);
}
- public void addOrIncreaseLine(String orderId, String orderItemSeqId, String shipGroupSeqId, double quantity, int packageSeqId) throws GeneralException {
- this.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, null, quantity, packageSeqId, 0, false);
+ public void addOrIncreaseLine(String orderId, String orderItemSeqId, String shipGroupSeqId, BigDecimal quantity, int packageSeqId) throws GeneralException {
+ this.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, null, quantity, packageSeqId, BigDecimal.ZERO, false);
}
- public void addOrIncreaseLine(String productId, double quantity, int packageSeqId) throws GeneralException {
- this.addOrIncreaseLine(null, null, null, productId, quantity, packageSeqId, 0, false);
+ public void addOrIncreaseLine(String productId, BigDecimal quantity, int packageSeqId) throws GeneralException {
+ this.addOrIncreaseLine(null, null, null, productId, quantity, packageSeqId, BigDecimal.ZERO, false);
}
public PackingSessionLine findLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) {
@@ -217,7 +217,7 @@
return null;
}
- protected void createPackLineItem(int checkCode, GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, double quantity, double weight, int packageSeqId) throws GeneralException {
+ protected void createPackLineItem(int checkCode, GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, BigDecimal weight, int packageSeqId) throws GeneralException {
// process the result; add new item if necessary
switch(checkCode) {
case 0:
@@ -234,7 +234,7 @@
}
// Add the line weight to the package weight
- if (weight > 0) this.addToPackageWeight(packageSeqId, new Double(weight));
+ if (weight.compareTo(BigDecimal.ZERO) > 0) this.addToPackageWeight(packageSeqId, weight);
// update the package sequence
if (packageSeqId > packageSeq) {
@@ -242,7 +242,7 @@
}
}
- protected String findOrderItemSeqId(String productId, String orderId, String shipGroupSeqId, double quantity) throws GeneralException {
+ protected String findOrderItemSeqId(String productId, String orderId, String shipGroupSeqId, BigDecimal quantity) throws GeneralException {
Map lookupMap = FastMap.newInstance();
lookupMap.put("orderId", orderId);
lookupMap.put("productId", productId);
@@ -267,8 +267,8 @@
Iterator resIter = reservations.iterator();
while (resIter.hasNext()) {
GenericValue res = (GenericValue) resIter.next();
- Double qty = res.getDouble("quantity");
- if (quantity <= qty.doubleValue()) {
+ BigDecimal qty = res.getBigDecimal("quantity");
+ if (quantity.compareTo(qty) <= 0) {
orderItemSeqId = item.getString("orderItemSeqId");
break;
}
@@ -283,27 +283,27 @@
}
}
- protected int checkLineForAdd(GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, double quantity, int packageSeqId, boolean update) {
+ protected int checkLineForAdd(GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity, int packageSeqId, boolean update) {
// check to see if the reservation can hold the requested quantity amount
String invItemId = res.getString("inventoryItemId");
- double resQty = res.getDouble("quantity").doubleValue();
+ BigDecimal resQty = res.getBigDecimal("quantity");
PackingSessionLine line = this.findLine(orderId, orderItemSeqId, shipGroupSeqId, productId, invItemId, packageSeqId);
- double packedQty = this.getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId);
+ BigDecimal packedQty = this.getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId);
Debug.log("Packed quantity [" + packedQty + "] + [" + quantity + "]", module);
if (line == null) {
Debug.log("No current line found testing [" + invItemId + "] R: " + resQty + " / Q: " + quantity, module);
- if (resQty < quantity) {
+ if (resQty.compareTo(quantity) < 0) {
return 0;
} else {
return 2;
}
} else {
- double newQty = update ? quantity : (line.getQuantity() + quantity);
+ BigDecimal newQty = update ? quantity : (line.getQuantity().add(quantity));
Debug.log("Existing line found testing [" + invItemId + "] R: " + resQty + " / Q: " + newQty, module);
- if (resQty < newQty) {
+ if (resQty.compareTo(newQty) < 0) {
return 0;
} else {
line.setQuantity(newQty);
@@ -351,16 +351,16 @@
return packageSeq;
}
- public double getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId) {
+ public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId) {
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, -1);
}
- public double getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, int packageSeq) {
+ public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, int packageSeq) {
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, packageSeq);
}
- public double getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) {
- double total = 0.0;
+ public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) {
+ BigDecimal total = BigDecimal.ZERO;
List lines = this.getLines();
Iterator i = lines.iterator();
while (i.hasNext()) {
@@ -369,7 +369,7 @@
shipGroupSeqId.equals(line.getShipGroupSeqId()) && productId.equals(line.getProductId())) {
if (inventoryItemId == null || inventoryItemId.equals(line.getInventoryItemId())) {
if (packageSeq == -1 || packageSeq == line.getPackageSeq()) {
- total += line.getQuantity();
+ total = total.add(line.getQuantity());
}
}
}
@@ -377,7 +377,7 @@
return total;
}
- public double getPackedQuantity(String productId, int packageSeq) {
+ public BigDecimal getPackedQuantity(String productId, int packageSeq) {
if (productId != null) {
try {
productId = ProductWorker.findProductId(this.getDelegator(), productId);
@@ -386,7 +386,7 @@
}
}
- double total = 0.0;
+ BigDecimal total = BigDecimal.ZERO;
if (productId != null ) {
List lines = this.getLines();
Iterator i = lines.iterator();
@@ -394,7 +394,7 @@
PackingSessionLine line = (PackingSessionLine) i.next();
if (productId.equals(line.getProductId())) {
if (packageSeq == -1 || packageSeq == line.getPackageSeq()) {
- total += line.getQuantity();
+ total = total.add(line.getQuantity());
}
}
}
@@ -402,49 +402,48 @@
return total;
}
- public double getPackedQuantity(int packageSeq) {
- double total = 0.0;
+ public BigDecimal getPackedQuantity(int packageSeq) {
+ BigDecimal total = BigDecimal.ZERO;
List lines = this.getLines();
Iterator i = lines.iterator();
while (i.hasNext()) {
PackingSessionLine line = (PackingSessionLine) i.next();
if (packageSeq == -1 || packageSeq == line.getPackageSeq()) {
- total += line.getQuantity();
+ total = total.add(line.getQuantity());
}
}
return total;
}
- public double getPackedQuantity(String productId) {
+ public BigDecimal getPackedQuantity(String productId) {
return getPackedQuantity(productId, -1);
}
- public double getCurrentReservedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId) {
- double reserved = -1;
+ public BigDecimal getCurrentReservedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId) {
+ BigDecimal reserved = BigDecimal.ONE.negate();
try {
GenericValue res = EntityUtil.getFirst(this.getDelegator().findByAnd("OrderItemAndShipGrpInvResAndItemSum", UtilMisc.toMap("orderId", orderId,
"orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId, "inventoryProductId", productId)));
- Double reservedDbl = res.getDouble("totQuantityAvailable");
- if (reservedDbl == null) {
- reservedDbl = new Double(-1);
+ reserved = res.getBigDecimal("totQuantityAvailable");
+ if (reserved == null) {
+ reserved = BigDecimal.ONE.negate();
}
- reserved = reservedDbl.doubleValue();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
return reserved;
}
- public double getCurrentShippedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId) {
- double shipped = 0.0;
+ public BigDecimal getCurrentShippedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId) {
+ BigDecimal shipped = BigDecimal.ZERO;
List issues = this.getItemIssuances(orderId, orderItemSeqId, shipGroupSeqId);
if (issues != null) {
Iterator i = issues.iterator();
while (i.hasNext()) {
GenericValue v = (GenericValue) i.next();
- Double qty = v.getDouble("quantity");
- if (qty == null) qty = new Double(0);
- shipped += qty.doubleValue();
+ BigDecimal qty = v.getBigDecimal("quantity");
+ if (qty == null) qty = BigDecimal.ZERO;
+ shipped = shipped.add(qty);
}
}
@@ -625,8 +624,8 @@
Iterator i = this.getLines().iterator();
while (i.hasNext()) {
PackingSessionLine line = (PackingSessionLine) i.next();
- double reservedQty = this.getCurrentReservedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId());
- double packedQty = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId());
+ BigDecimal reservedQty = this.getCurrentReservedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId());
+ BigDecimal packedQty = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId());
if (packedQty != reservedQty) {
errors.add("Packed amount does not match reserved amount for item (" + line.getProductId() + ") [" + packedQty + " / " + reservedQty + "]");
@@ -648,7 +647,7 @@
Iterator i = lines.iterator();
while (i.hasNext()) {
PackingSessionLine l = (PackingSessionLine) i.next();
- if (l.getQuantity() == 0) {
+ if (l.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
this.packLines.remove(l);
}
}
@@ -715,10 +714,10 @@
while (i.hasNext()) {
PackingSessionLine line = (PackingSessionLine) i.next();
if (this.checkLine(processedLines, line)) {
- double totalPacked = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(),
+ BigDecimal totalPacked = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(),
line.getShipGroupSeqId(), line.getProductId(), line.getInventoryItemId(), -1);
- line.issueItemToShipment(shipmentId, picklistBinId, userLogin, new Double(totalPacked), getDispatcher());
+ line.issueItemToShipment(shipmentId, picklistBinId, userLogin, totalPacked, getDispatcher());
processedLines.add(line);
}
}
@@ -766,8 +765,8 @@
}
protected void updateShipmentRouteSegments() throws GeneralException {
- Double shipmentWeight = new Double(getTotalWeight());
- if (shipmentWeight.doubleValue() <= 0) return;
+ BigDecimal shipmentWeight = getTotalWeight();
+ if (shipmentWeight.compareTo(BigDecimal.ZERO) <= 0) return;
List shipmentRouteSegments = getDelegator().findByAnd("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", this.getShipmentId()));
if (! UtilValidate.isEmpty(shipmentRouteSegments)) {
Iterator srit = shipmentRouteSegments.iterator();
@@ -814,40 +813,40 @@
}
}
- public Double getAdditionalShippingCharge() {
+ public BigDecimal getAdditionalShippingCharge() {
return additionalShippingCharge;
}
- public void setAdditionalShippingCharge(Double additionalShippingCharge) {
+ public void setAdditionalShippingCharge(BigDecimal additionalShippingCharge) {
this.additionalShippingCharge = additionalShippingCharge;
}
- public double getTotalWeight() {
- double total = 0.0;
+ public BigDecimal getTotalWeight() {
+ BigDecimal total = BigDecimal.ZERO;
for (int i = 0; i < packageSeq; i++) {
- Double packageWeight = getPackageWeight(i);
+ BigDecimal packageWeight = getPackageWeight(i);
if (! UtilValidate.isEmpty(packageWeight)) {
- total += packageWeight.doubleValue();
+ total = total.add(packageWeight);
}
}
return total;
}
- public Double getShipmentCostEstimate(GenericValue orderItemShipGroup, String productStoreId, List shippableItemInfo, Double shippableTotal, Double shippableWeight, Double shippableQuantity) {
+ public BigDecimal getShipmentCostEstimate(GenericValue orderItemShipGroup, String productStoreId, List shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) {
return getShipmentCostEstimate(orderItemShipGroup.getString("contactMechId"), orderItemShipGroup.getString("shipmentMethodTypeId"),
orderItemShipGroup.getString("carrierPartyId"), orderItemShipGroup.getString("carrierRoleTypeId"),
productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity);
}
- public Double getShipmentCostEstimate(GenericValue orderItemShipGroup, String productStoreId) {
+ public BigDecimal getShipmentCostEstimate(GenericValue orderItemShipGroup, String productStoreId) {
return getShipmentCostEstimate(orderItemShipGroup.getString("contactMechId"), orderItemShipGroup.getString("shipmentMethodTypeId"),
orderItemShipGroup.getString("carrierPartyId"), orderItemShipGroup.getString("carrierRoleTypeId"),
productStoreId, null, null, null, null);
}
- public Double getShipmentCostEstimate(String shippingContactMechId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String productStoreId, List shippableItemInfo, Double shippableTotal, Double shippableWeight, Double shippableQuantity) {
+ public BigDecimal getShipmentCostEstimate(String shippingContactMechId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String productStoreId, List shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) {
- Double shipmentCostEstimate = null;
+ BigDecimal shipmentCostEstimate = null;
Map serviceResult = null;
try {
Map serviceContext = FastMap.newInstance();
@@ -869,17 +868,17 @@
serviceContext.put("shippableItemInfo", shippableItemInfo);
if (UtilValidate.isEmpty(shippableWeight)) {
- shippableWeight = new Double(getTotalWeight());
+ shippableWeight = getTotalWeight();
}
serviceContext.put("shippableWeight", shippableWeight);
if (UtilValidate.isEmpty(shippableQuantity)) {
- shippableQuantity = new Double(getPackedQuantity(-1));
+ shippableQuantity = getPackedQuantity(-1);
}
serviceContext.put("shippableQuantity", shippableQuantity);
if (UtilValidate.isEmpty(shippableTotal)) {
- shippableTotal = new Double(0);
+ shippableTotal = BigDecimal.ZERO;
}
serviceContext.put("shippableTotal", shippableTotal);
@@ -891,7 +890,7 @@
}
if (! UtilValidate.isEmpty(serviceResult.get("shippingEstimateAmount"))) {
- shipmentCostEstimate = (Double) serviceResult.get("shippingEstimateAmount");
+ shipmentCostEstimate = (BigDecimal) serviceResult.get("shippingEstimateAmount");
}
return shipmentCostEstimate;
@@ -918,7 +917,7 @@
return new ArrayList(packageSeqIds);
}
- public void setPackageWeight(int packageSeqId, Double packageWeight) {
+ public void setPackageWeight(int packageSeqId, BigDecimal packageWeight) {
if (UtilValidate.isEmpty(packageWeight)) {
packageWeights.remove(new Integer(packageSeqId));
} else {
@@ -926,20 +925,20 @@
}
}
- public Double getPackageWeight(int packageSeqId) {
+ public BigDecimal getPackageWeight(int packageSeqId) {
if (this.packageWeights == null) return null;
- Double packageWeight = null;
+ BigDecimal packageWeight = null;
Object p = packageWeights.get(new Integer(packageSeqId));
if (p != null) {
- packageWeight = (Double) p;
+ packageWeight = (BigDecimal) p;
}
return packageWeight;
}
- public void addToPackageWeight(int packageSeqId, Double weight) {
+ public void addToPackageWeight(int packageSeqId, BigDecimal weight) {
if (UtilValidate.isEmpty(weight)) return;
- Double packageWeight = getPackageWeight(packageSeqId);
- Double newPackageWeight = UtilValidate.isEmpty(packageWeight) ? weight : new Double(weight.doubleValue() + packageWeight.doubleValue());
+ BigDecimal packageWeight = getPackageWeight(packageSeqId);
+ BigDecimal newPackageWeight = UtilValidate.isEmpty(packageWeight) ? weight : weight.add(packageWeight);
setPackageWeight(packageSeqId, newPackageWeight);
}
Modified: ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.shipment.packing;
+import java.math.BigDecimal;
import java.util.Map;
import javolution.util.FastMap;
@@ -40,11 +41,11 @@
protected String productId = null;
protected String inventoryItemId = null;
protected String shipmentItemSeqId = null;
- protected double quantity = 0;
- protected double weight = 0;
+ protected BigDecimal quantity = BigDecimal.ZERO;
+ protected BigDecimal weight = BigDecimal.ZERO;
protected int packageSeq = 0;
- public PackingSessionLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, double quantity, double weight, int packageSeq) {
+ public PackingSessionLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, BigDecimal quantity, BigDecimal weight, int packageSeq) {
this.orderId = orderId;
this.orderItemSeqId = orderItemSeqId;
this.shipGroupSeqId = shipGroupSeqId;
@@ -83,28 +84,28 @@
this.shipmentItemSeqId = shipmentItemSeqId;
}
- public double getQuantity() {
+ public BigDecimal getQuantity() {
return this.quantity;
}
- public void setQuantity(double quantity) {
+ public void setQuantity(BigDecimal quantity) {
this.quantity = quantity;
}
- public void addQuantity(double quantity) {
- this.quantity += quantity;
+ public void addQuantity(BigDecimal quantity) {
+ this.quantity = this.quantity.add(quantity);
}
- public double getWeight() {
+ public BigDecimal getWeight() {
return weight;
}
- public void setWeight(double weight) {
+ public void setWeight(BigDecimal weight) {
this.weight = weight;
}
- public void addWeight(double weight) {
- this.weight += weight;
+ public void addWeight(BigDecimal weight) {
+ this.weight = this.weight.add(weight);
}
public int getPackageSeq() {
@@ -124,9 +125,9 @@
return false;
}
- protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, Double quantity, LocalDispatcher dispatcher) throws GeneralException {
+ protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, LocalDispatcher dispatcher) throws GeneralException {
if (quantity == null) {
- quantity = new Double(this.getQuantity());
+ quantity = this.getQuantity();
}
Map issueMap = FastMap.newInstance();
@@ -163,8 +164,8 @@
GenericValue plItem = delegator.findByPrimaryKey("PicklistItem", itemLookup);
if (plItem != null) {
Debug.log("Found picklist bin: " + plItem, module);
- Double itemQty = plItem.getDouble("quantity");
- if (itemQty.doubleValue() == quantity.doubleValue()) {
+ BigDecimal itemQty = plItem.getBigDecimal("quantity");
+ if (itemQty.compareTo(quantity) == 0) {
// set to complete
itemLookup.put("itemStatusId", "PICKITEM_COMPLETED");
} else {
@@ -191,7 +192,7 @@
Map packageMap = FastMap.newInstance();
packageMap.put("shipmentId", shipmentId);
packageMap.put("shipmentItemSeqId", this.getShipmentItemSeqId());
- packageMap.put("quantity", new Double(this.getQuantity()));
+ packageMap.put("quantity", this.getQuantity());
packageMap.put("shipmentPackageSeqId", shipmentPackageSeqId);
packageMap.put("userLogin", userLogin);
Map packageResp = dispatcher.runSync("addShipmentContentToPackage", packageMap);