Skip to content

[EventRequest] Page 1702 "Deferral Schedule" - OnQueryClosePageOnBeforeCheckEarliestPostingDate #30005

@magdya7

Description

@magdya7

Why do you need this change?

In Intellias we need to use custom calculation method for deferrals with posting dates equal to last date of the period (month).
In current functionality "OnQueryClosePage' on page 1702 "Deferral Schedule" has check for first posting date (EarliestPostingDate) that no way to change or skip .
Because of this we need new event "OnQueryClosePageOnBeforeCheckEarliestPostingDate" with IsHandled parameter with possibility to skip executing code in OnQueryClosePage and run custom code instead.

Describe the request

Add an integration event "OnQueryClosePageOnBeforeCheckEarliestPostingDate" with IsHandled parameter in OnQueryClosePage trigger in page 1702 "Deferral Schedule" to run custom code.

trigger OnQueryClosePage(CloseAction: Action): Boolean
    var
        DeferralHeader: Record "Deferral Header";
        DeferralLine: Record "Deferral Line";
        DeferralUtilities: Codeunit "Deferral Utilities";
        EarliestPostingDate: Date;
        RecCount: Integer;
        ExpectedCount: Integer;
        ShowNoofPeriodsError: Boolean;
        IsHandled: Boolean; //new
    begin
        // Prevent closing of the window if the sum of the periods does not equal the Amount to Defer
        if DeferralHeader.Get(Rec."Deferral Doc. Type",
             Rec."Gen. Jnl. Template Name",
             Rec."Gen. Jnl. Batch Name",
             Rec."Document Type",
             Rec."Document No.", Rec."Line No.")
        then begin
            Rec.CalcFields("Schedule Line Total");
            if Rec."Schedule Line Total" <> DeferralHeader."Amount to Defer" then
                Error(TotalToDeferErr);
        end;

        DeferralLine.SetRange("Deferral Doc. Type", Rec."Deferral Doc. Type");
        DeferralLine.SetRange("Gen. Jnl. Template Name", Rec."Gen. Jnl. Template Name");
        DeferralLine.SetRange("Gen. Jnl. Batch Name", Rec."Gen. Jnl. Batch Name");
        DeferralLine.SetRange("Document Type", Rec."Document Type");
        DeferralLine.SetRange("Document No.", Rec."Document No.");
        DeferralLine.SetRange("Line No.", Rec."Line No.");
        OnOnQueryClosePageOnAfterDeferralLineSetFilters(Rec, DeferralLine);

        RecCount := DeferralLine.Count();
        ExpectedCount := DeferralUtilities.CalcDeferralNoOfPeriods(Rec."Calc. Method", Rec."No. of Periods", Rec."Start Date");
        ShowNoofPeriodsError := ExpectedCount <> RecCount;
        OnOnQueryClosePageOnAfterCalcShowNoofPeriodsError(Rec, DeferralLine, ShowNoofPeriodsError);
        if ShowNoofPeriodsError then
            Rec.FieldError("No. of Periods");

        DeferralLine.SetFilter("Posting Date", '>%1', 0D);
        if DeferralLine.FindFirst() then begin
            OnQueryClosePageOnBeforeCheckEarliestPostingDate(Rec, DeferralLine, IsHandled); //new
            if not IsHandled then begin //new
                EarliestPostingDate := DeferralLine."Posting Date";
                if EarliestPostingDate <> DeferralHeader."Start Date" then
                    Error(PostingDateErr);
            end;
        end;
    end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnQueryClosePageOnBeforeCheckEarliestPostingDate(DeferralHeader: Record "Deferral Header"; var DeferralLine: Record "Deferral Line"; var IsHandled: Boolean)
begin
    //new
end;

Internal work item: AB#635587

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