Best Practice - Format Multiple Currencies
Asked Answered
C

5

17

What is best practice for the scenario listed below?

We have an application which we would like to support multiple currencies. The software will respect the users locale and regional settings to dictate the correct number format, i.e. $10,000.00 or 10.000,00₴ etc.

We would however like to be able to format different numbers based upon a currency ID (perhaps the three letter ISO4217 code). Our idea is to store a table in the database with each currency and then request from the user to select the currency symbol which will be used. The program will then format all numbers based upon the locale/region setting but will use the currency symbol as defined in our program.

So, given the following values and currencies
10000 AUD
5989.34 USD
450 EUR

the program would output
$10,000.00
$5,989.34
€450.00

or with a regional setting that formated numbers as #####,##$ the result would be;
10000,00$
5989,34$
450,00€

Respecting locale/region number formatting but displaying different currencies, what is best practice for this?

I hope this makes sense.

Technology used is c# .NET 2.0.

Chockfull answered 24/4, 2009 at 7:0 Comment(1)
You should reference your previous question, I think they go well together: #784471Centri
T
7

I think this Q is an excellent and clear answer as to WHAT you should be doing

SO - Proper currency format when not displaying the native currency of a culture

And this Q has a good answer of HOW to do this in C#

SO - Currency formatting

Tonga answered 1/7, 2009 at 21:33 Comment(1)
I know this is an old answer, but you should quote the relevant portions of these links here.Ule
C
3

It sounds like you have a handle on the best practices for formatting data. If I were you I would worry less about what is technically the standard but focus more on what it is your users are accustomed to.

If you are operating in markets where users are fairly savvy about different currencies it is a very different thing than having more monocultural users. Depending on the case, you will need to design your interface in a different way.

Moreover, if your requirement is to display any currency to any locale, the ISO4217 standard is your best bet. It is what is shown at currency exchange shops across the world, on currency exchanges, invoices, etc. Otherwise, displaying currency symbols could be rather confusing to some users and the symbol by itself does not indicate what currency the amount actually is.

I would also reference the following SO questions. Not all of them directly relate to your problem, but they have very good meta discussions about the issues involved in supporting multiple currencies.

Centri answered 24/4, 2009 at 9:37 Comment(0)
G
1

Rather than storing just the currency symbol, you could store the culture string for each currency code, so AUD --> en-AU

CultureInfo ci = new CultureInfo("en-AU");
currencyValue.ToString( "c", ci );

I'm not sure how much flexibility there is in formatting available.

Not sure if this helps:

Formatting Numeric Data for a Specific Culture

Godmother answered 24/4, 2009 at 9:38 Comment(2)
This is not a viable solution for currencies which are used in multiple locales, like the Euro. Different countries in the Euro zone have different number formats.Narrows
i agree. the number format has to respect the current culture of the computer whilst the currency symbol represents any currency. the solution proposed is not viable.Chockfull
T
0

You could store the money value as a decimal, then append the currency symbol on the UI.

Fowler discusses the Money pattern in Patterns of Enterprise Application Architecture here: http://www.martinfowler.com/eaaCatalog/money.html

Tonsil answered 24/4, 2009 at 7:7 Comment(0)
M
0

I faced a similar situation. I found a way, dont know how useful it will be for you. But it solved my problems. I set a session string for each place like Session["cur"]="0.000" or "0.00" for each login authentication. And where ever currency comes in the system I used .ToString[Session["cur"].ToString()] to the model variables. It did the trick for me . Hope it helps you too .

Mind answered 13/2, 2017 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.