VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Virtuemart 1.1 Development (Archiv) => Quality & Testing VirtueMart 1.1.x => Topic started by: sobers_2002 on May 30, 2009, 10:05:30 AM

Title: Tax calculation issue with discount
Post by: sobers_2002 on May 30, 2009, 10:05:30 AM
Description:
This is a bug in the existing virtuemart (till 1.1.3) system that is seen when discounts are being used and the tax calculation is set to be done on the reduced price.

This issue is not seen when using tax calculation based on vendor address, but only in case of shipping address based tax calculation.

VirtueMart Version:
1.1.3

Joomla/Mambo Version:
1.5.9

Steps to replicate:
- Select tax calculation based on shipping address
- Enable discount calculation after the discount
- Checkout with relevant tax address information

Proposed fix(es):
Please visit my post here (http://www.nandebayo.org/blog/?p=80) for the fix.

System info:
Dreamhost

I hope this helps people facing the issue with a similar problem and hopefully the fix posted is correct.

I am not sure if this is the same issue as listed in the changelog of 1.1.3 for tax_rate().
Title: Re: Tax calculation issue with discount
Post by: aravot on June 17, 2009, 22:48:39 PM
Sobers, I tried your code, didn't work, we want to release 1.1.4 so if you can help us fix this bug it would be awesome.

For this purpose I created a product with price of $100 my tax is 9.25% and I created a coupon $50, I have 'Subtract payment discount before tax/shipping?' checked.

So the result should be:
$100 - 50(coupon) = 50 + 9.25%(tax) = 54.63

instead I get:
$100 - 50(coupon) = 50 + 9.25%(tax) = 59.25
it seem tax is still calculated from total price.
Title: Re: Tax calculation issue with discount
Post by: sobers_2002 on June 18, 2009, 06:57:08 AM
maybe I missed something ? I'll check into it because this is most definitely part, if not full of the code I used to fix the issue!
Title: Re: Tax calculation issue with discount
Post by: Jeffrey Hughes on July 29, 2009, 16:55:36 PM
The code worked great for me. Below is a review of what I did:
Before I did the code modification, tax was calculated of the $39.95 and came to $2.40 (39.95 x 0.06); which was incorrect. 

This is a major accomplishment and the word to this form needs to be spread throughout various VM Forms, please do so as you see people needing help in this issue.
Title: Re: Tax calculation issue with discount
Post by: sobers_2002 on August 05, 2009, 10:36:27 AM
Hi Jeffrey,

Thanks for your feedback and glad to know it worked out fine!! The issue that Aravot has reported is actually the above code not working with the SVN branch. It works fine with code upto 1.1.3 using the instructions I posted.

I'll be updating the code soon to make it work with the SVN branch and then it will be posted as a fix in the next VM release.

cheers,
Saurabh
Title: Re: Tax calculation issue with discount
Post by: Maverix on August 07, 2009, 08:52:00 AM
Is there a fix available which solves following problem:

Tax based on vendor address.

Zwischensumme :     EUR69,00
Rabatt:            - EUR2,90 (without tax)
Gutschein-Rabatt:    - EUR3,45 (with tax - but handled as without tax)
Versandkosten :    EUR6,90
enthaltene MwSt. :    EUR11,01
Endsumme:            EUR68,44

The first discount (-2.90) is a payment discount (- 5%)
The second discount (-3.45) is a coupon discount (- 5%)

It seems that both discounts are handled without tax although they both should be equal ( 5% each = 3.45 tax included)




The correct bill should look like this

Zwischensumme :     EUR69,00
Rabatt:            - EUR3,45 (with tax)
Gutschein-Rabatt:    - EUR3,45 (with tax)
Versandkosten :    EUR6,90
enthaltene MwSt. :    EUR11,02
Endsumme:            EUR69,00