svn commit: r566719 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r566719 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

jonesde
Author: jonesde
Date: Thu Aug 16 06:50:38 2007
New Revision: 566719

URL: http://svn.apache.org/viewvc?view=rev&rev=566719
Log:
Some changes to more robustly get an address for recalculating tax, AND made it optional so that if there is no address (which we technically allow in OFBiz) it won't blow up but instead just won't recalculate tax; note that orders in that category generally don't have tax in the first place; this was reported in Jira #OFBIZ-1198; also added note for handling face-to-face or immediately fulfilled orders, which would also be applicable for rental orders... ie that special case needs to be identified by appropriate criteria and handled as needed here in the OrderServices.recalcOrderTax method AND in the related method that works on the cart when an order is placed, namely CheckOutHelper.makeTaxContext

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.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?view=diff&rev=566719&r1=566718&r2=566719
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Thu Aug 16 06:50:38 2007
@@ -1344,6 +1344,16 @@
                     }
 
                     GenericValue shippingAddress = orh.getShippingAddress(shipGroupSeqId);
+                    // no shipping address, try the billing address
+                    if (shippingAddress == null) {
+                        List billingAddressList = orh.getBillingLocations();
+                        if (billingAddressList.size() > 0) {
+                            shippingAddress = (GenericValue) billingAddressList.get(0);
+                        }
+                    }
+                    
+                    // TODO and NOTE DEJ20070816: this is NOT a good way to determine if this is a face-to-face or immediatelyFulfilled order
+                    //this should be made consistent with the CheckOutHelper.makeTaxContext(int shipGroup, GenericValue shipAddress) method
                     if (shippingAddress == null) {
                         // face-to-face order; use the facility address
                         String facilityId = orderHeader.getString("originFacilityId");
@@ -1368,6 +1378,11 @@
                         }
                     }
 
+                    // 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) {
+                        continue;
+                    }
+                    
                     // prepare the service context
                     // pass in BigDecimal values instead of Double
                     Map serviceContext = UtilMisc.toMap("productStoreId", orh.getProductStoreId(), "itemProductList", products, "itemAmountList", amounts,