diff --git a/applications/accounting/widget/ReportFinancialSummaryForms.xml b/applications/accounting/widget/ReportFinancialSummaryForms.xml index 7e4031f8db7..af7970fb9fb 100644 --- a/applications/accounting/widget/ReportFinancialSummaryForms.xml +++ b/applications/accounting/widget/ReportFinancialSummaryForms.xml @@ -83,8 +83,8 @@ under the License. - - + + diff --git a/applications/content/script/org/ofbiz/content/content/ContentServices.xml b/applications/content/script/org/ofbiz/content/content/ContentServices.xml index b4dec2ff74c..d4f3f6d4dc1 100644 --- a/applications/content/script/org/ofbiz/content/content/ContentServices.xml +++ b/applications/content/script/org/ofbiz/content/content/ContentServices.xml @@ -982,18 +982,15 @@ - - - - + + - - + diff --git a/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml b/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml index 82fb5bb8d4d..aadad5e4d81 100644 --- a/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml +++ b/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml @@ -1112,18 +1112,18 @@ under the License.
${uiLabelMap.ProductAggregatedPrice}: <@ofbizCurrency amount=totalPrice isoCode=totalPrice.currencyUsed/>
<#else> - <#if price.competitivePrice?exists && price.price?exists && price.price?double < price.competitivePrice?double> + <#if price.competitivePrice?exists && price.price?exists && price.price < price.competitivePrice>
${uiLabelMap.ProductCompareAtPrice}: <@ofbizCurrency amount=price.competitivePrice isoCode=price.currencyUsed/>
- <#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double> + <#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
${uiLabelMap.ProductListPrice}: <@ofbizCurrency amount=price.listPrice isoCode=price.currencyUsed/>
- <#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price?double < price.defaultPrice?double && price.defaultPrice?double < price.listPrice?double> + <#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price < price.defaultPrice && price.defaultPrice < price.listPrice>
${uiLabelMap.ProductRegularPrice}: <@ofbizCurrency amount=price.defaultPrice isoCode=price.currencyUsed/>
@@ -253,15 +253,15 @@ function getConfigDetails(event) { ${uiLabelMap.OrderYourPrice}: <#if "Y" = product.isVirtual?if_exists> from <@ofbizCurrency amount=price.price isoCode=price.currencyUsed/>
- <#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double> - <#assign priceSaved = price.listPrice?double - price.price?double> - <#assign percentSaved = (priceSaved?double / price.listPrice?double) * 100> + <#if price.listPrice?exists && price.price?exists && price.price < price.listPrice> + <#assign priceSaved = price.listPrice - price.price> + <#assign percentSaved = (priceSaved / price.listPrice) * 100>
${uiLabelMap.OrderSave}: <@ofbizCurrency amount=priceSaved isoCode=price.currencyUsed/> (${percentSaved?int}%)
<#-- Included quantities/pieces --> - <#if product.quantityIncluded?exists && product.quantityIncluded?double != 0> + <#if product.quantityIncluded?exists && product.quantityIncluded != 0>
${uiLabelMap.OrderIncludes}: ${product.quantityIncluded?if_exists} ${product.quantityUomId?if_exists} @@ -610,7 +610,7 @@ function getConfigDetails(event) {
${uiLabelMap.OrderCustomerReviews}:
- <#if averageRating?exists && (averageRating?double > 0) && numRatings?exists && (numRatings?double > 1)> + <#if averageRating?exists && (averageRating > 0) && numRatings?exists && (numRatings > 1)>
${uiLabelMap.OrderAverageRating}: ${averageRating} <#if numRatings?exists>(${uiLabelMap.CommonFrom} ${numRatings} ${uiLabelMap.OrderRatings})
diff --git a/applications/ecommerce/webapp/ecommerce/catalog/productdetail.ftl b/applications/ecommerce/webapp/ecommerce/catalog/productdetail.ftl index a0c413efef1..1e28c163d51 100644 --- a/applications/ecommerce/webapp/ecommerce/catalog/productdetail.ftl +++ b/applications/ecommerce/webapp/ecommerce/catalog/productdetail.ftl @@ -315,13 +315,13 @@ ${virtualJavaScript?if_exists} - if price < defaultPrice and defaultPrice < listPrice, show default - if isSale show price with salePrice style and print "On Sale!" --> - <#if price.competitivePrice?exists && price.price?exists && price.price?double < price.competitivePrice?double> + <#if price.competitivePrice?exists && price.price?exists && price.price < price.competitivePrice>
${uiLabelMap.ProductCompareAtPrice}: <@ofbizCurrency amount=price.competitivePrice isoCode=price.currencyUsed/>
- <#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double> + <#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
${uiLabelMap.ProductListPrice}: <@ofbizCurrency amount=price.listPrice isoCode=price.currencyUsed/>
- <#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price?double < price.defaultPrice?double && price.defaultPrice?double < price.listPrice?double> + <#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price < price.defaultPrice && price.defaultPrice < price.listPrice>
${uiLabelMap.ProductRegularPrice}: <@ofbizCurrency amount=price.defaultPrice isoCode=price.currencyUsed/>
<#if price.specialPromoPrice?exists> @@ -343,9 +343,9 @@ ${virtualJavaScript?if_exists}
- <#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double> - <#assign priceSaved = price.listPrice?double - price.price?double> - <#assign percentSaved = (priceSaved?double / price.listPrice?double) * 100> + <#if price.listPrice?exists && price.price?exists && price.price < price.listPrice> + <#assign priceSaved = price.listPrice - price.price> + <#assign percentSaved = (priceSaved / price.listPrice) * 100>
${uiLabelMap.OrderSave}: <@ofbizCurrency amount=priceSaved isoCode=price.currencyUsed/> (${percentSaved?int}%)
<#-- show price details ("showPriceDetails" field can be set in the screen definition) --> @@ -363,32 +363,32 @@ ${virtualJavaScript?if_exists} ${uiLabelMap.OrderPieces}: ${product.piecesIncluded} - <#if (product.quantityIncluded?exists && product.quantityIncluded?double != 0) || product.quantityUomId?has_content> + <#if (product.quantityIncluded?exists && product.quantityIncluded != 0) || product.quantityUomId?has_content> <#assign quantityUom = product.getRelatedOneCache("QuantityUom")?if_exists/>
${uiLabelMap.CommonQuantity}: ${product.quantityIncluded?if_exists} ${((quantityUom.abbreviation)?default(product.quantityUomId))?if_exists}
- <#if (product.weight?exists && product.weight?double != 0) || product.weightUomId?has_content> + <#if (product.weight?exists && product.weight != 0) || product.weightUomId?has_content> <#assign weightUom = product.getRelatedOneCache("WeightUom")?if_exists/>
${uiLabelMap.CommonWeight}: ${product.weight?if_exists} ${((weightUom.abbreviation)?default(product.weightUomId))?if_exists}
- <#if (product.productHeight?exists && product.productHeight?double != 0) || product.heightUomId?has_content> + <#if (product.productHeight?exists && product.productHeight != 0) || product.heightUomId?has_content> <#assign heightUom = product.getRelatedOneCache("HeightUom")?if_exists/>
${uiLabelMap.CommonHeight}: ${product.productHeight?if_exists} ${((heightUom.abbreviation)?default(product.heightUomId))?if_exists}
- <#if (product.productWidth?exists && product.productWidth?double != 0) || product.widthUomId?has_content> + <#if (product.productWidth?exists && product.productWidth != 0) || product.widthUomId?has_content> <#assign widthUom = product.getRelatedOneCache("WidthUom")?if_exists/>
${uiLabelMap.CommonWidth}: ${product.productWidth?if_exists} ${((widthUom.abbreviation)?default(product.widthUomId))?if_exists}
- <#if (product.productDepth?exists && product.productDepth?double != 0) || product.depthUomId?has_content> + <#if (product.productDepth?exists && product.productDepth != 0) || product.depthUomId?has_content> <#assign depthUom = product.getRelatedOneCache("DepthUom")?if_exists/>
${uiLabelMap.CommonDepth}: ${product.productDepth?if_exists} ${((depthUom.abbreviation)?default(product.depthUomId))?if_exists} @@ -474,7 +474,7 @@ ${virtualJavaScript?if_exists} <#else> - <#assign isStoreInventoryNotAvailable = !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, product, 1.0?double))> + <#assign isStoreInventoryNotAvailable = !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, product, 1.0))> <#assign isStoreInventoryRequired = Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, product)> <#if isStoreInventoryNotAvailable> <#if isStoreInventoryRequired> @@ -618,7 +618,7 @@ ${virtualJavaScript?if_exists} <#-- Product Reviews -->
${uiLabelMap.OrderCustomerReviews}:
- <#if averageRating?exists && (averageRating?double > 0) && numRatings?exists && (numRatings?double > 1)> + <#if averageRating?exists && (averageRating > 0) && numRatings?exists && (numRatings > 1)>
${uiLabelMap.OrderAverageRating}: ${averageRating} <#if numRatings?exists>(${uiLabelMap.CommonFrom} ${numRatings} ${uiLabelMap.OrderRatings})

diff --git a/applications/ecommerce/webapp/ecommerce/forum/forumPaging.ftl b/applications/ecommerce/webapp/ecommerce/forum/forumPaging.ftl index 27f9654ac7e..094f8cb3474 100644 --- a/applications/ecommerce/webapp/ecommerce/forum/forumPaging.ftl +++ b/applications/ecommerce/webapp/ecommerce/forum/forumPaging.ftl @@ -25,8 +25,8 @@ under the License. <#assign listSize = forumMessages?size/> <#if highIndex gt listSize><#assign highIndex = listSize>
- <#assign r = listSize?double / viewSize?double /> - <#assign viewIndexMax = Static["java.lang.Math"].ceil(r?double)> + <#assign r = listSize / viewSize /> + <#assign viewIndexMax = Static["java.lang.Math"].ceil(r)> "> + ${uiLabelMap.OrderBillUpTo}: "> @@ -191,7 +191,7 @@ function submitForm(form, mode, value) {   - ${uiLabelMap.OrderBillUpTo}: "> + ${uiLabelMap.OrderBillUpTo}: "> @@ -226,8 +226,8 @@ function submitForm(form, mode, value) { diff --git a/applications/ecommerce/webapp/ecommerce/order/orderitems.ftl b/applications/ecommerce/webapp/ecommerce/order/orderitems.ftl index 34e51393e49..52022a21c04 100644 --- a/applications/ecommerce/webapp/ecommerce/order/orderitems.ftl +++ b/applications/ecommerce/webapp/ecommerce/order/orderitems.ftl @@ -91,23 +91,23 @@ under the License. <#if product.piecesIncluded?exists && product.piecesIncluded?long != 0> [${uiLabelMap.OrderPieces}: ${product.piecesIncluded}] - <#if (product.quantityIncluded?exists && product.quantityIncluded?double != 0) || product.quantityUomId?has_content> + <#if (product.quantityIncluded?exists && product.quantityIncluded != 0) || product.quantityUomId?has_content> <#assign quantityUom = product.getRelatedOneCache("QuantityUom")?if_exists/> [${uiLabelMap.CommonQuantity}: ${product.quantityIncluded?if_exists} ${((quantityUom.abbreviation)?default(product.quantityUomId))?if_exists}] - <#if (product.weight?exists && product.weight?double != 0) || product.weightUomId?has_content> + <#if (product.weight?exists && product.weight != 0) || product.weightUomId?has_content> <#assign weightUom = product.getRelatedOneCache("WeightUom")?if_exists/> [${uiLabelMap.CommonWeight}: ${product.weight?if_exists} ${((weightUom.abbreviation)?default(product.weightUomId))?if_exists}] - <#if (product.productHeight?exists && product.productHeight?double != 0) || product.heightUomId?has_content> + <#if (product.productHeight?exists && product.productHeight != 0) || product.heightUomId?has_content> <#assign heightUom = product.getRelatedOneCache("HeightUom")?if_exists/> [${uiLabelMap.CommonHeight}: ${product.productHeight?if_exists} ${((heightUom.abbreviation)?default(product.heightUomId))?if_exists}] - <#if (product.productWidth?exists && product.productWidth?double != 0) || product.widthUomId?has_content> + <#if (product.productWidth?exists && product.productWidth != 0) || product.widthUomId?has_content> <#assign widthUom = product.getRelatedOneCache("WidthUom")?if_exists/> [${uiLabelMap.CommonWidth}: ${product.productWidth?if_exists} ${((widthUom.abbreviation)?default(product.widthUomId))?if_exists}] - <#if (product.productDepth?exists && product.productDepth?double != 0) || product.depthUomId?has_content> + <#if (product.productDepth?exists && product.productDepth != 0) || product.depthUomId?has_content> <#assign depthUom = product.getRelatedOneCache("DepthUom")?if_exists/> [${uiLabelMap.CommonDepth}: ${product.productDepth?if_exists} ${((depthUom.abbreviation)?default(product.depthUomId))?if_exists}] diff --git a/applications/ecommerce/widget/CustomerScreens.xml b/applications/ecommerce/widget/CustomerScreens.xml index af02affced9..76683ccaba2 100644 --- a/applications/ecommerce/widget/CustomerScreens.xml +++ b/applications/ecommerce/widget/CustomerScreens.xml @@ -351,7 +351,7 @@ under the License. - + diff --git a/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomMapProcs.xml b/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomMapProcs.xml index 1c87383839b..4a7014d3d76 100644 --- a/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomMapProcs.xml +++ b/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomMapProcs.xml @@ -50,12 +50,12 @@ under the License. - + - + diff --git a/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml b/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml index 4941c15cb13..a3d21df19d6 100644 --- a/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml +++ b/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml @@ -58,7 +58,7 @@ under the License. - + @@ -70,7 +70,7 @@ under the License. - + @@ -132,13 +132,13 @@ under the License. - + - + @@ -148,7 +148,7 @@ under the License. - + @@ -174,10 +174,10 @@ under the License. - + - + @@ -207,10 +207,10 @@ under the License. - + - + @@ -234,7 +234,7 @@ under the License. - + @@ -243,7 +243,7 @@ under the License. - + @@ -282,8 +282,8 @@ under the License. - - + + @@ -301,10 +301,10 @@ under the License. - + - + @@ -354,7 +354,7 @@ under the License. - + @@ -362,7 +362,7 @@ under the License. - + @@ -383,10 +383,10 @@ under the License. - + - + diff --git a/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml b/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml index a8764e95c9c..896a4391972 100644 --- a/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml +++ b/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml @@ -47,13 +47,13 @@ under the License. - + - + @@ -85,13 +85,13 @@ under the License. - + - + @@ -137,13 +137,13 @@ under the License. - + - + diff --git a/applications/manufacturing/servicedef/services_bom.xml b/applications/manufacturing/servicedef/services_bom.xml index c536a86041f..ac403ad579a 100644 --- a/applications/manufacturing/servicedef/services_bom.xml +++ b/applications/manufacturing/servicedef/services_bom.xml @@ -110,8 +110,8 @@ under the License. - - + + @@ -119,8 +119,8 @@ under the License. location="org.ofbiz.manufacturing.bom.BOMServices" invoke="getManufacturingComponents"> Returns the product's routing id and the components of a given product (if necessary, running the configurator). - - + + @@ -132,7 +132,7 @@ under the License. location="org.ofbiz.manufacturing.bom.BOMServices" invoke="getProductsInPackages"> Returns the components (that needs to be packaged) of a given product (if necessary, running the configurator). - + @@ -140,8 +140,8 @@ under the License. location="org.ofbiz.manufacturing.bom.BOMServices" invoke="getNotAssembledComponents" auth="true"> Explodes a product id and returns all the components that are not manufactured on customer order: these components will be taken from warehouse. - - + + diff --git a/applications/manufacturing/servicedef/services_calendar.xml b/applications/manufacturing/servicedef/services_calendar.xml index 76163e2b9eb..badfac47015 100644 --- a/applications/manufacturing/servicedef/services_calendar.xml +++ b/applications/manufacturing/servicedef/services_calendar.xml @@ -50,19 +50,19 @@ under the License. - + - + - + - + - + - + - + @@ -70,19 +70,19 @@ under the License. - + - + - + - + - + - + - + @@ -96,7 +96,7 @@ under the License. - + @@ -104,7 +104,7 @@ under the License. - + diff --git a/applications/manufacturing/servicedef/services_formula.xml b/applications/manufacturing/servicedef/services_formula.xml index bb5a8606727..22c35141463 100644 --- a/applications/manufacturing/servicedef/services_formula.xml +++ b/applications/manufacturing/servicedef/services_formula.xml @@ -27,7 +27,7 @@ under the License. - + @@ -42,7 +42,7 @@ under the License. - + diff --git a/applications/manufacturing/servicedef/services_mrp.xml b/applications/manufacturing/servicedef/services_mrp.xml index 1cc147c8626..9012b8f5738 100644 --- a/applications/manufacturing/servicedef/services_mrp.xml +++ b/applications/manufacturing/servicedef/services_mrp.xml @@ -48,7 +48,7 @@ under the License. location="org.ofbiz.manufacturing.mrp.MrpServices" invoke="findProductMrpQoh" auth="true"> Find the quantity on hand of products for the MRP - + @@ -57,7 +57,7 @@ under the License. - + diff --git a/applications/manufacturing/servicedef/services_production_run.xml b/applications/manufacturing/servicedef/services_production_run.xml index 0dfb99a6f4f..0dffd569da0 100644 --- a/applications/manufacturing/servicedef/services_production_run.xml +++ b/applications/manufacturing/servicedef/services_production_run.xml @@ -29,7 +29,7 @@ under the License. location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRunsForProductBom" auth="true"> Explodes a product id and creates all the needed production runs. - + @@ -43,7 +43,7 @@ under the License. location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRun" auth="true"> Create a Production Run - + @@ -56,7 +56,7 @@ under the License. location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="updateProductionRun" auth="true"> Update a Production Run - + @@ -85,8 +85,8 @@ under the License. - - + + @@ -99,8 +99,8 @@ under the License. - - + + add a Product Component to an existing ProductionRun - + - + - + @@ -176,8 +176,8 @@ under the License. - - + + - + @@ -200,7 +200,7 @@ under the License. - + @@ -214,9 +214,9 @@ under the License. - + - + @@ -228,7 +228,7 @@ under the License. - + - + @@ -248,7 +248,7 @@ under the License. The components will be returned to inventory at ((Marketing Package Actual Inventory Unit Cost) / (Marketing Package Standard Cost)) * (Component Standard Cost) - + - - - - + + + + @@ -301,14 +301,14 @@ under the License. Given a productId and an optional date, returns the total qty of productId reserved by production runs - + Explodes a product id and creates all the needed production runs; if an order id is also provided, it links the production runs to the sales order. - + @@ -317,7 +317,7 @@ under the License. location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRunFromRequirement" auth="true"> Creates a production run from a requirement. - + - + diff --git a/applications/manufacturing/servicedef/services_routing.xml b/applications/manufacturing/servicedef/services_routing.xml index d620f132eea..3361c6cb311 100644 --- a/applications/manufacturing/servicedef/services_routing.xml +++ b/applications/manufacturing/servicedef/services_routing.xml @@ -63,9 +63,9 @@ under the License. - + - - + + diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java index d4aaeb6284b..f432d9133f4 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java @@ -154,7 +154,7 @@ public static String createProductionRunsForShipment(javax.servlet.http.HttpServ Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", module); continue; } - Map result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.toMap("quantity", shipmentPlan.getDouble("quantity"), "orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipmentId", shipmentId, "userLogin", userLogin)); + Map result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.toMap("quantity", shipmentPlan.getBigDecimal("quantity"), "orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipmentId", shipmentId, "userLogin", userLogin)); } } catch (Exception e) { // if there is an exception for either, the other probably wont work diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java index de368c8a327..660853672bf 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java @@ -19,6 +19,7 @@ package org.ofbiz.manufacturing.bom; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -59,11 +60,11 @@ public class BOMNode { private GenericValue productAssoc; // the product assoc record (from ProductAssoc entity) in which the current product is in productIdTo private ArrayList children; // current node's children (ProductAssocs) private ArrayList childrenNodes; // current node's children nodes (BOMNode) - private double quantityMultiplier; // the necessary quantity as declared in the bom (from ProductAssocs or ProductManufacturingRule) - private double scrapFactor; // the scrap factor as declared in the bom (from ProductAssocs) + private BigDecimal quantityMultiplier; // the necessary quantity as declared in the bom (from ProductAssocs or ProductManufacturingRule) + private BigDecimal scrapFactor; // the scrap factor as declared in the bom (from ProductAssocs) // Runtime fields private int depth; // the depth of this node in the current tree - private double quantity; // the quantity of this node in the current tree + private BigDecimal quantity; // the quantity of this node in the current tree private String bomTypeId; // the type of the current tree public BOMNode(GenericValue product, LocalDispatcher dispatcher, GenericValue userLogin) { @@ -76,11 +77,11 @@ public BOMNode(GenericValue product, LocalDispatcher dispatcher, GenericValue us parentNode = null; productForRules = null; bomTypeId = null; - quantityMultiplier = 1; - scrapFactor = 1; + quantityMultiplier = BigDecimal.ONE; + scrapFactor = BigDecimal.ONE; // Now we initialize the fields used in breakdowns depth = 0; - quantity = 0; + quantity = BigDecimal.ZERO; } public BOMNode(String productId, GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { @@ -145,11 +146,11 @@ private BOMNode substituteNode(BOMNode oneChildNode, List productFeatures, List String ruleCondition = (String)rule.get("productFeature"); String ruleOperator = (String)rule.get("ruleOperator"); String newPart = (String)rule.get("productIdInSubst"); - double ruleQuantity = 0; + BigDecimal ruleQuantity = BigDecimal.ZERO; try { - ruleQuantity = rule.getDouble("quantity").doubleValue(); + ruleQuantity = rule.getBigDecimal("quantity"); } catch(Exception exc) { - ruleQuantity = 0; + ruleQuantity = BigDecimal.ZERO; } GenericValue feature = null; @@ -179,7 +180,7 @@ private BOMNode substituteNode(BOMNode oneChildNode, List productFeatures, List oneChildNode.setRuleApplied(rule); oneChildNode.setProductAssoc(origNode.getProductAssoc()); oneChildNode.setScrapFactor(origNode.getScrapFactor()); - if (ruleQuantity > 0) { + if (ruleQuantity.compareTo(BigDecimal.ZERO) > 0) { oneChildNode.setQuantityMultiplier(ruleQuantity); } else { oneChildNode.setQuantityMultiplier(origNode.getQuantityMultiplier()); @@ -199,23 +200,24 @@ private BOMNode configurator(GenericValue node, List productFeatures, String pro oneChildNode.setTree(tree); oneChildNode.setProductAssoc(node); try { - oneChildNode.setQuantityMultiplier(node.getDouble("quantity").doubleValue()); + oneChildNode.setQuantityMultiplier(node.getBigDecimal("quantity")); } catch(Exception nfe) { - oneChildNode.setQuantityMultiplier(1); + oneChildNode.setQuantityMultiplier(BigDecimal.ONE); } try { - double percScrapFactor = node.getDouble("scrapFactor").doubleValue(); + BigDecimal percScrapFactor = node.getBigDecimal("scrapFactor"); - // A negative scrap factor is a salvage factor - if (percScrapFactor > -100 && percScrapFactor < 100) { - percScrapFactor = 1 + percScrapFactor / 100; + // A negative scrap factor is a salvage factor + BigDecimal bdHundred = new BigDecimal("100"); + if (percScrapFactor.compareTo(bdHundred.negate()) > 0 && percScrapFactor.compareTo(bdHundred.negate()) < 0) { + percScrapFactor = BigDecimal.ONE.add(percScrapFactor.movePointLeft(2)); } else { Debug.logWarning("A scrap factor of [" + percScrapFactor + "] was ignored", module); - percScrapFactor = 1; + percScrapFactor = BigDecimal.ONE; } oneChildNode.setScrapFactor(percScrapFactor); } catch(Exception nfe) { - oneChildNode.setScrapFactor(1); + oneChildNode.setScrapFactor(BigDecimal.ONE); } BOMNode newNode = oneChildNode; // CONFIGURATOR @@ -376,7 +378,7 @@ public void setParentNode(BOMNode parentNode) { } // ------------------------------------ // Method used for TEST and DEBUG purposes - public void print(StringBuffer sb, double quantity, int depth) { + public void print(StringBuffer sb, BigDecimal quantity, int depth) { for (int i = 0; i < depth; i++) { sb.append(" * "); } @@ -388,21 +390,21 @@ public void print(StringBuffer sb, double quantity, int depth) { depth++; for (int i = 0; i < children.size(); i++) { oneChild = (GenericValue)children.get(i); - double bomQuantity = 0; + BigDecimal bomQuantity = BigDecimal.ZERO; try { - bomQuantity = oneChild.getDouble("quantity").doubleValue(); + bomQuantity = oneChild.getBigDecimal("quantity"); } catch(Exception exc) { - bomQuantity = 1; + bomQuantity = BigDecimal.ONE; } oneChildNode = (BOMNode)childrenNodes.get(i); sb.append("
"); if (oneChildNode != null) { - oneChildNode.print(sb, (quantity * bomQuantity), depth); + oneChildNode.print(sb, quantity.multiply(bomQuantity), depth); } } } - public void print(ArrayList arr, double quantity, int depth, boolean excludeWIPs) { + public void print(ArrayList arr, BigDecimal quantity, int depth, boolean excludeWIPs) { // Now we set the depth and quantity of the current node // in this breakdown. this.depth = depth; @@ -418,27 +420,27 @@ public void print(ArrayList arr, double quantity, int depth, boolean excludeWIPs } if (serviceName != null) { Map resultContext = null; - Map arguments = UtilMisc.toMap("neededQuantity", new Double(quantity * quantityMultiplier), "amount", new Double((tree!=null? tree.getRootAmount():0))); - Double width = null; + Map arguments = UtilMisc.toMap("neededQuantity", quantity.multiply(quantityMultiplier), "amount", tree != null ? tree.getRootAmount() : BigDecimal.ZERO); + BigDecimal width = null; if (getProduct().get("productWidth") != null) { - width = getProduct().getDouble("productWidth"); + width = getProduct().getBigDecimal("productWidth"); } if (width == null) { - width = new Double(0); + width = BigDecimal.ZERO; } arguments.put("width", width); Map inputContext = UtilMisc.toMap("arguments", arguments, "userLogin", userLogin); try { resultContext = dispatcher.runSync(serviceName, inputContext); - Double calcQuantity = (Double)resultContext.get("quantity"); + BigDecimal calcQuantity = (BigDecimal)resultContext.get("quantity"); if (calcQuantity != null) { - this.quantity = calcQuantity.doubleValue(); + this.quantity = calcQuantity; } } catch (GenericServiceException e) { //Debug.logError(e, "Problem calling the getManufacturingComponents service", module); } } else { - this.quantity = quantity * quantityMultiplier * scrapFactor; + this.quantity = quantity.multiply(quantityMultiplier).multiply(scrapFactor); } // First of all we visit the current node. arr.add(this); @@ -458,11 +460,11 @@ public void print(ArrayList arr, double quantity, int depth, boolean excludeWIPs } } - public void getProductsInPackages(ArrayList arr, double quantity, int depth, boolean excludeWIPs) { + public void getProductsInPackages(ArrayList arr, BigDecimal quantity, int depth, boolean excludeWIPs) { // Now we set the depth and quantity of the current node // in this breakdown. this.depth = depth; - this.quantity = quantity * quantityMultiplier * scrapFactor; + this.quantity = quantity.multiply(quantityMultiplier).multiply(scrapFactor); // First of all we visit the current node. if (this.getProduct().getString("shipmentBoxTypeId") != null) { arr.add(this); @@ -492,7 +494,7 @@ public void sumQuantity(HashMap nodes) { nodes.put(product.getString("productId"), sameNode); } // Now we add the current quantity to the node - sameNode.setQuantity(sameNode.getQuantity() + quantity); + sameNode.setQuantity(sameNode.getQuantity().add(quantity)); // Now (recursively) we visit the children. BOMNode oneChildNode = null; for (int i = 0; i < childrenNodes.size(); i++) { @@ -554,7 +556,7 @@ public Map createManufacturingOrder(String facilityId, Date date, String workEff serviceContext.put("workEffortName", "SP_" + shipmentId + "_" + serviceContext.get("productId")); } - serviceContext.put("pRQuantity", new Double(getQuantity())); + serviceContext.put("pRQuantity", getQuantity()); if (UtilValidate.isNotEmpty(maxEndDate)) { serviceContext.put("startDate", maxEndDate); } else { @@ -695,11 +697,11 @@ public void isConfigured(ArrayList arr) { * @return Value of property quantity. * */ - public double getQuantity() { + public BigDecimal getQuantity() { return quantity; } - public void setQuantity(double quantity) { + public void setQuantity(BigDecimal quantity) { this.quantity = quantity; } @@ -764,7 +766,7 @@ public java.lang.String getBomTypeId() { * @return Value of property quantityMultiplier. * */ - public double getQuantityMultiplier() { + public BigDecimal getQuantityMultiplier() { return quantityMultiplier; } @@ -772,7 +774,7 @@ public double getQuantityMultiplier() { * @param quantityMultiplier New value of property quantityMultiplier. * */ - public void setQuantityMultiplier(double quantityMultiplier) { + public void setQuantityMultiplier(BigDecimal quantityMultiplier) { this.quantityMultiplier = quantityMultiplier; } @@ -796,7 +798,7 @@ public void setRuleApplied(org.ofbiz.entity.GenericValue ruleApplied) { * @return Value of property scrapFactor. * */ - public double getScrapFactor() { + public BigDecimal getScrapFactor() { return scrapFactor; } @@ -804,7 +806,7 @@ public double getScrapFactor() { * @param scrapFactor New value of property scrapFactor. * */ - public void setScrapFactor(double scrapFactor) { + public void setScrapFactor(BigDecimal scrapFactor) { this.scrapFactor = scrapFactor; } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java index 9e8a50cd421..39fbf65ecd5 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java @@ -19,6 +19,7 @@ package org.ofbiz.manufacturing.bom; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -290,8 +291,8 @@ public static Map getBOMTree(DispatchContext dctx, Map context) { String fromDateStr = (String) context.get("fromDate"); String bomType = (String) context.get("bomType"); Integer type = (Integer) context.get("type"); - Double quantity = (Double) context.get("quantity"); - Double amount = (Double) context.get("amount"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); + BigDecimal amount = (BigDecimal) context.get("amount"); if (type == null) { type = new Integer(0); } @@ -314,10 +315,10 @@ public static Map getBOMTree(DispatchContext dctx, Map context) { return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage()); } if (tree != null && quantity != null) { - tree.setRootQuantity(quantity.doubleValue()); + tree.setRootQuantity(quantity); } if (tree != null && amount != null) { - tree.setRootAmount(amount.doubleValue()); + tree.setRootAmount(amount); } result.put("tree", tree); @@ -339,16 +340,16 @@ public static Map getManufacturingComponents(DispatchContext dctx, Map context) GenericValue userLogin = (GenericValue)context.get("userLogin"); String productId = (String) context.get("productId"); - Double quantity = (Double) context.get("quantity"); - Double amount = (Double) context.get("amount"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); + BigDecimal amount = (BigDecimal) context.get("amount"); String fromDateStr = (String) context.get("fromDate"); Boolean excludeWIPs = (Boolean) context.get("excludeWIPs"); if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } if (amount == null) { - amount = new Double(0); + amount = BigDecimal.ZERO; } Date fromDate = null; @@ -372,8 +373,8 @@ public static Map getManufacturingComponents(DispatchContext dctx, Map context) ArrayList components = new ArrayList(); try { tree = new BOMTree(productId, "MANUF_COMPONENT", fromDate, BOMTree.EXPLOSION_SINGLE_LEVEL, delegator, dispatcher, userLogin); - tree.setRootQuantity(quantity.doubleValue()); - tree.setRootAmount(amount.doubleValue()); + tree.setRootQuantity(quantity); + tree.setRootAmount(amount); tree.print(components, excludeWIPs.booleanValue()); if (components.size() > 0) components.remove(0); } catch(GenericEntityException gee) { @@ -411,7 +412,7 @@ public static Map getManufacturingComponents(DispatchContext dctx, Map context) Map componentMap = new HashMap(); BOMNode node = (BOMNode)componentsIt.next(); componentMap.put("product", node.getProduct()); - componentMap.put("quantity", new Double(node.getQuantity())); + componentMap.put("quantity", node); componentsMap.add(componentMap); } result.put("componentsMap", componentsMap); @@ -423,16 +424,16 @@ public static Map getNotAssembledComponents(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String productId = (String) context.get("productId"); - Double quantity = (Double) context.get("quantity"); - Double amount = (Double) context.get("amount"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); + BigDecimal amount = (BigDecimal) context.get("amount"); String fromDateStr = (String) context.get("fromDate"); GenericValue userLogin = (GenericValue)context.get("userLogin"); if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } if (amount == null) { - amount = new Double(0); + amount = BigDecimal.ZERO; } Date fromDate = null; @@ -451,8 +452,8 @@ public static Map getNotAssembledComponents(DispatchContext dctx, Map context) { ArrayList notAssembledComponents = new ArrayList(); try { tree = new BOMTree(productId, "MANUF_COMPONENT", fromDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); - tree.setRootQuantity(quantity.doubleValue()); - tree.setRootAmount(amount.doubleValue()); + tree.setRootQuantity(quantity); + tree.setRootAmount(amount); tree.print(components); } catch(GenericEntityException gee) { return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage()); @@ -539,7 +540,7 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { // getProductsInPackages Map serviceContext = new HashMap(); serviceContext.put("productId", orderItem.getString("productId")); - serviceContext.put("quantity", orderShipment.getDouble("quantity")); + serviceContext.put("quantity", orderShipment.getBigDecimal("quantity")); Map resultService = null; try { resultService = dispatcher.runSync("getProductsInPackages", serviceContext); @@ -640,11 +641,10 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { String boxTypeId = (String)boxTypeContentEntry.getKey(); List contentList = (List)boxTypeContentEntry.getValue(); GenericValue boxType = (GenericValue)boxTypes.get(boxTypeId); - Double boxWidth = boxType.getDouble("boxLength"); - double totalWidth = 0; - double boxWidthDbl = 0; - if (boxWidth != null) { - boxWidthDbl = boxWidth.doubleValue(); + BigDecimal boxWidth = boxType.getBigDecimal("boxLength"); + BigDecimal totalWidth = BigDecimal.ZERO; + if (boxWidth == null) { + boxWidth = BigDecimal.ZERO; } String shipmentPackageSeqId = null; for (int i = 0; i < contentList.size(); i++) { @@ -655,7 +655,7 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { GenericValue orderShipment = (GenericValue)content.get("orderShipment"); GenericValue product = null; - double quantity = 0; + BigDecimal quantity = BigDecimal.ZERO; boolean subProduct = contentMap.containsKey("componentIndex"); if (subProduct) { // multi package @@ -671,35 +671,34 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale)); } - quantity = orderShipment.getDouble("quantity").doubleValue(); + quantity = orderShipment.getBigDecimal("quantity"); } - Double productDepth = product.getDouble("shippingDepth"); + BigDecimal productDepth = product.getBigDecimal("shippingDepth"); if (productDepth == null) { - productDepth = product.getDouble("productDepth"); + productDepth = product.getBigDecimal("productDepth"); } - double productDepthDbl = 1; - if (productDepth != null) { - productDepthDbl = productDepth.doubleValue(); + if (productDepth == null) { + productDepth = BigDecimal.ONE; } - int firstMaxNumOfProducts = (int)((boxWidthDbl - totalWidth) / productDepthDbl); - if (firstMaxNumOfProducts == 0) firstMaxNumOfProducts = 1; + BigDecimal firstMaxNumOfProducts = boxWidth.subtract(totalWidth).divide(productDepth, 0, BigDecimal.ROUND_FLOOR); + if (firstMaxNumOfProducts.compareTo(BigDecimal.ZERO) == 0) firstMaxNumOfProducts = BigDecimal.ONE; // - int maxNumOfProducts = (int)(boxWidthDbl / productDepthDbl); - if (maxNumOfProducts == 0) maxNumOfProducts = 1; + BigDecimal maxNumOfProducts = boxWidth.divide(productDepth, 0, BigDecimal.ROUND_FLOOR); + if (maxNumOfProducts.compareTo(BigDecimal.ZERO) == 0) maxNumOfProducts = BigDecimal.ONE; - double remQuantity = quantity; + BigDecimal remQuantity = quantity; boolean isFirst = true; - while (remQuantity > 0) { - int maxQuantity = 0; + while (remQuantity.compareTo(BigDecimal.ZERO) > 0) { + BigDecimal maxQuantity = BigDecimal.ZERO; if (isFirst) { maxQuantity = firstMaxNumOfProducts; isFirst = false; } else { maxQuantity = maxNumOfProducts; } - double qty = (remQuantity < maxQuantity? remQuantity: maxQuantity); + BigDecimal qty = (remQuantity.compareTo(maxQuantity) < 0 ? remQuantity : maxQuantity); // If needed, create the package if (shipmentPackageSeqId == null) { try { @@ -708,7 +707,7 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale)); } - totalWidth = 0; + totalWidth = BigDecimal.ZERO; } try { Map inputMap = null; @@ -718,21 +717,21 @@ public static Map createShipmentPackages(DispatchContext dctx, Map context) { "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"), "subProductId", product.getString("productId"), "userLogin", userLogin, - "subProductQuantity", new Double(qty)); + "subProductQuantity", qty); } else { inputMap = UtilMisc.toMap("shipmentId", orderShipment.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackageSeqId, "shipmentItemSeqId", orderShipment.getString("shipmentItemSeqId"), "userLogin", userLogin, - "quantity", new Double(qty)); + "quantity", qty); } Map resultService = dispatcher.runSync("createShipmentPackageContent", inputMap); } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale)); } - totalWidth += qty * productDepthDbl; - if (qty == maxQuantity) shipmentPackageSeqId = null; - remQuantity = remQuantity - qty; + totalWidth = totalWidth.add( qty.multiply(productDepth) ); + if (qty.compareTo(maxQuantity) == 0) shipmentPackageSeqId = null; + remQuantity = remQuantity.subtract(qty); } } } @@ -755,11 +754,11 @@ public static Map getProductsInPackages(DispatchContext dctx, Map context) { GenericValue userLogin = (GenericValue)context.get("userLogin"); String productId = (String) context.get("productId"); - Double quantity = (Double) context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); String fromDateStr = (String) context.get("fromDate"); if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } Date fromDate = null; if (UtilValidate.isNotEmpty(fromDateStr)) { @@ -779,7 +778,7 @@ public static Map getProductsInPackages(DispatchContext dctx, Map context) { ArrayList components = new ArrayList(); try { tree = new BOMTree(productId, "MANUF_COMPONENT", fromDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); - tree.setRootQuantity(quantity.doubleValue()); + tree.setRootQuantity(quantity); tree.getProductsInPackages(components); } catch(GenericEntityException gee) { return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage()); diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java index cf8b0b233db..f612c55659b 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java @@ -19,6 +19,7 @@ package org.ofbiz.manufacturing.bom; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -50,8 +51,8 @@ public class BOMTree { protected GenericDelegator delegator = null; BOMNode root; - double rootQuantity; - double rootAmount; + BigDecimal rootQuantity; + BigDecimal rootAmount; Date inDate; String bomTypeId; GenericValue inputProduct; @@ -157,8 +158,8 @@ public BOMTree(String productId, String bomTypeId, Date inDate, int type, Generi } this.bomTypeId = bomTypeId; this.inDate = inDate; - rootQuantity = 1; - rootAmount = 0; + rootQuantity = BigDecimal.ONE; + rootAmount = BigDecimal.ZERO; } public GenericValue getInputProduct() { @@ -199,7 +200,7 @@ public boolean isConfigured() { * @return Value of property rootQuantity. * */ - public double getRootQuantity() { + public BigDecimal getRootQuantity() { return rootQuantity; } @@ -207,7 +208,7 @@ public double getRootQuantity() { * @param rootQuantity New value of property rootQuantity. * */ - public void setRootQuantity(double rootQuantity) { + public void setRootQuantity(BigDecimal rootQuantity) { this.rootQuantity = rootQuantity; } @@ -215,7 +216,7 @@ public void setRootQuantity(double rootQuantity) { * @return Value of property rootAmount. * */ - public double getRootAmount() { + public BigDecimal getRootAmount() { return rootAmount; } @@ -223,7 +224,7 @@ public double getRootAmount() { * @param rootAmount New value of property rootAmount. * */ - public void setRootAmount(double rootAmount) { + public void setRootAmount(BigDecimal rootAmount) { this.rootAmount = rootAmount; } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java index 28753038d61..fd599b7dcb1 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java @@ -19,6 +19,7 @@ package org.ofbiz.manufacturing.jobshopmgt; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Iterator; import java.util.LinkedList; @@ -49,7 +50,7 @@ public class ProductionRun { protected GenericValue productionRun; // WorkEffort (PROD_ORDER_HEADER) protected GenericValue productionRunProduct; // WorkEffortGoodStandard (type: PRUN_PROD_DELIV) protected GenericValue productProduced; // Product (from WorkEffortGoodStandard of type: PRUN_PROD_DELIV) - protected Double quantity; // the estimatedQuantity + protected BigDecimal quantity; // the estimatedQuantity protected Timestamp estimatedStartDate; protected Timestamp estimatedCompletionDate; @@ -165,7 +166,7 @@ public GenericValue getProductProduced(){ try { List productionRunProducts = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV"),null); this.productionRunProduct = EntityUtil.getFirst(productionRunProducts); - quantity = productionRunProduct.getDouble("estimatedQuantity"); + quantity = productionRunProduct.getBigDecimal("estimatedQuantity"); productProduced = productionRunProduct.getRelatedOneCache("Product"); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); @@ -180,7 +181,7 @@ public GenericValue getProductProduced(){ * get the quantity property. * @return the quantity property **/ - public Double getQuantity(){ + public BigDecimal getQuantity(){ if (exist()) { if (quantity == null) getProductProduced(); return quantity; @@ -191,17 +192,17 @@ public Double getQuantity(){ * set the quantity property and recalculated the productComponent quantity. * @return **/ - public void setQuantity(Double newQuantity) { + public void setQuantity(BigDecimal newQuantity) { if (quantity == null) getProductProduced(); - double previousQuantity = quantity.doubleValue(), componentQuantity; + BigDecimal previousQuantity = quantity, componentQuantity; this.quantity = newQuantity; this.quantityIsUpdated = true; this.updateCompletionDate = true; if (productionRunComponents == null) getProductionRunComponents(); for (Iterator iter = productionRunComponents.iterator(); iter.hasNext();){ GenericValue component = (GenericValue) iter.next(); - componentQuantity = component.getDouble("estimatedQuantity").doubleValue(); - component.set("estimatedQuantity", new Double(componentQuantity / previousQuantity * newQuantity.doubleValue())); + componentQuantity = component.getBigDecimal("estimatedQuantity"); + component.set("estimatedQuantity", componentQuantity.divide(previousQuantity, 10, BigDecimal.ROUND_HALF_UP).multiply(newQuantity)); } } /** @@ -387,18 +388,15 @@ public void clearRoutingTasksList(){ } /* - * FIXME: the three getEstimatedTaskTime(...) methods will be removed and + * FIXME: the two getEstimatedTaskTime(...) methods will be removed and * implemented in the "getEstimatedTaskTime" service. */ - public static long getEstimatedTaskTime(GenericValue task, double quantity, LocalDispatcher dispatcher) { - return getEstimatedTaskTime(task, new Double(quantity), dispatcher); - } - public static long getEstimatedTaskTime(GenericValue task, Double quantity, LocalDispatcher dispatcher) { + public static long getEstimatedTaskTime(GenericValue task, BigDecimal quantity, LocalDispatcher dispatcher) { return getEstimatedTaskTime(task, quantity, null, null, dispatcher); } - public static long getEstimatedTaskTime(GenericValue task, Double quantity, String productId, String routingId, LocalDispatcher dispatcher) { + public static long getEstimatedTaskTime(GenericValue task, BigDecimal quantity, String productId, String routingId, LocalDispatcher dispatcher) { if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } if (task == null) return 0; double setupTime = 0; diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java index a960157046b..d4819a2288f 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.manufacturing.jobshopmgt; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Collection; import java.util.List; @@ -52,9 +53,9 @@ public static String productionRunDeclareAndProduce(HttpServletRequest request, Map parameters = UtilHttp.getParameterMap(request); - Double quantity = null; + BigDecimal quantity = null; try { - quantity = Double.valueOf((String)parameters.get("quantity")); + quantity = new BigDecimal((String)parameters.get("quantity")); } catch(NumberFormatException nfe) { String errMsg = "Invalid format for quantity field: " + nfe.toString(); Debug.logError(nfe, errMsg, module); diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java index 54e695b08ee..939cd37119d 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java @@ -193,7 +193,7 @@ public static Map createProductionRun(DispatchContext ctx, Map context) { // Mandatory input fields String productId = (String) context.get("productId"); Timestamp startDate = (Timestamp) context.get("startDate"); - Double pRQuantity = (Double) context.get("pRQuantity"); + BigDecimal pRQuantity = (BigDecimal) context.get("pRQuantity"); String facilityId = (String) context.get("facilityId"); // Optional input fields String workEffortId = (String) context.get("routingId"); @@ -405,7 +405,7 @@ public static Map createProductionRun(DispatchContext ctx, Map context) { serviceContext.put("fromDate", productBom.get("fromDate")); // Here we use the getQuantity method to get the quantity already // computed by the getManufacturingComponents service - serviceContext.put("estimatedQuantity", new Double(node.getQuantity())); + serviceContext.put("estimatedQuantity", node.getQuantity()); serviceContext.put("userLogin", userLogin); resultService = null; try { @@ -465,7 +465,7 @@ public static Map updateProductionRun(DispatchContext ctx, Map context) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); } - Double quantity = (Double) context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); if (quantity != null && ! quantity.equals(productionRun.getQuantity())) { productionRun.setQuantity(quantity); } @@ -809,22 +809,22 @@ public static Map changeProductionRunTaskStatus(DispatchContext ctx, Map context serviceContext.put("workEffortId", taskId); serviceContext.put("currentStatusId", "PRUN_COMPLETED"); serviceContext.put("actualCompletionDate", UtilDateTime.nowTimestamp()); - Double quantityToProduce = theTask.getDouble("quantityToProduce"); + BigDecimal quantityToProduce = theTask.getBigDecimal("quantityToProduce"); if (quantityToProduce == null) { - quantityToProduce = new Double(0); + quantityToProduce = BigDecimal.ZERO; } - Double quantityProduced = theTask.getDouble("quantityProduced"); + BigDecimal quantityProduced = theTask.getBigDecimal("quantityProduced"); if (quantityProduced == null) { - quantityProduced = new Double(0); + quantityProduced = BigDecimal.ZERO; } - Double quantityRejected = theTask.getDouble("quantityRejected"); + BigDecimal quantityRejected = theTask.getBigDecimal("quantityRejected"); if (quantityRejected == null) { - quantityRejected = new Double(0); + quantityRejected = BigDecimal.ZERO; } - double totalQuantity = quantityProduced.doubleValue() + quantityRejected.doubleValue(); - double diffQuantity = quantityToProduce.doubleValue() - totalQuantity; - if (diffQuantity > 0) { - quantityProduced = new Double(quantityProduced.doubleValue() + diffQuantity); + BigDecimal totalQuantity = quantityProduced.add(quantityRejected); + BigDecimal diffQuantity = quantityToProduce.subtract(totalQuantity); + if (diffQuantity.compareTo(BigDecimal.ZERO) > 0) { + quantityProduced = quantityProduced.add(diffQuantity); } serviceContext.put("quantityProduced", quantityProduced); if (theTask.get("actualSetupMillis") == null) { @@ -833,7 +833,7 @@ public static Map changeProductionRunTaskStatus(DispatchContext ctx, Map context if (theTask.get("actualMilliSeconds") == null) { Double autoMillis = null; if (theTask.get("estimatedMilliSeconds") != null) { - autoMillis = new Double(quantityProduced.doubleValue() * theTask.getDouble("estimatedMilliSeconds").doubleValue()); + autoMillis = new Double(quantityProduced.doubleValue() * theTask.getDouble("estimatedMilliSeconds")); } serviceContext.put("actualMilliSeconds", autoMillis); } @@ -1002,7 +1002,7 @@ public static Map createProductionRunTaskCosts(DispatchContext ctx, Map context) inMap.put("costComponentTypeId", "ACTUAL_" + workEffortCostCalc.getString("costComponentTypeId")); inMap.put("costComponentCalcId", costComponentCalc.getString("costComponentCalcId")); inMap.put("costUomId", costComponentCalc.getString("currencyUomId")); - inMap.put("cost", new Double(totalCost.doubleValue())); + inMap.put("cost", totalCost); dispatcher.runSync("createCostComponent", inMap); } else { // use the custom method (aka formula) to compute the costs @@ -1041,7 +1041,7 @@ public static Map createProductionRunTaskCosts(DispatchContext ctx, Map context) Map inMap = UtilMisc.toMap("userLogin", userLogin, "workEffortId", productionRunTaskId); inMap.put("costComponentTypeId", "ACTUAL_MAT_COST"); inMap.put("costUomId", currencyUomId); - inMap.put("cost", new Double(materialsCost.doubleValue())); + inMap.put("cost", materialsCost); dispatcher.runSync("createCostComponent", inMap); } } catch(Exception e) { @@ -1143,7 +1143,7 @@ public static Map addProductionRunComponent(DispatchContext ctx, Map context) { // Mandatory input fields String productionRunId = (String)context.get("productionRunId"); String productId = (String)context.get("productId"); - Double quantity = (Double) context.get("estimatedQuantity"); + BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity"); // Optional input fields String workEffortId = (String)context.get("workEffortId"); @@ -1215,7 +1215,7 @@ public static Map updateProductionRunComponent(DispatchContext ctx, Map context) String productId = (String)context.get("productId"); // Optional input fields String workEffortId = (String)context.get("workEffortId"); // the production run task - Double quantity = (Double) context.get("estimatedQuantity"); + BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity"); ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); List components = productionRun.getProductionRunComponents(); @@ -1300,7 +1300,7 @@ public static Map addProductionRunRoutingTask(DispatchContext ctx, Map context) // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); - Double pRQuantity = productionRun.getQuantity(); + BigDecimal pRQuantity = productionRun.getQuantity(); if (pRQuantity == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } @@ -1427,7 +1427,7 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { String productionRunId = (String)context.get("workEffortId"); // Optional input fields - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); String inventoryItemTypeId = (String)context.get("inventoryItemTypeId"); String lotId = (String)context.get("lotId"); Boolean createLotIfNeeded = (Boolean)context.get("createLotIfNeeded"); @@ -1457,29 +1457,29 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { if ("WIP".equals(productionRun.getProductProduced().getString("productTypeId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductIsWIP", locale)); } - Double quantityProduced = productionRun.getGenericValue().getDouble("quantityProduced"); + BigDecimal quantityProduced = productionRun.getGenericValue().getBigDecimal("quantityProduced"); if (quantityProduced == null) { - quantityProduced = new Double(0); + quantityProduced = BigDecimal.ZERO; } - Double quantityDeclared = lastTask.getDouble("quantityProduced"); + BigDecimal quantityDeclared = lastTask.getBigDecimal("quantityProduced"); if (quantityDeclared == null) { - quantityDeclared = new Double(0); + quantityDeclared = BigDecimal.ZERO; } // If the quantity already produced is not lower than the quantity declared, no inventory is created. - double maxQuantity = quantityDeclared.doubleValue() - quantityProduced.doubleValue(); + BigDecimal maxQuantity = quantityDeclared.subtract(quantityProduced); - if (maxQuantity <= 0) { + if (maxQuantity.compareTo(BigDecimal.ZERO) <= 0) { return result; } // If quantity was not passed, the max quantity is used if (quantity == null) { - quantity = new Double(maxQuantity); + quantity = maxQuantity; } // - if (quantity.doubleValue() > maxQuantity) { + if (quantity.compareTo(maxQuantity) > 0) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunProductProducedNotStillAvailable", locale)); } @@ -1520,7 +1520,7 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { Map outputMap = dispatcher.runSync("getProductionRunCost", UtilMisc.toMap("userLogin", userLogin, "workEffortId", productionRunId)); BigDecimal totalCost = (BigDecimal)outputMap.get("totalCost"); // FIXME - unitCost = totalCost.divide(BigDecimal.valueOf(quantity.doubleValue()), decimals, rounding); + unitCost = totalCost.divide(quantity, decimals, rounding); } catch (GenericServiceException e) { Debug.logWarning(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); @@ -1537,7 +1537,7 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { serviceContext.put("datetimeReceived", UtilDateTime.nowTimestamp()); serviceContext.put("comments", "Created by production run " + productionRunId); if (unitCost.compareTo(ZERO) != 0) { - serviceContext.put("unitCost", new Double(unitCost.doubleValue())); + serviceContext.put("unitCost", unitCost); } //serviceContext.put("serialNumber", productionRunId); serviceContext.put("lotId", lotId); @@ -1548,8 +1548,8 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { serviceContext.clear(); serviceContext.put("inventoryItemId", inventoryItemId); serviceContext.put("workEffortId", productionRunId); - serviceContext.put("availableToPromiseDiff", new Double(1)); - serviceContext.put("quantityOnHandDiff", new Double(1)); + serviceContext.put("availableToPromiseDiff", BigDecimal.ONE); + serviceContext.put("quantityOnHandDiff", BigDecimal.ONE); serviceContext.put("userLogin", userLogin); resultService = dispatcher.runSync("createInventoryItemDetail", serviceContext); serviceContext.clear(); @@ -1575,7 +1575,7 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { serviceContext.put("comments", "Created by production run " + productionRunId); serviceContext.put("lotId", lotId); if (unitCost.compareTo(ZERO) != 0) { - serviceContext.put("unitCost", new Double(unitCost.doubleValue())); + serviceContext.put("unitCost", unitCost); } serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("createInventoryItem", serviceContext); @@ -1609,7 +1609,7 @@ public static Map productionRunProduce(DispatchContext ctx, Map context) { } // Now the production run's quantityProduced is updated Map serviceContext = UtilMisc.toMap("workEffortId", productionRunId); - serviceContext.put("quantityProduced", new Double(quantityProduced.doubleValue() + quantity.doubleValue())); + serviceContext.put("quantityProduced", quantityProduced.add(quantity)); serviceContext.put("actualCompletionDate", UtilDateTime.nowTimestamp()); serviceContext.put("userLogin", userLogin); try { @@ -1633,22 +1633,22 @@ public static Map productionRunDeclareAndProduce(DispatchContext ctx, Map contex String productionRunId = (String)context.get("workEffortId"); // Optional input fields - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); Map componentsLocationMap = (Map)context.get("componentsLocationMap"); // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); - Double quantityProduced = productionRun.getGenericValue().getDouble("quantityProduced"); - Double quantityToProduce = productionRun.getGenericValue().getDouble("quantityToProduce"); + BigDecimal quantityProduced = productionRun.getGenericValue().getBigDecimal("quantityProduced"); + BigDecimal quantityToProduce = productionRun.getGenericValue().getBigDecimal("quantityToProduce"); if (quantityProduced == null) { - quantityProduced = new Double(0); + quantityProduced = BigDecimal.ZERO; } if (quantityToProduce == null) { - quantityToProduce = new Double(0); + quantityToProduce = BigDecimal.ZERO; } - double minimumQuantityProducedByTask = quantityProduced.doubleValue() + quantity.doubleValue(); - if (minimumQuantityProducedByTask > quantityToProduce.doubleValue()) { + BigDecimal minimumQuantityProducedByTask = quantityProduced.add(quantity); + if (minimumQuantityProducedByTask.compareTo(quantityToProduce) > 0) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingQuantityProducedIsHigherThanQuantityDeclared", locale)); } @@ -1657,14 +1657,14 @@ public static Map productionRunDeclareAndProduce(DispatchContext ctx, Map contex GenericValue oneTask = (GenericValue)tasks.get(i); String taskId = oneTask.getString("workEffortId"); if ("PRUN_RUNNING".equals(oneTask.getString("currentStatusId"))) { - Double quantityDeclared = oneTask.getDouble("quantityProduced"); + BigDecimal quantityDeclared = oneTask.getBigDecimal("quantityProduced"); if (quantityDeclared == null) { - quantityDeclared = new Double(0); + quantityDeclared = BigDecimal.ZERO; } - if (minimumQuantityProducedByTask > quantityDeclared.doubleValue()) { + if (minimumQuantityProducedByTask.compareTo(quantityDeclared) > 0) { try { Map serviceContext = UtilMisc.toMap("productionRunId", productionRunId, "productionRunTaskId", taskId); - serviceContext.put("addQuantityProduced", new Double(minimumQuantityProducedByTask - quantityDeclared.doubleValue())); + serviceContext.put("addQuantityProduced", minimumQuantityProducedByTask.subtract(quantityDeclared)); serviceContext.put("issueRequiredComponents", Boolean.TRUE); serviceContext.put("componentsLocationMap", componentsLocationMap); serviceContext.put("userLogin", userLogin); @@ -1696,12 +1696,12 @@ public static Map productionRunTaskProduce(DispatchContext ctx, Map context) { // Mandatory input fields String productionRunTaskId = (String)context.get("workEffortId"); String productId = (String)context.get("productId"); - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); // Optional input fields String facilityId = (String)context.get("facilityId"); String currencyUomId = (String)context.get("currencyUomId"); - Double unitCost = (Double)context.get("unitCost"); + BigDecimal unitCost = (BigDecimal)context.get("unitCost"); String inventoryItemTypeId = (String)context.get("inventoryItemTypeId"); // The default is non-serialized inventory item @@ -1735,8 +1735,8 @@ public static Map productionRunTaskProduce(DispatchContext ctx, Map context) { serviceContext.clear(); serviceContext.put("inventoryItemId", inventoryItemId); serviceContext.put("workEffortId", productionRunTaskId); - serviceContext.put("availableToPromiseDiff", new Double(1)); - serviceContext.put("quantityOnHandDiff", new Double(1)); + serviceContext.put("availableToPromiseDiff", BigDecimal.ONE); + serviceContext.put("quantityOnHandDiff", BigDecimal.ONE); serviceContext.put("userLogin", userLogin); resultService = dispatcher.runSync("createInventoryItemDetail", serviceContext); serviceContext.clear(); @@ -1803,8 +1803,8 @@ public static Map productionRunTaskReturnMaterial(DispatchContext ctx, Map conte String productionRunTaskId = (String)context.get("workEffortId"); String productId = (String)context.get("productId"); // Optional input fields - Double quantity = (Double)context.get("quantity"); - if (quantity == null || quantity.doubleValue() == 0) { + BigDecimal quantity = (BigDecimal)context.get("quantity"); + if (quantity == null || quantity.compareTo(ZERO) == 0) { return ServiceUtil.returnSuccess(); } // Verify how many items of the given productId @@ -1812,28 +1812,28 @@ public static Map productionRunTaskReturnMaterial(DispatchContext ctx, Map conte // If less than passed quantity then return an error message. try { Iterator issuances = (delegator.findByAnd("WorkEffortAndInventoryAssign", UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))).iterator(); - double totalIssued = 0.0; + BigDecimal totalIssued = BigDecimal.ZERO; while (issuances.hasNext()) { GenericValue issuance = (GenericValue)issuances.next(); - Double issued = issuance.getDouble("quantity"); + BigDecimal issued = issuance.getBigDecimal("quantity"); if (issued != null) { - totalIssued += issued.doubleValue(); + totalIssued = totalIssued.add(issued); } } Iterator returns = (delegator.findByAnd("WorkEffortAndInventoryProduced", UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))).iterator(); - double totalReturned = 0.0; + BigDecimal totalReturned = BigDecimal.ZERO; while (returns.hasNext()) { GenericValue returned = (GenericValue)returns.next(); GenericValue returnDetail = EntityUtil.getFirst(delegator.findByAnd("InventoryItemDetail", UtilMisc.toMap("inventoryItemId", returned.getString("inventoryItemId")), UtilMisc.toList("inventoryItemDetailSeqId"))); if (returnDetail != null) { - Double qtyReturned = returnDetail.getDouble("quantityOnHandDiff"); + BigDecimal qtyReturned = returnDetail.getBigDecimal("quantityOnHandDiff"); if (qtyReturned != null) { - totalReturned += qtyReturned.doubleValue(); + totalReturned = totalReturned.add(qtyReturned); } } } - if (quantity.doubleValue() > totalIssued - totalReturned) { - return ServiceUtil.returnError("Production Run Task with id [" + productionRunTaskId + "] cannot return more items [" + quantity + "] than the ones currently allocated [" + (totalIssued - totalReturned) + "]"); + if (quantity.compareTo(totalIssued.subtract(totalReturned)) > 0) { + return ServiceUtil.returnError("Production Run Task with id [" + productionRunTaskId + "] cannot return more items [" + quantity + "] than the ones currently allocated [" + (totalIssued.subtract(totalReturned)) + "]"); } } catch(GenericEntityException gee) { return ServiceUtil.returnError(gee.getMessage()); @@ -1874,8 +1874,8 @@ public static Map updateProductionRunTask(DispatchContext ctx, Map context) { // Optional input fields Timestamp fromDate = (Timestamp)context.get("fromDate"); Timestamp toDate = (Timestamp)context.get("toDate"); - Double addQuantityProduced = (Double)context.get("addQuantityProduced"); - Double addQuantityRejected = (Double)context.get("addQuantityRejected"); + BigDecimal addQuantityProduced = (BigDecimal)context.get("addQuantityProduced"); + BigDecimal addQuantityRejected = (BigDecimal)context.get("addQuantityRejected"); Double addSetupTime = (Double)context.get("addSetupTime"); Double addTaskTime = (Double)context.get("addTaskTime"); String comments = (String)context.get("comments"); @@ -1892,10 +1892,10 @@ public static Map updateProductionRunTask(DispatchContext ctx, Map context) { toDate = UtilDateTime.nowTimestamp(); } if (addQuantityProduced == null) { - addQuantityProduced = new Double(0); + addQuantityProduced = BigDecimal.ZERO; } if (addQuantityRejected == null) { - addQuantityRejected = new Double(0); + addQuantityRejected = BigDecimal.ZERO; } if (addSetupTime == null) { addSetupTime = new Double(0); @@ -1940,47 +1940,47 @@ public static Map updateProductionRunTask(DispatchContext ctx, Map context) { actualSetupMillis = new Double(0); } - Double quantityProduced = theTask.getDouble("quantityProduced"); + BigDecimal quantityProduced = theTask.getBigDecimal("quantityProduced"); if (quantityProduced == null) { - quantityProduced = new Double(0); + quantityProduced = BigDecimal.ZERO; } - Double quantityRejected = theTask.getDouble("quantityRejected"); + BigDecimal quantityRejected = theTask.getBigDecimal("quantityRejected"); if (quantityRejected == null) { - quantityRejected = new Double(0); + quantityRejected = BigDecimal.ZERO; } double totalMillis = actualMilliSeconds.doubleValue() + addTaskTime.doubleValue(); double totalSetupMillis = actualSetupMillis.doubleValue() + addSetupTime.doubleValue(); - double totalQuantityProduced = quantityProduced.doubleValue() + addQuantityProduced.doubleValue(); - double totalQuantityRejected = quantityRejected.doubleValue() + addQuantityRejected.doubleValue(); + BigDecimal totalQuantityProduced = quantityProduced.add(addQuantityProduced); + BigDecimal totalQuantityRejected = quantityRejected.add(addQuantityRejected); - if (issueRequiredComponents.booleanValue() && addQuantityProduced.doubleValue() > 0) { - Double quantityToProduce = theTask.getDouble("quantityToProduce"); + if (issueRequiredComponents.booleanValue() && addQuantityProduced.compareTo(ZERO) > 0) { + BigDecimal quantityToProduce = theTask.getBigDecimal("quantityToProduce"); if (quantityToProduce == null) { - quantityToProduce = new Double(0); + quantityToProduce = BigDecimal.ZERO; } - if (quantityToProduce.doubleValue() > 0) { + if (quantityToProduce.compareTo(ZERO) > 0) { try { List components = theTask.getRelated("WorkEffortGoodStandard"); for (GenericValue component : components) { - double totalRequiredMaterialQuantity = component.getDouble("estimatedQuantity").doubleValue() * totalQuantityProduced / quantityToProduce.doubleValue(); + BigDecimal totalRequiredMaterialQuantity = component.getBigDecimal("estimatedQuantity").multiply(totalQuantityProduced).divide(quantityToProduce, rounding); // now get the units that have been already issued and subtract them List issuances = delegator.findByAnd("WorkEffortAndInventoryAssign", UtilMisc.toMap("workEffortId", workEffortId, "productId", component.getString("productId"))); - double totalIssued = 0.0; + BigDecimal totalIssued = BigDecimal.ZERO; for (GenericValue issuance : issuances) { - Double issued = issuance.getDouble("quantity"); + BigDecimal issued = issuance.getBigDecimal("quantity"); if (issued != null) { - totalIssued += issued.doubleValue(); + totalIssued = totalIssued.add(issued); } } - double requiredQuantity = totalRequiredMaterialQuantity - totalIssued; - if (requiredQuantity > 0) { + BigDecimal requiredQuantity = totalRequiredMaterialQuantity.subtract(totalIssued); + if (requiredQuantity.compareTo(ZERO) > 0) { GenericPK key = component.getPrimaryKey(); Map componentsLocation = null; if (componentsLocationMap != null) { componentsLocation = (Map)componentsLocationMap.get(key); } Map serviceContext = UtilMisc.toMap("workEffortId", workEffortId, "productId", component.getString("productId"), "fromDate", component.getTimestamp("fromDate")); - serviceContext.put("quantity", new Double(requiredQuantity)); + serviceContext.put("quantity", requiredQuantity); if (componentsLocation != null) { serviceContext.put("locationSeqId", (String)componentsLocation.get("locationSeqId")); serviceContext.put("secondaryLocationSeqId", (String)componentsLocation.get("secondaryLocationSeqId")); @@ -2020,8 +2020,8 @@ public static Map updateProductionRunTask(DispatchContext ctx, Map context) { serviceContext.put("workEffortId", workEffortId); serviceContext.put("actualMilliSeconds", new Double(totalMillis)); serviceContext.put("actualSetupMillis", new Double(totalSetupMillis)); - serviceContext.put("quantityProduced", new Double(totalQuantityProduced)); - serviceContext.put("quantityRejected", new Double(totalQuantityRejected)); + serviceContext.put("quantityProduced", totalQuantityProduced); + serviceContext.put("quantityRejected", totalQuantityRejected); serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("updateWorkEffort", serviceContext); } catch(Exception exc) { @@ -2065,7 +2065,7 @@ public static Map createProductionRunFromRequirement(DispatchContext ctx, Map co // Mandatory input fields String requirementId = (String)context.get("requirementId"); // Optional input fields - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); GenericValue requirement = null; try { @@ -2080,7 +2080,7 @@ public static Map createProductionRunFromRequirement(DispatchContext ctx, Map co } if (quantity == null) { - quantity = requirement.getDouble("quantity"); + quantity = requirement.getBigDecimal("quantity"); } Map serviceContext = new HashMap(); serviceContext.clear(); @@ -2127,7 +2127,7 @@ public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map // Optional input fields String configId = (String)context.get("configId"); ProductConfigWrapper config = (ProductConfigWrapper)context.get("config"); - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); String orderId = (String)context.get("orderId"); String orderItemSeqId = (String)context.get("orderItemSeqId"); @@ -2142,7 +2142,7 @@ public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map return ServiceUtil.returnError("ProductConfigurationNotValid"); } if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } String instanceProductId = null; try { @@ -2175,13 +2175,13 @@ public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map //components.addAll(co.getComponents()); Iterator selComponents = co.getComponents().iterator(); while (selComponents.hasNext()) { - Double componentQuantity = null; + BigDecimal componentQuantity = null; GenericValue selComponent = (GenericValue)selComponents.next(); if (selComponent.get("quantity") != null) { - componentQuantity = selComponent.getDouble("quantity"); + componentQuantity = selComponent.getBigDecimal("quantity"); } if (componentQuantity == null) { - componentQuantity = new Double(1); + componentQuantity = BigDecimal.ONE; } String componentProductId = selComponent.getString("productId"); if (co.isVirtualComponent(selComponent)) { @@ -2190,10 +2190,10 @@ public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map componentProductId = (String)componentOptions.get(componentProductId); } } - componentQuantity = new Double(quantity.doubleValue() * componentQuantity.doubleValue()); + componentQuantity = quantity.multiply(componentQuantity); if (components.containsKey(componentProductId)) { - Double totalQuantity = (Double)components.get(componentProductId); - componentQuantity = new Double(totalQuantity.doubleValue() + componentQuantity.doubleValue()); + BigDecimal totalQuantity = (BigDecimal)components.get(componentProductId); + componentQuantity = totalQuantity.add(componentQuantity); } components.put(componentProductId, componentQuantity); @@ -2222,9 +2222,9 @@ public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map while (componentsIt.hasNext()) { Map.Entry component = (Map.Entry)componentsIt.next(); String productId = (String)component.getKey(); - Double componentQuantity = (Double)component.getValue(); + BigDecimal componentQuantity = (BigDecimal)component.getValue(); if (componentQuantity == null) { - componentQuantity = new Double(1); + componentQuantity = BigDecimal.ONE; } resultService = null; serviceContext = new HashMap(); @@ -2288,35 +2288,35 @@ public static Map createProductionRunForMktgPkg(DispatchContext ctx, Map context try { // first figure out how much of this product we already have in stock (ATP) - double existingAtp = 0.0; + BigDecimal existingAtp = BigDecimal.ZERO; Map tmpResults = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", orderItem.getString("productId"), "facilityId", facilityId, "userLogin", userLogin)); if (tmpResults.get("availableToPromiseTotal") != null) { - existingAtp = ((Double) tmpResults.get("availableToPromiseTotal")).doubleValue(); + existingAtp = (BigDecimal) tmpResults.get("availableToPromiseTotal"); } // if the order is immediately fulfilled, adjust the atp to compensate for it not reserved if (isImmediatelyFulfilled) { - existingAtp -= orderItem.getDouble("quantity"); + existingAtp = existingAtp.subtract(orderItem.getBigDecimal("quantity")); } if (Debug.verboseOn()) { Debug.logVerbose("Order item [" + orderItem + "] Existing ATP = [" + existingAtp + "]", module); } // we only need to produce more marketing packages if there isn't enough in stock. - if (existingAtp < 0.0) { + if (existingAtp.compareTo(ZERO) < 0) { // how many should we produce? If there already is some inventory, then just produce enough to bring ATP back up to zero. - double qtyRequired = 0 - existingAtp; + BigDecimal qtyRequired = BigDecimal.ZERO.subtract(existingAtp); // ok so that's how many we WANT to produce, but let's check how many we can actually produce based on the available components Map serviceContext = new HashMap(); serviceContext.put("productId", orderItem.getString("productId")); serviceContext.put("facilityId", facilityId); serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("getMktgPackagesAvailable", serviceContext); - double mktgPackagesAvailable = ((Double) resultService.get("availableToPromiseTotal")).doubleValue(); + BigDecimal mktgPackagesAvailable = (BigDecimal) resultService.get("availableToPromiseTotal"); - double qtyToProduce = Math.min(qtyRequired, mktgPackagesAvailable); + BigDecimal qtyToProduce = qtyRequired.min(mktgPackagesAvailable); - if (qtyToProduce > 0) { + if (qtyToProduce.compareTo(ZERO) > 0) { if (Debug.verboseOn()) { Debug.logVerbose("Required quantity (all orders) = [" + qtyRequired + "] quantity to produce = [" + qtyToProduce + "]", module); } - serviceContext.put("pRQuantity", new Double(qtyToProduce)); + serviceContext.put("pRQuantity", qtyToProduce); serviceContext.put("startDate", UtilDateTime.nowTimestamp()); //serviceContext.put("workEffortName", ""); @@ -2365,10 +2365,10 @@ public static Map createProductionRunsForOrder(DispatchContext dctx, Map context String shipmentId = (String) context.get("shipmentId"); String orderItemSeqId = (String) context.get("orderItemSeqId"); - Double quantity = (Double) context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); String fromDateStr = (String) context.get("fromDate"); - Double amount = null; + BigDecimal amount = null; Date fromDate = null; if (UtilValidate.isNotEmpty(fromDateStr)) { try { @@ -2411,7 +2411,7 @@ public static Map createProductionRunsForOrder(DispatchContext dctx, Map context continue; } if (orderItem.get("quantity") != null) { - quantity = orderItem.getDouble("quantity"); + quantity = orderItem.getBigDecimal("quantity"); } else { continue; } @@ -2425,16 +2425,16 @@ public static Map createProductionRunsForOrder(DispatchContext dctx, Map context return ServiceUtil.returnError("Error reading the WorkOrderItemFulfillment: " + gee.getMessage()); } if (orderItem.get("selectedAmount") != null) { - amount = orderItem.getDouble("selectedAmount"); + amount = orderItem.getBigDecimal("selectedAmount"); } if (amount == null) { - amount = new Double(0); + amount = BigDecimal.ZERO; } try { ArrayList components = new ArrayList(); BOMTree tree = new BOMTree(orderItem.getString("productId"), "MANUF_COMPONENT", fromDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); - tree.setRootQuantity(quantity.doubleValue()); - tree.setRootAmount(amount.doubleValue()); + tree.setRootQuantity(quantity); + tree.setRootAmount(amount); tree.print(components); tree.createManufacturingOrders(null, fromDate, null, null, null, orderId, orderItem.getString("orderItemSeqId"), shipmentId, userLogin); } catch(GenericEntityException gee) { @@ -2454,20 +2454,20 @@ public static Map createProductionRunsForProductBom(DispatchContext dctx, Map co String productId = (String)context.get("productId"); Timestamp startDate = (Timestamp)context.get("startDate"); - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); String facilityId = (String)context.get("facilityId"); String workEffortName = (String)context.get("workEffortName"); String description = (String)context.get("description"); String routingId = (String)context.get("routingId"); String workEffortId = null; if (quantity == null) { - quantity = new Double(1.0); + quantity = BigDecimal.ONE; } try { ArrayList components = new ArrayList(); BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", startDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); - tree.setRootQuantity(quantity.doubleValue()); - tree.setRootAmount(0.0); + tree.setRootQuantity(quantity); + tree.setRootAmount(BigDecimal.ZERO); tree.print(components); workEffortId = tree.createManufacturingOrders(facilityId, startDate, workEffortName, description, routingId, null, null, null, userLogin); } catch(GenericEntityException gee) { @@ -2688,7 +2688,7 @@ public static Map getProductionRunTotResQty(DispatchContext ctx, Map context) { if (startDate == null) { startDate = UtilDateTime.nowTimestamp(); } - double totQty = 0.0; + BigDecimal totQty = BigDecimal.ZERO; try { List findOutgoingProductionRunsConds = new LinkedList(); @@ -2707,16 +2707,16 @@ public static Map getProductionRunTotResQty(DispatchContext ctx, Map context) { if (outgoingProductionRuns != null) { for (int i = 0; i < outgoingProductionRuns.size(); i++) { GenericValue outgoingProductionRun = (GenericValue)outgoingProductionRuns.get(i); - Double dblQty = outgoingProductionRun.getDouble("estimatedQuantity"); - double qty = (dblQty != null? dblQty.doubleValue(): 0.0); - totQty += qty; + BigDecimal qty = outgoingProductionRun.getBigDecimal("estimatedQuantity"); + qty = qty != null ? qty : BigDecimal.ZERO; + totQty = totQty.add(qty); } } } catch (GenericEntityException e) { Debug.logError(e, "Problem calling the getProductionRunTotResQty service", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionResQtyCalc", locale)); } - result.put("reservedQuantity", new Double(totQty)); + result.put("reservedQuantity", totQty); return result; } @@ -2727,8 +2727,8 @@ public static Map checkDecomposeInventoryItem(DispatchContext ctx, Map context) GenericValue userLogin = (GenericValue) context.get("userLogin"); String inventoryItemId = (String)context.get("inventoryItemId"); /* - Double quantity = (Double)context.get("quantityAccepted"); - if (quantity != null && quantity.doubleValue() == 0) { + BigDecimal quantity = (BigDecimal)context.get("quantityAccepted"); + if (quantity != null && quantity.BigDecimalValue() == 0) { return ServiceUtil.returnSuccess(); } */ @@ -2737,7 +2737,7 @@ public static Map checkDecomposeInventoryItem(DispatchContext ctx, Map context) if (inventoryItem == null) { return ServiceUtil.returnError("Error: inventory item with id [" + inventoryItemId + "] not found."); } - if (inventoryItem.get("availableToPromiseTotal") != null && inventoryItem.getDouble("availableToPromiseTotal").doubleValue() <= 0) { + if (inventoryItem.get("availableToPromiseTotal") != null && inventoryItem.getBigDecimal("availableToPromiseTotal").compareTo(ZERO) <= 0) { return ServiceUtil.returnSuccess(); } GenericValue product = inventoryItem.getRelatedOne("Product"); @@ -2769,7 +2769,7 @@ public static Map decomposeInventoryItem(DispatchContext ctx, Map context) { GenericValue userLogin = (GenericValue) context.get("userLogin"); // Mandatory input fields String inventoryItemId = (String)context.get("inventoryItemId"); - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); List inventoryItemIds = new ArrayList(); try { GenericValue inventoryItem = delegator.findByPrimaryKey("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId)); @@ -2795,8 +2795,8 @@ public static Map decomposeInventoryItem(DispatchContext ctx, Map context) { serviceContext.put("quantity", quantity); } resultService = dispatcher.runSync("issueInventoryItemToWorkEffort", serviceContext); - Double issuedQuantity = (Double)resultService.get("quantityIssued"); - if (issuedQuantity.doubleValue() == 0) { + BigDecimal issuedQuantity = (BigDecimal)resultService.get("quantityIssued"); + if (issuedQuantity.compareTo(ZERO) == 0) { return ServiceUtil.returnError("Error decomposing inventory item: no marketing packages found in inventory item [" + inventoryItem.getString("inventoryItemId") + "]."); } // get the package's unit cost to compute a cost coefficient ratio which is the marketing package's actual unit cost divided by its standard cost @@ -2807,18 +2807,18 @@ public static Map decomposeInventoryItem(DispatchContext ctx, Map context) { "costComponentTypePrefix", "EST_STD", "userLogin", userLogin); resultService = dispatcher.runSync("getProductCost", serviceContext); - Double packageCost = (Double)resultService.get("productCost"); - Double inventoryItemCost = inventoryItem.getDouble("unitCost"); - Double costCoefficient = null; - if (packageCost == null || packageCost.doubleValue() == 0 || inventoryItemCost == null) { + BigDecimal packageCost = (BigDecimal)resultService.get("productCost"); + BigDecimal inventoryItemCost = inventoryItem.getBigDecimal("unitCost"); + BigDecimal costCoefficient = null; + if (packageCost == null || packageCost.compareTo(ZERO) == 0 || inventoryItemCost == null) { // if the actual cost of the item (marketing package) that we are decomposing is not available, or // if the standard cost of the marketing package is not available then // the cost coefficient ratio is set to 1.0: // this means that the unit costs of the inventory items of the components // will be equal to the components' standard costs - costCoefficient = new Double(1.0); + costCoefficient = BigDecimal.ONE; } else { - costCoefficient = new Double(inventoryItemCost.doubleValue() / packageCost.doubleValue()); + costCoefficient = inventoryItemCost.divide(packageCost, 10, rounding); } // the components are retrieved @@ -2841,10 +2841,10 @@ public static Map decomposeInventoryItem(DispatchContext ctx, Map context) { "costComponentTypePrefix", "EST_STD", "userLogin", userLogin); resultService = dispatcher.runSync("getProductCost", serviceContext); - Double componentCost = (Double)resultService.get("productCost"); + BigDecimal componentCost = (BigDecimal)resultService.get("productCost"); // return the component to inventory at its standard cost multiplied by the cost coefficient from above - Double componentInventoryItemCost = new Double(costCoefficient.doubleValue() * componentCost.doubleValue()); + BigDecimal componentInventoryItemCost = costCoefficient.multiply(componentCost); serviceContext.clear(); serviceContext = UtilMisc.toMap("productId", ((GenericValue)component.get("product")).getString("productId"), "quantity", component.get("quantity"), @@ -2886,18 +2886,18 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { "PRUN_CREATED".equals(genericResult.getString("currentStatusId"))) { continue; } - Double qtyToProduce = genericResult.getDouble("quantityToProduce"); + BigDecimal qtyToProduce = genericResult.getBigDecimal("quantityToProduce"); if (qtyToProduce == null) { - qtyToProduce = new Double(0); + qtyToProduce = BigDecimal.ZERO; } - Double qtyProduced = genericResult.getDouble("quantityProduced"); + BigDecimal qtyProduced = genericResult.getBigDecimal("quantityProduced"); if (qtyProduced == null) { - qtyProduced = new Double(0); + qtyProduced = BigDecimal.ZERO; } if (qtyProduced.compareTo(qtyToProduce) >= 0) { continue; } - double qtyDiff = qtyToProduce.doubleValue() - qtyProduced.doubleValue(); + BigDecimal qtyDiff = qtyToProduce.subtract(qtyProduced); String productId = genericResult.getString("productId"); Timestamp estimatedShipDate = genericResult.getTimestamp("estimatedCompletionDate"); if (estimatedShipDate == null) { @@ -2908,12 +2908,12 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { } TreeMap productMap = (TreeMap)products.get(productId); if (!productMap.containsKey(estimatedShipDate)) { - productMap.put(estimatedShipDate, UtilMisc.toMap("remainingQty", new Double(0.0), "reservations", FastList.newInstance())); + productMap.put(estimatedShipDate, UtilMisc.toMap("remainingQty", BigDecimal.ZERO, "reservations", FastList.newInstance())); } Map dateMap = (Map)productMap.get(estimatedShipDate); - Double remainingQty = (Double)dateMap.get("remainingQty"); + BigDecimal remainingQty = (BigDecimal)dateMap.get("remainingQty"); //List reservations = (List)dateMap.get("reservations"); - remainingQty = new Double(remainingQty.doubleValue() + qtyDiff); + remainingQty = remainingQty.add(qtyDiff); dateMap.put("remainingQty", remainingQty); } @@ -2935,7 +2935,7 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { } } String productId = genericResult.getString("productId"); - double orderQuantity = genericResult.getDouble("quantity").doubleValue(); + BigDecimal orderQuantity = genericResult.getBigDecimal("quantity"); GenericValue orderItemDeliverySchedule = null; try { orderItemDeliverySchedule = delegator.findByPrimaryKey("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId"))); @@ -2957,19 +2957,19 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { } TreeMap productMap = (TreeMap)products.get(productId); if (!productMap.containsKey(estimatedShipDate)) { - productMap.put(estimatedShipDate, UtilMisc.toMap("remainingQty", new Double(0.0), "reservations", FastList.newInstance())); + productMap.put(estimatedShipDate, UtilMisc.toMap("remainingQty", BigDecimal.ZERO, "reservations", FastList.newInstance())); } Map dateMap = (Map)productMap.get(estimatedShipDate); - Double remainingQty = (Double)dateMap.get("remainingQty"); + BigDecimal remainingQty = (BigDecimal)dateMap.get("remainingQty"); //List reservations = (List)dateMap.get("reservations"); - remainingQty = new Double(remainingQty.doubleValue() + orderQuantity); + remainingQty = remainingQty.add(orderQuantity); dateMap.put("remainingQty", remainingQty); } // backorders List backordersCondList = FastList.newInstance(); backordersCondList.add(EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.NOT_EQUAL, null)); - backordersCondList.add(EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0.0))); + backordersCondList.add(EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.GREATER_THAN, BigDecimal.ZERO)); //backordersCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.LESS_THAN, "ITEM_APPROVED"))); List backorders = delegator.findList("OrderItemAndShipGrpInvResAndItem", EntityCondition.makeCondition(backordersCondList, EntityOperator.AND), null, UtilMisc.toList("shipBeforeDate"), null, false); @@ -2981,8 +2981,8 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { "shipGroupSeqId", genericResult.get("shipGroupSeqId"))); Timestamp requiredByDate = orderItemShipGroup.getTimestamp("shipByDate"); - Double quantityNotAvailable = genericResult.getDouble("quantityNotAvailable"); - double quantityNotAvailableRem = quantityNotAvailable.doubleValue(); + BigDecimal quantityNotAvailable = genericResult.getBigDecimal("quantityNotAvailable"); + BigDecimal quantityNotAvailableRem = quantityNotAvailable; if (requiredByDate == null) { // If shipByDate is not set, 'now' is assumed. requiredByDate = now; @@ -2998,12 +2998,12 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { Timestamp currentDate = (Timestamp)subsetMapKeysIt.next(); Map currentDateMap = (Map) subsetMap.get(currentDate); //List reservations = (List)currentDateMap.get("reservations"); - Double remainingQty = (Double)currentDateMap.get("remainingQty"); - if (remainingQty.doubleValue() == 0) { + BigDecimal remainingQty = (BigDecimal)currentDateMap.get("remainingQty"); + if (remainingQty.compareTo(ZERO) == 0) { continue; } - if (remainingQty.doubleValue() >= quantityNotAvailableRem) { - remainingQty = new Double(remainingQty.doubleValue() - quantityNotAvailableRem); + if (remainingQty.compareTo(quantityNotAvailableRem) >= 0) { + remainingQty = remainingQty.subtract(quantityNotAvailableRem); currentDateMap.put("remainingQty", remainingQty); GenericValue orderItemShipGrpInvRes = delegator.findByPrimaryKey("OrderItemShipGrpInvRes", UtilMisc.toMap("orderId", genericResult.getString("orderId"), "shipGroupSeqId", genericResult.getString("shipGroupSeqId"), @@ -3011,11 +3011,11 @@ public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { "inventoryItemId", genericResult.getString("inventoryItemId"))); orderItemShipGrpInvRes.set("promisedDatetime", currentDate); orderItemShipGrpInvRes.store(); - // Todo: set the reservation + // TODO: set the reservation break; } else { - quantityNotAvailableRem = quantityNotAvailableRem - remainingQty.doubleValue(); - remainingQty = new Double(0.0); + quantityNotAvailableRem = quantityNotAvailableRem.subtract(remainingQty); + remainingQty = BigDecimal.ZERO; currentDateMap.put("remainingQty", remainingQty); } } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java index 31ae1222f37..64a0d68735a 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.manufacturing.mrp; +import java.math.BigDecimal; import java.util.Map; import org.ofbiz.base.util.Debug; @@ -49,7 +50,7 @@ public static Map createMrpEvent(DispatchContext ctx, Map context) { "productId", context.get("productId"), "eventDate", context.get("eventDate"), "mrpEventTypeId", context.get("mrpEventTypeId")); - Double quantity = (Double)context.get("quantity"); + BigDecimal quantity = (BigDecimal)context.get("quantity"); GenericValue mrpEvent = null; try { createOrUpdateMrpEvent(parameters, quantity, (String)context.get("facilityId"), (String)context.get("eventName"), false, delegator); @@ -60,7 +61,7 @@ public static Map createMrpEvent(DispatchContext ctx, Map context) { return ServiceUtil.returnSuccess(); } - public static void createOrUpdateMrpEvent(Map mrpEventKeyMap, Double newQuantity, String facilityId, String eventName, boolean isLate, GenericDelegator delegator) throws GenericEntityException { + public static void createOrUpdateMrpEvent(Map mrpEventKeyMap, BigDecimal newQuantity, String facilityId, String eventName, boolean isLate, GenericDelegator delegator) throws GenericEntityException { GenericValue mrpEvent = null; mrpEvent = delegator.findByPrimaryKey("MrpEvent", mrpEventKeyMap); if (mrpEvent == null) { @@ -71,8 +72,8 @@ public static void createOrUpdateMrpEvent(Map mrpEventKeyMap, Double newQuantity mrpEvent.put("isLate", (isLate? "Y": "N")); mrpEvent.create(); } else { - double qties = newQuantity.doubleValue() + ((Double)mrpEvent.get("quantity")).doubleValue(); - mrpEvent.put("quantity", new Double(qties)); + BigDecimal qties = newQuantity.add((BigDecimal)mrpEvent.get("quantity")); + mrpEvent.put("quantity", qties); if (!UtilValidate.isEmpty(eventName)) { String existingEventName = mrpEvent.getString("eventName"); mrpEvent.put("eventName", (UtilValidate.isEmpty(existingEventName)? eventName: existingEventName + ", " + eventName)); diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java index 61b04932cfd..15d7648bfd7 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java @@ -159,21 +159,21 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { while (iteratorResult.hasNext()) { genericResult = (GenericValue) iteratorResult.next(); String productId = genericResult.getString("productId"); - Double reservedQuantity = genericResult.getDouble("reservedQuantity"); - Double shipGroupQuantity = genericResult.getDouble("quantity"); - Double cancelledQuantity = genericResult.getDouble("cancelQuantity"); - Double eventQuantityTmp = new Double(0.0); + BigDecimal reservedQuantity = genericResult.getBigDecimal("reservedQuantity"); + BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity"); + BigDecimal cancelledQuantity = genericResult.getBigDecimal("cancelQuantity"); + BigDecimal eventQuantityTmp = BigDecimal.ZERO; if (UtilValidate.isNotEmpty(reservedQuantity)) { - eventQuantityTmp = new Double(-1.0 * reservedQuantity.doubleValue()); + eventQuantityTmp = reservedQuantity.negate(); } else { if (UtilValidate.isNotEmpty(cancelledQuantity)) { - shipGroupQuantity = new Double(shipGroupQuantity.doubleValue() - cancelledQuantity.doubleValue()); + shipGroupQuantity = shipGroupQuantity.subtract(cancelledQuantity); } - eventQuantityTmp = new Double(-1.0 * shipGroupQuantity.doubleValue()); + eventQuantityTmp = shipGroupQuantity.negate(); } - if (eventQuantityTmp.doubleValue() == 0) { + if (eventQuantityTmp.compareTo(BigDecimal.ZERO) == 0) { continue; } // This is the order in which order dates are considered: @@ -220,7 +220,7 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { while(iteratorResult.hasNext()){ genericResult = (GenericValue) iteratorResult.next(); String productId = genericResult.getString("productId"); - Double eventQuantityTmp = genericResult.getDouble("quantity"); + BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity"); if (productId == null || eventQuantityTmp == null) { continue; } @@ -270,13 +270,13 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { } String productId = genericResult.getString("productId"); - Double shipGroupQuantity = genericResult.getDouble("quantity"); - Double cancelledQuantity = genericResult.getDouble("cancelQuantity"); + BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity"); + BigDecimal cancelledQuantity = genericResult.getBigDecimal("cancelQuantity"); if (UtilValidate.isEmpty(shipGroupQuantity)) { - shipGroupQuantity = new Double(0); + shipGroupQuantity = BigDecimal.ZERO; } if (UtilValidate.isNotEmpty(cancelledQuantity)) { - shipGroupQuantity = new Double(shipGroupQuantity.doubleValue() - cancelledQuantity.doubleValue()); + shipGroupQuantity = shipGroupQuantity.subtract(cancelledQuantity); } OrderReadHelper orh = new OrderReadHelper(delegator, orderId); @@ -286,7 +286,7 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { } catch (GenericEntityException e) { } if (UtilValidate.isNotEmpty(shippedQuantity)) { - shipGroupQuantity = new Double(shipGroupQuantity.doubleValue() - shippedQuantity.doubleValue()); + shipGroupQuantity = shipGroupQuantity.subtract(shippedQuantity); } GenericValue orderItemDeliverySchedule = null; @@ -331,7 +331,7 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { while(iteratorResult.hasNext()){ genericResult = (GenericValue) iteratorResult.next(); String productId = genericResult.getString("productId"); - Double eventQuantityTmp = new Double(-1.0 * genericResult.getDouble("estimatedQuantity").doubleValue()); + BigDecimal eventQuantityTmp = genericResult.getBigDecimal("estimatedQuantity").negate(); Timestamp estimatedShipDate = genericResult.getTimestamp("estimatedStartDate"); if (estimatedShipDate == null) { estimatedShipDate = now; @@ -365,20 +365,20 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId"))) { continue; } - Double qtyToProduce = genericResult.getDouble("quantityToProduce"); + BigDecimal qtyToProduce = genericResult.getBigDecimal("quantityToProduce"); if (qtyToProduce == null) { - qtyToProduce = new Double(0); + qtyToProduce = BigDecimal.ZERO; } - Double qtyProduced = genericResult.getDouble("quantityProduced"); + BigDecimal qtyProduced = genericResult.getBigDecimal("quantityProduced"); if (qtyProduced == null) { - qtyProduced = new Double(0); + qtyProduced = BigDecimal.ZERO; } if (qtyProduced.compareTo(qtyToProduce) >= 0) { continue; } - double qtyDiff = qtyToProduce.doubleValue() - qtyProduced.doubleValue(); + BigDecimal qtyDiff = qtyToProduce.subtract(qtyProduced); String productId = genericResult.getString("productId"); - Double eventQuantityTmp = new Double(qtyDiff); + BigDecimal eventQuantityTmp = qtyDiff; Timestamp estimatedShipDate = genericResult.getTimestamp("estimatedCompletionDate"); if (estimatedShipDate == null) { estimatedShipDate = now; @@ -408,9 +408,9 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { while(iteratorResult.hasNext()){ genericResult = (GenericValue) iteratorResult.next(); String productId = genericResult.getString("productId"); - Double minimumStock = genericResult.getDouble("minimumStock"); + BigDecimal minimumStock = genericResult.getBigDecimal("minimumStock"); if (minimumStock == null) { - minimumStock = new Double(0); + minimumStock = BigDecimal.ZERO; } try { EntityFieldMap ecl = EntityCondition.makeCondition(UtilMisc.toMap("mrpId", mrpId, "productId", productId), EntityOperator.AND); @@ -422,13 +422,13 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { Debug.logError(e, "Unable to count MrpEvent records.", module); return ServiceUtil.returnError("Unable to count MrpEvent records."); } - double qoh = findProductMrpQoh(mrpId, productId, facilityId, dispatcher, delegator); - if (qoh >= minimumStock.longValue()) { + BigDecimal qoh = findProductMrpQoh(mrpId, productId, facilityId, dispatcher, delegator); + if (qoh.compareTo(minimumStock) >= 0) { continue; } parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", now, "mrpEventTypeId", "REQUIRED_MRP"); try { - InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, new Double(0.0), null, null, false, delegator); + InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, BigDecimal.ZERO, null, null, false, delegator); } catch (GenericEntityException e) { return ServiceUtil.returnError("Problem initializing the MrpEvent entity (REQUIRED_MRP)"); } @@ -475,11 +475,11 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { while (sfdIter.hasNext()) { genericResult = (GenericValue) sfdIter.next(); String productId = genericResult.getString("productId"); - Double eventQuantityTmp = genericResult.getDouble("quantity"); + BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity"); if (productId == null || eventQuantityTmp == null) { continue; } - eventQuantityTmp = new Double(-1.0 * eventQuantityTmp.doubleValue()); + eventQuantityTmp = eventQuantityTmp.negate(); parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"), "mrpEventTypeId", "SALES_FORECAST"); try { InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("salesForecastDetailId"), false, delegator); @@ -503,10 +503,10 @@ public static Map initMrpEvents(DispatchContext ctx, Map context) { * @param product the product for which the Quantity Available is required * @return the sum of all the totalAvailableToPromise of the inventoryItem related to the product, if the related facility is Mrp available (not yet implemented!!) */ - public static double findProductMrpQoh(String mrpId, GenericValue product, String facilityId, LocalDispatcher dispatcher, GenericDelegator delegator) { + public static BigDecimal findProductMrpQoh(String mrpId, GenericValue product, String facilityId, LocalDispatcher dispatcher, GenericDelegator delegator) { return findProductMrpQoh(mrpId, product.getString("productId"), facilityId, dispatcher, delegator); } - public static double findProductMrpQoh(String mrpId, String productId, String facilityId, LocalDispatcher dispatcher, GenericDelegator delegator) { + public static BigDecimal findProductMrpQoh(String mrpId, String productId, String facilityId, LocalDispatcher dispatcher, GenericDelegator delegator) { Map resultMap = null; try{ if (facilityId == null) { @@ -517,9 +517,9 @@ public static double findProductMrpQoh(String mrpId, String productId, String fa } catch (GenericServiceException e) { Debug.logError(e, "Error calling getProductInventoryAvailableByFacility service", module); logMrpError(mrpId, productId, "Unable to count inventory", delegator); - return 0; + return BigDecimal.ZERO; } - return ((Double)resultMap.get("quantityOnHandTotal")).doubleValue(); + return ((BigDecimal)resultMap.get("quantityOnHandTotal")); } public static void logMrpError(String mrpId, String productId, String errorMessage, GenericDelegator delegator) { @@ -551,7 +551,7 @@ public static void logMrpError(String mrpId, String productId, Timestamp eventDa * @return None */ - public static void processBomComponent(String mrpId, GenericValue product, double eventQuantity, Timestamp startDate, Map routingTaskStartDate, List listComponent) { + public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate, Map routingTaskStartDate, List listComponent) { // TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception GenericDelegator delegator = product.getDelegator(); @@ -570,9 +570,9 @@ public static void processBomComponent(String mrpId, GenericValue product, doubl parameters.put("mrpId", mrpId); parameters.put("eventDate", eventDate); parameters.put("mrpEventTypeId", "MRP_REQUIREMENT"); - double componentEventQuantity = node.getQuantity(); + BigDecimal componentEventQuantity = node.getQuantity(); try { - InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, new Double(-1.0 * componentEventQuantity), null, product.get("productId") + ": " + eventDate, false, delegator); + InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), null, product.get("productId") + ": " + eventDate, false, delegator); } catch (GenericEntityException e) { Debug.logError("Error : findByPrimaryKey(\"MrpEvent\", parameters) ="+parameters+"--"+e.getMessage(), module); logMrpError(mrpId, node.getProduct().getString("productId"), "Unable to create event (processBomComponent)", delegator); @@ -645,17 +645,17 @@ public static Map executeMrp(DispatchContext ctx, Map context) { } int bomLevelWithNoEvent = 0; - double stockTmp = 0; + BigDecimal stockTmp = BigDecimal.ZERO; String oldProductId = null; String productId = null; GenericValue product = null; GenericValue productFacility = null; - double eventQuantity = 0; + BigDecimal eventQuantity = BigDecimal.ZERO; Timestamp eventDate = null; boolean isNegative = false; - double quantityNeeded = 0; - double reorderQuantity = 0; - double minimumStock = 0; + BigDecimal quantityNeeded = BigDecimal.ZERO; + BigDecimal reorderQuantity = BigDecimal.ZERO; + BigDecimal minimumStock = BigDecimal.ZERO; int daysToShip = 0; List components = null; boolean isBuilt = false; @@ -703,10 +703,10 @@ public static Map executeMrp(DispatchContext ctx, Map context) { while (iteratorListInventoryEventForMRP.hasNext()) { inventoryEventForMRP = (GenericValue) iteratorListInventoryEventForMRP.next(); productId = inventoryEventForMRP.getString("productId"); - eventQuantity = inventoryEventForMRP.getDouble("quantity").doubleValue(); + eventQuantity = inventoryEventForMRP.getBigDecimal("quantity"); if (!productId.equals(oldProductId)) { - double positiveEventQuantity = (eventQuantity > 0? eventQuantity: -1 * eventQuantity); + BigDecimal positiveEventQuantity = eventQuantity.compareTo(BigDecimal.ZERO) > 0 ? eventQuantity: eventQuantity.negate(); // It's a new product, so it's necessary to read the MrpQoh try { product = inventoryEventForMRP.getRelatedOneCache("Product"); @@ -717,7 +717,7 @@ public static Map executeMrp(DispatchContext ctx, Map context) { stockTmp = findProductMrpQoh(mrpId, product, facilityId, dispatcher, delegator); try { InventoryEventPlannedServices.createOrUpdateMrpEvent(UtilMisc.toMap("mrpId", mrpId, "productId", product.getString("productId"), "mrpEventTypeId", "INITIAL_QOH", "eventDate", now), - new Double(stockTmp), facilityId, null, false, + stockTmp, facilityId, null, false, delegator); } catch (GenericEntityException e) { return ServiceUtil.returnError("Problem running createOrUpdateMrpEvent"); @@ -726,20 +726,20 @@ public static Map executeMrp(DispatchContext ctx, Map context) { // as well and cause problems daysToShip = 0; if (productFacility != null) { - reorderQuantity = (productFacility.getDouble("reorderQuantity") != null? productFacility.getDouble("reorderQuantity").doubleValue(): -1); - minimumStock = (productFacility.getDouble("minimumStock") != null? productFacility.getDouble("minimumStock").doubleValue(): 0); + reorderQuantity = (productFacility.getBigDecimal("reorderQuantity") != null ? productFacility.getBigDecimal("reorderQuantity"): BigDecimal.ONE.negate()); + minimumStock = (productFacility.getBigDecimal("minimumStock") != null ? productFacility.getBigDecimal("minimumStock"): BigDecimal.ZERO); if ("SALES_ORDER_SHIP".equals(inventoryEventForMRP.getString("mrpEventTypeId"))) { daysToShip = (productFacility.getLong("daysToShip") != null? productFacility.getLong("daysToShip").intValue(): 0); } } else { - minimumStock = 0; - reorderQuantity = -1; + minimumStock = BigDecimal.ZERO; + reorderQuantity = BigDecimal.ONE.negate(); } // ----------------------------------------------------- // The components are also loaded thru the configurator Map serviceResponse = null; try { - serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.toMap("productId", product.getString("productId"), "quantity", new Double(positiveEventQuantity), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); + serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.toMap("productId", product.getString("productId"), "quantity", positiveEventQuantity, "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); } catch (Exception e) { return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]"); } @@ -755,9 +755,9 @@ public static Map executeMrp(DispatchContext ctx, Map context) { oldProductId = productId; } - stockTmp = stockTmp + eventQuantity; - if(stockTmp < minimumStock){ - double qtyToStock = minimumStock - stockTmp; + stockTmp = stockTmp.add(eventQuantity); + if(stockTmp.compareTo(minimumStock) < 0){ + BigDecimal qtyToStock = minimumStock.subtract(stockTmp); //need to buy or build the product as we have not enough stock eventDate = inventoryEventForMRP.getTimestamp("eventDate"); // to be just before the requirement @@ -771,7 +771,7 @@ public static Map executeMrp(DispatchContext ctx, Map context) { // The components are also loaded thru the configurator Map serviceResponse = null; try { - serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.toMap("productId", product.getString("productId"), "quantity", new Double(proposedOrder.getQuantity()), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); + serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.toMap("productId", product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); } catch (Exception e) { return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]"); } @@ -817,12 +817,12 @@ public static Map executeMrp(DispatchContext ctx, Map context) { "eventDate", eventDate, "mrpEventTypeId", (isBuilt? "PROP_MANUF_O_RECP" : "PROP_PUR_O_RECP")); try { - InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, new Double(proposedOrder.getQuantity()), null, eventName, (proposedOrder.getRequirementStartDate().compareTo(now) < 0), delegator); + InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, proposedOrder.getQuantity(), null, eventName, (proposedOrder.getRequirementStartDate().compareTo(now) < 0), delegator); } catch (GenericEntityException e) { return ServiceUtil.returnError("Problem running createOrUpdateMrpEvent"); } // - stockTmp = stockTmp + proposedOrder.getQuantity(); + stockTmp = stockTmp.add(proposedOrder.getQuantity()); } } } else { diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java index 0c95193f517..91a7e867f84 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java @@ -19,6 +19,7 @@ package org.ofbiz.manufacturing.mrp; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.HashMap; import java.util.List; @@ -58,10 +59,10 @@ public class ProposedOrder { protected String mrpName; protected Timestamp requiredByDate; protected Timestamp requirementStartDate; - protected double quantity; + protected BigDecimal quantity; - public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, double quantity) { + public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, BigDecimal quantity) { this.product = product; this.productId = product.getString("productId"); this.facilityId = facilityId; @@ -75,7 +76,7 @@ public ProposedOrder(GenericValue product, String facilityId, String manufacturi * get the quantity property. * @return the quantity property **/ - public double getQuantity(){ + public BigDecimal getQuantity(){ return quantity; } /** @@ -202,10 +203,10 @@ public Map calculateStartDate(int daysToShip, GenericValue routing, GenericDeleg * Read the first ProductFacility.reorderQuantity and calculate the quantity : if (quantity < reorderQuantity) quantity = reorderQuantity; **/ // FIXME: facilityId - public void calculateQuantityToSupply(double reorderQuantity, double minimumStock, ListIterator listIterIEP){ + public void calculateQuantityToSupply(BigDecimal reorderQuantity, BigDecimal minimumStock, ListIterator listIterIEP){ // TODO : use a better algorithm using Order management cost et Product Stock cost to calculate the re-order quantity // the variable listIterIEP will be used for that - if (quantity < reorderQuantity) { + if (quantity.compareTo(reorderQuantity) < 0) { quantity = reorderQuantity; } /* @@ -243,7 +244,7 @@ public String create(DispatchContext ctx, GenericValue userLogin) { parameters.put("facilityId", (isBuilt? manufacturingFacilityId: facilityId)); parameters.put("requiredByDate", requiredByDate); parameters.put("requirementStartDate", requirementStartDate); - parameters.put("quantity", new Double(quantity)); + parameters.put("quantity", quantity); parameters.put("requirementTypeId", (isBuilt? "INTERNAL_REQUIREMENT" : "PRODUCT_REQUIREMENT")); if (mrpName != null) { parameters.put("description", "MRP_" + mrpName); diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java index a6c577614ca..aba75ca5ac0 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.manufacturing.routing; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -53,13 +54,13 @@ public static Map getEstimatedTaskTime(DispatchContext ctx, Map context) { // The mandatory IN parameters String taskId = (String) context.get("taskId"); - Double quantity = (Double) context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); // The optional IN parameters String productId = (String) context.get("productId"); String routingId = (String) context.get("routingId"); if (quantity == null) { - quantity = new Double(1); + quantity = BigDecimal.ONE; } GenericValue task = null; diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/BomSimulation.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/BomSimulation.groovy index 86aeb95b979..ea99ad41f26 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/BomSimulation.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/BomSimulation.groovy @@ -34,12 +34,12 @@ if (tree) { context.tree = treeArray; Iterator treeQtyIt = treeQty.values().iterator(); productsData = []; - Double grandTotalCost = null; + grandTotalCost = null; while (treeQtyIt) { BOMNode node = (BOMNode)treeQtyIt.next(); - Double unitCost = null; - Double totalCost = null; - Double qoh = null; + unitCost = null; + totalCost = null; + qoh = null; // The standard cost is retrieved try { outMap = [:]; @@ -48,7 +48,7 @@ if (tree) { currencyUomId : currencyUomId, costComponentTypePrefix : "EST_STD", userLogin : userLogin]); - unitCost = (Double)outMap.productCost; + unitCost = outMap.productCost; totalCost = unitCost * node.getQuantity(); grandTotalCost = grandTotalCost + totalCost ?: 0; } @@ -56,7 +56,7 @@ if (tree) { outMap = dispatcher.runSync("getInventoryAvailableByFacility", [productId : node.getProduct().productId, facilityId : facilityId, userLogin : userLogin]); - qoh = (Double)outMap.quantityOnHandTotal; + qoh = outMap.quantityOnHandTotal; } } catch(Exception e) {} productsData.add([node : node, unitCost : unitCost, totalCost : totalCost, qoh : qoh]); diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.groovy index 4a2d3ef18f8..831226e6671 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.groovy @@ -52,7 +52,7 @@ if (productionRunId) { context.dependentWorkEfforts = dependentWorkEfforts; } - Double quantityToProduce = productionRun.getGenericValue().getDouble("quantityToProduce") ?: new Double(0); + quantityToProduce = productionRun.getGenericValue().get("quantityToProduce") ?: 0.0; // Find the inventory items produced inventoryItems = delegator.findByAnd("WorkEffortInventoryProduced", [workEffortId : productionRunId]); @@ -64,28 +64,28 @@ if (productionRunId) { } // Find if the production run can produce inventory. - Double quantityProduced = productionRun.getGenericValue().getDouble("quantityProduced")?: new Double(0); - Double quantityRejected = productionRun.getGenericValue().getDouble("quantityRejected")?: new Double(0); + quantityProduced = productionRun.getGenericValue().quantityProduced ?: 0.0; + quantityRejected = productionRun.getGenericValue().quantityRejected ?: 0.0; lastTask = productionRun.getLastProductionRunRoutingTask(); - Double quantityDeclared = (lastTask ? (lastTask.getDouble("quantityProduced")?: new Double(0)): new Double(0)); + quantityDeclared = (lastTask ? (lastTask.quantityProduced ?: 0.0) : 0.0 ; if (lastTask && ("PRUN_RUNNING".equals(lastTask.currentStatusId) || "PRUN_COMPLETED".equals(lastTask.currentStatusId))) { context.canDeclareAndProduce = "Y"; } - double maxQuantity = quantityDeclared.doubleValue() - quantityProduced.doubleValue(); + maxQuantity = quantityDeclared - quantityProduced; productionRunData = [:]; productionRunData.workEffortId = productionRunId; productionRunData.productId = productionRun.getProductProduced().productId; if (maxQuantity > 0 && !"WIP".equals(productionRun.getProductProduced().productTypeId)) { - productionRunData.quantity = new Double(maxQuantity); + productionRunData.quantity = maxQuantity; context.canProduce = "Y"; } productionRunData.quantityToProduce = quantityToProduce; productionRunData.quantityProduced = quantityProduced; productionRunData.quantityRejected = quantityRejected; - productionRunData.quantityRemaining = new Double(quantityToProduce.doubleValue() - quantityProduced.doubleValue()); + productionRunData.quantityRemaining = quantityToProduce - quantityProduced; productionRunData.estimatedCompletionDate = productionRun.getEstimatedCompletionDate(); productionRunData.productionRunName = productionRun.getProductionRunName(); productionRunData.description = productionRun.getDescription(); @@ -188,21 +188,21 @@ if (productionRunId) { componentData.workEffortName = workEffortName; componentData.facilityId = productionRunTask.facilityId; issuances = delegator.findByAnd("WorkEffortAndInventoryAssign", [workEffortId : component.workEffortId, productId : product.productId]); - double totalIssued = 0.0; + totalIssued = 0.0; issuances.each { issuance -> - Double issued = issuance.getDouble("quantity"); + issued = issuance.quantity; if (issued) { - totalIssued += issued.doubleValue(); + totalIssued += issued; } } returns = delegator.findByAnd("WorkEffortAndInventoryProduced", [workEffortId : component.workEffortId , productId : product.productId]); - double totalReturned = 0.0; + totalReturned = 0.0; returns.each { returned -> returnDetail = EntityUtil.getFirst(delegator.findByAnd("InventoryItemDetail", [inventoryItemId : returned.inventoryItemId], ["inventoryItemDetailSeqId"])); if (returnDetail) { - Double qtyReturned = returnDetail.getDouble("quantityOnHandDiff"); + qtyReturned = returnDetail.quantityOnHandDiff; if (qtyReturned) { - totalReturned += qtyReturned.doubleValue(); + totalReturned += qtyReturned; } } } diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy index 69203c9fc89..d093661bb03 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy @@ -43,10 +43,10 @@ if (shipmentPlans) { // oneRow.putAll(shipmentPlan.getRelatedOne("OrderItemInventoryRes")); orderItem = shipmentPlan.getRelatedOne("OrderItem"); oneRow.productId = orderItem.productId; - orderedQuantity = orderItem.getDouble("quantity"); - canceledQuantity = orderItem.getDouble("cancelQuantity"); + orderedQuantity = orderItem.quantity; + canceledQuantity = orderItem.cancelQuantity; if (canceledQuantity) { - orderedQuantity = Double.valueOf(orderedQuantity.doubleValue() - canceledQuantity.doubleValue()); + orderedQuantity = orderedQuantity - canceledQuantity; } oneRow.totOrderedQuantity = orderedQuantity.intValue(); // Total quantity issued @@ -55,18 +55,18 @@ if (shipmentPlans) { issuances = orderItem.getRelated("ItemIssuance"); issuances.each { issuance -> if (issuance.quantity) { - issuedQuantity += issuance.getDouble("quantity"); + issuedQuantity += issuance.quantity; if (issuance.cancelQuantity) { - issuedQuantity -= issuance.getDouble("cancelQuantity"); - } + issuedQuantity -= issuance.cancelQuantity; + } if (qtyIssuedInShipment.containsKey(issuance.shipmentId)) { - qtyInShipment = ((Double)qtyIssuedInShipment.get(issuance.shipmentId)).doubleValue(); - qtyInShipment += issuance.getDouble("quantity"); + qtyInShipment = qtyIssuedInShipment[issuance.shipmentId]; + qtyInShipment += issuance.quantity; qtyIssuedInShipment.issuance.shipmentId = qtyInShipment; } else { - qtyInShipment = issuance.getDouble("quantity"); + qtyInShipment = issuance.quantity; if (issuance.cancelQuantity) { - qtyInShipment -= issuance.getDouble("cancelQuantity"); + qtyInShipment -= issuance.cancelQuantity; } qtyIssuedInShipment.issuance.shipmentId = qtyInShipment; } @@ -79,18 +79,18 @@ if (shipmentPlans) { plans = delegator.findByAnd("OrderShipment", [orderId : orderItem.orderId ,orderItemSeqId : orderItem.orderItemSeqId]); plans.each { plan -> if (plan.quantity) { - netPlanQty = plan.getDouble("quantity"); + netPlanQty = plan.quantity; if (qtyIssuedInShipment.containsKey(plan.shipmentId)) { - qtyInShipment = ((Double)qtyIssuedInShipment.get(plan.shipmentId)).doubleValue(); + qtyInShipment = qtyIssuedInShipment[plan.shipmentId]; if (netPlanQty > qtyInShipment) { netPlanQty -= qtyInShipment; } else { - netPlanQty = 0; + netPlanQty = 0.0; } } plannedQuantity += netPlanQty; if (qtyPlannedInShipment.containsKey(plan.shipmentId)) { - qtyInShipment = ((Double)qtyPlannedInShipment.get(plan.shipmentId)).doubleValue(); + qtyInShipment = qtyPlannedInShipment[plan.shipmentId]; qtyInShipment += netPlanQty; qtyPlannedInShipment.plan.shipmentId = qtyInShipment; } else { @@ -110,10 +110,10 @@ if (shipmentPlans) { reservations = orderItem.getRelated("OrderItemShipGrpInvRes"); reservations.each { reservation -> if (reservation.quantity) { - reservedQuantity += reservation.getDouble("quantity"); + reservedQuantity += reservation.quantity; } if (reservation.quantityNotAvailable) { - reservedNotAvailable += reservation.getDouble("quantityNotAvailable"); + reservedNotAvailable += reservation.quantityNotAvailable; } } oneRow.notAvailableQuantity = reservedNotAvailable; @@ -121,11 +121,11 @@ if (shipmentPlans) { product = orderItem.getRelatedOne("Product"); weight = 0.0; quantity = 0.0; - if (shipmentPlan.getDouble("quantity")) { - quantity = shipmentPlan.getDouble("quantity"); + if (shipmentPlan.quantity) { + quantity = shipmentPlan.quantity; } - if (product.getDouble("weight")) { - weight = product.getDouble("weight") * quantity; + if (product.weight) { + weight = product.weight * quantity; } oneRow.weight = weight; if (product.weightUomId) { @@ -133,19 +133,19 @@ if (shipmentPlans) { oneRow.weightUom = weightUom.abbreviation; } volume = 0.0; - if (product.getDouble("productHeight") && - product.getDouble("productWidth") && - product.getDouble("productDepth")) { + if (product.productHeight && + product.productWidth && + product.productDepth) { // TODO: check if uom conversion is needed - volume = product.getDouble("productHeight") * - product.getDouble("productWidth") * - product.getDouble("productDepth") * + volume = product.productHeight * + product.productWidth * + product.productDepth * quantity; } oneRow.volume = volume; - if (product.get("heightUomId") && - product.get("widthUomId") && - product.get("depthUomId")) { + if (product.heightUomId && + product.widthUomId && + product.depthUomId) { heightUom = delegator.findByPrimaryKeyCache("Uom", [uomId : product.heightUomId]); widthUom = delegator.findByPrimaryKeyCache("Uom", [uomId : product.widthUomId]); diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsComponentsByFeature.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsComponentsByFeature.groovy index 8fc375531ba..8ccac31b211 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsComponentsByFeature.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsComponentsByFeature.groovy @@ -91,9 +91,9 @@ if (allProductionRuns) { products.put(productionRunComponent.productId, [product : productionRunProduct, quantity : new Double(0), location : location]); } Map productMap = (Map)products.get(productionRunComponent.productId); - Double productMapQty = (Double)productMap.quantity; - Double currentProductQty = productionRunComponent.getDouble("estimatedQuantity"); - productMap.quantity = new Double(productMapQty.doubleValue() + currentProductQty.doubleValue()); + productMapQty = productMap.quantity; + currentProductQty = productionRunComponent.estimatedQuantity; + productMap.quantity = productMapQty + currentProductQty; } } // now create lists of products for each feature group @@ -105,14 +105,14 @@ if (allProductionRuns) { while (productsMapIt.hasNext()) { productMap = productsMapIt.next(); if (productMap.product.productWidth && productMap.product.productHeight) { - Double productMapQty = (Double)productMap.get("quantity"); - Double productHeight = (Double)productMap.get("product").get("productHeight"); - Double productWidth = (Double)productMap.get("product").get("productWidth"); - double productArea = (productHeight.doubleValue() * productWidth.doubleValue()) / (1000 * 1000); - double panelQty = 0.0; + productMapQty = productMap.quantity; + productHeight = productMap.product.productHeight; + productWidth = productMap.product.productWidth; + productArea = (productHeight * productWidth) / (1000 * 1000); + panelQty = 0.0; int panelQtyInt = 0; - if (productArea > 0) panelQty = productMapQty.doubleValue() / productArea; - panelQtyInt = (int)panelQty; + if (productArea > 0) panelQty = productMapQty / productArea; + panelQtyInt = panelQty; if (panelQtyInt < panelQty) panelQtyInt++; productMap.panelQuantity = new Integer(panelQtyInt); } diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsProductsStacks.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsProductsStacks.groovy index 91269cf188c..e30679ae123 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsProductsStacks.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/PRunsProductsStacks.groovy @@ -63,7 +63,7 @@ if (allProductionRuns) { // Stack information stackInfos = []; - productionRunQty = productionRun.getDouble("quantityToProduce"); + productionRunQty = productionRun.quantityToProduce; //numOfStacks = (int)productionRunQty / stackQty; // number of stacks numOfStacks = productionRunQty / stackQty; // number of stacks numOfStacks = numOfStacks.intValue(); diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentLabel.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentLabel.groovy index e92d38cc9ba..697bf8746cc 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentLabel.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentLabel.groovy @@ -46,10 +46,10 @@ if (shipment) { record = [:]; if (shipmentPackageComponent.subProductId) { record.productId = shipmentPackageComponent.subProductId; - record.quantity = shipmentPackageComponent.getDouble("subQuantity"); + record.quantity = shipmentPackageComponent.subQuantity; } else { record.productId = shipmentItem.productId; - record.quantity = shipmentPackageComponent.getDouble("quantity"); + record.quantity = shipmentPackageComponent.quantity; } record.shipmentPackageSeqId = shipmentPackageComponent.shipmentPackageSeqId; record.orderId = orderId; diff --git a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentPlanStockReport.groovy b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentPlanStockReport.groovy index 3198add8651..23aab354a47 100644 --- a/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentPlanStockReport.groovy +++ b/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/reports/ShipmentPlanStockReport.groovy @@ -39,12 +39,12 @@ if (shipment) { recordGroup.SHIPMENT_ITEM_SEQ_ID = shipmentPlan.shipmentItemSeqId; recordGroup.PRODUCT_ID = orderLine.productId; - recordGroup.QUANTITY = shipmentPlan.getDouble("quantity"); + recordGroup.QUANTITY = shipmentPlan.quantity; product = delegator.findByPrimaryKey("Product", [productId : orderLine.productId]); recordGroup.PRODUCT_NAME = product.internalName; inputPar = [productId : orderLine.productId, - quantity : shipmentPlan.getDouble("quantity"), + quantity : shipmentPlan.quantity, fromDate : "" + new Date(), userLogin: userLogin]; @@ -65,14 +65,14 @@ if (shipment) { if (!inventoryStock.containsKey(oneComponent.getProduct().productId)) { serviceInput = [productId : oneComponent.getProduct().productId , facilityId : facilityId]; serviceOutput = dispatcher.runSync("getInventoryAvailableByFacility",serviceInput); - qha = serviceOutput.quantityOnHandTotal ?: new Double(0); + qha = serviceOutput.quantityOnHandTotal ?: 0.0; inventoryStock.oneComponent.getProduct().productId = qha; } - qty = ((Double)inventoryStock.get(oneComponent.getProduct().productId)).floatValue(); - qty = (float)(qty - oneComponent.getQuantity()); - inventoryStock.oneComponent.getProduct().productId = new Double(qty); + qty = inventoryStock[oneComponent.getProduct().productId]; + qty = qty - oneComponent.getQuantity(); + inventoryStock.oneComponent.getProduct().productId = qty; } - record.componentOnHand = new Float(qty); + record.componentOnHand = qty; // Now we get the products qty already reserved by production runs serviceInput = [productId : oneComponent.getProduct().productId, userLogin : userLogin]; diff --git a/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml b/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml index 61ef34a67a0..700667f8f77 100644 --- a/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml +++ b/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml @@ -137,7 +137,7 @@ under the License.
- + @@ -151,7 +151,7 @@ under the License. - + diff --git a/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl b/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl index e5a161fd654..e6b8907ae37 100644 --- a/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl +++ b/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl @@ -211,7 +211,7 @@ document.lookupinventory.productId.focus(); - <#assign quantityAvailableAtDate = quantityAvailableAtDate?default(0) + inven.getDouble("quantity")> + <#assign quantityAvailableAtDate = quantityAvailableAtDate?default(0) + inven.getBigDecimal("quantity")> <#assign productTmp = product> <#assign MrpEventType = inven.getRelatedOne("MrpEventType")> diff --git a/applications/manufacturing/widget/manufacturing/CuttingListReport.groovy b/applications/manufacturing/widget/manufacturing/CuttingListReport.groovy index f450b14a2d2..dbba0a52cec 100644 --- a/applications/manufacturing/widget/manufacturing/CuttingListReport.groovy +++ b/applications/manufacturing/widget/manufacturing/CuttingListReport.groovy @@ -72,26 +72,26 @@ if (shipmentPlans) { productId = product.productId; productIdToProduct.put(productId, product); if (!productIdToQuantity.containsKey(productId)) { - productIdToQuantity.put(productId, new Double(0)); + productIdToQuantity.put(productId, 0.0); } - qty = (Double)productIdToQuantity.get(productId); - productIdToQuantity.put(productId, new Double(oneProductionRun.getGenericValue().getDouble("quantityToProduce").doubleValue() + qty.doubleValue())); + qty = productIdToQuantity.get(productId); + productIdToQuantity.put(productId, oneProductionRun.getGenericValue().quantityToProduce + qty); } } } } } productIdToProduct.values().each { product -> - heightD = product.getDouble("productHeight"); + heightD = product.productHeight; height = 0; if (heightD) { - height = (heightD.doubleValue() * 1000) as int; + height = (heightD * 1000) as int; } - widthD = product.getDouble("productWidth"); + widthD = product.productWidth; width = 0; if (widthD) { - width = (widthD.doubleValue() * 1000) as int; + width = (widthD * 1000) as int; } Dimension dim = new Dimension(width, height); if (!dimensionToProducts.containsKey(dim)) { @@ -101,10 +101,10 @@ if (shipmentPlans) { prodList.add(product); // tot qty per dimension if (!dimensionToQuantity.containsKey(dim)) { - dimensionToQuantity.put(dim, new Double(0)); + dimensionToQuantity.put(dim, 0.0); } - Double qty = (Double)dimensionToQuantity.get(dim); - dimensionToQuantity.put(dim, new Double(((Double)productIdToQuantity.get(product.productId)).doubleValue() + qty.doubleValue())); + qty = dimensionToQuantity[dim]; + dimensionToQuantity.put(dim, productIdToQuantity[product.productId] + qty); } // // @@ -113,8 +113,8 @@ if (shipmentPlans) { dimensionToProducts.keySet().each { dim -> map1 = [:]; list1.add(map1); - map1.width = (dim.getWidth() / 1000) as Double; - map1.height = (dim.getHeight() / 1000) as Double; + map1.width = (dim.getWidth() / 1000); + map1.height = (dim.getHeight() / 1000); map1.quantity = dimensionToQuantity.get(dim); list2 = [] as ArrayList; map1.products = list2; diff --git a/applications/party/data/ScheduledJobs.xml b/applications/party/data/ScheduledJobs.xml index 4ac5c45092d..91dc1cf6773 100644 --- a/applications/party/data/ScheduledJobs.xml +++ b/applications/party/data/ScheduledJobs.xml @@ -22,5 +22,28 @@ - + + + + + + + + + + + + + + + + + + + + + + + ]]> + diff --git a/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml b/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml index d9f583a71d4..b6f02eff985 100644 --- a/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml +++ b/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml @@ -361,6 +361,23 @@ under the License. + + + + + + + + + + + + + + + + + diff --git a/applications/party/servicedef/services.xml b/applications/party/servicedef/services.xml index 7b48a12e2bc..cf815ce3b06 100644 --- a/applications/party/servicedef/services.xml +++ b/applications/party/servicedef/services.xml @@ -792,6 +792,8 @@ under the License. Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email + + diff --git a/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java b/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java index 281bdc3b5ca..2c1ccae32d2 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java +++ b/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java @@ -76,7 +76,7 @@ public static Double formatPriceNumber(double price) { * @param maximumFractionDigits The maximum number of fraction digits used; if set to -1 than the default value for the locale is used * @return A String with the formatted price */ - public static String formatCurrency(BigDecimal price, String isoCode, Locale locale, int maximumFractionDigits) { + public static String formatCurrency(double price, String isoCode, Locale locale, int maximumFractionDigits) { //Debug.logInfo("formatting currency: " + price + ", isoCode: " + isoCode + ", locale: " + locale, module); com.ibm.icu.text.NumberFormat nf = com.ibm.icu.text.NumberFormat.getCurrencyInstance(locale); if (isoCode != null && isoCode.length() > 1) { @@ -90,6 +90,17 @@ public static String formatCurrency(BigDecimal price, String isoCode, Locale loc return nf.format(price); } + /** Formats a BigDecimal into a properly formatted currency string based on isoCode and Locale + * @param price The price double to be formatted + * @param isoCode the currency ISO code + * @param locale The Locale used to format the number + * @param maximumFractionDigits The maximum number of fraction digits used; if set to -1 than the default value for the locale is used + * @return A String with the formatted price + */ + public static String formatCurrency(BigDecimal price, String isoCode, Locale locale, int maximumFractionDigits) { + return formatCurrency(price.doubleValue(), isoCode, locale, maximumFractionDigits); + } + /** Formats a double into a properly formatted currency string based on isoCode and Locale * @param price The price double to be formatted * @param isoCode the currency ISO code