Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: NaiveMoney #66

Open
mehcode opened this issue Sep 16, 2021 · 3 comments
Open

Request: NaiveMoney #66

mehcode opened this issue Sep 16, 2021 · 3 comments

Comments

@mehcode
Copy link

mehcode commented Sep 16, 2021

It would be a useful abstraction to allow an unknown-currency NaiveMoney type that works as follows:

let money: NaiveMoney = NaiveMoney::from_minor(10);
let money: Money<USD> = money.with_currency(&USD);
  • NaiveMoney can only be constructed and converted to a Money<C>

In the abstract, this would be for any data structure that needs to store N monetary values where the currency type is determined dynamically from some other source.

As a concrete use case, I'd like to use this to represent MONEY from Postgres in SQLx.

Thoughts?

@petar-dambovaliev
Copy link

petar-dambovaliev commented Jan 22, 2022

I think the decision to have the currency type be static was a mistake.
There are so many use cases where you need to deal with data that has mixed currency types.
I really cannot use this library for the exact same reason.
I am parsing a stream of transactions that have transactions in different currencies.

@cameronbraid
Copy link

I think the decision to have the currency type be static was a mistake. There are so many use cases where you need to deal with data that has mixed currency types. I really cannot use this library for the exact same reason. I am parsing a stream of transactions that have transactions in different currencies.

agreed

I was hoping to use this library, but its not usable in any system that needs to deal with arbitrary money values - for example I have money amounts coming from protocol buffers that encode a currency code and a string value - there is no way to use this data with this library

@RonaldLaBelle-Deckers
Copy link

I was also hoping to use this library, but it seems to lack iso::DEM and due to macro usage iso cannot be added to at "our" compile time. It feels odd to have to fork it simply to add an iso.

Perhaps the real issue for my use, is that iso and arbitrary_currency_family do not have an enum wrapper to provide equivalence. As a result, I cannot return either an iso, or an arbitrary currency family during deserialization. If I come up with something, I'll share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants