[SOLVED] TAX default rules on products not applied after upgrade to vm208a

Started by bytelord, July 02, 2012, 15:04:12 PM

Previous topic - Next topic

bytelord

After upgrade to vm208a the pricing rules overrides for tax is not applied when "apply default rules" is selected. When save product and check it the "Tax Affecting" is empty. This happens to all products that have selected "apply default rules". If i select the specific rule then is working, but i have to do that for all the products.
I have reconfigure tax and calculation rules but the issue remains.

Thanks

Nikos
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

bytelord

I am searching it for hours and i think the issue is somewhere in calculationh.php under helpers after the new VatTax rule has been applied to 2.08a.
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

Wagoweb

Found out that the miscalculation only appears when not logged in.

bytelord

I am talking in the backend also. When you create or edit a product the default pricing rules overrides for TAX is not applied and Tax Affecting is empty.
In the frontend is not working because is not selected on the backend.
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

bytelord

After hours of searching i finally found the problem. The following solution resolves my issue that default tax rules are not apply on the back-end and also resolves other VM users issues that TAX rules are not apply in the frontend if the user is not logged in.

Inside the file administrator\components\com_virtuemart\helpers\calculationh.php in line 839 we have the $hitsDeliveryArea checking for state and country. In the new version of virtuemart 2.0.8 or sub-releases 8a or 8b the developers have changed the code so if not country or state found the $hitsDeliveryArea going to false. That means that in line 862 there is an condition that if hitscategory, hitsshopper and hitsdeliveryarea is true then and only then add rule rule for product pricing. So when endusers are not logged in and offcourse in the backend the default rules for TAX are not applied!!
After hours of searching and testing i found a solution like was in the 2.0.6 version of calculationh.php.

The solution is to comment the lines 844 and 850 insede the calculatioh.php so not change DeliveryArea value to false (//$hitsDeliveryArea = false;).

The final code is:

Line 839 until line 851 inside administrator\components\com_virtuemart\helpers\calculationh.php:

      $hitsDeliveryArea = true;
if(!empty($this->allrules[$this->productVendorId][$entrypoint][$i]['states'])){
if (!empty($this->_deliveryState)){
$hitsDeliveryArea = $this->testRulePartEffecting($this->allrules[$this->productVendorId][$entrypoint][$i]['states'], $this->_deliveryState);
} else {
// $hitsDeliveryArea = false;
}
} else if(!empty($this->allrules[$this->productVendorId][$entrypoint][$i]['countries'])){
if (!empty($this->_deliveryCountry)){
$hitsDeliveryArea = $this->testRulePartEffecting($this->allrules[$this->productVendorId][$entrypoint][$i]['countries'], $this->_deliveryCountry);
} else {
// $hitsDeliveryArea = false;
}


and all is working fine like in version 2.0.6.

----
The developers have a reason for change the value to false and if it possible to comment that thread so to be sure that the above solution is ok for production.

Thanks!
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

Milbo

Thx,

I rebuilt it. In your conclusion is imho only one little mistake. The whole thing can be only set to false, when there is a rule which is using a state or country.

So the problem is that anonymous users see a wrong tax. Maybe you create a tax for the anonymous users with your country/state and when they enter then their data the tax will be correctly displayed on the cart.

Another idea to solve this in the core more commode, could be to create a new option: "Assume for anonymous users the vendor country/state for the tax calculations"
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

bytelord

Hello Milbo,

Thanks for your quote. I cant say is mistake, is a logic issue that turn to mistake :).
The main issue i had was that default rules was not applied on the backend when i was editing or add new products because the default rules for tax affect was not applied. I tried the solution for the anonymous users but doesn't work either (for the backend), so i had to find where was the changes on the source code and figure out where the overrides are get changed. Because i am very new to VM i spend many hours testing values, debugging and compare source with previous releases to find how VM works and how it calculate taxes, prices, overrides...

Yes i think that the last idea is the best and also have an option to bypass that overrides at the backend, because as a vendor i have configured country/state but the default tax rule was not applied because was overrides also from $hitsDeliveryArea.

Thanks again.
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

Milbo

You did a good job man, and I almost followed your argumentation and logic.

Your solution works good for your case, but it is not a solution which works for shops with some more rules.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RosaMagma

Hello,
Milbo, Is this corrected in the last version (2.0.8e)? I have installed 2.0.8a version and I have some personalization, so I need some work to update.
Thanks

bytelord

Hello RosaMagma,

It doesn't need any fix, was a feature that has been enabled to check for country/state when applying tax/discount rules. What is exactly your issue. I am working great with 2.08e right now.

Thanks
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

cas

I have the same problem.  I upgraded from VM2.0.6 where all tax and calculation rules worked fine, to VM2.0.8e and the tax and calculation rules are not applied.  See topic: http://forum.virtuemart.net/index.php?topic=104997

This topic says SOLVED... what is the fix? 

bytelord

Hello gas,

For my custom solution was to comment the lines above so the tax rules not been overridden if country/state not applies. Could you please check if the taxes are been applied after you logon with a shopper account? Does the rules applied on the backend. Could you please check your tax/discount rules configuration and check what selections you have made on country/state and shopper groups?
If you want that rules to be applied to "everyone" you should leave state/country and shopper group blank.

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

cas

Hello bytelord,

VM2.0.8e is not in my production environment, so I don't need to do any emergency code fixes.  I just need the VM team to fix 2.0.8e to work correctly like it does in 2.0.6.   For some reason this topic is set to SOLVED, which doesn't make since when we all have to make coding changes to fix it. That is not SOLVED in my humble opinion until the VM team puts out a fixed version.   

To answer your questions:
I have one tax rule (type: TaxBill) that is only for USA California shoppers and the Shopper Group is set to -default-.  This is how it worked fine in 2.0.6 and it works fine in 2.0.8e.
I have 2 price calculations (type: Marge) that do not have any Shopper Group, Country, or State set.  This configuration worked fine in 2.0.6, but does NOT work in 2.0.8e.

The tax rule is being applied correctly when a user from California is logged in, just like it did in 2.0.6, but the problem in 2.0.8e is the other 2 price calculations (type: Marge) are not being applied in the backend or the frontend, regardless whether the user is logged in or not. 

To the VM Team, do you have a fixed version coming out soon? 

Chuck

emaravelia

Hello there,

I am having exactly the same issue but with vm2010 Do you suggest i try what you did? I am surprised this is not fixed in the newest version.

Thank you

emaravelia

Just an update. I created a tax rule for the anonymous shoppers and it knows shows the right tax for unregistered and registered users. I do believe though this should be fixed since these days you get a lot of people who just browse a page and it would be easier for sellers to just set as few rules as possible.

Thanks