Author: jacopoc
Date: Fri Dec 17 08:02:36 2010
New Revision: 1050304

URL: http://svn.apache.org/viewvc?rev=1050304&view=rev
Log:
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/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=1050304&r1=1050303&r2=1050304&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
 Fri Dec 17 08:02:36 2010
@@ -43,6 +43,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.ServiceUtil;
 
@@ -314,9 +315,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