Math Currency Requirements
The following requirements are necessary when defining currency requirements within math expressions.
General Currency Requirements
-
Math Currency attribute: the MathVariable element supports the ability to specify the Currency code for a currency math variable. The Currency Attribute is only supported by MathVariable Type=Decimal.
-
The Math Type CURRENCY supports an expression as the text of the MathVariable element. The result of the expression must result in a DECIMAL. All operands used in the expression must be a numeric type or numeric literal.
-
The Currency configuration for a math variable will only be specified using the three letter currency code as specified in ISO 4217.
-
Math supports the lookup of a Currency Code from a field by appending CurrencyCode to the field. For example, to look-up the currency code from a Plan field, the reference would be Plan:FieldX:CurrencyCode.
-
All expression operands must be either currency or numeric math variables. You cannot use literal values (i.e., James), or other variables that are not currency or decimal variables in math expressions.
-
All currency variables used in an expression in a math variable must be of the same currency. For example, you cannot have a currency operand of Currency USD and another currency operand of Currency GBP used in the same math expression.
-
A decimal literal can be used to assign a value to a math currency variable.
-
Currency to Decimal conversion: math supports the conversion of a currency math variable to another math variable of Type=Decimal.
-
Math does not support conversions to or from any non-numeric type.
-
Math provides access to the currency code for a math variable to be used in other places in configuration.
Converting Currency Requirements
-
The Math CURRENCY Type supports an OPERATION attribute that will handle currency requests.
-
Math supports the CONVERT OPERATION, which will process a currency conversion. The CONVERT OPERATION uses the following attributes:
-
FROMCURRENCY: The currency denomination an amount of money being converted from. Valid values include a three letter Currency Code or a reference to a field or other math variable that contains the currency code.
-
TOCURRENCY: The currency denomination an amount of money is being converted to. Valid values include a three letter Currency Code or a reference to a field or other math variable that contains the currency code.
-
MARKETMAKER: The GUID for the MarketMaker that provides the exchange rates used for the currency conversion.
-
EXCHANGEDATE: (Optional) The effective date for the exchange rate to be used in the conversion. If not specified, the last known exchange rate is used.
-
VALUE: The amount of money in FROMCURRENCY.
-
Math will allow a currency variable of one currency to be converted to a currency variable of another currency.
-
When a currency value is assigned to a math currency variable of a different currency designation, an implicit currency conversion will occur.
-
Math supports the conversion of a decimal variable to another math variable that is a currency.
-
Math provides access to the currency conversion details that can be used elsewhere in configuration. The Currency detail must provide the Originating Currency Code, Originating Currency Amount, Resulting Currency Code, Resulting Currency Amount, Currency Conversion Cost, and Exchange Rate.
XML Examples
The following XML examples demonstrate how currency is defined within math expressions.
Currency Conversion Example
This example shows the conversion of a currency variable from US dollars (USD ) to Japan Yen (JPY):
-
DisbursementAmt: This screen field contains the amount of currency to convert. It has an associated CurrencyCode of USD.
-
We are converting to JPY.
<MathVariable VARIABLENAME=”DisbursementAmountJPY”
TYPE=”CURRENCY”
OPERATION=”CONVERT”
FROMCURRENCY=”Activity:DisbursementAmt:CurrencyCode”
TOCURRENCY=”JPY”
MARKETMAKER=”MarketMakerRef”
EXCHANGEDATE="Activity:EffectiveDate">
DisbursementAmt
</MathVariable>
Math variable with decimal literal assignment
This example shows a currency math variable being defined:
-
SuspenseAmount: is set to 500,000 EUR
Math variable with currency math variables in an expression
This example shows three math variables being defined:
-
TransferAmount: is set to 100,000 USD
-
CommissionAmount: is set to 5,000 USD
-
TransferAdjustedAmount: is set to an expression, TransferAmount-CommissionAmount, which would result in 95,000 USD
Math variable with currency math variables in an expression and currency conversion
This examples shows three math variables being defined:
-
Premium: set to 100,000 USD
-
AdjustedFactor: set to 10 USD
-
PremiumAdjustedAmount: set to 100,000 USD divided by 10 USD, which is 1,000 USD. However, this amount must be converted to JPY (Japanese yen) through a currency conversion calculation (defined later). If the price of the currency conversion for USD/JPY is 1/110, then the result of the math expression would be 110,000 JPY.