Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

using EURO as a base currency in fMoney

posted by mrworks 9 years ago

Ciao! Would it be possible to use euro (or other currency) as a base currency in fMoney? I am going to build an application which involves different European currencies, but not USD. So it would be quite odd to use USD as a base currency :)

This should be pretty easy. First, define the Euro as a currency:

fMoney::defineCurrency(
    'EUR',            // The three digit ISO code
    'Euro',           // The name of the currency
    '',              // The currency symbol
    '2',              // The precision after the decimal point
    '1.00000000'      // The current exchange rate with your base currency - this will be 1 since it is your base
);

Then you'll probably to set the Euro as your default currency:

fMoney::setDefaultCurrency('EUR');

You can now defined any number of other currencies, just be sure to set their value relative to the euro so that conversions are accurate.

Even if you aren't planning on using USD, it comes defined by default, so you might want to re-define it with a correct value relative to the Euro. This way if a developer does use it, conversions will not be incorrect. Unfortunately there is currently no way to delete a defined currency, otherwise I would recommend deleting it.

posted by wbond 9 years ago