dgg / nmoneys Goto Github PK
View Code? Open in Web Editor NEW.Net implementation of Money Value Object
License: BSD 3-Clause "New" or "Revised" License
.Net implementation of Money Value Object
License: BSD 3-Clause "New" or "Revised" License
As part of the CI build, the TestResult.xml should be turned into an HTML report, pushed as an artifact and pushed to gh-pages tag.
Check
for reference
Add:
CurrencyIsoCode Currency.Parse(string)
bool Currency.TryParse(string , out CurrencyIsoCode)
CurrencyIsoCode? Currency.TryParse(string)
Original issue reported on code.google.com by [email protected]
on 14 Nov 2013 at 2:35
Add support for getting the html entity information for those currencies that
support it.
http://www.alanwood.net/unicode/currency_symbols.html
http://www.w3schools.com/tags/ref_entities.asp
Original issue reported on code.google.com by [email protected]
on 4 Nov 2010 at 9:41
Check whether the library is CLS compliant and if so, make it splicit.
Run static anlysis on it.
Original issue reported on code.google.com by [email protected]
on 4 Nov 2010 at 10:05
Whenever .Format() is called including the amount placeholder, the number is
formatted according to the default .ToString(), not as a monetary amount.
Original issue reported on code.google.com by [email protected]
on 17 Mar 2013 at 9:00
It would be great if the Json.net deserializer could accept a standard decimal
(float) value and make it into a Money data type with currency XXX. It would
help getting data from existing services.
Suggested code:
var token = JToken.ReadFrom(reader);
if(!token.HasValues)
{
decimal value;
if (!decimal.TryParse(token.ToString(), out value))
throw new ArgumentException("Invalid content");
return new Money(value);
}
return new Money(
readAmount(token),
readCurrency(token));
Original issue reported on code.google.com by [email protected]
on 12 May 2014 at 10:59
As Money is now a class, nulls need to be handled in operator and arithmetics
operations arguments
null + something = something
something + null = something
null + null = null
m.Add(null) = m
null - something = -something
something - null = something
null - null = null
m.Substract(null) = m
null * something = null
something * null = null
null * null = null
-null = null
...
Original issue reported on code.google.com by [email protected]
on 2 Jul 2010 at 6:30
Readme of the project has 2 different ISO numbers, but I guess is just a misspell and they should be the same. There is only 1 digit difference. And ISO 4417 seems to be about cloth sizes.
Are there any plans to support SerializableAttribute for .netstandard 2.0?
CLF goes from 0 decimals to 4
Original issue reported on code.google.com by [email protected]
on 6 Jan 2014 at 3:20
As the serialization files are added into the project and compiled together with the source files, the F# projects doesn't allow files with extensions like .cs to be added.
http://www.currency-iso.org/en/shared/amendments/iso-4217-amendment.html
MWK
name change: "Kwacha" to "Malawi Kwacha".PEN
: change currency name from "Nuevo Sol" to "Sol".VEF
name "Bolívar".Use OpenCover to run unit tests as part of the CI build and push reports to gh-pages
Check (https://channel9.msdn.com/coding4fun/blog/Free-Unit-Testing-Code-Coverage-with-OpenCover-and-ReportGenerator?WT.mc_id=dlvr_twitter_ch9) for information about how to do it
Is there any support for System.Text.Json (de)serialization or plans to add that?
XP: framework 2, 3.5, 3.5 SP1
2003 Server: framework 2, 3.5, 3.5 SP1
Vista: framework 2, 3.5, 3.5 SP1
2008 Server: framework 2, 3.5, 3.5 SP1
W7: framework 2, 3.5, 3.5 SP1
Original issue reported on code.google.com by [email protected]
on 12 Jul 2010 at 5:59
Hello
I've just recently adapted my app to use your excellent lib.
One of my fields contain an amount expressed with NMoneys (different currencies on different rows).
I just tryed binding directly to a NMoneys.Money field, but the datagrid would not order. Am i missing something ?
Sometimes passing a lowercase three-letter code is fine (as in
Currency.Get("usd")) but sometimes it throws (new Money(10m, "usd")).
Make it consistent (and preferably case-insensitive)
Original issue reported on code.google.com by [email protected]
on 4 May 2011 at 7:26
I don't found support for multiplication and division for decimal numbers.
For example I would like to use something like var valueOfSmth = price * 1.3; where price is Money.
Is it intentionally not implemented or it is good feature to implement?
Implement a functionality to parse a monetary amount.
Original issue reported on code.google.com by [email protected]
on 28 Oct 2010 at 7:08
You forgot to add this to Money so that xml serialization with web services
works correctly, [XmlSchemaProvider("GetSchema")]
Original issue reported on code.google.com by [email protected]
on 12 Dec 2011 at 8:03
Add <, >, <=, >= operator overloading to Money. Compare with Money and decimals.
Original issue reported on code.google.com by [email protected]
on 16 Jan 2011 at 5:06
Currencies are volatile, new currencies get added and old ones get substituted.
Currencies and moneys can be serialized somehow.
What steps will reproduce the problem?
1. have an old deprecated currency serialized
2. try to deserialize
3. the object can't be reconstructed
Explore the options to intercept the de-serialiation process.
Original issue reported on code.google.com by [email protected]
on 25 Oct 2010 at 12:58
Are there any plans to release a version of NMoneys implemented as a class and not a struct.
This would be really useful for using Money in Entity Framework applications.
Entity Framework does not support structs, only classes as a complex type columns.
It would be very nice if the entry on nuget.org was linking the GitHub repository. It's still linking to the old Google Code page. Thanks!
MakeChange()
works under the premise that the set of denominations that is passed is infinite, that is, we never "run out" of pieces for each denomination.
In the real-world, there is only a finite amount of pieces of each denomination. Change the algorithm (and change Denomination
as well) or create another method (taking, for instance a collection of FiniteDenomination
s) to support this real-world scenario.
Implement empty tests
Original issue reported on code.google.com by [email protected]
on 4 May 2011 at 12:07
Can you please sign the output assemblies so that we can use them in other
projects without having to sign them ourselves?
Original issue reported on code.google.com by [email protected]
on 19 Aug 2011 at 11:29
What steps will reproduce the problem?
1. Execute the following code in an en-US or en-GB context.
2. Console.WriteLine(Money.Parse("€1000.00", Currency.Eur));
What is the expected output? What do you see instead?
The output is "100.000,00 €". This is partially understandable but also
confusing. It is understandable insofar as Eurozone countries tend to use the
period/full-stop as the thousands separator and the comma as the decimal
separator. However, it is confusing in that the code is running in a culture
context that reverses these symbols. I would *not* argue for a change in the
current behaviour, but an ability to provide a NumberFormatInfo to use when
parsing the decimal portion would be good. See below for an example
implementation.
What version of the product are you using? On what operating system?
Version 3.5.1.0 on Windows 8.1 Update 1, .NET 4.5.
Please provide any additional information below.
Attached is a modification of Money.Parsing.cs file to add a new overload
taking NumberFormatInfo. I would very much like for this to be merged into the
code base. I assign the copyright to the copyright owner of the existing file,
provide no warranty as to its usage, etc. etc.!
Original issue reported on code.google.com by [email protected]
on 7 Aug 2014 at 10:21
Attachments:
CountWaysToMakeChange()
works under the premise that the set of denominations that is passed is infinite, that is, we never "run out" of pieces for each denomination.
In the real-world, there is only a finite amount of pieces of each denomination. Change the algorithm (and change Denomination
as well) or create another method (taking, for instance a collection of FiniteDenomination
s) to support this real-world scenario.
From 2014/01/01 Latvian lats LAT become deprecated in favor of EUR.
Original issue reported on code.google.com by [email protected]
on 6 Jan 2014 at 3:20
Just spotted that the ExchangeConversion class will instantiate a new Money
even if the target currencyCode is the same as the source currencyCode. Could
this be optimized like this:
public Money To(CurrencyIsoCode to)
{
if (_from.CurrencyCode == to)
return _from;
ExchangeRate rate = _provider.Get(_from.CurrencyCode, to);
return rate.Apply(_from);
}
Original issue reported on code.google.com by [email protected]
on 10 Sep 2012 at 8:29
While doing some research for the Ammendment 159, I discovered that CVE moneys
are not to be formatted with a symbol.
So 12.25 CVE should be formatted as 12$25 and not $12$25.
Original issue reported on code.google.com by [email protected]
on 1 Sep 2014 at 1:50
Xml: public class SerializationHelper<T> where T : class
{
public string SerializeXml(T o)
{
var serializer = new XmlSerializer(typeof(T));
var sb = new StringBuilder();
using (var tw = new StringWriter(sb))
{
serializer.Serialize(tw, o);
}
return sb.ToString();
}
public T DeserializeXml(string text)
{
var serializer = new XmlSerializer(typeof(T));
using (var tr = new StringReader(text))
{
return (T)serializer.Deserialize(tr);
}
}
}
Xaml and datacontract
Original issue reported on code.google.com by [email protected]
on 1 Jul 2010 at 11:12
When trying to make a NMoneys.Currency.Get(<<currencyIso>>) of an uninitialised
currency from multiple concurrent System.Threading.Tasks.Task you will get:
System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at NMoneys.Support.ThreadSafeCache`2.Add(TKey key, TValue value)
at NMoneys.Currency.Get(CurrencyIsoCode isoCode)
You have in the attach the unit test to reproduce this.
I may suggest to use ConcurrentDictionary<TKey, TValue> to keep the initialized
currencies.
Thank you for your useful library!
Regards,
Cosmin
Original issue reported on code.google.com by [email protected]
on 23 Feb 2015 at 9:27
Attachments:
Now that the information is easily available and a estrategy for obsolete
currencies is in place, historical currencies can be added to the library from
http://www.currency-iso.org/dl_iso_tables_a3.xls
Original issue reported on code.google.com by [email protected]
on 9 Mar 2011 at 12:00
Add a new overload to Currency.Get() and Currency.TryGet() that receives and
instance of RegionInfo
Original issue reported on code.google.com by [email protected]
on 20 Nov 2010 at 4:10
MakeOptimalChange()
works under the premise that the set of denominations that is passed is infinite, that is, we never "run out" of pieces for each denomination.
In the real-world, there is only a finite amount of pieces of each denomination. Change the algorithm (and change Denomination
as well) or create another method (taking, for instance a collection of FiniteDenomination
s) to support this real-world scenario.
Similarly to `CurrencyEqualityComparer` we can surface a faster enum comparer
for `CurrencyIsoCode`
Original issue reported on code.google.com by [email protected]
on 15 Apr 2014 at 9:07
Investigate Xaml serialization for Money now that it does not depend on Currency
Original issue reported on code.google.com by [email protected]
on 25 Oct 2010 at 2:27
Use some sort of tool to dig into the possible exceptions to be thrown
Check and test that TryXXX methods do not throw an exceptions
Original issue reported on code.google.com by [email protected]
on 21 Nov 2010 at 10:08
Hallo, i can not use NMoneys in .NET Core project. When is extension provided?
Currently is
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(Serialization.Data.Money.AMOUNT, Amount);
info.AddValue(Serialization.Data.Money.CURRENCY, CurrencyCode, typeof(Currency));
}
Should be:
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(Serialization.Data.Money.AMOUNT, Amount);
info.AddValue(Serialization.Data.Money.CURRENCY, CurrencyCode, typeof(CurrencyIsoCode));
}
See https://msdn.microsoft.com/en-us/library/akebc4z9(v=vs.110).aspx
https://github.com/dgg/nmoneys/blob/master/src/NMoneys/Money.Serialization.cs
With this fix, Money serializes fine with VelocityDB, see https://velocitydb.com/
It should make use of an internal Currency instance when needed, but is state
is made up of a decimal amount and a CurrencyIsoCode currency
Original issue reported on code.google.com by [email protected]
on 25 Oct 2010 at 12:55
Hey :)
Do you have any documentation regarding the decision for formatting DKK symbol as "kr" and not "kr."?
I'v been asked to change the formatting, and just want to make sure that we're doing the right thing.
Hi,
For CLP amounts, it doesn't add on 2 zero's for the minor amount. Is this expected behaviour or a bug?
Thanks
Neil
Hi!
That is a cool library, thanks for your time to develop it and make others life easier:)
While integrating it into my project I've found wrong allocation using ratios:
10m.Usd().Allocate(new RatioCollection(1m, 0m));
Expected result: 10m & 0m
Act result: 10.01m & -0.01m
NMoneys version: 6.1.0
Seems the problem is in Currency.Round
method in MidpointRounding
value.
internal decimal Round(decimal share)
{
decimal raw = share - (.5m * MinAmount);
decimal rounded = Math.Round(raw, SignificantDecimalDigits, MidpointRounding.AwayFromZero);
return rounded;
}
Thanks in advance.
New extensions methods to get the alphabetic and numeric codes for the
enumeration value itself can be included
Original issue reported on code.google.com by [email protected]
on 4 May 2011 at 1:56
As an effort to popularize the library, packages for the current packaging
systems in .NET:
* Openwrap
* Nu
* NuPack
* HornGet
* CoApp
* whichever one you request
Original issue reported on code.google.com by [email protected]
on 25 Oct 2010 at 9:22
In order to facilitate the approach for non-developers it would be advantageous
if the project had a desktop executable that showed-off the features of the
library.
A simple WPF application would do the work.
Original issue reported on code.google.com by [email protected]
on 28 Oct 2010 at 7:04
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.