How take the current exchange on register an invoice

DarkHorseDarkHorse Member Posts: 389
Dear sirs, I've an invoice report that shows the invoice amount and calculates the VAT over it. We work in EUR. We also want that when the currency is USD calculates the VAT with the change of the day that we register the invoice or the most approximate. The code is this:
CustAmount:="Sales Invoice Line".Amount;
IF ("Sales Invoice Header"."Currency Code" = '') THEN
AmountLCY:=CustAmount
ELSE
AmountLCY:=CurrExchRate.ExchangeAmtFCYToLCY(
WORKDATE,"Sales Invoice Header"."Currency Code",CustAmount,"Sales Invoice Header"."Currency Factor");
ProfitLCY := AmountLCY - CostLCY;
IF AmountLCY <> 0 THEN
 ProfitPct := ROUND(100 * ProfitLCY / AmountLCY,0.1);

CustAmonut, AmountLCY, ProfitPct are decimal variables


It works perfectly, but we noticed that takes the exchange of the present day, not when we registered the invoice, then, of course, the amount changes every time that we print the invoice. What I have to change in this code to get the exchange of the day that we registered the invoice?.
Thanks and regards.

Comments

  • MBergerMBerger Member Posts: 413
    That's because you are using the workdate, change that for the date you registered the invoice
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply, but, what is the code to do that?, I've try to erase the Workdate code but it shows me an error.
    Thanks.
  • philippegirodphilippegirod Member Posts: 191
    Be carefull !
    It is not the right solution to take exchange rate. On creating invoices the user is able to change the exchange rate (for many good reasons), so in posted invoices, the currency rate will be different.

    By luck, the Currency factor is in the Header ("Sales Invoice Header"."Currency Factor").

    Other problem, this Currency Factor is 0 if the Currency Code is empty (if in your example, the invoice is in EUR). But this point is very easy to solve.
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • DarkHorseDarkHorse Member Posts: 389
    Ok, thanks both for help; I've changed WORKDATE by "Sales Invoice Header"."Document Date" and it works fine;gets the exchange from the register date.
    Thanks again for help.
Sign In or Register to comment.