Author: jacopoc
Date: Fri Dec 17 08:09:12 2010
New Revision: 1050307

URL: http://svn.apache.org/viewvc?rev=1050307&view=rev
Log:
Backported rev. 1050304: "When tax rates are looked up for a product, if the 
product is a variant, the categories of the virtual are also considered in the 
lookup; this change fixes the issue where taxes are not applied to variant 
products even if they apply to the virtual."


Modified:
    
ofbiz/branches/release10.04/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java

Modified: 
ofbiz/branches/release10.04/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=1050307&r1=1050306&r2=1050307&view=diff
==============================================================================
--- 
ofbiz/branches/release10.04/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
 (original)
+++ 
ofbiz/branches/release10.04/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
 Fri Dec 17 08:09:12 2010
@@ -44,6 +44,7 @@ import org.ofbiz.entity.condition.Entity
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.party.contact.ContactMechWorker;
+import org.ofbiz.product.product.ProductWorker;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -291,9 +292,24 @@ public class TaxAuthorityServices {
             EntityCondition productCategoryCond = null;
             if (product != null) {
                 // find the tax categories associated with the product and 
filter by those, with an IN clause or some such
+                // if this product is variant, find the virtual product id and 
consider also the categories of the virtual
                 // question: get all categories, or just a special type? for 
now let's do all categories...
+                String virtualProductId = null;
+                if ("Y".equals(product.getString("isVariant"))) {
+                    virtualProductId = 
ProductWorker.getVariantVirtualId(product);
+                }
                 Set productCategoryIdSet = FastSet.newInstance();
-                List pcmList = 
delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", 
product.get("productId")));
+                EntityCondition productIdCond = null;
+                if (virtualProductId != null) {
+                    productIdCond = EntityCondition.makeCondition(
+                            EntityCondition.makeCondition("productId", 
EntityOperator.EQUALS, product.getString("productId")),
+                            EntityOperator.OR,
+                            EntityCondition.makeCondition("productId", 
EntityOperator.EQUALS, virtualProductId));
+
+                } else {
+                    productIdCond = EntityCondition.makeCondition("productId", 
EntityOperator.EQUALS, product.getString("productId"));
+                }
+                List pcmList = delegator.findList("ProductCategoryMember", 
productIdCond, UtilMisc.toSet("productCategoryId"), null, null, true);
                 pcmList = EntityUtil.filterByDate(pcmList, true);
                 Iterator pcmIter = pcmList.iterator();
                 while (pcmIter.hasNext()) {


Reply via email to