I am developing a financial system and want to have a defined policy for rounding monetary values.
Given the following layers:
- Entity Model
If I am passing a monetary value through these layers, and maybe using it in calculations in the model, at what layer (if any) should I be applying my "default" rounding policy?
My instinct is in the View, as rounding the number is a "view" concern, like formatting a date. I also feel it could cause problems if my entities round money values as this could affect the accuracy of calculations. However if my API specifies a value as "money" it would seem incorrect to provide consumers with values that are not rounded e.g. £109.563393939939 rather than £109.56.
I have been unable to find any "best practice" around this.
Aside from this old question: https://stackoverflow.com/a/3840903/470183