Apply Customer entries by code

nuno.silvanuno.silva Member Posts: 29
I need to apply customer payments with invoices and I can do that on the general journal when I'm posting the payment, but if the payment date is earlier than the invoice date, that is not possible to apply and post an entry to an entry with an earlier date.
So I'm trying apply the documents after they are already posting, But I'm always getting the message "The application was successfully posted though no entries have been applied." but if In look to the entries both remain open.

thee code That I used was:

CustLedgEntry.GET(1904988); //Payment
ApplyingCustLedgEntry.GET(1905055); //Invoice

CustEntrySetApplID.SetApplId(CustLedgEntry,ApplyingCustLedgEntry,GetAppliesToID);

ApplyingCustLedgEntry.VALIDATE("Amount to Apply", 25);
ApplyingCustLedgEntry.MODIFY;

CustEntryApplyPostedEntries.Apply(ApplyingCustLedgEntry,ApplyingCustLedgEntry."Document No.",ApplyingCustLedgEntry."Posting Date");

Where CustEntrySetApplID is the codeunit Cust. Entry-SetAppl.ID and CustEntryApplyPostedEntries is the codeunit CustEntry-Apply Posted Entries

Any sugestions?
thanks in advanced
===============
Nuno Silva

Best Answer

Answers

  • nuno.silvanuno.silva Member Posts: 29
    I took your words and create a field in the journal with the apply date and on the function where I get the error, ValidateApplyRequirements, I made an IF the apply date <> 0D compare with that apply date else compare with the journal posting date.
    After that I make a quick test posting and apply a document and every records look OK, he use in all applications the date of the invoice.

    thanks for the idea
    ===============
    Nuno Silva
Sign In or Register to comment.