Author: lektran
Date: Sat Oct 27 16:57:35 2007 New Revision: 589248 URL: http://svn.apache.org/viewvc?rev=589248&view=rev Log: Don't try to complete the marketing package production run if there aren't enough components available, it just result in an error and confuses order processing Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=589248&r1=589247&r2=589248&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sat Oct 27 16:57:35 2007 @@ -2151,20 +2151,26 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError("Error creating a production run for marketing package for order [" + orderId + " " + orderItemSeqId + "]: " + e.getMessage()); } - try { - serviceContext.clear(); - serviceContext.put("productionRunId", productionRunId); - serviceContext.put("statusId", "PRUN_COMPLETED"); - serviceContext.put("userLogin", userLogin); - resultService = dispatcher.runSync("quickChangeProductionRunStatus", serviceContext); - serviceContext.clear(); - serviceContext.put("workEffortId", productionRunId); - serviceContext.put("userLogin", userLogin); - resultService = dispatcher.runSync("productionRunProduce", serviceContext); - } catch (GenericServiceException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale)); + // only complete the production run if we have enough components available to produce the desired amount, otherwise errors will result + serviceContext.remove("pRQuantity"); + serviceContext.remove("startDate"); + resultService = dispatcher.runSync("getMktgPackagesAvailable", serviceContext); + double mktgPackagesAvailable = ((Double) resultService.get("availableToPromiseTotal")).doubleValue(); + if (mktgPackagesAvailable > qtyToProduce) { + try { + serviceContext.clear(); + serviceContext.put("productionRunId", productionRunId); + serviceContext.put("statusId", "PRUN_COMPLETED"); + serviceContext.put("userLogin", userLogin); + resultService = dispatcher.runSync("quickChangeProductionRunStatus", serviceContext); + serviceContext.clear(); + serviceContext.put("workEffortId", productionRunId); + serviceContext.put("userLogin", userLogin); + resultService = dispatcher.runSync("productionRunProduce", serviceContext); + } catch (GenericServiceException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale)); + } } - result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated", UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; |
Free forum by Nabble | Edit this page |