Skip to content

Instantly share code, notes, and snippets.

@bayramcetin
Created October 27, 2022 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayramcetin/8b933f958f750619da1c14665bf4f31f to your computer and use it in GitHub Desktop.
Save bayramcetin/8b933f958f750619da1c14665bf4f31f to your computer and use it in GitHub Desktop.
public class ETGFindExchRateHelper
{
public static ExchRate findExchRate(TransDate _transDate, CurrencyCode _fromCurrency, CurrencyCode _toCurrency = Ledger::find(Ledger::current()).AccountingCurrency)
{
ExchangeRateCurrencyPair exchangeRateCurrencyPair;
ExchRate exchRate;
select firstonly exchangeRateCurrencyPair
where exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType
&& exchangeRateCurrencyPair.FromCurrencyCode == _fromCurrency
&& exchangeRateCurrencyPair.ToCurrencyCode == _toCurrency;
exchRate = ExchangeRate::findByDate(exchangeRateCurrencyPair.RecId, _transDate).ExchangeRate;
return exchRate;
}
public static ExchRate findExchRateByExchangeRateType(ExchangeRateTypeRecId _exchangeRateType, TransDate _transDate, CurrencyCode _fromCurrency, CurrencyCode _toCurrency = Ledger::find(Ledger::current()).AccountingCurrency)
{
ExchangeRateCurrencyPair exchangeRateCurrencyPair;
ExchRate exchRate;
select firstonly exchangeRateCurrencyPair
where exchangeRateCurrencyPair.ExchangeRateType == _exchangeRateType
&& exchangeRateCurrencyPair.FromCurrencyCode == _fromCurrency
&& exchangeRateCurrencyPair.ToCurrencyCode == _toCurrency;
exchRate = ExchangeRate::findByDate(exchangeRateCurrencyPair.RecId, _transDate).ExchangeRate;
return exchRate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment