+ Reply to Thread
Results 1 to 2 of 2

Thread: Accounting for rounding errors

  1. #1
    squibs is offline Frontpage User squibs will become famous soon enough
    Join Date
    Aug 2007
    Posts
    23

    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?

  2. #2
    d-tour's Avatar
    d-tour is offline Coder d-tour will become famous soon enough
    Join Date
    Apr 2007
    Location
    Cork
    Posts
    82

    Default

    The answer sometimes aint in the software but the way you look at the problem.
    value = totalcost - amount is the only way im afraid, but it shouldnt be that much more php.
    Just add an extra field in your table for amount paid and update this for every payment.

+ Reply to Thread

Similar Threads

  1. coding errors
    By bennyhill in forum Coding Help
    Replies: 3
    Last Post: 27-10-2007, 04:59 PM
  2. webmaster tools verification errors
    By blacknight in forum Google
    Replies: 4
    Last Post: 24-10-2007, 09:27 PM
  3. Spamhaus errors blocking my email?
    By ButtermilkJack in forum Server / Technical Administration Tips and Queries
    Replies: 3
    Last Post: 07-03-2007, 04:42 PM
  4. Accounting Package
    By Amateur in forum The Business Aspects of Web Work
    Replies: 4
    Last Post: 29-11-2006, 11:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64