ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 5611 "Calculate Normal Depreciation" - SetHalfYearConventionMethod()

Open KennyTangBS opened this issue 1 year ago • 1 comments

Describe the request

Please add a new integration event OnBeforeSetHalfYearConventionMethod() with parameter FADeprBook, DeprMethod, Year365Days, FirstDeprDate, NewYearDate, Result and IsHandled in the Codeunit 5611 "Calculate Normal Depreciation" Example:

local procedure SetHalfYearConventionMethod(): Boolean
    var
        AccountingPeriod: Record "Accounting Period";
        Result: Boolean;
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeSetHalfYearConventionMethod(FADeprBook, DeprMethod, Year365Days, FirstDeprDate, NewYearDate, Result, IsHandled);
        if IsHandled then
            exit(Result);

        if not FADeprBook."Use Half-Year Convention" then
            exit(false);
        if FADeprBook."Depreciation Method" = FADeprBook."Depreciation Method"::Manual then
            exit(false);
        if DeprMethod = DeprMethod::"Below Zero" then
            exit(false);
        if AccountingPeriod.IsEmpty() then
            exit(false);

        AccountingPeriod.SetRange("New Fiscal Year", true);
        AccountingPeriod.SetFilter(
          "Starting Date", '>=%1',
          DepreciationCalc.ToMorrow(FADeprBook."Depreciation Starting Date", Year365Days));
        AccountingPeriod.FindFirst();
        NewYearDate := AccountingPeriod."Starting Date";
        if FirstDeprDate >= NewYearDate then
            exit(false);

        if DeprBook."No. of Days in Fiscal Year" <> 0 then
            DeprBook.TestField("No. of Days in Fiscal Year", 360);
        if DeprMethod in
           [DeprMethod::"Declining-Balance 2",
            DeprMethod::"DB2/SL",
            DeprMethod::"User-Defined"]
        then
            Error(
              Text004,
              FADeprBook.FieldCaption("Depreciation Method"),
              FADeprBook."Depreciation Method",
              GetFAName());
        exit(true);
    end;
[IntegrationEvent(false, false)]
local procedure OnBeforeSetHalfYearConventionMethod(FADeprBook: Record "FA Depreciation Book"; DeprMethod: Enum "FA Depr. Method Internal"; Year365Days: Boolean; FirstDeprDate: Date; NewYearDate: Date; var Result: Boolean; var IsHandled: Boolean)
    begin
    end;

Additional context

Set the global variable UseHalfYearConvention in this codeunit by custom logic. Internal work item: AB#565246

KennyTangBS avatar Feb 07 '25 22: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: 30425.

JesperSchulz avatar Feb 21 '25 09:02 JesperSchulz