Author: jacopoc
Date: Sun Jun 14 14:09:54 2009 New Revision: 784563 URL: http://svn.apache.org/viewvc?rev=784563&view=rev Log: Fix for NPE. Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?rev=784563&r1=784562&r2=784563&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Sun Jun 14 14:09:54 2009 @@ -461,30 +461,32 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError("Problem, we can not find CustomTimePeriod, for more detail look at the log"); } - if (customTimePeriod.getDate("thruDate") != null && customTimePeriod.getDate("thruDate").before(UtilDateTime.nowDate())) { - continue; - } else { - List salesForecastDetails = null; - Iterator sfdIter = null; - try { - salesForecastDetails = delegator.findByAnd("SalesForecastDetail", UtilMisc.toMap("salesForecastId", genericResult.getString("salesForecastId"))); - } catch (GenericEntityException e) { - return ServiceUtil.returnError("Problem, we can not find SalesForecastDetails, for more detail look at the log"); - } - sfdIter = salesForecastDetails.iterator(); - while (sfdIter.hasNext()) { - genericResult = (GenericValue) sfdIter.next(); - String productId = genericResult.getString("productId"); - BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity"); - if (productId == null || eventQuantityTmp == null) { - continue; - } - eventQuantityTmp = eventQuantityTmp.negate(); - parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"), "mrpEventTypeId", "SALES_FORECAST"); + if (customTimePeriod != null) { + if (customTimePeriod.getDate("thruDate") != null && customTimePeriod.getDate("thruDate").before(UtilDateTime.nowDate())) { + continue; + } else { + List salesForecastDetails = null; + Iterator sfdIter = null; try { - InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("salesForecastDetailId"), false, delegator); + salesForecastDetails = delegator.findByAnd("SalesForecastDetail", UtilMisc.toMap("salesForecastId", genericResult.getString("salesForecastId"))); } catch (GenericEntityException e) { - return ServiceUtil.returnError("Problem initializing the MrpEvent entity (SalesForecastDetail)"); + return ServiceUtil.returnError("Problem, we can not find SalesForecastDetails, for more detail look at the log"); + } + sfdIter = salesForecastDetails.iterator(); + while (sfdIter.hasNext()) { + genericResult = (GenericValue) sfdIter.next(); + String productId = genericResult.getString("productId"); + BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity"); + if (productId == null || eventQuantityTmp == null) { + continue; + } + 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); + } catch (GenericEntityException e) { + return ServiceUtil.returnError("Problem initializing the MrpEvent entity (SalesForecastDetail)"); + } } } } |
Free forum by Nabble | Edit this page |