VAT calculation problem

19 views
Skip to first unread message

Dave

unread,
Oct 12, 2009, 5:38:05 AM10/12/09
to Spree
Hi,
Initially I wanted to sell something at (for example), 100 euros.

I enable the setting to show prices inc. VAT , and setup the VAT to
0.21. But now I have a problem that seems to be due to rounding/
truncation - and adding VAT to the net price.
First of all, the sales price increased to 121 euros, but I really
want to sell for 100 euros.

I changed the net price to 82.65, and get a sales price inc VAT of
100.01 euros.
I changed the net price to 82.64, and get a sales price inc VAT of
99.99 euros.

Any ideas, apart from re-writing the VAT calculation?
Thanks in advance,

David V.

Marcin Raczkowski

unread,
Oct 12, 2009, 6:14:49 AM10/12/09
to spree...@googlegroups.com

99.99 are nice prices ;)

But seriously, we use decimal numbers where we can, but it's possible to
get rounding errors, anyway you probably will have to rewrite
calculation BUT, there's good news, it shouldn't be to hard.

First of all price of item stored is _assumed_ to be price netto, and
adjustment are calculated upon that, what you can do, is just ignore vat
charge when calculating order total.

Order.class_eval do
def charge_total
charges.reload.reject{|c| c.secondary_type == "TaxCharge"}.total
end
end

second thing to do is to change vat calcuator to treat prices as brutto
not netto (as it's assumed right now), here's the pastie, you actually
just need to change 3 lines, but they are inside different methods, so
whole file is here(we probably should abstract it out):

http://pastie.org/651261

I don't guarantee it'll work flawlessly

Good luck

--
Marcin Raczkowski
---------------------------------------
Rails Dog LLC
5335 Wisconsin Avenue NW
Suite 440
Washington, DC 20015
voice: (301)560-2000
---------------------------------------

Denis (jumph4x)

unread,
Mar 28, 2011, 8:32:46 PM3/28/11
to spree...@googlegroups.com, Dave
Consider forcing calculators to use something similar to this:

Reply all
Reply to author
Forward
0 new messages