[OFBiz] SVN: r7537 - in trunk/applications/accounting: servicedef src/org/ofbiz/accounting/tax

jacopo@svn.ofbiz.org jacopo at svn.ofbiz.org
Sat May 6 11:37:36 CDT 2006


Author: jacopo
Date: 2006-05-06 11:37:26 -0500 (Sat, 06 May 2006)
New Revision: 7537

Modified:
   trunk/applications/accounting/servicedef/services_tax.xml
   trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
Log:
Added a new optional parameter to the taxCalcInterface service: payToPartyId.
If the parameter is not passed, then the party id is retrieved from the product store (as is now).
This is a small step forward in the attempt to make the calcTax services indipendent from the product store.


Modified: trunk/applications/accounting/servicedef/services_tax.xml
===================================================================
--- trunk/applications/accounting/servicedef/services_tax.xml	2006-05-06 16:02:38 UTC (rev 7536)
+++ trunk/applications/accounting/servicedef/services_tax.xml	2006-05-06 16:37:26 UTC (rev 7537)
@@ -30,7 +30,8 @@
     <!-- Tax Calc Interfaces -->
     <service name="calcTaxInterface" engine="interface" location="" invoke="">
         <description>Tax Calc Service Interface</description>
-        <attribute name="productStoreId" type="String" mode="IN" optional="false"><!-- this will be used to find the payToPartyId, and as one of the columns to constrain by on the lookup --></attribute>
+        <attribute name="productStoreId" type="String" mode="IN" optional="false"><!-- this will be used to find the payToPartyId, if the payToPartyId parameter is not explicitly passed, and as one of the columns to constrain by on the lookup --></attribute>
+        <attribute name="payToPartyId" type="String" mode="IN" optional="true"/>
         <attribute name="billToPartyId" type="String" mode="IN" optional="true"><!-- would like to have this not-optional, but in some circumstances may need a tax estimate without knowing who the customer is --></attribute>
         <attribute name="itemProductList" type="java.util.List" mode="IN" optional="false"><!-- List of GenericValues --></attribute>
         <attribute name="itemAmountList" type="java.util.List" mode="IN" optional="false"><!-- List of BigDecimals --></attribute>

Modified: trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java	2006-05-06 16:02:38 UTC (rev 7536)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java	2006-05-06 16:37:26 UTC (rev 7537)
@@ -103,7 +103,7 @@
                     throw new IllegalArgumentException("Could not find any Tax Authories for store with ID [" + productStoreId + "] for tax calculation; the store settings may need to be corrected.");
                 }
                 
-                List taxAdustmentList = getTaxAdjustments(delegator, product, productStore, billToPartyId, taxAuthoritySet, basePrice, amount, shippingPrice);
+                List taxAdustmentList = getTaxAdjustments(delegator, product, productStore, null, billToPartyId, taxAuthoritySet, basePrice, amount, shippingPrice);
                 if (taxAdustmentList.size() == 0) {
                     // this is something that happens every so often for different products and such, so don't blow up on it...
                     Debug.logWarning("Could not find any Tax Authories Rate Rules for store with ID [" + productStoreId + "], productId [" + productId + "], basePrice [" + basePrice + "], amount [" + amount + "], for tax calculation; the store settings may need to be corrected.", module);
@@ -140,6 +140,7 @@
     public static Map rateProductTaxCalc(DispatchContext dctx, Map context) {
         GenericDelegator delegator = dctx.getDelegator();
         String productStoreId = (String) context.get("productStoreId");
+        String payToPartyId = (String) context.get("payToPartyId");
         String billToPartyId = (String) context.get("billToPartyId");
         List itemProductList = (List) context.get("itemProductList");
         List itemAmountList = (List) context.get("itemAmountList");
@@ -179,13 +180,13 @@
             BigDecimal shippingAmount = (BigDecimal) itemShippingList.get(i);
             List taxList = null;
             if (shippingAddress != null) {
-                taxList = getTaxAdjustments(delegator, product, productStore, billToPartyId, taxAuthoritySet, itemPrice, itemAmount, shippingAmount);
+                taxList = getTaxAdjustments(delegator, product, productStore, payToPartyId, billToPartyId, taxAuthoritySet, itemPrice, itemAmount, shippingAmount);
             }
             // this is an add and not an addAll because we want a List of Lists of GenericValues, one List of Adjustments per item
             itemAdjustments.add(taxList);
         }
         if (orderShippingAmount.doubleValue() > 0) {
-            List taxList = getTaxAdjustments(delegator, null, productStore, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, orderShippingAmount);
+            List taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, orderShippingAmount);
             orderAdjustments.addAll(taxList);
         }
 
@@ -213,11 +214,13 @@
         taxAuthoritySet.addAll(taxAuthorityRawList);
     }
 
-    private static List getTaxAdjustments(GenericDelegator delegator, GenericValue product, GenericValue productStore, String billToPartyId, Set taxAuthoritySet, BigDecimal itemPrice, BigDecimal itemAmount, BigDecimal shippingAmount) {
+    private static List getTaxAdjustments(GenericDelegator delegator, GenericValue product, GenericValue productStore, String payToPartyId, String billToPartyId, Set taxAuthoritySet, BigDecimal itemPrice, BigDecimal itemAmount, BigDecimal shippingAmount) {
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         List adjustments = FastList.newInstance();
 
-        String payToPartyId = productStore.getString("payToPartyId");
+        if (payToPartyId == null) {
+            payToPartyId = productStore.getString("payToPartyId");
+        }
 
         // store expr
         EntityCondition storeCond = new EntityExpr("productStoreId", EntityOperator.EQUALS, productStore.get("productStoreId"));



More information about the Svn mailing list