ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 5631 "FA Jnl.-Check Line" - CheckFADepAcrossFiscalYear()

Open KennyTangBS opened this issue 1 year ago • 1 comments

Describe the request

Please add a new integration event OnBeforeCheckFADepAcrossFiscalYear() with parameters StartingDate, GenJnlLine and IsHandled in the Codeunit 5631 "FA Jnl.-Check Line" Example:

local procedure CheckFADepAcrossFiscalYear()
    var
        AccPeriod: Record "Accounting Period";
        DepreciationCalculation: Codeunit "Depreciation Calculation";
        AccountingPeriodMgt: Codeunit "Accounting Period Mgt.";
        EndingDate: Date;
        StartingDate: Date;
        IsHandled: Boolean;
    begin
        if (GenJnlLine."FA Posting Type" = GenJnlLine."FA Posting Type"::Depreciation) and
           (GenJnlLine."No. of Depreciation Days" <> 0) and
           (FADeprBook."Depreciation Method" = FADeprBook."Depreciation Method"::"Declining-Balance 1")
        then begin
            EndingDate := DepreciationCalculation.ToMorrow(GenJnlLine."FA Posting Date", DeprBook."Fiscal Year 365 Days");
            if DeprBook."Fiscal Year 365 Days" then
                StartingDate := CalcDate(StrSubstNo('<-%1D>', GenJnlLine."No. of Depreciation Days"), EndingDate)
            else begin
                StartingDate := CalcDate(StrSubstNo('<-%1M>', GenJnlLine."No. of Depreciation Days" div 30), EndingDate);
                StartingDate := CalcDate(StrSubstNo('<-%1D>', GenJnlLine."No. of Depreciation Days" mod 30), StartingDate);
            end;

            IsHandled := false;
            OnBeforeCheckFADepAcrossFiscalYear(StartingDate, GenJnlLine, IsHandled);
            if IsHandled then
                exit;

            AccPeriod.SetFilter("Starting Date", '>%1&<=%2', AccountingPeriodMgt.FindFiscalYear(StartingDate), GenJnlLine."FA Posting Date");
            AccPeriod.SetRange("New Fiscal Year", true);
            if not AccPeriod.IsEmpty() then
                Error(Text019Err);
        end;
    end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckFADepAcrossFiscalYear(StartingDate: Date; GenJnlLine: Record "Gen. Journal Line"; var IsHandled: Boolean)
    begin
    end;

Additional context

Check the fiscal year by custom logic. Internal work item: AB#565800

KennyTangBS avatar Feb 10 '25 19:02 KennyTangBS

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 30839.

JesperSchulz avatar Feb 28 '25 13:02 JesperSchulz