View Single Post

  #1 (permalink)  
Old 22-05-2008, 03:18 PM
squibs squibs is offline
Frontpage User
 
Join Date: Aug 2007
Posts: 23
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
squibs will become famous soon enough
Default Accounting for rounding errors

I posted this as an accountancy question on another forum. Perhaps it is more of a coding issue.

I'm writing an invoicing system in PHP/mySQL at the moment, for my own use, to suit my own business rules. A major premise is that when a quote is accepted, the invoices are generated from that quote, as stage-payment percentages of the overall cost. There can be as many stages as required, each with an abitrary percentage specified (not exceeding 100, obviously).

If I quote somebody for €1075.50 and invoice them in 3 stages for 17%, 50% and 33% of the total, these values work out at
182.83500000
537.75000000 and
354.91500000

On an invoice, I believe nobody issues invoices for a fraction of a penny, so these would be rounded to the penny, giving
182.83
537.75 and
354.91
if I round down giving a total invoiced of 1075.49, and

182.84
537.75 and
354.92
if I round up giving a total invoiced of 1075.51

Both these values differ from the quote value of 1075.50
How can I reconcile the error?


I could calculate when the last invoice had reached 100 percent and make it's value = totalcost - amount already invoiced. But this adds an unwieldy special case with lots of extra programming.

Can anybody suggest a more elegant solution?
__________________
Ones and zeros - which are you?
Reply With Quote