Apply Customer Ledger Entries in Code unit 12
Mauddib
Member Posts: 269
Whatexactly are the conditions for Completed to become true in Code unit 12 function ApplyCustLedgEntry(). This function being called in the line....
ApplyCustLedgEntry(
CVLedgEntryBuf,DtldCVLedgEntryBuf,GenJnlLine,NextTransactionNo,
GLSetup."Appln. Rounding Precision");
My head is burning up trying to find out what is required for the loop to end when it reaches the line:
UNTIL Completed;
The reason for asking is that for one customer, and it has never happed to any other customer, the code is looping here to infinity and nothing happens when trying to post an invoice.
Thinking there may be something wrong with the invoice posting i tried to post an INVOICE journal to take all PAYMENTS off the customers account. I then intended to post a PAYMENT journal of one line to put the balance back on the customers account. Thinking this would help.
However the same infinity loop happens then too so I cant remove the customer ledger entries and hence bypass whichever one has become corrupt, so instead I need to know why its happening so I can fix the corrupt data.
ApplyCustLedgEntry(
CVLedgEntryBuf,DtldCVLedgEntryBuf,GenJnlLine,NextTransactionNo,
GLSetup."Appln. Rounding Precision");
My head is burning up trying to find out what is required for the loop to end when it reaches the line:
UNTIL Completed;
The reason for asking is that for one customer, and it has never happed to any other customer, the code is looping here to infinity and nothing happens when trying to post an invoice.
Thinking there may be something wrong with the invoice posting i tried to post an INVOICE journal to take all PAYMENTS off the customers account. I then intended to post a PAYMENT journal of one line to put the balance back on the customers account. Thinking this would help.
However the same infinity loop happens then too so I cant remove the customer ledger entries and hence bypass whichever one has become corrupt, so instead I need to know why its happening so I can fix the corrupt data.
0
Comments
-
Hi there Mauddib.
Lately I've changed my codeunit 12 so that I could insert a new condition to this Completed variable you're stuck at.
Look at this code (it's exactly where the Completed variable is set):IF GenJnlLine."Applies-to Doc. No." <> '' THEN Completed := TRUE ELSE IF OldCustLedgEntry.GETFILTER(OldCustLedgEntry.Positive) <> '' THEN BEGIN IF OldCustLedgEntry.NEXT = 1 THEN Completed := FALSE ELSE BEGIN OldCustLedgEntry.SETRANGE(Positive); OldCustLedgEntry.FIND('-'); OldCustLedgEntry.CALCFIELDS("Remaining Amount"); Completed := OldCustLedgEntry."Remaining Amount" * NewCVLedgEntryBuf."Remaining Amount" >= 0; END END ELSE BEGIN IF NewCVLedgEntryBuf.Open THEN Completed := OldCustLedgEntry.NEXT = 0 ELSE Completed := TRUE; END;
You should check back on the code, and rather debug it to see all the variables so that you can check why Completed is never TRUE.
Note: This code is right above the "UNTIL Completed" line.
Best regards,
Marcelo Borges
D365 Business Central Solutions Architect
BC AL/NAV C/AL Developer
BC Repositories.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 333 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 991 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
