Skip to content

codeunit 386 "Reverse Payment Rec. Journal" - procedure "InsertRelatedAndAppliedEntries" - New Event OnAfterFilterLedgerEntry #29983

@AndreaRux

Description

@AndreaRux

Why do you need this change?

A more specific filter is needed to reverse ledger entries.

Describe the request

Please add three new Events in
codeunit 386 "Reverse Payment Rec. Journal"
procedure "InsertRelatedAndAppliedEntries"

    local procedure InsertRelatedAndAppliedEntries(BankAccountNo: Code[20]; StatementNo: Code[20]; StatementLineNo: Integer; AccountType: Enum "Gen. Journal Account Type"; var BankAccountLedgerEntry: Record "Bank Account Ledger Entry")
    var
        CustLedgerEntry: Record "Cust. Ledger Entry";
        VendorLedgerEntry: Record "Vendor Ledger Entry";
        EmployeeLedgerEntry: Record "Employee Ledger Entry";
    begin
        InsertBankPaymentRecRelatedEntry(BankAccountLedgerEntry, StatementNo, StatementLineNo);
        // Find if there's any Customer, Vendor or Employee related entries for this Bank Account Ledger Entry
        case AccountType of
            AccountType::Customer:
                begin
                    CustLedgerEntry.SetRange("Document No.", BankAccountLedgerEntry."Document No.");
                    CustLedgerEntry.SetRange("Posting Date", BankAccountLedgerEntry."Posting Date");
                    CustLedgerEntry.SetRange(Reversed, false);
                    CustLedgerEntry.SetRange("Transaction No.", BankAccountLedgerEntry."Transaction No.");
                    CustLedgerEntry.SetRange("Customer No.", BankAccountLedgerEntry."Bal. Account No.");
                    OnAfterFilterCustLedgerEntry(CustLedgerEntry, BankAccountLedgerEntry);
                    if CustLedgerEntry.FindSet() then
                        repeat
                            InsertRelatedAndAppliedEntries(BankAccountNo, StatementNo, StatementLineNo, CustLedgerEntry);
                        until CustLedgerEntry.Next() = 0;
                end;
            AccountType::Vendor:
                begin
                    VendorLedgerEntry.SetRange("Document No.", BankAccountLedgerEntry."Document No.");
                    VendorLedgerEntry.SetRange("Posting Date", BankAccountLedgerEntry."Posting Date");
                    VendorLedgerEntry.SetRange(Reversed, false);
                    VendorLedgerEntry.SetRange("Transaction No.", BankAccountLedgerEntry."Transaction No.");
                    VendorLedgerEntry.SetRange("Vendor No.", BankAccountLedgerEntry."Bal. Account No.");
                    OnAfterFilterVendorLedgerEntry(VendorLedgerEntry, BankAccountLedgerEntry);
                    if VendorLedgerEntry.FindSet() then
                        repeat
                            InsertRelatedAndAppliedEntries(BankAccountNo, StatementNo, StatementLineNo, VendorLedgerEntry);
                        until VendorLedgerEntry.Next() = 0;
                end;
            AccountType::Employee:
                begin
                    EmployeeLedgerEntry.SetRange("Document No.", BankAccountLedgerEntry."Document No.");
                    EmployeeLedgerEntry.SetRange("Posting Date", BankAccountLedgerEntry."Posting Date");
                    EmployeeLedgerEntry.SetRange(Reversed, false);
                    EmployeeLedgerEntry.SetRange("Transaction No.", BankAccountLedgerEntry."Transaction No.");
                    EmployeeLedgerEntry.SetRange("Employee No.", BankAccountLedgerEntry."Bal. Account No.");
                    OnAfterFilterEmployeeLedgerEntry(EmployeeLedgerEntry, BankAccountLedgerEntry);
                    if EmployeeLedgerEntry.FindSet() then
                        repeat
                            InsertRelatedAndAppliedEntries(BankAccountNo, StatementNo, StatementLineNo, EmployeeLedgerEntry);
                        until EmployeeLedgerEntry.Next() = 0;
                end;
        end;
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterFilterCustLedgerEntry(var CustLedgerEntry: Record "Cust. Ledger Entry"; var BankAccountLedgerEntry: Record "Bank Account Ledger Entry")
    begin
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterFilterVendorLedgerEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; var BankAccountLedgerEntry: Record "Bank Account Ledger Entry")
    begin
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterFilterEmployeeLedgerEntry(var EmployeeLedgerEntry: Record "Employee Ledger Entry"; var BankAccountLedgerEntry: Record "Bank Account Ledger Entry")
    begin
    end;

Internal work item: AB#632877

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions