Author: jleroux
Date: Wed Sep 19 00:00:12 2007 New Revision: 577172 URL: http://svn.apache.org/viewvc?rev=577172&view=rev Log: Applied fix from trunk for revision: 566369 Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java ofbiz/branches/release4.0/applications/order/webapp/ordermgr/requirement/RequirementForms.xml Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=577172&r1=577171&r2=577172&view=diff ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Wed Sep 19 00:00:12 2007 @@ -2260,27 +2260,21 @@ // set as the default shipping location the first from the list of available shipping locations String companyId = this.getBillToCustomerPartyId(); if (companyId != null) { - try { - List facilities = delegator.findByAndCache("Facility", UtilMisc.toMap("ownerPartyId", companyId)); - // TODO: improve code here to select the best ship to facility (from requirements?); - // for now, we consider the first one - GenericValue facility = EntityUtil.getFirst(facilities); - if (facility != null) { - List facilityContactMechValueMaps = ContactMechWorker.getFacilityContactMechValueMaps(delegator, facility.getString("facilityId"), false, null); - if (facilityContactMechValueMaps != null) { - Iterator facilityContactMechValueMapsIt = facilityContactMechValueMaps.iterator(); - while (facilityContactMechValueMapsIt.hasNext()) { - Map facilityContactMechValueMap = (Map)facilityContactMechValueMapsIt.next(); - if (facilityContactMechValueMap.get("postalAddress") != null) { - GenericValue postalAddress = (GenericValue)facilityContactMechValueMap.get("postalAddress"); - this.setShippingContactMechId(0, postalAddress.getString("contactMechId")); - break; - } + // the facilityId should be set prior to triggering default options, otherwise we do not set up facility information + String defaultFacilityId = getFacilityId(); + if (defaultFacilityId != null) { + List facilityContactMechValueMaps = ContactMechWorker.getFacilityContactMechValueMaps(delegator, defaultFacilityId, false, null); + if (facilityContactMechValueMaps != null) { + Iterator facilityContactMechValueMapsIt = facilityContactMechValueMaps.iterator(); + while (facilityContactMechValueMapsIt.hasNext()) { + Map facilityContactMechValueMap = (Map)facilityContactMechValueMapsIt.next(); + if (facilityContactMechValueMap.get("postalAddress") != null) { + GenericValue postalAddress = (GenericValue)facilityContactMechValueMap.get("postalAddress"); + this.setShippingContactMechId(0, postalAddress.getString("contactMechId")); + break; } } } - } catch (GenericEntityException e) { - Debug.logError(e, "Error setting shippingContactMechId in setDefaultCheckoutOptions() method.", module); } } // shipping options Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=577172&r1=577171&r2=577172&view=diff ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Wed Sep 19 00:00:12 2007 @@ -408,6 +408,12 @@ } catch (NumberFormatException e) { //throw new EventHandlerException("Invalid value for _rowCount"); } + + // assume that the facility is the same for all requirements + String facilityId = (String) context.get("facilityId_o_0"); + if (UtilValidate.isNotEmpty(facilityId)) { + cart.setFacilityId(facilityId); + } // now loop throw the rows and prepare/invoke the service for each for (int i = 0; i < rowCount; i++) { Modified: ofbiz/branches/release4.0/applications/order/webapp/ordermgr/requirement/RequirementForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/webapp/ordermgr/requirement/RequirementForms.xml?rev=577172&r1=577171&r2=577172&view=diff ============================================================================== --- ofbiz/branches/release4.0/applications/order/webapp/ordermgr/requirement/RequirementForms.xml (original) +++ ofbiz/branches/release4.0/applications/order/webapp/ordermgr/requirement/RequirementForms.xml Wed Sep 19 00:00:12 2007 @@ -293,6 +293,7 @@ <field name="productId" widget-style="buttontext"> <hyperlink also-hidden="true" target-type="inter-app" description="${productId}" target="/catalog/control/EditProductInventoryItems?productId=${productId}" target-window="top"/> </field> + <field name="facilityId"><hidden value="${parameters.facilityId}"/></field> <field name="internalName" entry-name="productId"> <display-entity entity-name="Product" key-field-name="productId" description="${internalName}"/> </field> |
Free forum by Nabble | Edit this page |