Monday 6 January 2020

conver amount from one currency to another currency

conver amount from one currency to another currency

 fromCurrecncy = projTable.currencyId();
        toCurrency  = Ledger::findByLegalEntity(CompanyInfo::findDataArea(curext()).RecId).AccountingCurrency;

        if(fromCurrecncy != toCurrency)
        {
            select ExchangeRate,ExchangeRateCurrencyPair from exchangeRate order by RecId desc
                join RecId,ExchangeRateDisplayFactor,ToCurrencyCode,FromCurrencyCode from exchangeRateCurrencyPair
                join RecId,Name from exchangeRateType where exchangeRate.ExchangeRateCurrencyPair == exchangeRateCurrencyPair.RecId
                    && exchangeRateType.RecId == exchangeRateCurrencyPair.ExchangeRateType
                    && exchangeRateType.Name == 'Default'
                    && exchangeRateCurrencyPair.FromCurrencyCode == fromCurrecncy
                    && exchangeRateCurrencyPair.ToCurrencyCode == toCurrency;

            conRevenueAmount = (exchangeRate.ExchangeRate * revenueAmount1)/minOne(exchangeRateCurrencyPair.ExchangeRateDisplayFactor);

            conRevAmount = strFmt("%1",conRevenueAmount);

            curExRate = strFmt("%1",exchangeRate.ExchangeRate);
        }