{"id":19993621,"url":"https://github.com/dgg/nmoneys","last_synced_at":"2026-01-18T10:39:01.581Z","repository":{"id":28936236,"uuid":"32461990","full_name":"dgg/nmoneys","owner":"dgg","description":".Net implementation of Money Value Object","archived":false,"fork":false,"pushed_at":"2025-02-24T13:48:19.000Z","size":37903,"stargazers_count":80,"open_issues_count":6,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-21T18:52:53.866Z","etag":null,"topics":["bson","currency","entity-framework","iso-standard","iso4217","json","monetary-quantities","money","mongodb","serialization"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-18T13:58:19.000Z","updated_at":"2025-05-29T05:00:46.000Z","dependencies_parsed_at":"2023-12-28T16:51:46.321Z","dependency_job_id":"e977f971-e140-482e-9956-f53ae161bbaf","html_url":"https://github.com/dgg/nmoneys","commit_stats":{"total_commits":488,"total_committers":6,"mean_commits":81.33333333333333,"dds":"0.35655737704918034","last_synced_commit":"4634edd009b2674eafea039376c739f3887d14c1"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/dgg/nmoneys","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgg%2Fnmoneys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgg%2Fnmoneys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgg%2Fnmoneys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgg%2Fnmoneys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgg","download_url":"https://codeload.github.com/dgg/nmoneys/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgg%2Fnmoneys/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bson","currency","entity-framework","iso-standard","iso4217","json","monetary-quantities","money","mongodb","serialization"],"created_at":"2024-11-13T04:52:51.416Z","updated_at":"2026-01-18T10:39:01.563Z","avatar_url":"https://github.com/dgg.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"![logo](https://raw.githubusercontent.com/dgg/nmoneys/wiki/NMoneys_long.png)\n\nImplementation of the Money Value Object to support representing moneys in the currencies defined in the ISO 4217 standard\n\n![GitHub tag NMoneys)](https://img.shields.io/github/v/tag/dgg/nmoneys?logo=github\u0026label=NMoneys)\n[![Build status](https://github.com/dgg/nmoneys/actions/workflows/build.yml/badge.svg)](https://github.com/dgg/nmoneys/actions/workflows/build.yml)\n[![Coverage Status](https://coveralls.io/repos/github/dgg/nmoneys/badge.svg?branch=master)](https://coveralls.io/github/dgg/nmoneys?branch=master)\n[![codecov](https://codecov.io/gh/dgg/nmoneys/branch/master/graph/badge.svg)](https://codecov.io/gh/dgg/nmoneys)\n\n![Nuget NMoneys](https://img.shields.io/nuget/v/nmoneys?logo=nuget\u0026label=NMoneys)\n\n# What\n\n_NMoneys_ (plural) is a simple .Net library to represent monetary quantities.\n\nWhat does _NMoneys_ provide?\n * types for __representing__ _currencies_ that conform to the ISO 4217 standard and quantities of _money_ in a given currency.\n * __simple but extensible operations__ with monetary quantities of the __same currency__, including allocations of several sorts.\n * ways of __formatting__ the representation of monetary quantities\n * a simple way of __contributing__ to improve the completeness and correctness of the library\n\n## What not\n_NMoneys_ __does not provide__ any support for __exchanging__ monetary quantities in different currencies.\nThat means that you could not \"convert\", for example, 10 Euro into the equivalent quantity in dollars using an internal exchange rate in the library.\nInstead, you could, for example, perform the conversion with numeric types and then display the resultant quantity in a meaningful way by using types provided by NMoneys.\n\nIf you need to convert monetary quantities into other currencies you can use the (from now an on) archived library _NMoneys.Exchange_ alongside your trusted currency rates feed.\n\nNMoneys does not provide, as of now, __complex monetary or financial operations__\n\n## What might\nThe aim of _NMoneys_ is being simple and to-the-point: represent monetary quantities.\n\nBut, one of the reasons of making it Open-Source is that people with knowledge in the areas related with the subject of the library, that is money, can contribute with correct and useful ways to operate with the concepts in the library without cluttering its original purpose.\n\n# Quickstart\n\nInstall [Nuget package](https://www.nuget.org/packages/NMoneys).\n\n```shell\ndotnet add package NMoneys\n```\n\nInstantiate monetary quantities:\n``` csharp\nvar threeDollars = new Money(3m, Currency.Usd);\nvar twoandAHalfPounds = new Money(2.5m, CurrencyIsoCode.GBP);\nvar tenEuro = new Money(10m, \"EUR\");\n```\n\nObtain currencies or symbols:\n``` csharp\nCurrency cad = Currency.Get(CurrencyIsoCode.CAD);\nCurrency australianDollar = Currency.Get(\"AUD\");\nCurrency euro = Currency.Get(CultureInfo.GetCultureInfo(\"es-ES\"));\n\nstring isoSymbol;\nbool wasFound = Currency.TryGet(isoSymbol, out Currency? itMightNotBe);\n\nCurrency.Code.TryCast(36, out CurrencyIsoCode? maybeAud);\nCurrency.Code.TryParse(\"036\", out CurrencyIsoCode? possiblyAud);\n```\n\nOperate with monetary quantities:\n\n```csharp\nint isPositive = new Money(3m, Currency.Nok).CompareTo(new Money(2m, CurrencyIsoCode.NOK));\n\nvar three = new Money(3m);\nvar two = new Money(2m);\nMoney five = three.Plus(two);\nMoney oneOwed = two - three;\nMoney one = oneOwed.Abs();\n\n10m.Eur().ToString(); // default formatting \"10,00 €\"\nnew Money(1500, Currency.Eur).Format(\"{1} {0:#,#.00}\"); // rich formatting \"€ 1.500,00\"\n\nAllocation fair = 40m.Eur().Allocate(4);\n// fair.IsComplete --\u003e true\n// fair.Remainder --\u003e 0€\n// fair --\u003e \u003c 10€, 10€, 10€ \u003e\n\nMoney moneyBack = 1m.Usd().Minus(.37m.Usd()); // ¢63\nDenomination[] usCoins = \n{\n\tnew Denomination(.25m), // quarters\n\tnew Denomination(.10m), // dimes\n\tnew Denomination(.05m), // nickels\n\tnew Denomination(.01m)  // pennies\n};\nChangeSolution change = moneyBack.MakeChange(usCoins);\n// --\u003e six coins (optimal): 2 quarters, 1 dime, 3 pennies\n```\n\nA more complete quick-start can be found [here](https://github.com/dgg/nmoneys/wiki/DeveloperQuickStart#use-the-library).\n\n# Why\n\n## The .NET Framework\n.Net does not provide a good way of representing and operating with monetary quantities.\nNonetheless, it does support numeric types that can be used to represent monetary quantities and it also provides support for formatting those numeric values in different cultures. But it is surprisingly easy to mix the concept of \"_10 represented euros when was saved_\" with \"_now, 10 represents something else because of the current culture of the thread_\".\n\nThe .Net Framework mixes numbers, currencies, cultures and formats in a way that it becomes confusing, difficult and/or impossible to represent something as simple as \"one Euro\" or \"ten-and-the-half Zambian kwacha\".\n\nOn top of that mixture of concepts, it does not support a complete implementation for the ISO standard and for the subset implemented, the information may be outdated or even wrong. Fixes might be issued for wrong/outdated data, but they may take too long to be rolled-out and to add further confusion currency formatting information can be modified by the user.\n\n## Other libraries\nThere might be others libraries or simple code snippets that might cover a necessity.\nBut they did not cover mine for one or another reason: different goals, lack of activity/outdated, not suitable API,...\n\n## Open source\nI have been using different incarnations of this library in commercial projects for some time now. It started with a limited set of well-known currencies. Then it grew to include some others until I decided to support all ISO currencies.\nAt that point I realised that there was no way I could support correctly all scenarios for multiple reasons:\n * lack of cultural knowledge (e.g. how does one represent decimals in Swaziland?)\n * lack of technical knowledge (e.g how does one distribute an amount of money amongst a number of parties?)\n\nWith the realisation came the proposal to my employer to Open-Source the library and modify it so that is easy enough for people to help out, even if they are not .Net programmers.\n\nAnd here we are.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgg%2Fnmoneys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgg%2Fnmoneys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgg%2Fnmoneys/lists"}