Strange report issue

nverma
Member Posts: 396
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???
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
-
Would you provide some more detail?
DataItems in the report
Sections are you using to display the values
Variables and maybe code you are using to get the data?Gerry Kistler
KCP Consultores0 -
DateItems and OnAfterGetRecord: http://www2.zshare.ma/153ofl2anrxx
Sections and Code: http://www2.zshare.ma/dr3vjuqa8tnh0 -
Is the Total footer supposed to be per document or a grouping of documents?
I do not see where you are adding TotalAmountE anywhere if that matters.Gerry Kistler
KCP Consultores0 -
Its doing it per document and TotalAmountE is calculated here:
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????0 -
Well if Totals is meant to be the total for the report, why do you have the Total integer data item? I would do the adding in the Cust. Ledger Entry OnAfterGetRecord and put the Totals in the Cust. Ledger Entry footer with TotalAmountP and AmountOwing.
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.Gerry Kistler
KCP Consultores0 -
I dont want it to show to the line if the document type is credit memo (I dont want to see the description). But i still want it to keep track of the totalAmountIC field so i can use that to calculate the totals field and display the correct answer beside the description of the (document type: invoice)
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=533430 -
Fair enough, I am not sure why you started a new thread instead of posting in the original. Now that everything is together in my head the issue is that the Total dataitem is indented under Cust. Ledger Entry. Do not indent it, place it directly below.
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.Gerry Kistler
KCP Consultores0 -
I did it the way you suggested: I moved Integer DateItem under the Cust. Ledger entry.
Cust. Ledger Entry - OnAfterGetRecord"Cust. Ledger Entry".CALCFIELDS(Amount); //OMODNV01 - ADD Start //Checks to see if the Document Type is Payment. If it is, then Dont show this section. //Calculate the Total Amount by adding all the Amount field of "Document Type" 'Payment' //Checks to see if the "Document Type" is 'Invoice'. If it is, calculates the Total Amount // by addding all the Amount fields. IF ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::Payment) OR ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::" ") THEN BEGIN // CurrReport.SHOWOUTPUT(FALSE); TotalAmountP += "Cust. Ledger Entry".Amount; END; IF ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::Invoice) THEN BEGIN // CurrReport.SHOWOUTPUT(TRUE); TotalAmountI += "Cust. Ledger Entry".Amount; END; //OMODNV01 - ADD Start //OMODNV04 - ADD Start // Checks to see if the Document Type is Credit Memo and if it is, then it keeps tracks of the Amount field // for the selected line IF ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::"Credit Memo") THEN BEGIN // CurrReport.SHOWOUTPUT(FALSE); TotalAmountIC += "Cust. Ledger Entry".Amount; END; //OMODNV02 - ADD Start // If the Document Type is "Credit Memo" or "Refund" or "Finance Charge Memmo" or "Reminder" then do not // show in this section. 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; //OMODNV02 - ADD End // Totals is calculated by Adding the Document Type: Invoice and Document Type:Credit Memo Totals :=TotalAmountIC + TotalAmountI ; //OMODNV04 - ADD End //OMODNV01 - ADD Start //Calculates the AmountOwing by adding the TotalAmountI (Invoice) and TotalAmountP (Payment) and TotalAmountE (EverythingElse) AmountOwing := TotalAmountI + TotalAmountP + TotalAmountE; //OMODNV01 - ADD End
( Cust. Ledger entry - PostDateItem ) & (Totals - PostDataItem) has the following code://OMODNV03 - Add Start // If the UserDescription Field is empty, it will automatically be set to Cust. Ledger Entries description. IF UserDescription = '' THEN BEGIN //OMODNV04 - ADD Start IF ("Cust. Ledger Entry"."Document Type" = "Cust. Ledger Entry"."Document Type"::Invoice) THEN //OMODNV04 - ADD End UserDescription := "Cust. Ledger Entry".Description; END; //OMODNV03 - Add Start
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. ](*,)0 -
Put your UserDescription population in the Cust. Ledger Entry with the totalling.Gerry Kistler
KCP Consultores0 -
:shock:
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???0 -
Because the footer only knows the last record read.Gerry Kistler
KCP Consultores0
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
- 320 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