How take the current exchange on register an invoice

DarkHorse
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:
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.
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.
0
Comments
-
That's because you are using the workdate, change that for the date you registered the invoice0
-
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.0 -
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 light0 -
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 321 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions