VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: maxxer on December 04, 2012, 15:30:01 PM

Title: Wrong product_item_price in order in case of price override
Post by: maxxer on December 04, 2012, 15:30:01 PM
Hi.
In our shop we have several products with an imposed discounted final price. The price is overridden using the "Override final price" option.
With these settings the #__virtuemart_order_items.product_item_price  value is set to product's product_price, resulting in a wrong price shown to customers!

An example:
Product A, final price 105, 21% VAT, base price 86.77686.
Override final price with 84.9.

If a customer buys this product, the order summary will have:
Product cost: 86,78 € | Base price included tax: 105,00 € | Gross price: 84,90 € | Taxes: 18,22 € | Total: 84,90

Just the total value is correct...
Title: Re: Wrong product_item_price in order in case of price override
Post by: sleepigrl on December 04, 2012, 23:01:40 PM
Since you're overriding the final price, you probably don't want to show the other prices.  You can adjust which prices are shown in VM Configuration, on the Prices tab.
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 05, 2012, 08:22:26 AM
Quote from: sleepigrl on December 04, 2012, 23:01:40 PM
Since you're overriding the final price, you probably don't want to show the other prices.
Why should I? If I override the final price my government still wants me to pay taxes, so they must be calculated anyway! :)
I cannot print an invoice with wrong taxable and tax amount, just because te final price is different than the "base" one.

This is indeed a bug, wrong prices are taken into the order when final is overridden...
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 18, 2012, 17:39:38 PM
no comments from dev?
thanks...
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 18, 2012, 19:09:56 PM
The tax works, in special since the version 2.0.15b. Maybe you choosed the tax and not vat tax.

and your numbers are not easy for comparison. VatTax is recalculated from the final amount. Example

baseprice 2 $
discount 40% => -80 cent
final price 1,20, 20% tax is then 20 cent. net 1$

or baseprice is 2
with tax is 2.4
discount 96 cent
final price 1,44 tax is then 24 cent net is 1,2
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 18, 2012, 20:05:01 PM
Quote from: Milbo on December 18, 2012, 19:09:56 PM
The tax works, in special since the version 2.0.15b. Maybe you choosed the tax and not vat tax.
Thanks for your reply.
indeed, by mistake, I was using tax and not vattax, but it still doesn't work.
I'm using 2.0.14, the latest available for download... Where should I get 2.0.15b?

After fixing with VatTax I made the purchase of a product with base price 57.43802, vat 21%, final price 69.5. Overridden price: 45.5.
In my order, I get the following:
Cost: 57.44
Base price: 69.5
Net price: 45.5
Tax: 7.9
Total: 45.5

If the tax was recalculated it should have been:
Total: 45.5
Tax: (45.5/100)*21 = 9,555
Base price: 55,055

I checked in _order_calc_rules and correctly contains VatTax as rule for the product.
What's wrong?

thanks
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 18, 2012, 20:37:57 PM
Your calculation is wrong:

If you recalculate the tax you are not allowed just to remove 21% and say thats it. Look 30% of 9 is 3. 9+3 = 12. But 12 -30%(of 12) = 8

So the calculation is different. You search for the number which multiplied by 1,21 is 45,5 =>  x * 1,21 = 45,5  => x = 45,5/1,21 = 37,6, so your tax is 7,897 ~7,90

correct
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 18, 2012, 21:26:16 PM
Quote from: Milbo on December 18, 2012, 20:37:57 PMSo the calculation is different. You search for the number which multiplied by 1,21 is 45,5 =>  x * 1,21 = 45,5  => x = 45,5/1,21 = 37,6, so your tax is 7,897 ~7,90

indeed I was wrong.
So the NET price is 37,6, but I cannot find it anywhere. The order summary in the backend doesn't have the recalculated taxable anywhere. Or anywhere I can find it ;)

thanks again.
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 22, 2012, 19:29:14 PM
so no way to get 37.6 written somewhere?
if you can point me to where the VAT is recalculated, I can try to make a patch. thanks
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 23, 2012, 11:03:25 AM
Use VatTax and imho everything works.
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 23, 2012, 12:41:03 PM
I tried using VatTax and indeed it fixed the Vat calculation, but the Order Taxable is still at full value (see attachment).
I still miss the 37,6 value somewhere in the order, to produce a correct invoice.
thanks

[attachment cleanup by admin]
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 23, 2012, 14:01:17 PM
of a new order or of an old ordeR? Do you change the tax and think it would change an old order? that would be illegal. Orders are always stored "plain", that means without references most time.
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 23, 2012, 14:05:59 PM
Quote from: Milbo on December 23, 2012, 14:01:17 PM
of a new order or of an old ordeR? Do you change the tax and think it would change an old order? that would be illegal. Orders are always stored "plain", that means without references most time.
this one was a new order after editing the cal rule to VatTax
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 23, 2012, 15:23:57 PM
Can you please repeat it with easier numbers? The problem is the order, the cart, the invoice, the mail? or only order? Sorry I lost a bit track
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 23, 2012, 16:20:03 PM
in the attached example the overridden final price is 12,1€. VAT is 21%, so the taxable is 10€  (10*1,2 = 12,1).
Original price is 20€ taxable, +vat becomes 24,2.
As you can see in no place I can find the new taxable amount of 10€.

[attachment cleanup by admin]
Title: Re: Wrong product_item_price in order in case of price override
Post by: Milbo on December 23, 2012, 18:47:04 PM
So you mean it is missing in the order view?
Title: R: Wrong product_item_price in order in case of price override
Post by: maxxer on December 23, 2012, 19:31:30 PM
Yes but the main problem is that the value is missing from the database

Thanks
Title: Re: Wrong product_item_price in order in case of price override
Post by: maxxer on December 27, 2012, 11:42:57 AM
hi Milbo, did you had any chance to give a look at this?
thanks for your support.