My friend asked me to "Automatically apply one payment to all pending invoices for a Vendor ".
Here is my code:
Documentation()
OnInitReport()
GenJournalLine.SETRANGE("Journal Batch Name",'BANK');
GenJournalLine.SETRANGE("Journal Template Name",'PAYMENT');
OnPreReport()
GenJournalLine.INIT;
GenJournalLine."Posting Date":=020119D;
GenJournalLine."Journal Batch Name":='BANK';
GenJournalLine."Document Type":=GenJournalLine."Document Type"::Payment;
GenJournalLine."Document No.":='ADI91';
GenJournalLine."Journal Template Name":='PAYMENT';
GenJournalLine."Account Type":=GenJournalLine."Account Type"::Vendor;
GenJournalLine."Account No.":="Vendor no";
GenJournalLine."Recipient Bank Account":='ECA';
GenJournalLine."Payment Method Code":='CASH';
GenJournalLine."Bal. Account Type":=GenJournalLine."Bal. Account Type"::"Bank Account";
GenJournalLine."Bal. Account No.":='GIRO';
GenJournalLine."Applies-to Doc. Type":=GenJournalLine."Applies-to Doc. Type"::Invoice;
GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
VendorLedgerEntry.SETRANGE("Vendor No.","Vendor no");
VendorLedgerEntry.SETRANGE("Document Type",VendorLedgerEntry."Document Type"::Invoice);
IF VendorLedgerEntry.FINDSET THEN
REPEAT
VendorLedgerEntry.Applies-to ID":=GenJournalLine."Documnet NO.";
VendorLedgerEntry.CALCFIELDS("Remaining Amount");
VendorLedgerEntry."Amount to Apply":=GenJournalLine."Remaining Amount";
VendorLedgerEntry.MODIFY;
UNTIL VendorLedgerEntry.NEXT=0;
GenJournalLine.Amount:=-amt;
GenJournalLine.INSERT;
OnPostReport()
CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post",GenJournalLine);
But I'm getting this error:
Please help me guys.
Answers
Set Permissions property in Your report
Use build in functionality.
but basically it do the same as Codeunit 111 Vend. Entry-SetAppl.ID function SetApplId
Yeah , You are Right.
But after posting I'm getting this error
Which value I've to pass to this field ->GenJournalLine."Dimension Set ID" ?