Author: lektran
Date: Fri Jul 18 05:18:51 2008 New Revision: 677885 URL: http://svn.apache.org/viewvc?rev=677885&view=rev Log: * Added a new method to ContactMechWorker to make it easier to get a valid facility contact mech, changed the code in few places to use it * A few more bsh -> groovy conversions * Fixed a couple of bugs related to the return pdf template Added: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy - copied, changed from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy - copied, changed from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy - copied, changed from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy - copied, changed from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy - copied, changed from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh Removed: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl ofbiz/trunk/applications/order/webapp/ordermgr/return/returnReportHeaderInfo.fo.ftl ofbiz/trunk/applications/order/widget/ordermgr/OrderPrintScreens.xml ofbiz/trunk/applications/order/widget/ordermgr/OrderReturnScreens.xml ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java 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=677885&r1=677884&r2=677885&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 Fri Jul 18 05:18:51 2008 @@ -51,6 +51,7 @@ import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; import org.ofbiz.order.shoppingcart.shipping.ShippingEvents; import org.ofbiz.party.contact.ContactHelper; +import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.party.party.PartyWorker; import org.ofbiz.product.product.ProductWorker; import org.ofbiz.product.store.ProductStoreWorker; @@ -1450,19 +1451,11 @@ // face-to-face order; use the facility address String facilityId = orderHeader.getString("originFacilityId"); if (facilityId != null) { - List fcp = null; - try { - fcp = delegator.findByAnd("FacilityContactMechPurpose", UtilMisc.toMap("facilityId", - facilityId, "contactMechPurposeTypeId", "SHIP_ORIG_LOCATION")); - } catch (GenericEntityException e) { - Debug.logError(e, module); - } - fcp = EntityUtil.filterByDate(fcp); - GenericValue purp = EntityUtil.getFirst(fcp); - if (purp != null) { + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { try { shippingAddress = delegator.findByPrimaryKey("PostalAddress", - UtilMisc.toMap("contactMechId", purp.getString("contactMechId"))); + UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); } catch (GenericEntityException e) { Debug.logError(e, module); } 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=677885&r1=677884&r2=677885&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 Fri Jul 18 05:18:51 2008 @@ -2399,17 +2399,9 @@ // 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; - } - } + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIPPING_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { + this.setShippingContactMechId(0, facilityContactMech.getString("contactMechId")); } } } Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy (from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh&r1=677210&r2=677885&rev=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy Fri Jul 18 05:18:51 2008 @@ -17,11 +17,9 @@ * under the License. */ -import org.ofbiz.base.util.UtilMisc; - -prepare = dispatcher.runSync("prepareFind", UtilMisc.toMap("inputFields", parameters, "entityName", "Requirement")); -if (prepare.get("entityConditionList") != null) { - results = dispatcher.runSync("getRequirementsForSupplier", UtilMisc.toMap("requirementConditions", prepare.get("entityConditionList"), "partyId", parameters.get("partyId"))); - context.put("requirementsForSupplier", results.get("requirementsForSupplier")); - context.put("quantityReport", UtilMisc.toMap("distinctProductCount", results.get("distinctProductCount"), "quantityTotal", results.get("quantityTotal"), "amountTotal", results.get("amountTotal"))); +prepare = dispatcher.runSync("prepareFind", [inputFields : parameters, entityName : "Requirement"]); +if (prepare.entityConditionList) { + results = dispatcher.runSync("getRequirementsForSupplier", [requirementConditions : prepare.entityConditionList, partyId : parameters.partyId]); + context.requirementsForSupplier = results.requirementsForSupplier; + context.quantityReport = [distinctProductCount : results.distinctProductCount, quantityTotal : results.quantityTotal, amountTotal : results.amountTotal]; } Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy (from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh&r1=677210&r2=677885&rev=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy Fri Jul 18 05:18:51 2008 @@ -29,16 +29,14 @@ import org.ofbiz.entity.util.*; import org.ofbiz.entity.condition.*; -delegator = request.getAttribute("delegator"); - -fields = UtilMisc.toSet("partyId", "productId"); +fields = ["partyId", "productId"] as Set; options = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); -orderBy = UtilMisc.toList("partyId"); -conditions = EntityCondition.makeCondition( UtilMisc.toList( +orderBy = ["partyId"]; +conditions = EntityCondition.makeCondition([ EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "SUPPLIER"), EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_APPROVED"), EntityCondition.makeCondition("requirementTypeId", EntityOperator.EQUALS, "PRODUCT_REQUIREMENT"), EntityUtil.getFilterByDateExpr() - ), EntityOperator.AND); + ], EntityOperator.AND); requirements = delegator.find("RequirementPartyProductCount", conditions, null, fields, orderBy, options); -context.put("requirements", requirements); +context.requirements = requirements; Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy (from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh&r1=677210&r2=677885&rev=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy Fri Jul 18 05:18:51 2008 @@ -24,18 +24,16 @@ import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; -Map prepare = dispatcher.runSync("prepareFind", UtilMisc.toMap("inputFields", parameters, "entityName", "Requirement")); -EntityConditionList statusCondition = EntityCondition.makeCondition( - UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_CREATED"), - EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_PROPOSED")), - EntityOperator.OR); -EntityConditionList ecl = null; -if (UtilValidate.isNotEmpty(prepare.get("entityConditionList"))) { - ecl = EntityCondition.makeCondition(UtilMisc.toList((EntityConditionList)prepare.get("entityConditionList"), - statusCondition), - EntityOperator.AND); +prepare = dispatcher.runSync("prepareFind", [inputFields : parameters, entityName : "Requirement"]); +EntityConditionList statusCondition = EntityCondition.makeCondition([ + EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_CREATED"), + EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_PROPOSED")], + EntityOperator.OR); +ecl = null; +if (prepare.entityConditionList) { + ecl = EntityCondition.makeCondition(prepare.entityConditionList, statusCondition), EntityOperator.AND); } else { ecl = statusCondition; } -results = dispatcher.runSync("executeFind", UtilMisc.toMap("entityConditionList", ecl, "entityName", "Requirement")); -context.put("requirements", results.get("listIt")); +results = dispatcher.runSync("executeFind", [entityConditionList : ecl, entityName : "Requirement"]); +context.requirements = results.listIt; Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy (from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh&r1=677210&r2=677885&rev=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy Fri Jul 18 05:18:51 2008 @@ -24,74 +24,68 @@ import org.ofbiz.party.contact.*; import org.ofbiz.product.store.*; -dispatcher = request.getAttribute("dispatcher"); -delegator = request.getAttribute("delegator"); -orderId = request.getParameter("orderId"); -context.put("orderId", orderId); - -partyId = request.getParameter("party_id"); -context.put("partyId", partyId); - -if (partyId != null) { - party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); - context.put("party", party); +orderId = parameters.orderId; +context.orderId = orderId; + +partyId = parameters.party_id; +context.partyId = partyId; + +if (partyId) { + party = delegator.findByPrimaryKey("Party", [partyId : partyId]); + context.party = party; } -returnHeaders = delegator.findByAnd("ReturnHeader", UtilMisc.toMap("statusId", "RETURN_REQUESTED"), UtilMisc.toList("entryDate")); -context.put("returnHeaders", returnHeaders); +returnHeaders = delegator.findByAnd("ReturnHeader", [statusId : "RETURN_REQUESTED"], ["entryDate"]); +context.returnHeaders = returnHeaders; // put in the return to party information from the order header -if (orderId != null) { - order = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); +if (orderId) { + order = delegator.findByPrimaryKey("OrderHeader", [orderId : orderId]); productStore = order.getRelatedOne("ProductStore"); - if (productStore != null) { - context.put("destinationFacilityId", ProductStoreWorker.determineSingleFacilityForStore(delegator, productStore.getString("productStoreId"))); + if (productStore) { + context.destinationFacilityId = ProductStoreWorker.determineSingleFacilityForStore(delegator, productStore.productStoreId); } orh = new OrderReadHelper(order); - context.put("orh", orh); - context.put("toPartyId", productStore.getString("payToPartyId")); - context.put("orderHeaderAdjustments", orh.getAvailableOrderHeaderAdjustments()); + context.orh = orh; + context.toPartyId = productStore.payToPartyId; + context.orderHeaderAdjustments = orh.getAvailableOrderHeaderAdjustments(); } // payment method info -if (partyId != null) { - List creditCardList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndCreditCard", UtilMisc.toMap("partyId", partyId))); - if (UtilValidate.isNotEmpty(creditCardList)) { - context.put("creditCardList", creditCardList); +if (partyId) { + creditCardList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndCreditCard", [partyId : partyId])); + if (creditCardList) { + context.creditCardList = creditCardList; } - List eftAccountList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndEftAccount", UtilMisc.toMap("partyId", partyId))); - if (UtilValidate.isNotEmpty(eftAccountList)) { - context.put("eftAccountList", eftAccountList); + eftAccountList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndEftAccount", [partyId : partyId])); + if (eftAccountList) { + context.eftAccountList = eftAccountList; } } -returnTypes = delegator.findList("ReturnType", null, null, UtilMisc.toList("sequenceId"), null, false); -context.put("returnTypes", returnTypes); +returnTypes = delegator.findList("ReturnType", null, null, ["sequenceId"], null, false); +context.returnTypes = returnTypes; -returnReasons = delegator.findList("ReturnReason", null, null, UtilMisc.toList("sequenceId"), null, false); -context.put("returnReasons", returnReasons); +returnReasons = delegator.findList("ReturnReason", null, null, ["sequenceId"], null, false); +context.returnReasons = returnReasons; -itemStts = delegator.findByAnd("StatusItem", UtilMisc.toMap("statusTypeId", "INV_SERIALIZED_STTS"), UtilMisc.toList("sequenceId")); -context.put("itemStts", itemStts); +itemStts = delegator.findByAnd("StatusItem", [statusTypeId : "INV_SERIALIZED_STTS"], ["sequenceId"]); +context.itemStts = itemStts; -returnItemTypeMap = delegator.findByAnd("ReturnItemTypeMap", UtilMisc.toMap("returnHeaderTypeId", "CUSTOMER_RETURN")); -iter = returnItemTypeMap.iterator(); -typeMap = new HashMap(); -while (iter.hasNext()) { - value = iter.next(); - typeMap.put(value.getString("returnItemMapKey"), value.getString("returnItemTypeId")); +typeMap = [:]; +returnItemTypeMap = delegator.findByAnd("ReturnItemTypeMap", [returnHeaderTypeId : "CUSTOMER_RETURN"]); +returnItemTypeMap.each { value -> + typeMap[value.returnItemMapKey] = value.returnItemTypeId; } -context.put("returnItemTypeMap", typeMap); +context.returnItemTypeMap = typeMap; -if (orderId != null) { - Map returnRes = dispatcher.runSync("getReturnableItems", UtilMisc.toMap("orderId", orderId)); - context.put("returnableItems", returnRes.get("returnableItems")); - orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", UtilMisc.toMap("orderId", orderId)); - context.put("orderHeader", orderHeader); +if (orderId) { + returnRes = dispatcher.runSync("getReturnableItems", [orderId : orderId]); + context.returnableItems = returnRes.returnableItems; + orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", [orderId : orderId]); + context.orderHeader = orderHeader; } -context.put("shippingContactMechList", ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false)); - - +context.shippingContactMechList = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false); Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy (from r677210, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh&r1=677210&r2=677885&rev=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy Fri Jul 18 05:18:51 2008 @@ -28,64 +28,53 @@ returnId = parameters.get("returnId"); returnHeader = null; -if (returnId != null) { - returnHeader = delegator.findByPrimaryKey("ReturnHeader", UtilMisc.toMap("returnId", returnId)); - if (returnHeader != null) { - partyId = returnHeader.getString("fromPartyId"); - toPartyId = parameters.get("toPartyId"); +if (returnId) { + returnHeader = delegator.findByPrimaryKey("ReturnHeader", [returnId : returnId]); + if (returnHeader) { + partyId = returnHeader.fromPartyId; + toPartyId = parameters.toPartyId; + + context.currentStatus = returnHeader.getRelatedOneCache("StatusItem"); } } -context.put("returnHeader", returnHeader); -context.put("returnId", returnId); +context.returnHeader = returnHeader; +context.returnId = returnId; // billing account info billingAccountList = null; -if (partyId != null) { - billingAccountList = delegator.findByAnd("BillingAccountAndRole", UtilMisc.toMap("partyId", partyId)); +if (partyId) { + billingAccountList = delegator.findByAnd("BillingAccountAndRole", [partyId : partyId]); billingAccountList = EntityUtil.filterByDate(billingAccountList); } -context.put("billingAccountList", billingAccountList); +context.billingAccountList = billingAccountList; // payment method info List creditCardList = null; List eftAccountList = null; -if (partyId != null) { - creditCardList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndCreditCard", UtilMisc.toMap("partyId", partyId))); - eftAccountList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndEftAccount", UtilMisc.toMap("partyId", partyId))); +if (partyId) { + creditCardList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndCreditCard", [partyId : partyId])); + eftAccountList = EntityUtil.filterByDate(delegator.findByAnd("PaymentMethodAndEftAccount", [partyId : partyId])); } -context.put("creditCardList", creditCardList); -context.put("eftAccountList", eftAccountList); +context.creditCardList = creditCardList; +context.eftAccountList = eftAccountList; orderRole = null; orderHeader = null; -if (orderId != null) { - orderRoles = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_TO_CUSTOMER")); +if (orderId) { + orderRoles = delegator.findByAnd("OrderRole", [orderId : orderId, roleTypeId : "BILL_TO_CUSTOMER"]); orderRole = EntityUtil.getFirst(orderRoles); - orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", UtilMisc.toMap("orderId", orderId)); + orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", [orderId : orderId]); } -context.put("orderRole", orderRole); -context.put("orderHeader", orderHeader); +context.orderRole = orderRole; +context.orderHeader = orderHeader; // from address addresses = ContactMechWorker.getPartyPostalAddresses(request, partyId, "_NA_"); -context.put("addresses", addresses); +context.addresses = addresses; -if (returnHeader != null) { - postalAddressTo = null; - facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", returnHeader.getString("destinationFacilityId"))); - if (facility != null) { - facilityContactMechs = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facility.getString("facilityId")), UtilMisc.toList("fromDate DESC")); - - facilityContactMechIterator = facilityContactMechs.iterator(); - while (facilityContactMechIterator.hasNext()) { - facilityContactMech = facilityContactMechIterator.next(); - contactMech = facilityContactMech.getRelatedOne("ContactMech"); - if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) { - postalAddressTo = contactMech.getRelatedOne("PostalAddress"); - break; - } - } - } - context.put("postalAddressTo", postalAddressTo); +if (returnHeader) { + contactMechTo = ContactMechWorker.getFacilityContactMechByPurpose(delegator, returnHeader.destinationFacilityId, ["PUR_RET_LOCATION", "SHIPPING_LOCATION", "PRIMARY_LOCATION"]); + postalAddressTo = delegator.findOne("PostalAddress", [contactMechId : contactMechTo.contactMechId], true); + context.postalAddressTo = postalAddressTo; } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/return/returnItemInc.ftl Fri Jul 18 05:18:51 2008 @@ -59,7 +59,7 @@ <#assign rowCount = 0> <#assign alt_row = false> <#list returnableItems.keySet() as orderItem> - <#if orderItem.orderAdjustmentId?has_content> + <#if orderItem.getEntityName() == "OrderAdjustment"> <#-- this is an order item adjustment --> <#assign returnAdjustmentType = returnItemTypeMap.get(orderItem.get("orderAdjustmentTypeId"))/> <#assign adjustmentType = orderItem.getRelatedOne("OrderAdjustmentType")/> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/return/returnReportHeaderInfo.fo.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/return/returnReportHeaderInfo.fo.ftl?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/return/returnReportHeaderInfo.fo.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/return/returnReportHeaderInfo.fo.ftl Fri Jul 18 05:18:51 2008 @@ -44,7 +44,7 @@ <fo:table-row> <fo:table-cell text-align="center" border-style="solid" border-width="0.2pt"> - <fo:block padding="1mm">${entryDate?string("yyyy-MM-dd")}</fo:block> + <fo:block padding="1mm">${returnHeader.entryDate?string("yyyy-MM-dd")}</fo:block> </fo:table-cell> <fo:table-cell text-align="center" border-style="solid" border-width="0.2pt"> <fo:block padding="1mm">${returnId}</fo:block> Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderPrintScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderPrintScreens.xml?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/OrderPrintScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/OrderPrintScreens.xml Fri Jul 18 05:18:51 2008 @@ -93,7 +93,7 @@ <property-map resource="OrderUiLabels" map-name="uiLabelMap" global="true"/> <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy"/> <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/returnItems.bsh"/> </actions> <widgets> Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderReturnScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderReturnScreens.xml?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/OrderReturnScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/OrderReturnScreens.xml Fri Jul 18 05:18:51 2008 @@ -77,7 +77,7 @@ <actions> <set field="titleProperty" value="PageTitleFindQuickReturn"/> <set field="headerItem" value="return"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/quickReturn.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/QuickReturn.groovy"/> </actions> <widgets> <decorator-screen name="CommonOrderReturnDecorator"> @@ -112,7 +112,7 @@ <set field="headerItem" value="return"/> <set field="tabButtonItem" value="OrderReturnHeader"/> <property-to-field field="defaultCurrencyUomId" resource="general" property="currency.uom.id.default" default="USD"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/returnHeader.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/return/ReturnHeader.groovy"/> </actions> <widgets> <decorator-screen name="CommonOrderReturnDecorator"> Modified: ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/RequirementScreens.xml Fri Jul 18 05:18:51 2008 @@ -131,7 +131,7 @@ <set field="tabButtonItem" value="ApproveRequirements"/> <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/> <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/selectCreatedProposed.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/SelectCreatedProposed.groovy"/> </actions> <widgets> <decorator-screen name="CommonRequirementsDecorator"> @@ -178,7 +178,7 @@ <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/> <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/> <set field="_rowSubmit" value="Y"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirements.groovy"/> </actions> <widgets> <decorator-screen name="CommonRequirementsDecorator"> @@ -282,7 +282,7 @@ <set field="tabButtonItem" value="ApprovedProductRequirementsByVendor"/> <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/> <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/requirement/ApprovedProductRequirementsByVendor.groovy"/> </actions> <widgets> <decorator-screen name="CommonRequirementsDecorator"> Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Fri Jul 18 05:18:51 2008 @@ -39,6 +39,8 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.util.EntityUtil; /** @@ -484,6 +486,55 @@ } } + /** Returns the first valid FacilityContactMech found based on the given facilityId and a prioritized list of purposes + * @param delegator + * @param facilityId + * @param purposeTypes A List of ContactMechPurposeType ids which will be checked one at a time until a valid contact mech is found + * @return + */ + public static GenericValue getFacilityContactMechByPurpose(GenericDelegator delegator, String facilityId, List purposeTypes) { + if (UtilValidate.isEmpty(facilityId)) return null; + if (UtilValidate.isEmpty(purposeTypes)) return null; + + Iterator ptIt = purposeTypes.iterator(); + while (ptIt.hasNext()) { + String purposeType = (String) ptIt.next(); + + List facilityContactMechPurposes = null; + List conditionList = FastList.newInstance(); + conditionList.add(EntityCondition.makeCondition("facilityId", facilityId)); + conditionList.add(EntityCondition.makeCondition("contactMechPurposeTypeId", purposeType)); + conditionList.add(EntityCondition.makeConditionDate("fromDate", "thruDate")); + EntityCondition entityCondition = EntityCondition.makeCondition(conditionList); + try { + facilityContactMechPurposes = delegator.findList("FacilityContactMechPurpose", entityCondition, null, UtilMisc.toList("-fromDate"), null, true); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + Iterator fcmpIt = facilityContactMechPurposes.iterator(); + while (fcmpIt.hasNext()) { + GenericValue facilityContactMechPurpose = (GenericValue) fcmpIt.next(); + String contactMechId = facilityContactMechPurpose.getString("contactMechId"); + List facilityContactMechs = null; + conditionList = FastList.newInstance(); + conditionList.add(EntityCondition.makeCondition("facilityId", facilityId)); + conditionList.add(EntityCondition.makeCondition("contactMechId", contactMechId)); + conditionList.add(EntityCondition.makeConditionDate("fromDate", "thruDate")); + entityCondition = EntityCondition.makeCondition(conditionList); + try { + facilityContactMechs = delegator.findList("FacilityContactMech", entityCondition, null, UtilMisc.toList("-fromDate"), null, true); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + if (UtilValidate.isNotEmpty(facilityContactMechs)) { + return EntityUtil.getFirst(facilityContactMechs); + } + } + + } + return null; + } + public static void getFacilityContactMechAndRelated(ServletRequest request, String facilityId, Map target) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml Fri Jul 18 05:18:51 2008 @@ -582,42 +582,46 @@ <string-to-list string="-fromDate" list-name="descendingFromDateOrder"/> <if-not-empty field="shipment.originFacilityId"> <if-empty field="shipment.originContactMechId"> - <set from-field="shipment.originFacilityId" field="findFcmpMap.facilityId"/> - <set value="SHIP_ORIG_LOCATION" field="findFcmpMap.contactMechPurposeTypeId"/> - <find-by-and entity-name="FacilityContactMechPurpose" map-name="findFcmpMap" order-by-list-name="descendingFromDateOrder" list-name="facilityContactMechPurposes"/> - <filter-list-by-date list-name="facilityContactMechPurposes"/> - <first-from-list entry-name="facilityContactMechPurpose" list-name="facilityContactMechPurposes"/> - <set from-field="facilityContactMechPurpose.contactMechId" field="shipment.originContactMechId"/> + <call-bsh><![CDATA[ + facilityContactMech = org.ofbiz.party.contact.ContactMechWorker.getFacilityContactMechByPurpose( + delegator, shipment.get("originFacilityId"), org.ofbiz.base.util.UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION") + ); + if (facilityContactMech != null) { + shipment.put("originContactMechId", facilityContactMech.get("contactMechId"); + } + ]]></call-bsh> </if-empty> <if-empty field="shipment.originTelecomNumberId"> - <set from-field="shipment.originFacilityId" field="findFcmpMap.facilityId"/> - <set value="PHONE_SHIP_ORIG" field="findFcmpMap.contactMechPurposeTypeId"/> - <find-by-and entity-name="FacilityContactMechPurpose" map-name="findFcmpMap" order-by-list-name="descendingFromDateOrder" list-name="facilityContactMechPurposes"/> - <filter-list-by-date list-name="facilityContactMechPurposes"/> - <first-from-list entry-name="facilityContactMechPurpose" list-name="facilityContactMechPurposes"/> - <set from-field="facilityContactMechPurpose.contactMechId" field="shipment.originTelecomNumberId"/> + <call-bsh><![CDATA[ + facilityContactMech = org.ofbiz.party.contact.ContactMechWorker.getFacilityContactMechByPurpose( + delegator, shipment.get("originFacilityId"), org.ofbiz.base.util.UtilMisc.toList("PHONE_SHIP_ORIG", "PRIMARY_PHONE") + ); + if (facilityContactMech != null) { + shipment.put("originTelecomNumberId", facilityContactMech.get("contactMechId"); + } + ]]></call-bsh> </if-empty> </if-not-empty> <if-not-empty field="shipment.destinationFacilityId"> <if-empty field="shipment.destinationContactMechId"> - <set from-field="shipment.destinationFacilityId" field="findFcmpMap.facilityId"/> - <set value="SHIPPING_LOCATION" field="findFcmpMap.contactMechPurposeTypeId"/> - <find-by-and entity-name="FacilityContactMechPurpose" map-name="findFcmpMap" order-by-list-name="descendingFromDateOrder" list-name="facilityContactMechPurposes"/> - <filter-list-by-date list-name="facilityContactMechPurposes"/> - <first-from-list entry-name="facilityContactMechPurpose" list-name="facilityContactMechPurposes"/> - <set from-field="facilityContactMechPurpose.contactMechId" field="shipment.destinationContactMechId"/> + <call-bsh><![CDATA[ + facilityContactMech = org.ofbiz.party.contact.ContactMechWorker.getFacilityContactMechByPurpose( + delegator, shipment.get("destinationFacilityId"), org.ofbiz.base.util.UtilMisc.toList("SHIPPING_LOCATION", "PRIMARY_LOCATION") + ); + if (facilityContactMech != null) { + shipment.put("destinationContactMechId", facilityContactMech.get("contactMechId"); + } + ]]></call-bsh> </if-empty> <if-empty field="shipment.destinationTelecomNumberId"> - <set from-field="shipment.destinationFacilityId" field="findFcmpMap.facilityId"/> - <set value="PHONE_SHIPPING" field="findFcmpMap.contactMechPurposeTypeId"/> - <find-by-and entity-name="FacilityContactMechPurpose" map-name="findFcmpMap" order-by-list-name="descendingFromDateOrder" list-name="facilityContactMechPurposes"/> - <filter-list-by-date list-name="facilityContactMechPurposes"/> - <!-- This check is necessary or some random contactMechId might be filled in by minilang, possibly from another call earlier, if facilityContactMechPurpoess is indeed null. - It should probably be implemented for all of the above but I have not had a chance to test it. (Si) --> - <if-not-empty field="facilityContactMechPurposes"> - <first-from-list entry-name="facilityContactMechPurpose" list-name="facilityContactMechPurposes"/> - <set from-field="facilityContactMechPurpose.contactMechId" field="shipment.destinationTelecomNumberId"/> - </if-not-empty> + <call-bsh><![CDATA[ + facilityContactMech = org.ofbiz.party.contact.ContactMechWorker.getFacilityContactMechByPurpose( + delegator, shipment.get("destinationFacilityId"), org.ofbiz.base.util.UtilMisc.toList("PHONE_SHIPPING", "PRIMARY_PHONE") + ); + if (facilityContactMech != null) { + shipment.put("destinationTelecomNumberId", facilityContactMech.get("contactMechId"); + } + ]]></call-bsh> </if-empty> </if-not-empty> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java Fri Jul 18 05:18:51 2008 @@ -51,6 +51,7 @@ import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -1955,23 +1956,12 @@ // locate the ship-from address based on the product store's default facility GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator); if (productStore != null && productStore.get("inventoryFacilityId") != null) { - List shipLocs = null; - try { - shipLocs = delegator.findByAnd("FacilityContactMechPurpose", UtilMisc.toMap("facilityId", - productStore.getString("inventoryFacilityId"), "contactMechPurposeTypeId", - "SHIP_ORIG_LOCATION"), UtilMisc.toList("-fromDate")); - } catch (GenericEntityException e) { - Debug.logError(e, module); - } - if (shipLocs != null) { - shipLocs = EntityUtil.filterByDate(shipLocs); - GenericValue purp = EntityUtil.getFirst(shipLocs); - if (purp != null) { - try { - shipFromAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", purp.getString("contactMechId"))); - } catch (GenericEntityException e) { - Debug.logError(e, module); - } + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, productStore.getString("inventoryFacilityId"), UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { + try { + shipFromAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); + } catch (GenericEntityException e) { + Debug.logError(e, module); } } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java Fri Jul 18 05:18:51 2008 @@ -36,6 +36,7 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -72,23 +73,17 @@ String originationZip = null; GenericValue productStore = ProductStoreWorker.getProductStore(((String) context.get("productStoreId")), delegator); if (productStore != null && productStore.get("inventoryFacilityId") != null) { - try { - List shipLocs = delegator.findByAnd("FacilityContactMechPurpose", - UtilMisc.toMap("facilityId", productStore.getString("inventoryFacilityId"), - "contactMechPurposeTypeId", "SHIP_ORIG_LOCATION"), UtilMisc.toList("-fromDate")); - if (UtilValidate.isNotEmpty(shipLocs)) { - shipLocs = EntityUtil.filterByDate(shipLocs); - GenericValue purp = EntityUtil.getFirst(shipLocs); - if (purp != null) { - GenericValue shipFromAddress = delegator.findByPrimaryKey("PostalAddress", - UtilMisc.toMap("contactMechId", purp.getString("contactMechId"))); - if (shipFromAddress != null) { - originationZip = shipFromAddress.getString("postalCode"); - } + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, productStore.getString("inventoryFacilityId"), UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { + try { + GenericValue shipFromAddress = delegator.findByPrimaryKey("PostalAddress", + UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); + if (shipFromAddress != null) { + originationZip = shipFromAddress.getString("postalCode"); } + } catch (GenericEntityException e) { + Debug.logError(e, module); } - } catch (GenericEntityException e) { - Debug.logError(e, module); } } if (UtilValidate.isEmpty(originationZip)) { Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?rev=677885&r1=677884&r2=677885&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Fri Jul 18 05:18:51 2008 @@ -53,6 +53,7 @@ import org.ofbiz.order.shoppingcart.ShoppingCart; import org.ofbiz.order.shoppingcart.ShoppingCartItem; import org.ofbiz.order.shoppinglist.ShoppingListEvents; +import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.pos.component.Journal; import org.ofbiz.pos.component.Output; import org.ofbiz.pos.device.DeviceLoader; @@ -865,19 +866,13 @@ if (facility == null) { return null; } - - List fcp = null; - try { - fcp = facility.getRelatedByAnd("FacilityContactMechPurpose", UtilMisc.toMap("contactMechPurposeTypeId", "SHIP_ORIG_LOCATION")); - } catch (GenericEntityException e) { - Debug.logError(e, module); - } - fcp = EntityUtil.filterByDate(fcp); - GenericValue purp = EntityUtil.getFirst(fcp); - if (purp != null) { + + GenericDelegator delegator = session.getDelegator(); + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { try { this.shipAddress = session.getDelegator().findByPrimaryKey("PostalAddress", - UtilMisc.toMap("contactMechId", purp.getString("contactMechId"))); + UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); } catch (GenericEntityException e) { Debug.logError(e, module); } |
Free forum by Nabble | Edit this page |