Friday, February 23

AX 2012: How to get Exchange Rate from sales Quotation Record.

There are many ways out there to find out the exchange rate of the current record in sales quotation form but below is the standard way to fetch the valid exchange rate amount with valid time frame.



static void GetSalesQuotationTableExhRate(Args _args)
{
    date      _date = systemDateGet();
    SalesQuotationTable tb = SalesQuotationTable::find("ISO-000081");
    CustExchRate    exchRate = 0;
    if (tb.SettleVoucher == SettlementType::SelectedTransact && SalesParameters::find().UseSettleExchRate)
    {
        exchRate = tb.settleExchRate(false);
    }
    if (!exchRate)
    {
        if (tb.FixedExchRate)
        {
            exchRate = tb.FixedExchRate;
        }
        else
        {
            exchRate = Currency::exchRate(tb.CurrencyCode, _date);
        }
    }
    info(strFmt("%3: %1 - %2",tb.CurrencyCode,exchRate/100,tb.QuotationId));
}

No comments:

Post a Comment

Popular Posts