VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: thebeuving on September 07, 2012, 23:51:47 PM

Title: BUG: US/State specific Tax applied to international user without a state
Post by: thebeuving on September 07, 2012, 23:51:47 PM
In our virtuemart install (v2.0.8e) on Joomla 2.5.6 we have a sales tax rule setup Idaho (US). If an international user from a country that has states fails to select a state Idaho sales tax is applied.

Here is our tax config:

Published = Yes
Ordering = 0
Description = Empty
Type of Arithmetic Operation = Tax per bill
Math Operation = -%
Value = 6.00000
Currency = USD
Product Category = Empty/All
Shopper Groups = Empty/All
Country = United States
State = Idaho
Visible for Shopper = Yes
Visible for vendor = Yes
Start Date = Empty
End Date = Empty
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: jjk on September 08, 2012, 13:18:08 PM
Quote from: thebeuving on September 07, 2012, 23:51:47 PM
Math Operation = -%

Normally (I think :-) this should be +%. Most american shops display the price without the tax, which only is added if the shopper selects a state in which the tax applies (Idaho in your case).
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: thebeuving on September 11, 2012, 23:00:59 PM
Quote from: jjk on September 08, 2012, 13:18:08 PM
Quote from: thebeuving on September 07, 2012, 23:51:47 PM
Math Operation = -%

Normally (I think :-) this should be +%. Most american shops display the price without the tax, which only is added if the shopper selects a state in which the tax applies (Idaho in your case).

Good catch that was a typo, I do have it confirgured as "+%" but it automatically adds tax in the shopping cart and only removes it after a user selects a state other than Idaho.

Any thoughts on why that is happening would be great.

David
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: jjk on September 12, 2012, 15:52:32 PM
Do you get the same after updating to VM2.0.10? (2.0.11 very soon)
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: Milbo on September 13, 2012, 09:25:52 AM
Please use the latest version first.
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: thebeuving on September 14, 2012, 23:31:37 PM
I just tested in svn r6454 and the problem is the same. The problem is in calculationh.php the function testRulePartEffecting returns true if $data is not set.

I think the easiest solution is just to cast $this->_deliveryState and $this->_deliveryCountry to integers in the setCountryState function.


                if (!empty($this->_cart->ST['virtuemart_state_id'])) {
                        $this->_deliveryState = (int)$this->_cart->ST['virtuemart_state_id'];
                } else if (!empty($cart->BT['virtuemart_state_id'])) {
                        $this->_deliveryState = (int)$this->_cart->BT['virtuemart_state_id'];
                }


That way if no state is selected it will be set to 0 since 0 isn't a valid id in the database this should be safe. Also this will also fix the problem some people are having with state specific taxes all being listed out before a user sets there state.

Let me know if this is something we can get into the code base.

Thanks,
David
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: Milbo on September 15, 2012, 13:28:02 PM
Fixing something with a cast sounds always good. I added it to the core.
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: razor7 on November 05, 2012, 15:34:29 PM
Thanks!, patched my VM 2.0.10 file calculationh.php, function testRulePartEffecting but it didn't fixed it, the tax is applyed to all customers, no matter wich country they are.

I have set up a Florida VAT, see screenshot for details

Best Regards!

[attachment cleanup by admin]
Title: Re: BUG: US/State specific Tax applied to international user without a state
Post by: razor7 on November 05, 2012, 16:48:33 PM
Well, I had to modify function gatherEffectingRulesForBill of calculationh.php, added cast for $this->_deliveryState on line 870 and it worked!

Quote
      $hitsDeliveryArea = $this->testRulePartEffecting($states, (int)$this->_deliveryState);