This is an automated email from the ASF dual-hosted git repository.
pawan pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release18.12 by this push: new a42f03a Fixed: Production run not created for marketing package auto type product if component inventory is not available (OFBIZ-10585) a42f03a is described below commit a42f03aa1052bbbcbc323588c342a69581598d8e Author: Pawan Verma <[hidden email]> AuthorDate: Sat Nov 23 11:59:07 2019 +0530 Fixed: Production run not created for marketing package auto type product if component inventory is not available (OFBIZ-10585) When we create an order for marketing package auto, the system checks the component inventory and if found then it creates the production run job and produce marketing package inventory, but if component quantity not available then it does not create the job. So if we don't have an inventory item of component then production run should be created with created status. Thanks: Yashwant Dhakad for report and Ankush Upadhyay for the patch. --- .../jobshopmgt/ProductionRunServices.java | 23 ++++++++++++++++++++++ applications/order/template/order/OrderItems.ftl | 1 - .../product/inventory/InventoryServices.xml | 13 +++++------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java index ad9fab8..af8731f 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java @@ -2800,6 +2800,29 @@ public class ProductionRunServices { BigDecimal mktgPackagesAvailable = (BigDecimal) serviceResult.get("availableToPromiseTotal"); BigDecimal qtyToProduce = qtyRequired.min(mktgPackagesAvailable); + /* + Creating production run job for remaining quantity in created status + This will handle cases like if production run job creates for partial quantities or in case of fully backordered scenario. + */ + BigDecimal remainingQty = orderItem.getBigDecimal("quantity").subtract(qtyToProduce); + if(remainingQty.compareTo(ZERO) > 0) { + serviceContext.clear(); + serviceContext.put("facilityId", facilityId); + serviceContext.put("userLogin", userLogin); + serviceContext.put("productId", orderItem.getString("productId")); + serviceContext.put("pRQuantity", remainingQty); + serviceContext.put("startDate", UtilDateTime.nowTimestamp()); + serviceResult = dispatcher.runSync("createProductionRun", serviceContext); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } + String productionRunIdForRemainingQty = (String)serviceResult.get("productionRunId"); + try { + delegator.create("WorkOrderItemFulfillment", UtilMisc.toMap("workEffortId", productionRunIdForRemainingQty, "orderId", orderId, "orderItemSeqId", orderItemSeqId)); + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunForMarketingPackagesCreationError", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "errorString", e.getMessage()), locale)); + } + } if (qtyToProduce.compareTo(ZERO) > 0) { if (Debug.verboseOn()) { Debug.logVerbose("Required quantity (all orders) = [" + qtyRequired + "] quantity to produce = [" + qtyToProduce + "]", module); } diff --git a/applications/order/template/order/OrderItems.ftl b/applications/order/template/order/OrderItems.ftl index 450c053..91c1ab5 100644 --- a/applications/order/template/order/OrderItems.ftl +++ b/applications/order/template/order/OrderItems.ftl @@ -361,7 +361,6 @@ under the License. </#if> </td> </tr> - <#break><#-- need only the first one --> </#list> </#if> <#-- show linked order lines --> diff --git a/applications/product/minilang/product/inventory/InventoryServices.xml b/applications/product/minilang/product/inventory/InventoryServices.xml index 76f087b..75a0594 100644 --- a/applications/product/minilang/product/inventory/InventoryServices.xml +++ b/applications/product/minilang/product/inventory/InventoryServices.xml @@ -703,19 +703,16 @@ under the License. <set from-field="parameters.productId" field="lookupMktgPkgParams.productId"/> <entity-one entity-name="Product" value-field="product"/> <set field="isMarketingPkgAuto" value="${groovy: org.apache.ofbiz.entity.util.EntityTypeUtil.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG_AUTO')}" type="Boolean"/> + <!-- In case of MARKETING_PKG_AUTO, pass MANUF_COMPONENT else PRODUCT_COMPONENT for MARKETING_PKG_PICK--> <if-compare field="isMarketingPkgAuto" operator="equals" value="true" type="Boolean"> - <set field="productIdMap.productId" from-field="product.productId"/> - <call-service service-name="getProductInventoryAvailable" in-map-name="productIdMap"> - <result-to-field result-name="availableToPromiseTotal"/> - <result-to-field result-name="quantityOnHandTotal"/> - </call-service> + <set field="lookupMktgPkgParams.type" value="MANUF_COMPONENT"/> <else> <set value="PRODUCT_COMPONENT" field="lookupMktgPkgParams.type"/> - <call-service service-name="getAssociatedProducts" in-map-name="lookupMktgPkgParams"> - <result-to-field result-name="assocProducts"/> - </call-service> </else> </if-compare> + <call-service service-name="getAssociatedProducts" in-map-name="lookupMktgPkgParams"> + <result-to-field result-name="assocProducts"/> + </call-service> <!-- if there are any components, then the ATP and QOH are based on the quantities of those component products and found with another service --> |
Free forum by Nabble | Edit this page |