microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
785 stars 620 forks source link

[Event Change Request] Codeunit 5611 "Calculate Normal Depreciation" - CalculateDeprAmount, OnAfterCalculateFinalAmount #26989

Closed UrbMigle closed 1 month ago

UrbMigle commented 2 months ago

Describe the request

Hello,

Please add additional parameters (global variables) to the event OnAfterCalculateFinalAmount that are needed to be able to change calculation of the amount.

            case DeprMethod of
                DeprMethod::"Straight-Line":
                    Amount := Amount + CalcSLAmount();
                DeprMethod::"Declining-Balance 1":
                    Amount := Amount + CalcDB1Amount();
                DeprMethod::"Declining-Balance 2":
                    Amount := Amount + CalcDB2Amount();
                DeprMethod::Manual:
                    Amount := 0;
                DeprMethod::"User-Defined":
                    Amount := Amount + CalcUserDefinedAmount(EndingDate);
                DeprMethod::"Country Specific":
                    ; // Reserved for implementation of country specific
                else
                    OnCalculateDeprAmountOnDeprMethodCaseLastDeprEntry(
                        FADeprBook, BookValue, DeprBasis, DeprYears, DaysInFiscalYear, NumberOfDays, Amount, DateFromProjection, UntilDate);
            end;
            DepreciationCalc.GetDeprPeriod(
              "No.", DeprBookCode, UntilDate, StartingDate, EndingDate, NumberOfDays, Year365Days);
            FirstDeprDate := StartingDate;
        end;
    end;
end;

IsHandled := false;
OnAfterCalculateFinalAmount(DeprBook, Amount, IsHandled, FA, UntilDate, BookValue); <-- Added parameters
if not IsHandled then
    if Amount >= 0 then
        exit(0);
    [IntegrationEvent(false, false)]
    local procedure OnAfterCalculateFinalAmount(DepreBook: Record "Depreciation Book"; var Amount: Decimal; var IsHandled: Boolean; FA: Record "Fixed Asset"; UntilDate: Date; BookValue: Decimal)
    begin
    end;

Additional context

We want to change calculation of the amount, but are missing the parameters to do so, could you please add them? Thank you Internal work item: AB#545279

JesperSchulz commented 1 month ago

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: 24354.