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
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).
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
Do you get the same after updating to VM2.0.10? (2.0.11 very soon)
Please use the latest version first.
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
Fixing something with a cast sounds always good. I added it to the core.
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]
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);