savoirfairelinux / sous-chef

Sous-Chef is a web application to help organizations to plan and deliver meals, and to manage clients files.
GNU Affero General Public License v3.0
67 stars 45 forks source link

Floating point money #840

Open kousu opened 5 years ago

kousu commented 5 years ago

In the orders model (and where else? probably billing) there are floating points used to store money amounts.

https://github.com/savoirfairelinux/sous-chef/blob/396f86d696fd1dc541b6556dacea8a621e2b7420/src/order/models.py#L57-L62

This will lead to roundoff errors. Money should always be counted in integers (so, for us, in CAD cents). The numbers used there happen to be exactly representable in binary (e.g. five-and-a-half, three-quarters, one) so maybe this problem has been lurking without biting anywhere, but if any divisions or averagings or different prices added to the system it might explode.