Author: jacopoc
Date: Thu Aug 20 13:05:17 2009 New Revision: 806157 URL: http://svn.apache.org/viewvc?rev=806157&view=rev Log: Formatting change only. Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy?rev=806157&r1=806156&r2=806157&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.groovy Thu Aug 20 13:05:17 2009 @@ -21,143 +21,143 @@ import org.ofbiz.product.inventory.InventoryWorker if (product) { -//If product is virtual gather summary data from variants -if (product.isVirtual && "Y".equals(product.isVirtual)) { - //Get the virtual product feature types - result = dispatcher.runSync("getProductFeaturesByType", [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']); - featureTypeIds = result.productFeatureTypes; - - //Get the variants - result = dispatcher.runSync("getAllProductVariants", [productId : productId]); - variants = result.assocProducts; - variantIterator = variants.iterator(); - variantInventorySummaries = []; - while (variantIterator) { - variant = variantIterator.next(); - - //create a map of each variant id and inventory summary (all facilities) - inventoryAvailable = dispatcher.runSync("getProductInventoryAvailable", [productId : variant.productIdTo]); - - variantInventorySummary = [productId : variant.productIdTo, - availableToPromiseTotal : inventoryAvailable.availableToPromiseTotal, - quantityOnHandTotal : inventoryAvailable.quantityOnHandTotal]; - - //add the applicable features to the map - featureTypeIdsIterator = featureTypeIds.iterator(); - while (featureTypeIdsIterator) { - featureTypeId = featureTypeIdsIterator.next(); - result = dispatcher.runSync("getProductFeatures", [productId : variant.productIdTo, type : 'STANDARD_FEATURE', distinct : featureTypeId]); - variantFeatures = result.productFeatures; - if (variantFeatures) { - //there should only be one result in this collection - variantInventorySummary.put(featureTypeId, variantFeatures.get(0)); + //If product is virtual gather summary data from variants + if (product.isVirtual && "Y".equals(product.isVirtual)) { + //Get the virtual product feature types + result = dispatcher.runSync("getProductFeaturesByType", [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']); + featureTypeIds = result.productFeatureTypes; + + //Get the variants + result = dispatcher.runSync("getAllProductVariants", [productId : productId]); + variants = result.assocProducts; + variantIterator = variants.iterator(); + variantInventorySummaries = []; + while (variantIterator) { + variant = variantIterator.next(); + + //create a map of each variant id and inventory summary (all facilities) + inventoryAvailable = dispatcher.runSync("getProductInventoryAvailable", [productId : variant.productIdTo]); + + variantInventorySummary = [productId : variant.productIdTo, + availableToPromiseTotal : inventoryAvailable.availableToPromiseTotal, + quantityOnHandTotal : inventoryAvailable.quantityOnHandTotal]; + + //add the applicable features to the map + featureTypeIdsIterator = featureTypeIds.iterator(); + while (featureTypeIdsIterator) { + featureTypeId = featureTypeIdsIterator.next(); + result = dispatcher.runSync("getProductFeatures", [productId : variant.productIdTo, type : 'STANDARD_FEATURE', distinct : featureTypeId]); + variantFeatures = result.productFeatures; + if (variantFeatures) { + //there should only be one result in this collection + variantInventorySummary.put(featureTypeId, variantFeatures.get(0)); + } } + variantInventorySummaries.add(variantInventorySummary); } - variantInventorySummaries.add(variantInventorySummary); - } - context.featureTypeIds = featureTypeIds; - context.variantInventorySummaries = variantInventorySummaries; -} else { //Gather information for a non virtual product - quantitySummaryByFacility = [:]; - manufacturingInQuantitySummaryByFacility = [:]; - manufacturingOutQuantitySummaryByFacility = [:]; - // The warehouse list is selected - showAllFacilities = parameters.showAllFacilities; - if (showAllFacilities && "Y".equals(showAllFacilities)) { - facilityList = delegator.findList("Facility", null, null, null, null, false); - } else { - facilityList = delegator.findList("ProductFacility", EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), null, null, null, false); - } - facilityIterator = facilityList.iterator(); - dispatcher = request.getAttribute("dispatcher"); - Map contextInput = null; - Map resultOutput = null; - - // inventory quantity summary by facility: For every warehouse the product's atp and qoh - // are obtained (calling the "getInventoryAvailableByFacility" service) - while (facilityIterator) { - facility = facilityIterator.next(); - resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", [productId : productId, facilityId : facility.facilityId]); - - quantitySummary = [:]; - quantitySummary.facilityId = facility.facilityId; - quantitySummary.totalQuantityOnHand = resultOutput.quantityOnHandTotal; - quantitySummary.totalAvailableToPromise = resultOutput.availableToPromiseTotal; - - // if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components - if ("MARKETING_PKG_AUTO".equals(product.productTypeId) || - "MARKETING_PKG_PICK".equals(product.productTypeId)) { - resultOutput = dispatcher.runSync("getMktgPackagesAvailable", [productId : productId, facilityId : facility.facilityId]); - quantitySummary.mktgPkgQOH = resultOutput.quantityOnHandTotal; - quantitySummary.mktgPkgATP = resultOutput.availableToPromiseTotal; + context.featureTypeIds = featureTypeIds; + context.variantInventorySummaries = variantInventorySummaries; + } else { //Gather information for a non virtual product + quantitySummaryByFacility = [:]; + manufacturingInQuantitySummaryByFacility = [:]; + manufacturingOutQuantitySummaryByFacility = [:]; + // The warehouse list is selected + showAllFacilities = parameters.showAllFacilities; + if (showAllFacilities && "Y".equals(showAllFacilities)) { + facilityList = delegator.findList("Facility", null, null, null, null, false); + } else { + facilityList = delegator.findList("ProductFacility", EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), null, null, null, false); } - - quantitySummaryByFacility.put(facility.facilityId, quantitySummary); - } - - productInventoryItems = delegator.findByAnd("InventoryItem", - [productId : productId], - ['facilityId', '-datetimeReceived', '-inventoryItemId']); - - // TODO: get all incoming shipments not yet arrived coming into each facility that this product is in, use a view entity with ShipmentAndItem - findIncomingShipmentsConds = []; - - findIncomingShipmentsConds.add(EntityCondition.makeCondition('productId', EntityOperator.EQUALS, productId)); - - findIncomingShipmentsTypeConds = []; - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "INCOMING_SHIPMENT")); - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "PURCHASE_SHIPMENT")); - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "SALES_RETURN")); - findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsTypeConds, EntityOperator.OR)); - - findIncomingShipmentsStatusConds = []; - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED")); - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED")); - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PURCH_SHIP_RECEIVED")); - findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsStatusConds, EntityOperator.AND)); - - findIncomingShipmentsStatusCondition = EntityCondition.makeCondition(findIncomingShipmentsConds, EntityOperator.AND); - incomingShipmentAndItems = delegator.findList("ShipmentAndItem", findIncomingShipmentsStatusCondition, null, ['-estimatedArrivalDate'], null, false); - incomingShipmentAndItemIter = incomingShipmentAndItems.iterator(); - while (incomingShipmentAndItemIter) { - incomingShipmentAndItem = incomingShipmentAndItemIter.next(); - facilityId = incomingShipmentAndItem.destinationFacilityId; - - quantitySummary = quantitySummaryByFacility.get(facilityId); - if (!quantitySummary) { + facilityIterator = facilityList.iterator(); + dispatcher = request.getAttribute("dispatcher"); + Map contextInput = null; + Map resultOutput = null; + + // inventory quantity summary by facility: For every warehouse the product's atp and qoh + // are obtained (calling the "getInventoryAvailableByFacility" service) + while (facilityIterator) { + facility = facilityIterator.next(); + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", [productId : productId, facilityId : facility.facilityId]); + quantitySummary = [:]; - quantitySummary.facilityId = facilityId; - quantitySummaryByFacility.facilityId = quantitySummary; + quantitySummary.facilityId = facility.facilityId; + quantitySummary.totalQuantityOnHand = resultOutput.quantityOnHandTotal; + quantitySummary.totalAvailableToPromise = resultOutput.availableToPromiseTotal; + + // if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components + if ("MARKETING_PKG_AUTO".equals(product.productTypeId) || + "MARKETING_PKG_PICK".equals(product.productTypeId)) { + resultOutput = dispatcher.runSync("getMktgPackagesAvailable", [productId : productId, facilityId : facility.facilityId]); + quantitySummary.mktgPkgQOH = resultOutput.quantityOnHandTotal; + quantitySummary.mktgPkgATP = resultOutput.availableToPromiseTotal; + } + + quantitySummaryByFacility.put(facility.facilityId, quantitySummary); } - - incomingShipmentAndItemList = quantitySummary.incomingShipmentAndItemList; - if (!incomingShipmentAndItemList) { - incomingShipmentAndItemList = []; - quantitySummary.incomingShipmentAndItemList = incomingShipmentAndItemList; + + productInventoryItems = delegator.findByAnd("InventoryItem", + [productId : productId], + ['facilityId', '-datetimeReceived', '-inventoryItemId']); + + // TODO: get all incoming shipments not yet arrived coming into each facility that this product is in, use a view entity with ShipmentAndItem + findIncomingShipmentsConds = []; + + findIncomingShipmentsConds.add(EntityCondition.makeCondition('productId', EntityOperator.EQUALS, productId)); + + findIncomingShipmentsTypeConds = []; + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "INCOMING_SHIPMENT")); + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "PURCHASE_SHIPMENT")); + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "SALES_RETURN")); + findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsTypeConds, EntityOperator.OR)); + + findIncomingShipmentsStatusConds = []; + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED")); + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED")); + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PURCH_SHIP_RECEIVED")); + findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsStatusConds, EntityOperator.AND)); + + findIncomingShipmentsStatusCondition = EntityCondition.makeCondition(findIncomingShipmentsConds, EntityOperator.AND); + incomingShipmentAndItems = delegator.findList("ShipmentAndItem", findIncomingShipmentsStatusCondition, null, ['-estimatedArrivalDate'], null, false); + incomingShipmentAndItemIter = incomingShipmentAndItems.iterator(); + while (incomingShipmentAndItemIter) { + incomingShipmentAndItem = incomingShipmentAndItemIter.next(); + facilityId = incomingShipmentAndItem.destinationFacilityId; + + quantitySummary = quantitySummaryByFacility.get(facilityId); + if (!quantitySummary) { + quantitySummary = [:]; + quantitySummary.facilityId = facilityId; + quantitySummaryByFacility.facilityId = quantitySummary; + } + + incomingShipmentAndItemList = quantitySummary.incomingShipmentAndItemList; + if (!incomingShipmentAndItemList) { + incomingShipmentAndItemList = []; + quantitySummary.incomingShipmentAndItemList = incomingShipmentAndItemList; + } + + incomingShipmentAndItemList.add(incomingShipmentAndItem); } - - incomingShipmentAndItemList.add(incomingShipmentAndItem); + + // -------------------- + // Production Runs + resultOutput = dispatcher.runSync("getProductManufacturingSummaryByFacility", + [productId : productId, userLogin : userLogin]); + // incoming products + manufacturingInQuantitySummaryByFacility = resultOutput.summaryInByFacility; + // outgoing products (materials) + manufacturingOutQuantitySummaryByFacility = resultOutput.summaryOutByFacility; + + showEmpty = "true".equals(request.getParameter("showEmpty")); + + // Find oustanding purchase orders for this item. + purchaseOrders = InventoryWorker.getOutstandingPurchaseOrders(productId, delegator); + + context.productInventoryItems = productInventoryItems; + context.quantitySummaryByFacility = quantitySummaryByFacility; + context.manufacturingInQuantitySummaryByFacility = manufacturingInQuantitySummaryByFacility; + context.manufacturingOutQuantitySummaryByFacility = manufacturingOutQuantitySummaryByFacility; + context.showEmpty = showEmpty; + context.purchaseOrders = purchaseOrders; } - - // -------------------- - // Production Runs - resultOutput = dispatcher.runSync("getProductManufacturingSummaryByFacility", - [productId : productId, userLogin : userLogin]); - // incoming products - manufacturingInQuantitySummaryByFacility = resultOutput.summaryInByFacility; - // outgoing products (materials) - manufacturingOutQuantitySummaryByFacility = resultOutput.summaryOutByFacility; - - showEmpty = "true".equals(request.getParameter("showEmpty")); - - // Find oustanding purchase orders for this item. - purchaseOrders = InventoryWorker.getOutstandingPurchaseOrders(productId, delegator); - - context.productInventoryItems = productInventoryItems; - context.quantitySummaryByFacility = quantitySummaryByFacility; - context.manufacturingInQuantitySummaryByFacility = manufacturingInQuantitySummaryByFacility; - context.manufacturingOutQuantitySummaryByFacility = manufacturingOutQuantitySummaryByFacility; - context.showEmpty = showEmpty; - context.purchaseOrders = purchaseOrders; -} } \ No newline at end of file |
Free forum by Nabble | Edit this page |