NMoneys 2.2


It is hard to believe the last release was on September. That only means one thing: I was about time!

There are quite a few changes in the release, so I will get straight to the point(s)

Money Allocation

2.2 should be a happy release. Why? Well, besides the fact it is the first release in more than 6 months it is the first one that contains code contributed by someone else but me.
Thank you, Berryl, for the feature, let’s hope it’s useful to many.

The problem that we try to solve is a simple one: we have a certain amount of money and we want to allocate it amongst several recipients. If we are lucky (and so are the receivers) the amount can be distributed evenly and so every recipient will receive the same amount of money. But most of the time that is not the case and we since money cannot be subdivided forever (there are no coins for one thousandth of a euro, for instance) we need to find away to distribute the money as fair (or unfair) as possible.

How to allocate a monetary quantity? Invoke .Allocate() on the quantity. How is the remainder distributed? An implementation of IRemainderAllocator will decide. There a some ready to use implementations, accessible using the static factory RemainderAllocator: FirstToLast, LastToFirst and Random. The significant decimals of the currency of the monetary quantity are used to determine the minimal amount of money that can be allocated.

Of course, no one prevents passing a custom IRemainderAllocator as long as the allocator distributes all the money.

ISO is as ISO does

NMoneys claims to implement the ISO4217 standard for the .NET platform. That was accurate to a certain extent. It is true all currencies defined in the standard were present. But not all the information they contained was as the standard defines, because the baseline of the information was not the standard, was the information contained in the .NET culture tables.

But from this version on, all currencies will have the name as defined in the standard list (except some Bond Market units that lost their prefix).

But most importantly, currencies will have as many significant decimal digits as the specification says.

As a result, a bunch of currencies have changed name and precision. For a complete list, head to the Changelog.

Get it while it’s hot

As usual, visit the download page for the latest binary package. Or update/install the Nuget package. Or let the hipster in you install the Ruby Gem.

Oh, and if you like what you see. Spread the word, contribute or, simply, use it.