Having googled extensively about storing money in Rails, it seems to be
accepted that the best way is to store the prices etc in the smallest
part of the currency so that you can use an integer i.e Â£20 would be
stored as 2000 pence.
This is fine and I’ve made a nice pretty wrapper that outputs the price
in the standard form for invoicing and what not - but here I’ve come
across a problem. My company is registered for VAT (Sales Tax) which I
have to charge at 17.5%.
How would I go about multiplying the original cost in pence but a
floating point? According to the the tax rules, if the final result is
over half way it should be rounded up, otherwise it should be rounded
1.743 should round down to 1.74
1.16 should round up to 1.17
I’m not sure the best way to do the multiplication so that I end up with
an integer that follows the rules. This is pretty much the only thing
holding back which in all other ways is a great little system.
Any help would be very very gratefully received!