svn commit: r1870212 - in /ofbiz/branches/release16.11/applications: manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ order/template/order/ product/minilang/product/inventory/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1870212 - in /ofbiz/branches/release16.11/applications: manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ order/template/order/ product/minilang/product/inventory/

Pawan Verma-2
Author: pawan
Date: Sat Nov 23 06:58:00 2019
New Revision: 1870212

URL: http://svn.apache.org/viewvc?rev=1870212&view=rev
Log:
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.

Modified:
    ofbiz/branches/release16.11/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
    ofbiz/branches/release16.11/applications/order/template/order/OrderItems.ftl
    ofbiz/branches/release16.11/applications/product/minilang/product/inventory/InventoryServices.xml

Modified: ofbiz/branches/release16.11/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=1870212&r1=1870211&r2=1870212&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/branches/release16.11/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sat Nov 23 06:58:00 2019
@@ -2565,6 +2565,29 @@ public class ProductionRunServices {
                 BigDecimal mktgPackagesAvailable = (BigDecimal) resultService.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());
+                    resultService = dispatcher.runSync("createProductionRun", serviceContext);
+                    if (ServiceUtil.isError(resultService)) {
+                        return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resultService));
+                    }
+                    String productionRunIdForRemainingQty = (String)resultService.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); }

Modified: ofbiz/branches/release16.11/applications/order/template/order/OrderItems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/order/template/order/OrderItems.ftl?rev=1870212&r1=1870211&r2=1870212&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/order/template/order/OrderItems.ftl (original)
+++ ofbiz/branches/release16.11/applications/order/template/order/OrderItems.ftl Sat Nov 23 06:58:00 2019
@@ -354,7 +354,6 @@ under the License.
                                         </#if>
                                     </td>
                                 </tr>
-                                <#break><#-- need only the first one -->
                             </#list>
                         </#if>
                         <#-- show linked order lines -->

Modified: ofbiz/branches/release16.11/applications/product/minilang/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/product/minilang/product/inventory/InventoryServices.xml?rev=1870212&r1=1870211&r2=1870212&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/product/minilang/product/inventory/InventoryServices.xml (original)
+++ ofbiz/branches/release16.11/applications/product/minilang/product/inventory/InventoryServices.xml Sat Nov 23 06:58:00 2019
@@ -701,19 +701,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 -->