Author Topic: [SOLVED] TAX default rules on products not applied after upgrade to vm208a  (Read 12709 times)

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
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

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: TAX default rules on products not applied after upgrade to vm208a
« Reply #1 on: July 03, 2012, 08:38:45 am »
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

  • Beginner
  • *
  • Posts: 1
Re: TAX default rules on products not applied after upgrade to vm208a
« Reply #2 on: July 03, 2012, 15:48:28 pm »
Found out that the miscalculation only appears when not logged in.

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: TAX default rules on products not applied after upgrade to vm208a
« Reply #3 on: July 03, 2012, 18:02:50 pm »
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

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: TAX default rules on products not applied after upgrade to vm208a
« Reply #4 on: July 03, 2012, 20:55:00 pm »
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:

      
Code: [Select]
$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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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"
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RosaMagma

  • Beginner
  • *
  • Posts: 22
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

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
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

  • Jr. Member
  • **
  • Posts: 487
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

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
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

  • Jr. Member
  • **
  • Posts: 487
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

  • Beginner
  • *
  • Posts: 6
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

  • Beginner
  • *
  • Posts: 6
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