hey yall,
I created a report for our client where he can select multiple lines and it will create a receipt.
If the user selects a line which has a document type of: credit memo and then he select another line with a document type of invoice; my report works perfectly fine (it calculates the values correctly). However, if its the other way around, and the invoice document type line is before the credit memo document type, then my calculations dont work. I tried debugging the code and in the debugger, it calculates the correct answer but it doesnt display it, so i end up getting the wrong answer.
Any idea what might be happening???
0
Answers
DataItems in the report
Sections are you using to display the values
Variables and maybe code you are using to get the data?
KCP Consultores
Sections and Code: http://www2.zshare.ma/dr3vjuqa8tnh
I do not see where you are adding TotalAmountE anywhere if that matters.
KCP Consultores
IF ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::"Credit Memo") OR
("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::Refund) OR
("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::"Finance Charge Memo") OR
("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::Reminder) THEN
BEGIN
CurrReport.SHOWOUTPUT(FALSE);
TotalAmountE += "Cust. Ledger Entry".Amount;
END;
I have been working on this for few hours now and the strange part is that the debugger calculates the correct answer for Totals variable...but its not outputting the correct answer. No matter what the value the debugger has for totals fields...it always output value of the Inovice's amount..... ](*,)
When I am going through the debugger and it calculates this line: Totals := TotalAmountI + TotalAmountIC;
after that it goes through Totals (PreDateItem) trigger that has the following code: "Cust. Ledger Entry".CALCFIELDS(Amount); Do you think this might be resetting the value to the invoice amount????
You are skipping to show the Total footer section if the document type is Credit Memo anyway so that will not show and would give you a wrong number unless an Invoice was last.
If I don't have what you are trying to show, maybe a sample of what you want and what you are getting would help.
KCP Consultores
Initially I had only the cust. ledger entry as a dataitem...but i had to change it since i couldnt get it to display the correct totals and i believe you are the one who helped me by telling me that i should create a totals dataitem to keep track of totals. .
viewtopic.php?f=23&t=53343
Also as I said in an earlier post and the original, do your adding in the OnAfterGetRecord of Cust. Ledger Entry. The Integer dataitem is just to display the totals after you have accumulated them.
KCP Consultores
Cust. Ledger Entry - OnAfterGetRecord
( Cust. Ledger entry - PostDateItem ) & (Totals - PostDataItem) has the following code:
ScreenShot of what the report looks like now: http://www2.zshare.ma/n7pzojj030sq
Now it performs the calculations perfectly :thumbsup:. But a whole new issue has been created: If the document type invoice is above the credit memo line, now it wont show the UserDescription. But if its the other way around (credit memo above invoice) it shows the description. ](*,)
KCP Consultores
It works now!!!
I have been working with NAV for few months now and I thought I was slowly getting better at troubleshooting and coding but then there are problems like these which I am completely lost.
Why did moving everything to OnAfterGetRecord (cust. ledger entry) worked??? I sorta see the point of using Totals and putting all the fields in the footer of total but I dont get it at the same time.... Why did it not work initially when we placed the code in the footer of cust. ledger entry???
KCP Consultores