VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Anders69 on March 10, 2012, 15:24:00 PM

Title: Wrong tax if a price discount is given
Post by: Anders69 on March 10, 2012, 15:24:00 PM
Hi!
I'm using Joomla! 2.5.2 and Virtuemart 2.0.2
I have a problem with taxes. If i give a product the price of 100 swedish krona and the taxrate is 25% and then set an discount of say 50 swedish krona.
The tax is still 25% of 100 swedish krona and not 25% of 50 kr. Is it a bug or is it me who cant get it right?
Title: Re: Wrong tax if a price discount is given
Post by: Biggreuda on March 10, 2012, 19:02:05 PM
I couldn't find that either.
Since we only use one tax rule here for everything, we hardcoded it temporarily until there is a better solution.
In administrator\components\com_virtuemart\helpers\calculationh.php we added the following lines at line 370 (after "$prices['priceWithoutTax'] = $salesPrice - $prices['taxAmount'];"):
if ($this->override) {
$prices['taxAmount'] = $this->product_override_price/119*19;
}


We have 19% here, so it would be

if ($this->override) {
$prices['taxAmount'] = $this->product_override_price/125*25;
}

in your case.
This is a very dirty solution, so i wouldn't recommend it, but it's the only solution for this i know so far ;)
Title: Re: Wrong tax if a price discount is given
Post by: PRO on March 11, 2012, 11:54:25 AM
what do you have the discount setting to?

Title: Re: Wrong tax if a price discount is given
Post by: Anders69 on March 11, 2012, 14:53:11 PM
Thank you Biggreuda for your solution. I have not tried it yet but i will. Not sure it will work for me, i have both 25% and 6% products.

Quote from: BanquetTables.pro on March 11, 2012, 11:54:25 AM
what do you have the discount setting to?


In this case a used Pricing rules overrides and entered the Discounted Price there. The help text there says that the store will create a new discount from the price you enter. Can´t see that i did.
Title: Re: Wrong tax if a price discount is given
Post by: Milbo on March 12, 2012, 20:35:07 PM
oha guys, you will get in deep trouble with the tax office. Please learn this basics !

When you do a discount after the tax, you have to pay the tax for the netto.

When you use the discount before tax, yes then you get a difference, because then you change your netto.
Title: Re: Wrong tax if a price discount is given
Post by: Biggreuda on March 14, 2012, 13:50:50 PM
What is that supposed to mean?   ???
In our shop, all prices are with tax and we added that info on all places where any prices are shown.
Of course all our discounts are before tax, too. We are able to think that far, it's going like this for dozens of years now ;)
A good thing would be to have a simple way to add a discount before tax directly into the product, because they are all individual (backward-calculation of the full price with tax is still a big issue, too).
I tried twice to create a discount with "DBTax", but it was added immediatly to the whole store, even if i did not select any category or whatever.
This and the inconvenient way of adding a whole rule for each reduced article did lead us to this desperate measure.
Title: Re: Wrong tax if a price discount is given
Post by: zebrafilm on April 01, 2012, 14:15:19 PM
OK I have to hook in here:

I am on 2.0.3H and also have a problem with the TAX / discounts:

There is 19% VAT rule for each product. Works fine.
I have a discount coupon for 100% discount.

When I go to the checkout and enter the discount it still shows the VAT left over, everything else zero's out as it should be but VM2 still wants the client to pay VAT over a non existing price.
Seems a bug to me.

Bastiaan

Attachment is a screenshot of the problem.





[attachment cleanup by admin]
Title: Re: Wrong tax if a price discount is given
Post by: woutsun on May 03, 2012, 14:28:48 PM
This is a bug for me. From above posts I assume* that it is normal in some countries to add a discount AFTER the tax. Like Milbo said.
Where I live... it's nothing but absurd really.
*Just saying.. don't really believe this but ok.

Let me explain the difference between the way virtuemart works and how I, and most likely a few others, need it to work.

Say you have a € 1000,00 product and the tax rate is 19%.
Where I'm at tax is always calculated on top of the sales price. Not the stated sales price but the actual price for which the product is sold.
This makes Sales Price + 19% or € 1000,00 x 1,19  =  € 1190,00. The tax is € 190,00.

A 10 % discount on this price is € 1190,00 x 0,10  =  € 119,00
Now € 1190,00 - € 119,00 = € 1071,00 which is the new sales price
In virtuemart the tax stays the same even though the sales price has changed: € 190,00. This makes my netto price 1071,00 - 190,00 = € 881,00
Where I live the tax has to be calculated again: € 1071,00 / 1,19 = € 900 - My Netto price. Notice the difference of € 19,00.
The new tax amount is 19% of 900 so €900 x 0,19 = € 171,00.. Also a difference of €19,00

Should you need any more clarifications please let me know.


Since this is my first post I also want to compliment everybody developing VM. I'm getting the hang of it right now and it keeps working better and better!


Title: Re: Wrong tax if a price discount is given
Post by: dj55b on May 08, 2012, 18:22:29 PM
I'm also in the same boat as these guys.
Title: Re: Wrong tax if a price discount is given
Post by: Milbo on May 09, 2012, 00:42:33 AM
Quote from: Milbo on March 12, 2012, 20:35:07 PM
oha guys, you will get in deep trouble with the tax office. Please learn this basics !

When you do a discount after the tax, you have to pay the tax for the netto.

When you use the discount before tax, yes then you get a difference, because then you change your netto.

oha guys, what a shame on me ! Imho your problem is fixed. After long discussions, with various merchants, retail price options and whatever...

The new version has now a VAT tax option, which is recalculated. Please try the svn, or http://dev.virtuemart.net/projects/virtuemart/files

expect version b tomorrow, just too tired, todo the installer now.
Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on May 16, 2012, 14:27:11 PM
Quote from: Milbo on May 09, 2012, 00:42:33 AM
The new version has now a VAT tax option, which is recalculated. Please try the svn, or http://dev.virtuemart.net/projects/virtuemart/files
expect version b tomorrow, just too tired, todo the installer now.

Hello, I have tried version 2.0.7b and I am able to add a discount to the products.
There are still some problems:

Price calculation:
default_showprices.php shows:
----base price without tax (= old price without discount with tax) (example: 100 euro)
----discounted price without tax (example: 10 euro)
----discounted price with tax (example: 11,90 euro)
----tax only.  (1,90 euro)
----discount (base price-discounted price with tax = 100 euro - 11,90 euro = 88,10 euro).

2 things are wrong:
- 1. Page doesn't display base price with tax  (= old price without discount, with tax: example 119 euro)
- 2. Discount is calculated wrong. It should be: "base price WITH TAX - discounted price WITH tax"  or "(base price WITHOUT TAX - discounted price WITHOUT tax) * TAX"

Error message
After updating to v2.0.7 and I tried to edit a product I get the following error:
"Warning: shell_exec() has been disabled for security reasons in /public_html/administrator/components/com_virtuemart/models/orderstatus.php on line 79"

Calculation base price doesn't work as expected
When I add a final price (let's say 100 euro) and I click "Calculate base price" , the final price becomes 99.99996

I hope you can figure out what's going wrong with price calculation, cause it's the most important feature of a shop I guess.
Title: Re: Wrong tax if a price discount is given
Post by: Milbo on May 20, 2012, 15:24:09 PM
Please check again the latest svn, I found a small error, with the VatTax, imho fixed now
Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on May 21, 2012, 16:30:11 PM
Quote from: Milbo on May 20, 2012, 15:24:09 PM
Please check again the latest svn, I found a small error, with the VatTax, imho fixed now

Hello, thank you for the update, but there are still the same problems:

- No display of "base price with tax".
- Wrong calculation of Discounted price.

I have a screenshot attached.
My base price is 100 euro (shown)
Tax is 19%.
Base price with tax is 119 euro (still not shown!)

Discounted price without tax is 10 euro (shown).
Discounted price WITH tax is 11,90euro (shown).
Discount ammount: 88,10 euro is shown, but not correct.

Discounted ammount calculation is at the moment:
Base price without tax - discounted price WITH tax = discounted ammount, but it should be:
base price with tax - discounted price with tax = discounted ammount
or
(base price without tax - discounted price without tax) * tax = discounted ammount

I hope you can fix this, cause if it isn't fixed correctly a store without correct price calculation is quite useless.

Thanks in advance,
Bart

[attachment cleanup by admin]
Title: Re: Wrong tax if a price discount is given
Post by: jjk on May 21, 2012, 17:00:34 PM
Your calculation looks to me like you are applying a 90 percent discount to your base price, for which the numbers are correct.
Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on May 21, 2012, 17:22:59 PM
No, it is still not correct.

I have no discount rules, only a tax rule.

I use the discount option on the product page. See attached a new screenshot of the product admin.

Still, the calculation is wrong, even if I have done what you suggested:

You suggested:
100 euro base price (without tax)
90% of base price:
100 - (100x0,9) = 10 euro without tax.
10 euro * 19 % tax = 11,90 (still correct).

I have done:
100 euro base price (without tax)
new price without price = 10 euro (= 11,90 with tax)

These calculations are correct (but not used in VM)
Discount ammount without tax:
base price without tax - sales price without tax = discount ammount without tax
100 - 10 = 90 euro (not 88,10 as in the screenshot in my last post.

Discount with 19% tax:
base price with tax - sales price with tax = discount ammount with tax
119 - 11,90 = 107,10 (still not 88,10).

So it doesn't matter which way you look at it: discount and tax calculations are still wrong.
This calculation is now used in VM and NOT correct
base price without tax - sales price WITH tax = wrong discounted ammount
100 - 11,90 = 88,10 (is not correct because there is a tax conflict. )



note: see also the error message noted in a previous post on the screenshot

[attachment cleanup by admin]
Title: Re: Wrong tax if a price discount is given
Post by: jjk on May 21, 2012, 18:42:24 PM
Concerning your error message I suppose that your PHP configuration doesn't allow the 'shell_exec()' function. This is one of the functions disabled when PHP is run in Safe Mode.

Concering your price: What do you actually want to achieve? In your screenshot you instruct VM2 to overwrite your base price (100 €) and instead use a net price of 10 € and a final sales price (including 19% BTW) of 11.80 €. There is no discount set.
Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on May 21, 2012, 18:53:19 PM
Ok. Maybe I don't understand the way a discount works, could you point me in the right direction?

But when I use these settings, on the front-end the "discount price" will show up as you can see in the other screenshot.
There is still a wrong discount amount shown as I have noticed before.

Hope someone can help me out with this. A discount amount of 88,10 Euro which is calculated from a price without tax minus a price with tax doesn't make any sense.
Title: Re: Wrong tax if a price discount is given
Post by: jjk on May 21, 2012, 20:19:55 PM
How to set up pricing, tax and discounts depends on how much of the price calculations you want VirtueMart to do.

Before starting to add lots of products into VM2, you should answer yourself some questions:
Do you want VM2 to calculate the final price from the cost price (the price you have to pay to your supplier) or are you doing this calculation elsewhere?
Do you buy your products in your home currency only or also in countries using other currencies?
Do you want to add the same profit margin (currently VM2 can handle only one) to your cost price?
Do you sell only new products or also used (second hand) products? (when you sell i.e. used cars, BTW is only applied to your profit)
...

However, if you just want to enter a net price into VM2, from which BTW and discounts are calculated, the procedure is not very complicated. In 'Taxes and Calculation Rules' configure the following:

1. Configure BTW 19%, tax per product
2. Configure 'Discount 10% or 10 Euro (before tax) and set it 'visible for vendor and shopper'

Also enable 'Show tax in Cart' in VM2 configuration

Then in your Product Edit view, enter i.e:
100 Euro as the cost price (includes your profit margin, if you don't use a profit margin rule)
Set Override price to 'Disabled'
Select Tax: 19% BTW
Select Discount Type: 10% Discount (or whatever you previously configured in the tax and calculation rules)

In your example this would lead to a final sales price of 107,10 Euro (10% discount on 119 Euro), a tax of 17,10 Euro and a net price of 90,00 Euro




Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on May 21, 2012, 23:00:06 PM
Oké. Thank you for your explanation.
But what if I want to give a couple of products all a different kind of discount. So let say one product 5 Euro discount , the next 8 euro etc.
I thought I could use the price override per product.

And still I do not understand why you guys let VM calculate a discount amount from a base price without tax minus a new price (override) with tax.

This is not something I make up , but something that you could see yourself in the two attached screenshots in the previous posts.

I will mention it again and I hope you will finally see it yourself that it really doesn't make any sense.
In the example I have a base price without tax from 100 Euro. VM says it is without tax calculated.
I have a price override of 10 Euro, from which VM has calculated 11,90 because of the tax rule of 19% I have set.
This is all correct. But now comes the problem.
When I have a price override, VM doesn't show the old price with tax, it shows only the base price without tax.
And, as I have said before, a discount amount is calculated by VM of 88,10 Euro which is the base price without tax minus the price override including tax. It should be both including tax or both be without it.

Could someone explain it to me why this happens? This problem drives me crazy.
Title: Re: Wrong tax if a price discount is given
Post by: bpluijms on June 08, 2012, 11:19:37 AM
After updating to the 2.0.7d the problem is fixed and all prices shown fine. Thank you!