Reciprocal exchange rate in same legal entity

In some D365 FinOps implementations, we face scenarios where there is a requirement for reciprocal exchange rate between currencies. Out of the Box, D365 FinOps calculates B to A rate when A to B rate is configured and does not allow set up of B to A when A to B rate is configured. To achieve the requirement, we can make a small customization /extension to allow configuration of exchange rate B to A, while having A to B configured in the same exchange rate type.




                                                                                                                                                               



The below extension to the table "ExchangeRateCurrencyPair", enables the setup of reciprocal currency exchange rate.


[ExtensionOf(tableStr(ExchangeRateCurrencyPair))]
public final class NDSExchangeRateCurrencyPair_T_Extension
{
public boolean validateWrite()
    {
        boolean                  ret = next validateWrite();        
        ErrorMsg                 msg;
        int                      infoLineNum;
        
        if (!ret && this.FromCurrencyCode != this.ToCurrencyCode)
        {
            infoLineNum = infologLine();
// Find if the error @SYS340385 is thrown due to reciprocal currency setup and undo the validation error and clear message
            msg = strFmt("@SYS340385", this.FromCurrencyCode, this.ToCurrencyCode);

            if (infolog.text(infoLineNum) == msg)
            {
                infolog.clear(infoLineNum-1);
                ret = true;
            }
        }

        return ret;
    }
}

No other code changes required for Exchange rate pickup for transactions, D365 FinOps standard code first checks for exchange rate "A to B", if not found, then looks for "B to A" to calculate the reciprocal value.

Happy DAXing :)

Comments

Popular posts from this blog

Invoicing multiple Sales order using code in AX 2012

External Code unique value limitation D365FO