<div dir="ltr"><div dir="auto">On 5 Apr 2017 04:15, "Richard A. O'Keefe" <<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>> wrote:<br type="attribution"><blockquote class="gmail-m_7477707439873621214quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_7477707439873621214quoted-text"><br>> On 4/04/2017, at 11:21 PM, Saurabh Nanda <<a href="mailto:saurabhnanda@gmail.com" target="_blank">saurabhnanda@gmail.com</a>> wrote:<br></div><div class="gmail-m_7477707439873621214quoted-text"><br>> * Allowing end-customers to see product prices in different currencies (so, currency conversion)<br>> * Various reports to see total sales, total receivables, and total payables (basically a **very** small subset of small-business accounting)<br><br></div>There are Haskell data types that will let you compute sums and<br>differences of money times percentages exactly. For final reporting,<br>you will need to round.<br></blockquote><div><br></div><div>Careful here. I've worked on systems where one of the fundamental requirements is that any sums of columns of numbers representing amounts of money _must_ add up precisely. In a situation where you apply different tax rates to different items you could either calculate the tax on each one (and round it to £0.01) or group the items together into subtotals that all had the same tax rate, then calculate the tax on the subtotal (and round it to £0.01). What you couldn't do was keep track of the precise amount of tax on each item and round it at the very end for reporting purposes only, because you had to show the tax breakdown (using numbers rounded to £0.01) and if your working calculation was more precise then the numbers in the report wouldn't always quite add up, which would upset the auditors.</div><div><br></div><div>This is why it's frequently recommended to use an integral type representing multiples of your smallest reporting unit for representing money.</div><div><br></div><div><blockquote class="gmail-m_7477707439873621214quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_7477707439873621214quoted-text">The rounding rule is *probably* the one<br></div>you learned in school, but you really should check with a friendly<br>accountant.</blockquote><div><br></div><div>The actual rounding rule in question seemed relatively unimportant compared with the requirement that numbers in reports must add up precisely, although I also agree that you should check with an accountant. They may not even mention the columns-of-numbers-must-add-up thing because that's so fundamental it almost goes without saying.</div><div><br></div><div>Cheers,</div><div><br></div><div>David</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><blockquote class="gmail-m_7477707439873621214quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote></div></div></div>
</div>