Author: jonesde
Date: Fri Aug 27 03:20:10 2010 New Revision: 990007 URL: http://svn.apache.org/viewvc?rev=990007&view=rev Log: Related to 990006 the tax calc address code is made more consistent and supported at a lower level by passing in a facilityId when available; this is the order component part and the other commit was the lower level accounting component part Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.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=990007&r1=990006&r2=990007&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 Aug 27 03:20:10 2010 @@ -1529,6 +1529,7 @@ public class OrderServices { // if shippingAddress is still null then don't calculate tax; it may be an situation where no tax is applicable, or the data is bad and we don't have a way to find an address to check tax for if (shippingAddress == null) { + Debug.logWarning("Not calculating tax for Order [" + orderId + "] because there is no shippingAddress, and no address on the origin facility [" + orderHeader.getString("originFacilityId") + "]", module); continue; } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=990007&r1=990006&r2=990007&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Fri Aug 27 03:20:10 2010 @@ -56,6 +56,7 @@ import org.ofbiz.order.shoppingcart.prod import org.ofbiz.order.shoppingcart.shipping.ShippingEvents; import org.ofbiz.order.thirdparty.paypal.ExpressCheckoutEvents; import org.ofbiz.party.contact.ContactHelper; +import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -759,7 +760,7 @@ public class CheckOutHelper { int shipGroups = this.cart.getShipGroupSize(); for (int i = 0; i < shipGroups; i++) { Map<Integer, ShoppingCartItem> shoppingCartItemIndexMap = new HashMap<Integer, ShoppingCartItem>(); - Map<String, Object> serviceContext = this.makeTaxContext(i, shipAddress, shoppingCartItemIndexMap); + Map<String, Object> serviceContext = this.makeTaxContext(i, shipAddress, shoppingCartItemIndexMap, cart.getFacilityId()); List<List<? extends Object>> taxReturn = this.getTaxAdjustments(dispatcher, "calcTax", serviceContext); if (Debug.verboseOn()) Debug.logVerbose("ReturnList: " + taxReturn, module); @@ -786,7 +787,7 @@ public class CheckOutHelper { } } - private Map<String, Object> makeTaxContext(int shipGroup, GenericValue shipAddress, Map<Integer, ShoppingCartItem> shoppingCartItemIndexMap) { + private Map<String, Object> makeTaxContext(int shipGroup, GenericValue shipAddress, Map<Integer, ShoppingCartItem> shoppingCartItemIndexMap, String originFacilityId) { ShoppingCart.CartShipInfo csi = cart.getShipInfo(shipGroup); int totalItems = csi.shipItemInfo.size(); @@ -835,6 +836,26 @@ public class CheckOutHelper { } } + if (shipAddress == null) { + // face-to-face order; use the facility address + if (originFacilityId != null) { + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, originFacilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + if (facilityContactMech != null) { + try { + shipAddress = delegator.findByPrimaryKey("PostalAddress", + UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + } + } + } + + // if shippingAddress is still null then don't calculate tax; it may be an situation where no tax is applicable, or the data is bad and we don't have a way to find an address to check tax for + if (shipAddress == null) { + Debug.logWarning("Not calculating tax for new order because there is no shipping address, no billing address, and no address on the origin facility [" + originFacilityId + "]", module); + } + Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("productStoreId", cart.getProductStoreId()); serviceContext.put("payToPartyId", cart.getBillFromVendorPartyId()); serviceContext.put("billToPartyId", cart.getBillToCustomerPartyId()); |
Free forum by Nabble | Edit this page |