Shotgun: Building the OSS Moneysafe Library from Scratch
Eric Elliott

Your post (and library) is mostly correct, but the system has a few limitations.

First off, Moneysafe doesn’t throw errors when a calculation loses precision. You are correct that unless you start calculating GDPs, Moneysafe is mostly correct, but I’d still want the library to detect when I’m leaving the bounds of precision and throw an error. This is a money library after all, we’re not going to calculate thousands of calculations per second, the performance hit is acceptable and then I know for sure it’s not doing anything incorrect.

Secondly, it doesn’t do double ledger, which is a fairly strong limitation. What this means is that if it rounds a cent here and a cent there, one cent might disappear out of the system. This is unacceptable for accounting purposes, so Moneysafe can’t be used in accounting software or anything feeding into your existing accounting software. Knowing this limitation, you can still use it in a single ledger system, like, say, your webshop, but you’d need a different back-end to handle the sales.

Fixing Moneysafe to be double ledger compliant would be possible in two ways: one, you could make it a double ledger system that doesn’t ever lose a cent, but that would be a bigger and different library, two, you could make it a proper base for such a system by replacing Math.round with a proper rounding function.

The last issue is that for legal purposes, I probably can’t use Moneysafe at all, as the law quite clearly stipulates how rounding should be done and this differs from country to country.

I like the software and the lessons it teaches, but I’d put a heavy disclaimer next to it, telling people not to use it in production without being versed in accountancy (or getting help from their accountant).

Disclaimer: I’m a programmer and a certified accountant, but I haven’t gotten any professional experience as an accountant (just a minor I took in college more or less).

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.