Skip to content

[Event Request] table 274 "Bank Acc. Reconciliation Line" #29933

@Stefano-Zaccaria-Agic

Description

@Stefano-Zaccaria-Agic

Why do you need this change?

Hi,
we need the ability to override the default behavior of the RemoveApplication procedure in table 274 "Bank Acc. Reconciliation Line" from an extension, without resorting to unsupported modifications. Currently, there is no event that allows subscribers to intercept and fully replace the logic executed by this procedure.

Describe the request

We need to override the behavior of procedure RemoveApplication() in table 274 "Bank Acc. Reconciliation Line"

Current implementation:

    protected procedure RemoveApplication()
    var
        BankAccRecMatchBuffer: Record "Bank Acc. Rec. Match Buffer";
        BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
        ManyToOneBLEFound: Boolean;
    begin
        if "Statement Type" <> "Statement Type"::"Bank Reconciliation" then
            exit;
        FilterManyToOneMatches(BankAccRecMatchBuffer);
        if BankAccRecMatchBuffer.FindFirst() then begin
            BankAccLedgEntry.Reset();
            BankAccLedgEntry.SetRange("Entry No.", BankAccRecMatchBuffer."Ledger Entry No.");
            BankAccLedgEntry.SetRange(Open, true);
            BankAccLedgEntry.SetRange(
                "Statement Status", BankAccLedgEntry."Statement Status"::"Bank Acc. Entry Applied");
            if BankAccLedgEntry.FindFirst() then begin
                ManyToOneBLEFound := true;
                BankAccSetStmtNo.RemoveReconNo(BankAccLedgEntry, Rec, false);
                BankAccRecMatchBuffer.Delete();
            end;
        end;

        BankAccRecMatchBuffer.Reset();
        BankAccRecMatchBuffer.SetRange("Ledger Entry No.", BankAccLedgEntry."Entry No.");
        BankAccRecMatchBuffer.SetRange("Statement No.", Rec."Statement No.");
        BankAccRecMatchBuffer.SetRange("Bank Account No.", Rec."Bank Account No.");
        if (BankAccRecMatchBuffer.FindSet()) and (ManyToOneBLEFound) then begin
            repeat
                BankAccReconciliationLine.SetRange("Statement Line No.", BankAccRecMatchBuffer."Statement Line No.");
                BankAccReconciliationLine.SetRange("Statement No.", BankAccRecMatchBuffer."Statement No.");
                BankAccReconciliationLine.SetRange("Bank Account No.", BankAccRecMatchBuffer."Bank Account No.");
                if BankAccReconciliationLine.FindFirst() then begin
                    BankAccReconciliationLine."Applied Entries" := 0;
                    BankAccReconciliationLine.Validate("Applied Amount", 0);
                    BankAccReconciliationLine.Modify();
                end;
            until BankAccRecMatchBuffer.Next() = 0;

            BankAccRecMatchBuffer.DeleteAll();
        end;

        BankAccLedgEntry.Reset();
        BankAccLedgEntry.SetCurrentKey("Bank Account No.", Open);
        BankAccLedgEntry.SetRange("Bank Account No.", "Bank Account No.");
        BankAccLedgEntry.SetRange(Open, true);
        BankAccLedgEntry.SetFilter(
            "Statement Status", '%1|%2', BankAccLedgEntry."Statement Status"::"Bank Acc. Entry Applied", BankAccLedgEntry."Statement Status"::"Check Entry Applied");
        BankAccLedgEntry.SetRange("Statement No.", "Statement No.");
        BankAccLedgEntry.SetRange("Statement Line No.", "Statement Line No.");
        OnRemoveApplicationOnAfterBankAccLedgEntrySetFilters(Rec, BankAccLedgEntry);
        BankAccLedgEntry.LockTable();
        CheckLedgEntry.LockTable();
        if BankAccLedgEntry.Find('-') then
            repeat
                BankAccSetStmtNo.RemoveReconNo(BankAccLedgEntry, Rec, true);
            until BankAccLedgEntry.Next() = 0;
        "Applied Entries" := 0;
        Validate("Applied Amount", 0);
        Modify();
    end;

Requested extensibility:
Please add an event before the standard logic, following the standard IsHandled pattern:

    protected procedure RemoveApplication()
    var
        BankAccRecMatchBuffer: Record "Bank Acc. Rec. Match Buffer";
        BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
        ManyToOneBLEFound: Boolean;
        IsHandled: Boolean;
    begin
        OnBeforeRemoveApplication(Rec, IsHandled);
        if IsHandled then
            exit;

        if "Statement Type" <> "Statement Type"::"Bank Reconciliation" then
            exit;
        FilterManyToOneMatches(BankAccRecMatchBuffer);
        if BankAccRecMatchBuffer.FindFirst() then begin
            BankAccLedgEntry.Reset();
            BankAccLedgEntry.SetRange("Entry No.", BankAccRecMatchBuffer."Ledger Entry No.");
            BankAccLedgEntry.SetRange(Open, true);
            BankAccLedgEntry.SetRange(
                "Statement Status", BankAccLedgEntry."Statement Status"::"Bank Acc. Entry Applied");
            if BankAccLedgEntry.FindFirst() then begin
                ManyToOneBLEFound := true;
                BankAccSetStmtNo.RemoveReconNo(BankAccLedgEntry, Rec, false);
                BankAccRecMatchBuffer.Delete();
            end;
        end;

        BankAccRecMatchBuffer.Reset();
        BankAccRecMatchBuffer.SetRange("Ledger Entry No.", BankAccLedgEntry."Entry No.");
        BankAccRecMatchBuffer.SetRange("Statement No.", Rec."Statement No.");
        BankAccRecMatchBuffer.SetRange("Bank Account No.", Rec."Bank Account No.");
        if (BankAccRecMatchBuffer.FindSet()) and (ManyToOneBLEFound) then begin
            repeat
                BankAccReconciliationLine.SetRange("Statement Line No.", BankAccRecMatchBuffer."Statement Line No.");
                BankAccReconciliationLine.SetRange("Statement No.", BankAccRecMatchBuffer."Statement No.");
                BankAccReconciliationLine.SetRange("Bank Account No.", BankAccRecMatchBuffer."Bank Account No.");
                if BankAccReconciliationLine.FindFirst() then begin
                    BankAccReconciliationLine."Applied Entries" := 0;
                    BankAccReconciliationLine.Validate("Applied Amount", 0);
                    BankAccReconciliationLine.Modify();
                end;
            until BankAccRecMatchBuffer.Next() = 0;

            BankAccRecMatchBuffer.DeleteAll();
        end;

        BankAccLedgEntry.Reset();
        BankAccLedgEntry.SetCurrentKey("Bank Account No.", Open);
        BankAccLedgEntry.SetRange("Bank Account No.", "Bank Account No.");
        BankAccLedgEntry.SetRange(Open, true);
        BankAccLedgEntry.SetFilter(
            "Statement Status", '%1|%2', BankAccLedgEntry."Statement Status"::"Bank Acc. Entry Applied", BankAccLedgEntry."Statement Status"::"Check Entry Applied");
        BankAccLedgEntry.SetRange("Statement No.", "Statement No.");
        BankAccLedgEntry.SetRange("Statement Line No.", "Statement Line No.");
        OnRemoveApplicationOnAfterBankAccLedgEntrySetFilters(Rec, BankAccLedgEntry);
        BankAccLedgEntry.LockTable();
        CheckLedgEntry.LockTable();
        if BankAccLedgEntry.Find('-') then
            repeat
                BankAccSetStmtNo.RemoveReconNo(BankAccLedgEntry, Rec, true);
            until BankAccLedgEntry.Next() = 0;
        "Applied Entries" := 0;
        Validate("Applied Amount", 0);
        Modify();
    end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforeRemoveApplication(var BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; var IsHandled: Boolean)
    begin
    end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions