Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Mon Jan 5 23:13:36 2009 @@ -227,7 +227,7 @@ NOTE that this does manage OrderShipment records, but NOTHING else, so it is only to be used for Shipment Plan stuff BEFORE the items are issued, shipment packed, etc.</description> <auto-attributes entity-name="ShipmentItem" include="pk" mode="IN" optional="false"/> - <attribute name="newItemQuantity" type="Double" mode="IN" optional="false"/> + <attribute name="newItemQuantity" type="BigDecimal" mode="IN" optional="false"/> <attribute name="newShipmentItemSeqId" type="String" mode="OUT" optional="true"/> </service> @@ -395,7 +395,7 @@ <description>Issue an OrderItem to a Shipment - only for non-sales orders</description> <auto-attributes entity-name="Shipment" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="OrderItemShipGroupAssoc" include="pk" mode="IN" optional="false"/> - <attribute name="quantity" type="Double" mode="IN" optional="false"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/> <attribute name="shipmentItemSeqId" type="String" mode="OUT" optional="false"/> <attribute name="itemIssuanceId" type="String" mode="OUT" optional="false"/> </service> @@ -404,7 +404,7 @@ <description>Add an OrderItemShipGrpInvRes to a Shipment - only for sales orders</description> <auto-attributes entity-name="Shipment" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="OrderItemShipGrpInvRes" include="pk" mode="IN" optional="false"/> - <attribute name="quantity" type="Double" mode="IN" optional="false"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/> <attribute name="shipmentItemSeqId" type="String" mode="OUT" optional="false"/> <attribute name="itemIssuanceId" type="String" mode="OUT" optional="false"/> </service> @@ -413,7 +413,7 @@ <description>Issue an InventoryItem to a FixedAssetMaint - for conversion to use as supples/parts</description> <auto-attributes entity-name="InventoryItem" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="FixedAssetMaint" include="pk" mode="IN" optional="false"/> - <attribute name="quantity" type="Double" mode="IN" optional="false"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/> <attribute name="itemIssuanceId" type="String" mode="OUT" optional="false"/> </service> <service name="returnInventoryItemIssuedToFixedAssetMaint" engine="simple" @@ -425,8 +425,8 @@ location="org/ofbiz/shipment/issuance/IssuanceServices.xml" invoke="cancelOrderItemIssuanceFromSalesShipment" auth="true"> <description>Cancel an ItemIssuance from Sales Shipment</description> <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/> - <attribute name="cancelQuantity" type="Double" mode="IN" optional="true"/> - <attribute name="canceledQuantity" type="Double" mode="OUT" optional="false"/> + <attribute name="cancelQuantity" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="canceledQuantity" type="BigDecimal" mode="OUT" optional="false"/> </service> <service name="issueInventoryItemToShipment" engine="simple" @@ -435,8 +435,8 @@ <attribute name="shipmentId" type="String" mode="IN" optional="false"/> <attribute name="shipmentItemSeqId" type="String" mode="IN" optional="false"/> <attribute name="inventoryItemId" type="String" mode="IN" optional="false"/> - <attribute name="quantity" type="Double" mode="IN" optional="false"/> - <attribute name="totalIssuedQty" type="Double" mode="IN" optional="false"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="totalIssuedQty" type="BigDecimal" mode="IN" optional="false"/> <attribute name="itemIssuanceId" type="String" mode="OUT" optional="false"/> </service> @@ -448,7 +448,7 @@ <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="orderId" type="String" mode="IN" optional="true"/> <attribute name="shipGroupSeqId" type="String" mode="IN" optional="true"/> - <attribute name="quantity" type="Double" mode="IN" optional="true"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/> <attribute name="packageSeq" type="Integer" mode="IN" optional="false"/> <attribute name="pickerPartyId" type="String" mode="IN" optional="true"/> <attribute name="handlingInstructions" type="String" mode="IN" optional="true"/> @@ -489,7 +489,7 @@ <attribute name="carrierPartyId" type="String" mode="IN" optional="false"/> <attribute name="carrierRoleTypeId" type="String" mode="IN" optional="false"/> <attribute name="productStoreId" type="String" mode="IN" optional="false"/> - <attribute name="additionalShippingCharge" type="Double" mode="OUT" optional="true"/> + <attribute name="additionalShippingCharge" type="BigDecimal" mode="OUT" optional="true"/> </service> <service name="clearPackAll" engine="java" @@ -521,7 +521,7 @@ <attribute name="packingSession" type="org.ofbiz.shipment.packing.PackingSession" mode="IN" optional="false"/> <attribute name="handlingInstructions" type="String" mode="IN" optional="true"/> <attribute name="pickerPartyId" type="String" mode="IN" optional="true"/> - <attribute name="additionalShippingCharge" type="Double" mode="IN" optional="true"/> + <attribute name="additionalShippingCharge" type="BigDecimal" mode="IN" optional="true"/> <attribute name="forceComplete" type="Boolean" mode="IN" optional="true"/> <attribute name="packageWeights" type="Map" string-map-prefix="packageWeight_" mode="IN" optional="true"/> <attribute name="weightUomId" type="String" mode="IN" optional="true"/> @@ -545,7 +545,7 @@ location="org/ofbiz/shipment/shipment/ShipmentServices.xml" invoke="getQuantityForShipment" auth="true"> <description>get the order item quantity still not put in shipments</description> <auto-attributes include="pk" mode="IN" optional="false"/> - <attribute name="remainingQuantity" type="Double" mode="OUT" optional="false"/> + <attribute name="remainingQuantity" type="BigDecimal" mode="OUT" optional="false"/> </service> <!-- ============================================================== --> <!-- Receipt Services --> @@ -638,29 +638,29 @@ <attribute name="fromGeo" type="String" mode="IN" optional="true"/> <attribute name="partyId" type="String" mode="IN" optional="true"/> <attribute name="roleTypeId" type="String" mode="IN" optional="true"/> - <attribute name="flatPercent" type="Double" mode="IN" optional="false"/> - <attribute name="flatPrice" type="Double" mode="IN" optional="true"/> - <attribute name="flatItemPrice" type="Double" mode="IN" optional="true"/> - <attribute name="shippingPricePercent" type="Double" mode="IN" optional="true"/> + <attribute name="flatPercent" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="flatPrice" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="flatItemPrice" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="shippingPricePercent" type="BigDecimal" mode="IN" optional="true"/> <attribute name="productFeatureGroupId" type="String" mode="IN" optional="true"/> - <attribute name="featurePercent" type="Double" mode="IN" optional="true"/> - <attribute name="featurePrice" type="Double" mode="IN" optional="true"/> - <attribute name="oversizeUnit" type="Double" mode="IN" optional="true"/> - <attribute name="oversizePrice" type="Double" mode="IN" optional="true"/> + <attribute name="featurePercent" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="featurePrice" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="oversizeUnit" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="oversizePrice" type="BigDecimal" mode="IN" optional="true"/> <attribute name="weightBreakId" type="String" mode="IN" optional="true"/> - <attribute name="wmin" type="Double" mode="IN" optional="true"/> - <attribute name="wmax" type="Double" mode="IN" optional="true"/> - <attribute name="wprice" type="Double" mode="IN" optional="true"/> + <attribute name="wmin" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="wmax" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="wprice" type="BigDecimal" mode="IN" optional="true"/> <attribute name="wuom" type="String" mode="IN" optional="true"/> <attribute name="quantityBreakId" type="String" mode="IN" optional="true"/> - <attribute name="qmin" type="Double" mode="IN" optional="true"/> - <attribute name="qmax" type="Double" mode="IN" optional="true"/> - <attribute name="qprice" type="Double" mode="IN" optional="true"/> + <attribute name="qmin" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="qmax" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="qprice" type="BigDecimal" mode="IN" optional="true"/> <attribute name="quom" type="String" mode="IN" optional="true"/> <attribute name="priceBreakId" type="String" mode="IN" optional="true"/> - <attribute name="pmin" type="Double" mode="IN" optional="true"/> - <attribute name="pmax" type="Double" mode="IN" optional="true"/> - <attribute name="pprice" type="Double" mode="IN" optional="true"/> + <attribute name="pmin" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="pmax" type="BigDecimal" mode="IN" optional="true"/> + <attribute name="pprice" type="BigDecimal" mode="IN" optional="true"/> <attribute name="puom" type="String" mode="IN" optional="true"/> <attribute name="shipmentCostEstimateId" type="String" mode="OUT"/> </service> @@ -674,7 +674,7 @@ <service name="calcShipmentEstimateInterface" engine="interface" location="" invoke=""> <description>Interface for shipment estimate calc service</description> <attribute name="serviceConfigProps" type="String" mode="IN" optional="true"/> - <attribute name="initialEstimateAmt" type="Double" mode="IN" optional="true"/> + <attribute name="initialEstimateAmt" type="BigDecimal" mode="IN" optional="true"/> <attribute name="shippingContactMechId" type="String" mode="IN" optional="true"/> <attribute name="shippingOriginContactMechId" type="String" mode="IN" optional="true"/> <attribute name="shippingPostalCode" type="String" mode="IN" optional="true"/> @@ -685,11 +685,11 @@ <attribute name="productStoreShipMethId" type="String" mode="IN" optional="true"/> <attribute name="productStoreId" type="String" mode="IN" optional="false"/> <attribute name="shippableItemInfo" type="List" mode="IN" optional="false"/> - <attribute name="shippableWeight" type="Double" mode="IN" optional="false"/> - <attribute name="shippableQuantity" type="Double" mode="IN" optional="false"/> - <attribute name="shippableTotal" type="Double" mode="IN" optional="false"/> + <attribute name="shippableWeight" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shippableQuantity" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shippableTotal" type="BigDecimal" mode="IN" optional="false"/> <attribute name="partyId" type="String" mode="IN" optional="true"/> - <attribute name="shippingEstimateAmount" type="Double" mode="OUT" optional="false"/> + <attribute name="shippingEstimateAmount" type="BigDecimal" mode="OUT" optional="false"/> </service> <service name="calcShipmentCostEstimate" engine="java" @@ -736,7 +736,7 @@ <attribute name="orderId" type="String" mode="IN" optional="false"/> <attribute name="orderItemSeqId" type="String" mode="IN" optional="false"/> <attribute name="shipGroupSeqId" type="String" mode="IN" optional="false"/> - <attribute name="quantity" type="Double" mode="IN" optional="true"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/> <attribute name="reservedDatetime" type="Timestamp" mode="IN" optional="true"/> <attribute name="requireInventory" type="String" mode="IN" optional="true"/> <attribute name="reserveOrderEnumId" type="String" mode="IN" optional="true"/> @@ -744,7 +744,7 @@ <attribute name="serialNumber" type="String" mode="IN" optional="true"/> <attribute name="trackingNum" type="String" mode="IN" optional="true"/> <attribute name="originFacilityId" type="String" mode="IN" optional="true"/> - <attribute name="quantityNotReserved" type="Double" mode="IN" optional="true"/> + <attribute name="quantityNotReserved" type="BigDecimal" mode="IN" optional="true"/> <attribute name="promisedDatetime" type="Timestamp" mode="IN" optional="false"/> <attribute name="shipmentPackageSeqId" type="String" mode="IN" optional="true"/> </service> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment_ups.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment_ups.xml?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment_ups.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment_ups.xml Mon Jan 5 23:13:36 2009 @@ -64,7 +64,7 @@ <description>UPS On-Line rate inquire tool. Also supports rate shopping by setting upsRateInquireMode to 'Shop', and upsRateCodeMap will return a Map of serviceCode -> rate</description> <attribute name="serviceConfigProps" type="String" mode="IN" optional="true"/> - <attribute name="initialEstimateAmt" type="Double" mode="IN" optional="true"/> + <attribute name="initialEstimateAmt" type="BigDecimal" mode="IN" optional="true"/> <!-- The postal code must not be required or service validation could create an exception and break other things. It will be checked in the service and a Failure (not Error) will be returned if it is null --> <attribute name="shippingPostalCode" type="String" mode="IN" optional="true"/> @@ -75,10 +75,10 @@ <!-- Passing in a list of package weights will override the splitting of packages and calculation of package weights by item --> <attribute name="packageWeights" type="List" mode="IN" optional="true"/> <attribute name="shippableItemInfo" type="List" mode="IN" optional="false"/> - <attribute name="shippableWeight" type="Double" mode="IN" optional="false"/> - <attribute name="shippableQuantity" type="Double" mode="IN" optional="false"/> - <attribute name="shippableTotal" type="Double" mode="IN" optional="false"/> - <attribute name="shippingEstimateAmount" type="Double" mode="OUT" optional="false"/> + <attribute name="shippableWeight" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shippableQuantity" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shippableTotal" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shippingEstimateAmount" type="BigDecimal" mode="OUT" optional="false"/> <attribute name="upsRateInquireMode" type="String" mode="IN" optional="true"/> <attribute name="upsRateCodeMap" type="Map" mode="OUT" optional="false"/> <attribute name="isResidentialAddress" type="String" mode="IN" optional="true"/> Modified: ofbiz/trunk/applications/product/servicedef/services_store.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_store.xml?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_store.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_store.xml Mon Jan 5 23:13:36 2009 @@ -45,11 +45,11 @@ <attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute> <attribute name="productId" type="String" mode="IN" optional="false"></attribute> <attribute name="facilityId" type="String" mode="IN" optional="true"></attribute> - <attribute name="quantity" type="Double" mode="IN" optional="false"></attribute> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"></attribute> <attribute name="orderId" type="String" mode="IN" optional="true"></attribute> <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"></attribute> <attribute name="shipGroupSeqId" type="String" mode="IN" optional="true"></attribute> - <attribute name="quantityNotReserved" type="Double" mode="OUT" optional="false"></attribute> + <attribute name="quantityNotReserved" type="BigDecimal" mode="OUT" optional="false"></attribute> </service> <service name="isStoreInventoryRequired" engine="simple" @@ -59,7 +59,7 @@ <attribute name="productStore" type="GenericValue" mode="IN" optional="true"></attribute> <attribute name="productId" type="String" mode="IN" optional="false"></attribute> <attribute name="product" type="GenericValue" mode="IN" optional="true"></attribute> - <attribute name="requireInventory" type="String" mode="OUT" optional="false"></attribute><!-- Y/N --> + <attribute name="requireInventory" type="String" mode="OUT" optional="false"><!-- Y/N --></attribute> </service> <service name="isStoreInventoryAvailable" engine="simple" location="org/ofbiz/product/store/ProductStoreServices.xml" invoke="isStoreInventoryAvailable" auth="false"> @@ -68,8 +68,8 @@ <attribute name="productStore" type="GenericValue" mode="IN" optional="true"></attribute> <attribute name="productId" type="String" mode="IN" optional="false"></attribute> <attribute name="product" type="GenericValue" mode="IN" optional="true"></attribute> - <attribute name="quantity" type="Double" mode="IN" optional="false"></attribute> - <attribute name="available" type="String" mode="OUT" optional="false"></attribute><!-- Y/N --> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"></attribute> + <attribute name="available" type="String" mode="OUT" optional="false"><!-- Y/N --></attribute> </service> <service name="isStoreInventoryAvailableOrNotRequired" engine="simple" location="org/ofbiz/product/store/ProductStoreServices.xml" invoke="isStoreInventoryAvailableOrNotRequired" auth="false"> @@ -78,8 +78,8 @@ <attribute name="productStore" type="GenericValue" mode="IN" optional="true"></attribute> <attribute name="productId" type="String" mode="IN" optional="false"></attribute> <attribute name="product" type="GenericValue" mode="IN" optional="true"></attribute> - <attribute name="quantity" type="Double" mode="IN" optional="false"></attribute> - <attribute name="availableOrNotRequired" type="String" mode="OUT" optional="false"></attribute><!-- Y/N --> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"></attribute> + <attribute name="availableOrNotRequired" type="String" mode="OUT" optional="false"><!-- Y/N --></attribute> </service> <!-- Product Store Role Services --> Modified: ofbiz/trunk/applications/product/servicedef/services_uom.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_uom.xml?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_uom.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_uom.xml Mon Jan 5 23:13:36 2009 @@ -27,7 +27,7 @@ <!-- UOM Formulas --> <service name="interfaceUomFormula" engine="interface" location="" invoke=""> <attribute mode="IN" name="arguments" optional="false" type="java.util.Map"/> - <attribute mode="OUT" name="convertedValue" optional="true" type="Double"/> + <attribute mode="OUT" name="convertedValue" optional="true" type="BigDecimal"/> </service> <service name="convertUomProduct" engine="simple" auth="false" location="org/ofbiz/product/product/ProductUomFormulas.xml" invoke="convertUomProduct"> Modified: ofbiz/trunk/applications/product/servicedef/services_view.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_view.xml?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_view.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_view.xml Mon Jan 5 23:13:36 2009 @@ -86,7 +86,7 @@ <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="partyId" type="String" mode="IN" optional="true"/> <attribute name="currencyUomId" type="String" mode="IN" optional="true"/> - <attribute name="quantity" type="Double" mode="IN" optional="true"/> + <attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/> <attribute name="canDropShip" type="String" mode="IN" optional="true"/> <attribute name="supplierProducts" type="java.util.List" mode="OUT" optional="false"/> </service> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java Mon Jan 5 23:13:36 2009 @@ -20,11 +20,12 @@ package org.ofbiz.product.config; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.Locale; import javolution.util.FastList; import javolution.util.FastMap; @@ -56,8 +57,8 @@ protected GenericDelegator delegator; protected GenericValue product = null; // the aggregated product protected GenericValue autoUserLogin = null; - protected double basePrice = 0.0; - protected double defaultPrice = 0.0; + protected BigDecimal basePrice = BigDecimal.ZERO; + protected BigDecimal defaultPrice = BigDecimal.ZERO; protected String configId = null; // Id of persisted ProductConfigWrapper protected List<ConfigItem> questions = null; // ProductConfigs @@ -103,9 +104,9 @@ Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId, "currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin); Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", priceContext); - Double price = (Double)priceMap.get("price"); + BigDecimal price = (BigDecimal) priceMap.get("price"); if (price != null) { - basePrice = price.doubleValue(); + basePrice = price; } questions = FastList.newInstance(); if (product.getString("productTypeId") != null && product.getString("productTypeId").equals("AGGREGATED")) { @@ -292,25 +293,25 @@ return defaultOptions; } - public double getTotalPrice() { - double totalPrice = basePrice; + public BigDecimal getTotalPrice() { + BigDecimal totalPrice = basePrice; List<ConfigOption> options = getSelectedOptions(); for (ConfigOption oneOption: options) { - totalPrice += oneOption.getPrice(); + totalPrice = totalPrice.add(oneOption.getPrice()); } return totalPrice; } private void setDefaultPrice() { - double totalPrice = basePrice; + BigDecimal totalPrice = basePrice; List<ConfigOption> options = getDefaultOptions(); for (ConfigOption oneOption: options) { - totalPrice += oneOption.getPrice(); + totalPrice = totalPrice.add(oneOption.getPrice()); } defaultPrice = totalPrice; } - public double getDefaultPrice(){ + public BigDecimal getDefaultPrice(){ return defaultPrice; } @@ -503,7 +504,7 @@ } public class ConfigOption implements java.io.Serializable { - double optionPrice = 0; + BigDecimal optionPrice = BigDecimal.ZERO; Date availabilityDate = null; List<GenericValue> componentList = null; // lists of ProductConfigProduct Map<String, String> componentOptions = null; @@ -518,31 +519,31 @@ parentConfigItem = configItem; componentList = option.getRelated("ConfigOptionProductConfigProduct"); for (GenericValue oneComponent: componentList) { - double price = 0; + BigDecimal price = BigDecimal.ZERO; // Get the component's price Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId, "currencyUomId", currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", autoUserLogin); Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); - Double componentPrice = (Double) priceMap.get("price"); + BigDecimal componentPrice = (BigDecimal) priceMap.get("price"); Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); - double mult = 1; - if (oneComponent.getDouble("quantity") != null) { - mult = oneComponent.getDouble("quantity").doubleValue(); + BigDecimal mult = BigDecimal.ONE; + if (oneComponent.getBigDecimal("quantity") != null) { + mult = oneComponent.getBigDecimal("quantity"); } - if (mult == 0) { - mult = 1; + if (mult.compareTo(BigDecimal.ZERO) == 0) { + mult = BigDecimal.ONE; } if (componentPrice != null && validPriceFound.booleanValue()) { - price = componentPrice.doubleValue(); + price = componentPrice; } else { fieldMap.put("productPricePurposeId", "PURCHASE"); Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); - Double purchasePrice = (Double) purchasePriceResultMap.get("price"); + BigDecimal purchasePrice = (BigDecimal) purchasePriceResultMap.get("price"); if (purchasePrice != null) { - price = purchasePrice.doubleValue(); + price = purchasePrice; } } - optionPrice += (price * mult); + optionPrice = optionPrice.add(price.multiply(mult)); // TODO: get the component's availability date } } @@ -560,9 +561,9 @@ } public void recalculateOptionPrice(ProductConfigWrapper pcw) throws Exception { - optionPrice = 0; + optionPrice = BigDecimal.ZERO; for (GenericValue oneComponent: componentList) { - double price = 0; + BigDecimal price = BigDecimal.ZERO; GenericValue oneComponentProduct = oneComponent.getRelatedOne("ProductProduct"); String variantProductId = componentOptions.get(oneComponent.getString("productId")); @@ -574,26 +575,26 @@ Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId, "currencyUomId", pcw.currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", pcw.autoUserLogin); Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); - Double componentPrice = (Double) priceMap.get("price"); + BigDecimal componentPrice = (BigDecimal) priceMap.get("price"); Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); - double mult = 1; - if (oneComponent.getDouble("quantity") != null) { - mult = oneComponent.getDouble("quantity").doubleValue(); + BigDecimal mult = BigDecimal.ONE; + if (oneComponent.getBigDecimal("quantity") != null) { + mult = oneComponent.getBigDecimal("quantity"); } - if (mult == 0) { - mult = 1; + if (mult.compareTo(BigDecimal.ZERO) == 0) { + mult = BigDecimal.ONE; } if (componentPrice != null && validPriceFound.booleanValue()) { - price = componentPrice.doubleValue(); + price = componentPrice; } else { fieldMap.put("productPricePurposeId", "PURCHASE"); Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); - Double purchasePrice = (Double) purchasePriceResultMap.get("price"); + BigDecimal purchasePrice = (BigDecimal) purchasePriceResultMap.get("price"); if (purchasePrice != null) { - price = purchasePrice.doubleValue(); + price = purchasePrice; } } - optionPrice += (price * mult); + optionPrice = optionPrice.add(price.multiply(mult)); } } @@ -613,14 +614,14 @@ this.comments = comments; } - public double getPrice() { + public BigDecimal getPrice() { return optionPrice; } - public double getOffsetPrice() { + public BigDecimal getOffsetPrice() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); if (parentConfigItem.isSingleChoice() && UtilValidate.isNotEmpty(defaultConfigOption)){ - return optionPrice - defaultConfigOption.getPrice(); + return optionPrice.subtract(defaultConfigOption.getPrice()); } else { // can select multiple or no default; show full price return optionPrice; } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java Mon Jan 5 23:13:36 2009 @@ -18,6 +18,8 @@ *******************************************************************************/ package org.ofbiz.product.inventory; +import java.math.BigDecimal; +import java.math.MathContext; import java.sql.Timestamp; import java.util.Calendar; import java.util.List; @@ -54,10 +56,12 @@ public final static String module = InventoryServices.class.getName(); + public static final MathContext generalRounding = new MathContext(10); + public static Map<String, Object> prepareInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) { GenericDelegator delegator = dctx.getDelegator(); String inventoryItemId = (String) context.get("inventoryItemId"); - Double xferQty = (Double) context.get("xferQty"); + BigDecimal xferQty = (BigDecimal) context.get("xferQty"); GenericValue inventoryItem = null; GenericValue newItem = null; GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -77,8 +81,8 @@ String inventoryType = inventoryItem.getString("inventoryItemTypeId"); if (inventoryType.equals("NON_SERIAL_INV_ITEM")) { - Double atp = inventoryItem.getDouble("availableToPromiseTotal"); - Double qoh = inventoryItem.getDouble("quantityOnHandTotal"); + BigDecimal atp = inventoryItem.getBigDecimal("availableToPromiseTotal"); + BigDecimal qoh = inventoryItem.getBigDecimal("quantityOnHandTotal"); if (atp == null) { return ServiceUtil.returnError("The request transfer amount is not available, there is no available to promise on the Inventory Item with ID " + inventoryItem.getString("inventoryItemId")); @@ -88,7 +92,7 @@ } // first make sure we have enough to cover the request transfer amount - if (xferQty.doubleValue() > atp.doubleValue()) { + if (xferQty.compareTo(atp) > 0) { return ServiceUtil.returnError("The request transfer amount is not available, the available to promise [" + atp + "] is not sufficient for the desired transfer quantity [" + xferQty + "] on the Inventory Item with ID " + inventoryItem.getString("inventoryItemId")); } @@ -101,16 +105,16 @@ // at this point we have already made sure that the xferQty is less than or equals to the atp, so if less that just create a new inventory record for the quantity to be moved // NOTE: atp should always be <= qoh, so if xfer < atp, then xfer < qoh, so no need to check/handle that // however, if atp < qoh && atp == xferQty, then we still need to split; oh, but no need to check atp == xferQty in the second part because if it isn't greater and isn't less, then it is equal - if (xferQty.doubleValue() < atp.doubleValue() || atp.doubleValue() < qoh.doubleValue()) { - Double negXferQty = Double.valueOf(-xferQty.doubleValue()); + if (xferQty.compareTo(atp) < 0 || atp.compareTo(qoh) < 0) { + BigDecimal negXferQty = xferQty.negate(); // NOTE: new inventory items should always be created calling the // createInventoryItem service because in this way we are sure // that all the relevant fields are filled with default values. // However, the code here should work fine because all the values // for the new inventory item are inerited from the existing item. newItem = GenericValue.create(inventoryItem); - newItem.set("availableToPromiseTotal", Double.valueOf(0)); - newItem.set("quantityOnHandTotal", Double.valueOf(0)); + newItem.set("availableToPromiseTotal", BigDecimal.ZERO); + newItem.set("quantityOnHandTotal", BigDecimal.ZERO); delegator.createSetNextSeqId(newItem); @@ -150,9 +154,9 @@ GenericValue inventoryItemToClear = newItem == null ? inventoryItem : newItem; inventoryItemToClear.refresh(); - double atp = inventoryItemToClear.get("availableToPromiseTotal") == null ? 0 : inventoryItemToClear.getDouble("availableToPromiseTotal").doubleValue(); - if (atp != 0) { - Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(-atp), + BigDecimal atp = inventoryItemToClear.get("availableToPromiseTotal") == null ? BigDecimal.ZERO : inventoryItemToClear.getBigDecimal("availableToPromiseTotal"); + if (atp.compareTo(BigDecimal.ZERO) != 0) { + Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", atp.negate(), "inventoryItemId", inventoryItemToClear.get("inventoryItemId"), "userLogin", userLogin); try { Map<String, Object> result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap); @@ -214,9 +218,9 @@ if (inventoryType.equals("NON_SERIAL_INV_ITEM")) { // add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP - double atp = inventoryItem.get("availableToPromiseTotal") == null ? 0 : inventoryItem.getDouble("availableToPromiseTotal").doubleValue(); - double qoh = inventoryItem.get("quantityOnHandTotal") == null ? 0 : inventoryItem.getDouble("quantityOnHandTotal").doubleValue(); - Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp), + BigDecimal atp = inventoryItem.get("availableToPromiseTotal") == null ? BigDecimal.ZERO : inventoryItem.getBigDecimal("availableToPromiseTotal"); + BigDecimal qoh = inventoryItem.get("quantityOnHandTotal") == null ? BigDecimal.ZERO : inventoryItem.getBigDecimal("quantityOnHandTotal"); + Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", qoh.subtract(atp), "inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin); try { Map<String, Object> result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap); @@ -304,9 +308,9 @@ // re-set the fields on the item if (inventoryType.equals("NON_SERIAL_INV_ITEM")) { // add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP - double atp = inventoryItem.get("availableToPromiseTotal") == null ? 0 : inventoryItem.getDouble("availableToPromiseTotal").doubleValue(); - double qoh = inventoryItem.get("quantityOnHandTotal") == null ? 0 : inventoryItem.getDouble("quantityOnHandTotal").doubleValue(); - Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp), + BigDecimal atp = inventoryItem.get("availableToPromiseTotal") == null ? BigDecimal.ZERO : inventoryItem.getBigDecimal("availableToPromiseTotal"); + BigDecimal qoh = inventoryItem.get("quantityOnHandTotal") == null ? BigDecimal.ZERO : inventoryItem.getBigDecimal("quantityOnHandTotal"); + Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", qoh.subtract(atp), "inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin); try { @@ -360,7 +364,7 @@ // find all inventory items w/ a negative ATP List<GenericValue> inventoryItems = null; try { - EntityExpr ee = EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.LESS_THAN, Double.valueOf(0)); + EntityExpr ee = EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.LESS_THAN, BigDecimal.ZERO); inventoryItems = delegator.findList("InventoryItem", ee, null, null, null, false); } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting inventory items", module); @@ -408,7 +412,7 @@ Debug.log("Reservations for item: " + reservations.size(), module); // available at the time of order - double availableBeforeReserved = inventoryItem.getDouble("availableToPromiseTotal").doubleValue(); + BigDecimal availableBeforeReserved = inventoryItem.getBigDecimal("availableToPromiseTotal"); // go through all the reservations in order for (GenericValue reservation: reservations) { @@ -430,10 +434,10 @@ // find the next possible ship date Timestamp nextShipDate = null; - double availableAtTime = 0.00; + BigDecimal availableAtTime = BigDecimal.ZERO; for (GenericValue shipmentItem: shipmentAndItems) { - availableAtTime += shipmentItem.getDouble("quantity").doubleValue(); - if (availableAtTime >= availableBeforeReserved) { + availableAtTime = availableAtTime.add(shipmentItem.getBigDecimal("quantity")); + if (availableAtTime.compareTo(availableBeforeReserved) >= 0) { nextShipDate = shipmentItem.getTimestamp("estimatedArrivalDate"); break; } @@ -506,7 +510,7 @@ } // subtract our qty from reserved to get the next value - availableBeforeReserved -= reservation.getDouble("quantity").doubleValue(); + availableBeforeReserved = availableBeforeReserved.subtract(reservation.getBigDecimal("quantity")); } } @@ -558,8 +562,8 @@ /* Figure out if we must cancel all items. */ if (!maySplit && cancelItems != null) { cancelAll = true; - Set cancelSet = cancelItems.keySet(); - cancelAllTime = (Timestamp) cancelItems.get(cancelSet.iterator().next()); + Set<String> cancelSet = cancelItems.keySet(); + cancelAllTime = cancelItems.get(cancelSet.iterator().next()); } // if there are none to cancel just create an empty map @@ -631,23 +635,23 @@ String facilityId = (String)context.get("facilityId"); String statusId = (String)context.get("statusId"); - Double availableToPromiseTotal = Double.valueOf(0); - Double quantityOnHandTotal = Double.valueOf(0); + BigDecimal availableToPromiseTotal = BigDecimal.ZERO; + BigDecimal quantityOnHandTotal = BigDecimal.ZERO; if (UtilValidate.isNotEmpty(productAssocList)) { - // minimum QOH and ATP encountered - double minQuantityOnHandTotal = Double.MAX_VALUE; - double minAvailableToPromiseTotal = Double.MAX_VALUE; + // minimum QOH and ATP encountered + BigDecimal minQuantityOnHandTotal = null; + BigDecimal minAvailableToPromiseTotal = null; // loop through each associated product. for (GenericValue productAssoc: productAssocList) { String productIdTo = productAssoc.getString("productIdTo"); - Double assocQuantity = productAssoc.getDouble("quantity"); + BigDecimal assocQuantity = productAssoc.getBigDecimal("quantity"); // if there is no quantity for the associated product in ProductAssoc entity, default it to 1.0 if (assocQuantity == null) { Debug.logWarning("ProductAssoc from [" + productAssoc.getString("productId") + "] to [" + productAssoc.getString("productIdTo") + "] has no quantity, assuming 1.0", module); - assocQuantity = Double.valueOf(1.0); + assocQuantity = BigDecimal.ONE; } // figure out the inventory available for this associated product @@ -666,16 +670,16 @@ } // Figure out what the QOH and ATP inventory would be with this associated product - Double currentQuantityOnHandTotal = (Double) resultOutput.get("quantityOnHandTotal"); - Double currentAvailableToPromiseTotal = (Double) resultOutput.get("availableToPromiseTotal"); - double tmpQuantityOnHandTotal = currentQuantityOnHandTotal.doubleValue()/assocQuantity.doubleValue(); - double tmpAvailableToPromiseTotal = currentAvailableToPromiseTotal.doubleValue()/assocQuantity.doubleValue(); + BigDecimal currentQuantityOnHandTotal = (BigDecimal) resultOutput.get("quantityOnHandTotal"); + BigDecimal currentAvailableToPromiseTotal = (BigDecimal) resultOutput.get("availableToPromiseTotal"); + BigDecimal tmpQuantityOnHandTotal = currentQuantityOnHandTotal.divide(assocQuantity, generalRounding); + BigDecimal tmpAvailableToPromiseTotal = currentAvailableToPromiseTotal.divide(assocQuantity, generalRounding); // reset the minimum QOH and ATP quantities if those quantities for this product are less - if (tmpQuantityOnHandTotal < minQuantityOnHandTotal) { + if (minQuantityOnHandTotal == null || tmpQuantityOnHandTotal.compareTo(minQuantityOnHandTotal) < 0) { minQuantityOnHandTotal = tmpQuantityOnHandTotal; } - if (tmpAvailableToPromiseTotal < minAvailableToPromiseTotal) { + if (minAvailableToPromiseTotal == null || tmpAvailableToPromiseTotal.compareTo(minAvailableToPromiseTotal) < 0) { minAvailableToPromiseTotal = tmpAvailableToPromiseTotal; } @@ -685,8 +689,8 @@ } } // the final QOH and ATP quantities are the minimum of all the products - quantityOnHandTotal = Double.valueOf(minQuantityOnHandTotal); - availableToPromiseTotal = Double.valueOf(minAvailableToPromiseTotal); + quantityOnHandTotal = minQuantityOnHandTotal; + availableToPromiseTotal = minAvailableToPromiseTotal; } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -701,10 +705,10 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); List<GenericValue> orderItems = UtilGenerics.checkList(context.get("orderItems")); String facilityId = (String) context.get("facilityId"); - Map<String, Double> atpMap = FastMap.newInstance(); - Map<String, Double> qohMap = FastMap.newInstance(); - Map<String, Double> mktgPkgAtpMap = FastMap.newInstance(); - Map<String, Double> mktgPkgQohMap = FastMap.newInstance(); + Map<String, BigDecimal> atpMap = FastMap.newInstance(); + Map<String, BigDecimal> qohMap = FastMap.newInstance(); + Map<String, BigDecimal> mktgPkgAtpMap = FastMap.newInstance(); + Map<String, BigDecimal> mktgPkgQohMap = FastMap.newInstance(); Map<String, Object> results = ServiceUtil.returnSuccess(); // get a list of all available facilities for looping @@ -733,10 +737,10 @@ return ServiceUtil.returnError("Unable to retrive product with id [" + productId + "]"); } - double atp = 0.0; - double qoh = 0.0; - double mktgPkgAtp = 0.0; - double mktgPkgQoh = 0.0; + BigDecimal atp = BigDecimal.ZERO; + BigDecimal qoh = BigDecimal.ZERO; + BigDecimal mktgPkgAtp = BigDecimal.ZERO; + BigDecimal mktgPkgQoh = BigDecimal.ZERO; // loop through all the facilities for (GenericValue facility: facilities) { @@ -758,23 +762,23 @@ // add the results for this facility to the ATP/QOH counter for all facilities if (!ServiceUtil.isError(invResult)) { - Double fatp = (Double) invResult.get("availableToPromiseTotal"); - Double fqoh = (Double) invResult.get("quantityOnHandTotal"); - if (fatp != null) atp += fatp.doubleValue(); - if (fqoh != null) qoh += fqoh.doubleValue(); + BigDecimal fatp = (BigDecimal) invResult.get("availableToPromiseTotal"); + BigDecimal fqoh = (BigDecimal) invResult.get("quantityOnHandTotal"); + if (fatp != null) atp = atp.add(fatp); + if (fqoh != null) qoh = qoh.add(fqoh); } if (("MARKETING_PKG_AUTO".equals(product.getString("productTypeId")) || "MARKETING_PKG_PICK".equals(product.getString("productTypeId"))) && (!ServiceUtil.isError(mktgPkgInvResult))) { - Double fatp = (Double) mktgPkgInvResult.get("availableToPromiseTotal"); - Double fqoh = (Double) mktgPkgInvResult.get("quantityOnHandTotal"); - if (fatp != null) mktgPkgAtp += fatp.doubleValue(); - if (fqoh != null) mktgPkgQoh += fqoh.doubleValue(); + BigDecimal fatp = (BigDecimal) mktgPkgInvResult.get("availableToPromiseTotal"); + BigDecimal fqoh = (BigDecimal) mktgPkgInvResult.get("quantityOnHandTotal"); + if (fatp != null) mktgPkgAtp = mktgPkgAtp.add(fatp); + if (fqoh != null) mktgPkgQoh = mktgPkgQoh.add(fqoh); } } - atpMap.put(productId, Double.valueOf(atp)); - qohMap.put(productId, Double.valueOf(qoh)); - mktgPkgAtpMap.put(productId, Double.valueOf(mktgPkgAtp)); - mktgPkgQohMap.put(productId, Double.valueOf(mktgPkgQoh)); + atpMap.put(productId, atp); + qohMap.put(productId, qoh); + mktgPkgAtpMap.put(productId, mktgPkgAtp); + mktgPkgQohMap.put(productId, mktgPkgQoh); } results.put("availableToPromiseMap", atpMap); @@ -791,7 +795,7 @@ Timestamp checkTime = (Timestamp)context.get("checkTime"); String facilityId = (String)context.get("facilityId"); String productId = (String)context.get("productId"); - String minimumStock = (String)context.get("minimumStock"); + String minimumStockStr = (String)context.get("minimumStock"); String statusId = (String)context.get("statusId"); Map<String, Object> result = FastMap.newInstance(); @@ -822,30 +826,30 @@ } } // filter for quantities - int minimumStockInt = 0; - if (minimumStock != null) { - minimumStockInt = Double.valueOf(minimumStock).intValue(); + BigDecimal minimumStock = BigDecimal.ZERO; + if (minimumStockStr != null) { + minimumStock = new BigDecimal(minimumStockStr); } - int quantityOnHandTotalInt = 0; + BigDecimal quantityOnHandTotal = BigDecimal.ZERO; if (resultOutput.get("quantityOnHandTotal") != null) { - quantityOnHandTotalInt = ((Double)resultOutput.get("quantityOnHandTotal")).intValue(); + quantityOnHandTotal = (BigDecimal)resultOutput.get("quantityOnHandTotal"); } - int offsetQOHQtyAvailable = quantityOnHandTotalInt - minimumStockInt; + BigDecimal offsetQOHQtyAvailable = quantityOnHandTotal.subtract(minimumStock); - int availableToPromiseTotalInt = 0; + BigDecimal availableToPromiseTotal = BigDecimal.ZERO; if (resultOutput.get("availableToPromiseTotal") != null) { - availableToPromiseTotalInt = ((Double)resultOutput.get("availableToPromiseTotal")).intValue(); + availableToPromiseTotal = (BigDecimal)resultOutput.get("availableToPromiseTotal"); } - int offsetATPQtyAvailable = availableToPromiseTotalInt - minimumStockInt; + BigDecimal offsetATPQtyAvailable = availableToPromiseTotal.subtract(minimumStock); - double quantityOnOrder = InventoryWorker.getOutstandingPurchasedQuantity(productId, delegator); + BigDecimal quantityOnOrder = InventoryWorker.getOutstandingPurchasedQuantity(productId, delegator); result.put("totalQuantityOnHand", resultOutput.get("quantityOnHandTotal").toString()); result.put("totalAvailableToPromise", resultOutput.get("availableToPromiseTotal").toString()); - result.put("quantityOnOrder", Double.valueOf(quantityOnOrder)); + result.put("quantityOnOrder", quantityOnOrder); - result.put("offsetQOHQtyAvailable", Integer.valueOf(offsetQOHQtyAvailable)); - result.put("offsetATPQtyAvailable", Integer.valueOf(offsetATPQtyAvailable)); + result.put("offsetQOHQtyAvailable", offsetQOHQtyAvailable); + result.put("offsetATPQtyAvailable", offsetATPQtyAvailable); List<GenericValue> productPrices = null; try { @@ -857,15 +861,15 @@ //change this for product price for (GenericValue onePrice: productPrices) { if(onePrice.getString("productPriceTypeId").equals("DEFAULT_PRICE")){ //defaultPrice - result.put("defultPrice", onePrice.getDouble("price")); + result.put("defultPrice", onePrice.getBigDecimal("price")); }else if(onePrice.getString("productPriceTypeId").equals("WHOLESALE_PRICE")){// - result.put("wholeSalePrice", onePrice.getDouble("price")); + result.put("wholeSalePrice", onePrice.getBigDecimal("price")); }else if(onePrice.getString("productPriceTypeId").equals("LIST_PRICE")){//listPrice - result.put("listPrice", onePrice.getDouble("price")); + result.put("listPrice", onePrice.getBigDecimal("price")); }else{ - result.put("defultPrice", onePrice.getDouble("price")); - result.put("listPrice", onePrice.getDouble("price")); - result.put("wholeSalePrice", onePrice.getDouble("price")); + result.put("defultPrice", onePrice.getBigDecimal("price")); + result.put("listPrice", onePrice.getBigDecimal("price")); + result.put("wholeSalePrice", onePrice.getBigDecimal("price")); } } @@ -924,12 +928,12 @@ } // Sum the sales usage quantities found - double salesUsageQuantity = 0; + BigDecimal salesUsageQuantity = BigDecimal.ZERO; GenericValue salesUsageItem = null; while((salesUsageItem = salesUsageIt.next()) != null) { if (salesUsageItem.get("quantity") != null) { try { - salesUsageQuantity += salesUsageItem.getDouble("quantity").doubleValue(); + salesUsageQuantity = salesUsageQuantity.add(salesUsageItem.getBigDecimal("quantity")); } catch (Exception e) { // Ignore } @@ -961,12 +965,12 @@ } // Sum the production usage quantities found - double productionUsageQuantity = 0; + BigDecimal productionUsageQuantity = BigDecimal.ZERO; GenericValue productionUsageItem = null; while((productionUsageItem = productionUsageIt.next()) != null) { if (productionUsageItem.get("quantity") != null) { try { - productionUsageQuantity += productionUsageItem.getDouble("quantity").doubleValue(); + productionUsageQuantity = productionUsageQuantity.add(productionUsageItem.getBigDecimal("quantity")); } catch (Exception e) { // Ignore } @@ -979,7 +983,7 @@ e.printStackTrace(); } - result.put("usageQuantity", Double.valueOf((salesUsageQuantity + productionUsageQuantity))); + result.put("usageQuantity", salesUsageQuantity.add(productionUsageQuantity)); } return result; Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java?rev=731851&r1=731850&r2=731851&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java Mon Jan 5 23:13:36 2009 @@ -19,6 +19,7 @@ package org.ofbiz.product.inventory; +import java.math.BigDecimal; import java.util.Collection; import java.util.List; import java.util.Map; @@ -71,22 +72,22 @@ * @param delegator * @return */ - public static double getOutstandingPurchasedQuantity(String productId, GenericDelegator delegator) { - double qty = 0.0; + public static BigDecimal getOutstandingPurchasedQuantity(String productId, GenericDelegator delegator) { + BigDecimal qty = BigDecimal.ZERO; List<GenericValue> purchaseOrders = getOutstandingPurchaseOrders(productId, delegator); if (UtilValidate.isEmpty(purchaseOrders)) { return qty; } else { for (GenericValue nextOrder: purchaseOrders) { if (nextOrder.get("quantity") != null) { - double itemQuantity = nextOrder.getDouble("quantity").doubleValue(); - double cancelQuantity = 0.0; + BigDecimal itemQuantity = nextOrder.getBigDecimal("quantity"); + BigDecimal cancelQuantity = BigDecimal.ZERO; if (nextOrder.get("cancelQuantity") != null) { - cancelQuantity = nextOrder.getDouble("cancelQuantity").doubleValue(); + cancelQuantity = nextOrder.getBigDecimal("cancelQuantity"); } - itemQuantity -= cancelQuantity; - if (itemQuantity >= 0.0) { - qty += itemQuantity; + itemQuantity = itemQuantity.subtract(cancelQuantity); + if (itemQuantity.compareTo(BigDecimal.ZERO) >= 0) { + qty = qty.add(itemQuantity); } } } @@ -124,7 +125,7 @@ try { List<GenericValue> orderedProducts = delegator.findList("OrderItemQuantityReportGroupByProduct", conditions, fieldsToSelect, null, null, false); for (GenericValue value: orderedProducts) { - results.put(value.getString("productId"), value.getDouble("quantityOpen")); + results.put(value.getString("productId"), value.getBigDecimal("quantityOpen")); } } catch (GenericEntityException e) { Debug.logError(e, module); |
Free forum by Nabble | Edit this page |