Re: Dev - Questions about the way taxes are calculated
Posted by
David E. Jones on
May 07, 2006; 2:13pm
URL: http://ofbiz.116.s1.nabble.com/Dev-Questions-about-the-way-taxes-are-calculated-tp167888p167891.html
Jacopo Cappellato wrote:
> Ok, this makes sense, however right now the following condition is used:
>
> storeCond = new EntityExpr("productStoreId", EntityOperator.EQUALS,
> productStore.get("productStoreId"));
>
> and so only the TARP with the productStoreId field set are retrieved;
> so, I propose to use the following code to implement what you are
> describing:
>
> storeCond = new EntityExpr(
> new EntityExpr("productStoreId", EntityOperator.EQUALS,
> productStore.get("productStoreId")),
> EntityOperator.OR,
> new EntityExpr("productStoreId", EntityOperator.EQUALS, null));
This change looks good, either on its own or in the attached patch.
> However, I really like to make the productStoreId an optional parameter
> (I need to invoke the calcTax service to calculate the taxes of a
> manually created invoice with no order and no store behind it) and so
> I'd suggest the code in the attached patch:
>
> in this way, if the productStoreId is passed, all the TARP records for
> that store and also the TARP records with an empty productStoreId are
> selected; if the productStoreId is not passed, only the TARP records
> with an empty productStoreId are selected.
>
> What do you think of this? Can I go on with this change?
This is a good point... In the calcTax service it users the productStoreId to get the payToPartyId (needs this to know the tax nexuses that apply to the company party), so we should add a condition inside the service that says if the productStoreId is empty then make sure the payToPartyId is _not_ empty.
For the calcTaxForDisplay service the situation is different and it is much more simple, but limited in applicability of course. It uses the taxAuthority settings on the ProductStore to determine the 1 tax authority to use rather than looking for all tax authorities where the company has a nexus (a sufficient presence to be required to pay taxes there; of course that doesn't apply for all tax authorities...).
-David
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev