Skip to content

codeunit 1720 "Deferral Utilities" - GetPeriodStartingDate #29725

@Henriquantos

Description

@Henriquantos

Why do you need this change?

Can you please add the event OnBeforeGetPeriodStartingDate to the procedure GetPeriodStartingDate of Codeunit "Deferral Utilities" (1720)? This will be used to control the returned Date.

Describe the request

Actual Code

local procedure GetPeriodStartingDate(PostingDate: Date): Date
var
    AccountingPeriod: Record "Accounting Period";
begin
    if AccountingPeriod.IsEmpty() then
        exit(CalcDate('<-CM>', PostingDate));

    AccountingPeriod.SetFilter("Starting Date", '<%1', PostingDate);
    if AccountingPeriod.FindLast() then
        exit(AccountingPeriod."Starting Date");

    Error(DeferSchedOutOfBoundsErr);
end;

Suggestion

local procedure GetPeriodStartingDate(PostingDate: Date): Date
var
    AccountingPeriod: Record "Accounting Period";
    Result: Date;
begin
    OnBeforeGetPeriodStartingDate(PostingDate, Result);
    if Result <> 0D then
        exit(Result)

    if AccountingPeriod.IsEmpty() then
        exit(CalcDate('<-CM>', PostingDate));

    AccountingPeriod.SetFilter("Starting Date", '<%1', PostingDate);
    if AccountingPeriod.FindLast() then
        exit(AccountingPeriod."Starting Date");

    Error(DeferSchedOutOfBoundsErr);
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeGetPeriodStartingDate(PostingDate: Date; var Result: Date)
begin
end;

Internal work item: AB#622428

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions