Author: bibryam
Date: Tue Aug 26 01:30:05 2008 New Revision: 688993 URL: http://svn.apache.org/viewvc?rev=688993&view=rev Log: Applied (with few modifications) patch from Len Shein, OFBIZ-1928: "Allow the Shopping Cart to accept a facility per ship group to specify where inventory should be reserved from". Also added a dropdown button to choose a facility in order manager shipping screen. Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/ShipSettings.groovy ofbiz/trunk/applications/order/webapp/ordermgr/entry/shipsettings.ftl ofbiz/trunk/applications/product/config/ProductUiLabels.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml ofbiz/trunk/applications/product/servicedef/services_store.xml Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Tue Aug 26 01:30:05 2008 @@ -794,6 +794,7 @@ <field name="vendorPartyId" type="id"><description>For use with multi-vendor stores, order will be split so that each ship group is associated with only one vendor (only if applicable)</description></field> <field name="carrierPartyId" type="id"></field> <field name="carrierRoleTypeId" type="id"></field> + <field name="facilityId" type="id"></field> <field name="contactMechId" type="id"></field> <field name="telecomContactMechId" type="id"></field> <field name="trackingNumber" type="short-varchar"></field> @@ -826,6 +827,9 @@ <key-map field-name="carrierPartyId" rel-field-name="partyId"/> <key-map field-name="carrierRoleTypeId" rel-field-name="roleTypeId"/> </relation> + <relation type="one" fk-name="ORDER_ITSG_FAC" rel-entity-name="Facility"> + <key-map field-name="facilityId"/> + </relation> <relation type="one" fk-name="ORDER_ITSG_SHMTP" rel-entity-name="ShipmentMethodType"> <key-map field-name="shipmentMethodTypeId"/> </relation> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Aug 26 01:30:05 2008 @@ -1115,6 +1115,8 @@ continue; } GenericValue orderItem = (GenericValue) itemValuesBySeqId.get(orderItemShipGroupAssoc.get("orderItemSeqId")); + GenericValue orderItemShipGroup = orderItemShipGroupAssoc.getRelatedOne("OrderItemShipGroup"); + String shipGroupFacilityId = orderItemShipGroup.getString("facilityId"); String itemStatus = orderItem.getString("statusId"); if ("ITEM_REJECTED".equals(itemStatus) || "ITEM_CANCELLED".equals(itemStatus) || "ITEM_COMPLETED".equals(itemStatus)) { Debug.logInfo("Order item [" + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + "] is not in a proper status for reservation", module); @@ -1153,6 +1155,7 @@ reserveInput.put("shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); reserveInput.put("quantity", quantity); reserveInput.put("userLogin", userLogin); + reserveInput.put("facilityId", shipGroupFacilityId); Map reserveResult = dispatcher.runSync("reserveStoreInventory", reserveInput); if (ServiceUtil.isError(reserveResult)) { @@ -1173,6 +1176,7 @@ reserveInput.put("orderId", orderItem.getString("orderId")); reserveInput.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); reserveInput.put("shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); + reserveInput.put("facilityId", shipGroupFacilityId); // use the quantity from the orderItemShipGroupAssoc, NOT the orderItem, these are reserved by item-group assoc reserveInput.put("quantity", orderItemShipGroupAssoc.getDouble("quantity")); reserveInput.put("userLogin", userLogin); @@ -1195,7 +1199,11 @@ // that can actually create and run a production run GenericValue permUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system")); Map inputMap = new HashMap(); - inputMap.put("facilityId", productStore.getString("inventoryFacilityId")); + if (UtilValidate.isNotEmpty(shipGroupFacilityId)) { + inputMap.put("facilityId", shipGroupFacilityId); + } else { + inputMap.put("facilityId", productStore.getString("inventoryFacilityId")); + } inputMap.put("orderId", orderItem.getString("orderId")); inputMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); inputMap.put("userLogin", permUserLogin); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Tue Aug 26 01:30:05 2008 @@ -751,6 +751,8 @@ shippingContactMechId = (String) request.getAttribute("contactMechId"); // FIXME } String supplierPartyId = request.getParameter(shipGroupIndex + "_supplierPartyId"); + String facilityId = request.getParameter(shipGroupIndex + "_shipGroupFacilityId"); + cart.setShipGroupFacilityId(shipGroupIndex, facilityId); callResult = checkOutHelper.finalizeOrderEntryShip(shipGroupIndex, shippingContactMechId, supplierPartyId); ServiceUtil.addErrors(errorMessages, errorMaps, callResult); } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Aug 26 01:30:05 2008 @@ -2310,6 +2310,16 @@ return this.getCarrierPartyId(0); } + public void setShipGroupFacilityId(int idx, String facilityId) { + CartShipInfo csi = this.getShipInfo(idx); + csi.facilityId = facilityId; + } + + public String getShipGroupFacilityId(int idx) { + CartShipInfo csi = this.getShipInfo(idx); + return csi.facilityId; + } + public void setOrderAdditionalEmails(String orderAdditionalEmails) { this.orderAdditionalEmails = orderAdditionalEmails; } @@ -4193,6 +4203,7 @@ public String supplierPartyId = null; public String carrierRoleTypeId = null; public String carrierPartyId = null; + public String facilityId = null; public String giftMessage = null; public String shippingInstructions = null; public String maySplit = "N"; @@ -4214,6 +4225,7 @@ public String getShipmentMethodTypeId() { return shipmentMethodTypeId; } public double getShipEstimate() { return shipEstimate; } public String getShipGroupSeqId() { return shipGroupSeqId; } + public String getFacilityId() { return facilityId; } public void setShipGroupSeqId(String shipGroupSeqId) { this.shipGroupSeqId = shipGroupSeqId; } @@ -4247,6 +4259,7 @@ shipGroup.set("isGift", isGift); shipGroup.set("shipGroupSeqId", shipGroupSeqId); shipGroup.set("vendorPartyId", vendorPartyId); + shipGroup.set("facilityId", facilityId); // use the cart's default ship before and after dates here if ((shipBeforeDate == null) && (cart.getDefaultShipBeforeDate() != null)) { Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/ShipSettings.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/ShipSettings.groovy?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/ShipSettings.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/ShipSettings.groovy Tue Aug 26 01:30:05 2008 @@ -63,6 +63,10 @@ // suppliers for the drop-ship select box suppliers = delegator.findByAnd("PartyRole", [roleTypeId : "SUPPLIER"]); context.suppliers = suppliers; + + // facilities used to reserve the items per ship group + productStoreFacilities = delegator.findByAnd("ProductStoreFacility", [productStoreId : cart.getProductStoreId()]); + context.productStoreFacilities = productStoreFacilities; } else { // Purchase order if (!"_NA_".equals(orderPartyId)) { Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/shipsettings.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/shipsettings.ftl?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/entry/shipsettings.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/shipsettings.ftl Tue Aug 26 01:30:05 2008 @@ -117,6 +117,7 @@ <#assign currShipContactMechId = cart.getShippingContactMechId(shipGroupIndex)?if_exists> <#assign supplierPartyId = cart.getSupplierPartyId(shipGroupIndex)?if_exists> +<#assign facilityId = cart.getShipGroupFacilityId(shipGroupIndex)?if_exists> <hr/> <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> @@ -134,6 +135,14 @@ <option value="${supplier.partyId}"<#if supplierPartyId?exists><#if supplier.partyId == supplierPartyId> selected</#if></#if>>${Static["org.ofbiz.party.party.PartyHelper"].getPartyName(supplier, true)}</option> </#list> </select> + ${uiLabelMap.ProductReserveInventoryFromFacility}: + <select name="${shipGroupIndex?default("0")}_shipGroupFacilityId"> + <option value=""></option> + <#list productStoreFacilities as productStoreFacility> + <#assign facility = productStoreFacility.getRelatedOne("Facility")> + <option value="${productStoreFacility.facilityId}"<#if facilityId?exists><#if productStoreFacility.facilityId == facilityId> selected</#if></#if>>${facility.facilityName?if_exists} </option> + </#list> + </select> </div> </td> </tr> Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.xml?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/product/config/ProductUiLabels.xml (original) +++ ofbiz/trunk/applications/product/config/ProductUiLabels.xml Tue Aug 26 01:30:05 2008 @@ -14996,8 +14996,11 @@ <value xml:lang="th">รายà¸à¸²à¸£à¸ªà¸±à¹à¸à¸à¸à¸</value> <value xml:lang="zh">é¢è®¢è®¢å</value> </property> + <property key="ProductReserveInventoryFromFacility"> + <value xml:lang="en">Reserve inventory from facility</value> + </property> <property key="ProductReserveInventory"> - <value xml:lang="en">Reservenventory</value> + <value xml:lang="en">Reserve Inventory</value> <value xml:lang="fr">Réservation de stock</value> <value xml:lang="es">Inventario reservado</value> <value xml:lang="fr">Stock de réserve</value> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml Tue Aug 26 01:30:05 2008 @@ -411,65 +411,97 @@ <call-simple-method method-name="isStoreInventoryRequiredInline"/> - <if-compare value="Y" field="productStore.oneInventoryFacility" operator="equals"> - <if-empty field="productStore.inventoryFacilityId"> - <add-error><fail-message message="ProductStore with id ${productStoreId} has Y for oneInventoryFacility but inventoryFacilityId is empty, not reserving inventory."/></add-error> - <check-errors/> - </if-empty> - - <set-service-fields map-name="parameters" to-map-name="callServiceMap" service-name="reserveProductInventoryByFacility"/> - <set from-field="productStore.inventoryFacilityId" field="callServiceMap.facilityId"/> - <set from-field="requireInventory" field="callServiceMap.requireInventory"/> - <set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/> - <call-service service-name="reserveProductInventoryByFacility" in-map-name="callServiceMap"> - <result-to-field result-name="quantityNotReserved"/> - </call-service> - - <if-compare value="0" field="quantityNotReserved" operator="equals" type="Double"> - <log level="info" message="Inventory IS reserved in facility with id [${productStore.inventoryFacilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> + <set from-field="parameters.facilityId" field="facilityId"/> + <if-empty field="facilityId"> + <if-compare value="Y" field="productStore.oneInventoryFacility" operator="equals"> + <if-empty field="productStore.inventoryFacilityId"> + <add-error><fail-message message="ProductStore with id ${productStoreId} has Y for oneInventoryFacility but inventoryFacilityId is empty, not reserving inventory."/></add-error> + <check-errors/> + </if-empty> + <set-service-fields map-name="parameters" to-map-name="callServiceMap" service-name="reserveProductInventoryByFacility"/> + <set from-field="productStore.inventoryFacilityId" field="callServiceMap.facilityId"/> + <set from-field="requireInventory" field="callServiceMap.requireInventory"/> + <set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/> + <call-service service-name="reserveProductInventoryByFacility" in-map-name="callServiceMap"> + <result-to-field result-name="quantityNotReserved"/> + </call-service> + + <if-compare value="0" field="quantityNotReserved" operator="equals" type="Double"> + <log level="info" message="Inventory IS reserved in facility with id [${productStore.inventoryFacilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> + <else> + <log level="info" message="There is insufficient inventory available in facility with id [${productStore.inventoryFacilityId}] for product id [${parameters.productId}]; desired quantity is ${parameters.quantity}, amount could not reserve is ${quantityNotReserved}"/> + </else> + </if-compare> <else> - <log level="info" message="There is insufficient inventory available in facility with id [${productStore.inventoryFacilityId}] for product id [${parameters.productId}]; desired quantity is ${parameters.quantity}, amount could not reserve is ${quantityNotReserved}"/> + <entity-and entity-name="ProductStoreFacility" list-name="productStoreFacilities" use-cache="true"> + <field-map env-name="productStore.productStoreId" field-name="productStoreId"/> + <order-by field-name="sequenceNum"/> + </entity-and> + <iterate list-name="productStoreFacilities" entry-name="productStoreFacility"> + <!-- in this case quantityNotReserved will always be empty until it finds a facility it can totally reserve from, then it will be 0.0 and we are done --> + <if-empty field="storeFound"> + <!-- TODO: must entire quantity be available in one location? --> + <!-- Right now the answer is yes, it only succeeds if one facility has sufficient inventory for the order. --> + <set from-field="parameters.productId" field="callServiceMap.productId"/> + <set from-field="productStoreFacility.facilityId" field="callServiceMap.facilityId"/> + <log level="info" message="ProductStoreService:In productStoreFacilities loop: [${parameters.facilityId}]"/> + <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + <clear-field field-name="callServiceMap"/> + + <if-compare-field field="availableToPromiseTotal" to-field="parameters.quantity" operator="greater-equals" type="Double"> + <set field="storeFound" from-field="productStoreFacility"/> + </if-compare-field> + <clear-field field-name="availableToPromiseTotal"/> + </if-empty> + </iterate> + + <!-- didn't find anything? Take the first facility from list --> + <if-empty field="storeFound"> + <first-from-list list-name="productStoreFacilities" entry-name="storeFound"/> + </if-empty> + <set from-field="storeFound.facilityId" field="facilityId" default-value=""/> + <set-service-fields map-name="parameters" to-map-name="callServiceMap" service-name="reserveProductInventoryByFacility"/> + <set from-field="facilityId" field="callServiceMap.facilityId"/> + <set from-field="requireInventory" field="callServiceMap.requireInventory"/> + <set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/> + <call-service service-name="reserveProductInventoryByFacility" in-map-name="callServiceMap"> + <result-to-field result-name="quantityNotReserved"/> + </call-service> + <log level="info" message="Inventory IS reserved in facility with id [${storeFound.facilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> </else> </if-compare> <else> <entity-and entity-name="ProductStoreFacility" list-name="productStoreFacilities" use-cache="true"> <field-map env-name="productStore.productStoreId" field-name="productStoreId"/> + <field-map env-name="facilityId" field-name="facilityId"/> <order-by field-name="sequenceNum"/> </entity-and> - <iterate list-name="productStoreFacilities" entry-name="productStoreFacility"> - <!-- in this case quantityNotReserved will always be empty until it finds a facility it can totally reserve from, then it will be 0.0 and we are done --> - <if-empty field="storeFound"> - <!-- TODO: must entire quantity be available in one location? --> - <!-- Right now the answer is yes, it only succeeds if one facility has sufficient inventory for the order. --> - <set from-field="parameters.productId" field="callServiceMap.productId"/> - <set from-field="productStoreFacility.facilityId" field="callServiceMap.facilityId"/> - <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> - <result-to-field result-name="availableToPromiseTotal"/> - </call-service> - <clear-field field-name="callServiceMap"/> - - <if-compare-field field="availableToPromiseTotal" to-field="parameters.quantity" operator="greater-equals" type="Double"> - <set field="storeFound" from-field="productStoreFacility"/> - </if-compare-field> - <clear-field field-name="availableToPromiseTotal"/> - </if-empty> + <!-- Search Product Store Facilities to insure the facility passed in is associated to the Product Store passed in --> + <set field="facilityFound" from-field="productStoreFacility"/> + <log level="info" message="ProductStoreService:Facility Found : [${facilityFound}]"/> </iterate> - <!-- didn't find anything? Take the first facility from list --> - <if-empty field="storeFound"> - <first-from-list list-name="productStoreFacilities" entry-name="storeFound"/> + <if-empty field="facilityFound"> + <add-error><fail-message message="Facility with id ${parameters.facilityId} is not associated to ProductStore with id ${parameters.productStoreId}, not reserving inventory."/></add-error> + <check-errors/> </if-empty> <set-service-fields map-name="parameters" to-map-name="callServiceMap" service-name="reserveProductInventoryByFacility"/> - <set from-field="storeFound.facilityId" field="callServiceMap.facilityId"/> + <set from-field="facilityId" field="callServiceMap.facilityId"/> <set from-field="requireInventory" field="callServiceMap.requireInventory"/> <set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/> <call-service service-name="reserveProductInventoryByFacility" in-map-name="callServiceMap"> <result-to-field result-name="quantityNotReserved"/> </call-service> - <log level="info" message="Inventory IS reserved in facility with id [${storeFound.facilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> - </else> - </if-compare> - + <if-compare value="0" field="quantityNotReserved" operator="equals" type="Double"> + <log level="info" message="Inventory IS reserved in facility with id [${facilityId}] for product id [${parameters.productId}]; desired quantity was ${parameters.quantity}"/> + <else> + <log level="info" message="There is insufficient inventory available in facility with id [${facilityId}] for product id [${parameters.productId}]; desired quantity is ${parameters.quantity}, amount could not reserve is ${quantityNotReserved}"/> + </else> + </if-compare> + </else> + </if-empty> <field-to-result field-name="quantityNotReserved"/> </simple-method> Modified: ofbiz/trunk/applications/product/servicedef/services_store.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_store.xml?rev=688993&r1=688992&r2=688993&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_store.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_store.xml Tue Aug 26 01:30:05 2008 @@ -44,6 +44,7 @@ <description>Reserve Inventory in a Product Store</description> <attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute> <attribute name="productId" type="String" mode="IN" optional="false"></attribute> + <attribute name="facilityId" type="String" mode="IN" optional="true"></attribute> <attribute name="quantity" type="Double" mode="IN" optional="false"></attribute> <attribute name="orderId" type="String" mode="IN" optional="true"></attribute> <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"></attribute> |
Free forum by Nabble | Edit this page |