Options

Customer Legder Entry - Remaining Amount not zero after posting Gen. Journal Line - Payment

robthemobbrobthemobb Member Posts: 14
Hi everyone!

I wrote some code in a XML port which set up some lines in Gen. Journal Line (table 81). Afterwards I ran CU "Gen. Jnl.-Post". It works almost fine. If I double-check in the Customer Ledger Entries, the remaining amount is still as high as the Original Amount and the Amount. If I key-in all the values manually within the General Journal, the Remaining Amount in the Customer Ledger Entry is 0 (as expected). Does anybody has a clue why and how I can tell NAV to update the Remaining Amount?

Help is appreciated.
Rob
GeneralJournalLine.VALIDATE("Posting Date", TODAY);
GeneralJournalLine.VALIDATE("Document No.", DocNo);
GeneralJournalLine.VALIDATE("Document Type", GeneralJournalLine."Document Type"::Payment);
GeneralJournalLine.VALIDATE("Account Type", GeneralJournalLine."Account Type"::Customer);

[...]
	
GeneralJournalLine.VALIDATE("Account No.", CustLedgerEntry."Customer No.");
GeneralJournalLine.VALIDATE("Applies-to Doc. No.", CustLedgerEntry."Document No.");
GeneralJournalLine.VALIDATE("Applies-to Doc. Type", CustLedgerEntry."Document Type");
GeneralJournalLine.VALIDATE(Amount, Amount);
GeneralJournalLine.VALIDATE("Bal. Account Type", GeneralJournalLine."Bal. Account Type"::"G/L Account");
GeneralJournalLine.VALIDATE("Bal. Account No.", '1210');

IsInserted := FALSE;
IsInserted := GeneralJournalLine.INSERT(TRUE);

IF IsInserted THEN
  CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post", GeneralJournalLine)

Best Answer

Answers

  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hi, could be the validation order.

    Try to put Aplies-To* field validation at the end you your code and in reversed order:
    GeneralJournalLine.VALIDATE("Applies-to Doc. Type", CustLedgerEntry."Document Type");
    GeneralJournalLine.VALIDATE("Applies-to Doc. No.", CustLedgerEntry."Document No.");
    

    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    robthemobbrobthemobb Member Posts: 14
    Hi, unfortunately this isn't the solution for my problem. If you do have any other hint, I am happy to try hear it. Thanks for your help!

    R
  • Options
    lubostlubost Member Posts: 614
    Hi,
    you should use the same validation sequence in code as you entered recodr manually. With standard object table 81 should be the best solution Slawek suggested.
  • Options
    robthemobbrobthemobb Member Posts: 14
    After all, @Slawek_Guzek's first answer is right, though. I am sorry for flagging it wrong!

    I had entered also a Validate for the field "Applies-to Ext. Doc. No.", even though the external doc number isn't linked to the G/L entry.

    I do insert the populated line, now. It works fine.

    Thanks anyway!
    rob
Sign In or Register to comment.