Search

Custom Search

Monday, September 1, 2008

Convert Balance

Introduction:

While you build your report you may face a case that you want to convert balance or money amount from currency to another. This case comes from that fact that when you want to store balances you store the amount in a decimal type column in your database and you store the currency in another column. This gives you the flexibility to use any convert balance function later to display your balance in your report currency. So we accept that you may display your balances in report with currency (report currency) that differs from the currency stored in the database (database currency).

Report Level Convert:

Business objects presents 4 functions that you can use to convert your balance. But there is two restrictions to use these functions.

Functions:

EuroConvertFrom(balance_amount ; from_currency_ISO ; Decimals _Blaces)

2) EuroConvertFrom(balance_amount; from_currency_ISO ; Decimals _Blaces)

3) EuroFromRoundError(balance_amount; from_currency_ISO ; Decimals _Blaces)

4) EuroToRoundError(balance_amount; from_currency_ISO ; Decimals _Blaces)

Restrictions:

1) You can convert from or to Euro only.

2) You have to select one of the following currencies (Reason: those European nation currencies have a fixed exchange rate with Euro)

Currencies table:

(code):country(currency)

BEF: Belgian (franc)

DEM: German (mark)

GRD: Greek (drachma)

ESP: Spanish (peseta)

FRF: French (franc)

IEP: Irish (punt)

ITL: Italian (lira)

LUF: Luxembourg (franc)

NLG: Dutch (guilder)

ATS: Austrian (schilling)

PTS: Portugese (escudo)

FIM: Finnish (mark)

Universe Level Convert:

You have to write a database procedure and use it whenever you need to convert balance. You can write a tailored procedure or a general use one. Here is a small pseudo code that you can use:

Convert_balance (p_balance, p_from_currency, p_to_currency, p_as_of_date) return converted _balance

{

Select exchange_rate

Into v_exchange_rate

From daily_exchange_rate_table a

Where a.as_of_date = p_As_of_date

And a.from_Currency = p_from_currency

And a.to_currency = p_to_currency

Return p_balance * v_exchange_rate;

}

No comments:

Post a Comment