hi all,
i write below code for testing purpose to get exchange rate for sales order line
Gl - setup
public display Amount GDJ_ExchangeRate() { ExchangeRate exchangeRate; ExchangeRateType ExchangeRateType; ExchangeRateCurrencyPair exchangeRateCurrencyPair; real exchRate; CurrencyCode fromCurrency = 'USD'; CurrencyCode toCurrency = Ledger::find(Ledger::current()).AccountingCurrency ; TransDate transDate = mkDate(7,8,2020);//this.TransDate; while select exchangeRateCurrencyPair where exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType && exchangeRateCurrencyPair.FromCurrencyCode == fromCurrency && exchangeRateCurrencyPair.ToCurrencyCode == toCurrency { exchRate = exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,transDate).ExchangeRate; info(strFmt("%1",exchRate/100)); } return exchRate/100; }
i debugged the above code
form Currency- USD
to Currency = JPY
transdate = mkdate();
while select exchangeRateCurrencyPair
where exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType
***here i am getting ReciD = 0, if i am not wrong , it should be return Standard
please help me
Sure, i will check
actually yesterday my functional consultant said, to get the value 1.07 exchange rate . So, i set the formula
Hi @rp@n,
Usually, the exchange rate is stored per 100 (but depends on set up), so in your case, it's not 12.166, but 121.66 (USD->JPY) (12166 \ 100)
1.07 most likely is JPY -> USD (again it's per 100 JPY)
In CustConfirmJour you can see the actual exchange rate that was used when the confirmation was posted.
Does your customer want that? If yes, then please use it.
Your code could return different result for many reasons:
- Different date is used in your code than what was used for determining CustInvoiceJour.ExchRate
- You have changed the exchange rates for that date after the confirmation was posted
- Your code has a bug
But none of the above are relevant if you actually need the exchange rate of the confirmation. Then there's no need to use time and money struggling with your custom code. That's why its' important to always check if the business requirement can be fulfilled by using the features (or data) that already exists in the standard system.
yes Nikoloas,
i saw in table CustConfirmJour
but it's showing 12.166 exchnage rate
in my code it's coming 1.07 exchange rate
please give me more shed on his
By the way, in your code you are selecting CustConfirmJour. You could just use CustConfirmJour.ExchRate without needing to fetch the exchange rate from anywhere else.
Please see this document to learn how to multiply with x : docs.microsoft.com/.../arithmetic-operators
If you have value "x" in exchangeRate variable, and you would want it to be "100x", following code will do it for you:
exchangeRate = exchangeRate * 100;
Is it now clear?
yes, per 1 unit i need the exchange rate. like 1.07 exchange rate in pics i marked
Are you saying that the result that you get is 1/100 of what you would want?
And you need help in multiplying exchangeRate variable by 100?
Is this correct?
public void GDJ_ExchangeRates(Args _args) { SalesTable salesTable; CustConfirmJour custConfrmJour; ExchangeRateHelper exchangeRateHelper; CurrencyCode fromCurrency,toCurrency; CustAccount customerCode; TransDate confirmDate; real exchangeRate; real a,b; ; while select SalesTable where SalesTable.SalesId == "SO-0000008" { customerCode = salesTable.CustAccount; fromCurrency = custTable::find(customerCode).Currency; // USD toCurrency = Ledger::accountingCurrency();//"JPY"; select custConfrmJour where custConfrmJour.SalesId == salesTable.SalesId; if(custConfrmJour) { confirmDate = custConfrmJour.ConfirmDate; exchangeRate = Currency::exchRate(fromCurrency, confirmDate); info(strFmt("%1",exchangeRate)); } } }
the above code, return the exchange rate based on Quotation unit = 100 i.e 0.01
formula = 100/9332.69 = 0.01
i have required the exchange rate based on quotation unit = 1
i have required the out put 1.07 exchange rate
please give me more shed on this
thanks Nikoloas
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156