microsoft / ALAppExtensions

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

[Event Change Request] Codeunit 5611 "Calculate Normal Depreciation" - CalculateDeprAmount, OnCalculateDeprAmountOnBeforeCalculateDeprAmount #26991

Closed UrbMigle closed 1 day ago

UrbMigle commented 1 month ago

Describe the request

Hello,

Please add two additional parameters to the event OnCalculateDeprAmountOnBeforeCalculateDeprAmount. They are needed for us to change the value of the Amount variable.

        IsHandled := false;
        OnAfterCalculateFinalAmount(DeprBook, Amount, IsHandled);
        if not IsHandled then
            if Amount >= 0 then
                exit(0);

        IsHandled := false;
        OnCalculateDeprAmountOnBeforeCalculateDeprAmount(FA, SkipOnZero, DeprBookCode, Amount, BookValue2, SalvageValue2, EndingBookValue, FinalRoundingAmount, IsHandled, BookValue, UntilDate); <--- New Parameters Added
        if IsHandled then
            exit(Amount);

        if not SkipOnZero then
            DepreciationCalc.AdjustDepr(
              DeprBookCode, Amount, Abs(BookValue2), -Abs(SalvageValue2),
              EndingBookValue, FinalRoundingAmount);
    [IntegrationEvent(false, false)]
    local procedure OnCalculateDeprAmountOnBeforeCalculateDeprAmount(FixedAsset: Record "Fixed Asset"; SkipOnZero: Boolean; DeprBookCode: Code[20]; var Amount: Decimal; BookValue: Decimal; SalvageValue2: Decimal; EndingBookValue: Decimal; FinalRoundingAmount: Decimal; var IsHandled: Boolean; BookValue: Decimal; UntilDate: Date)
    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 to the event publisher? Thank you Internal work item: AB#545278

AndersLarsenMicrosoft commented 1 day ago

We cannot just take this as it will conflict/confuse on the naming When calling we are using BookValue2 OnCalculateDeprAmountOnBeforeCalculateDeprAmount(FA, SkipOnZero, DeprBookCode, Amount, BookValue2, SalvageValue2, EndingBookValue, FinalRoundingAmount, IsHandled);

but it gets exposed as BookValue [IntegrationEvent(false, false)] local procedure OnCalculateDeprAmountOnBeforeCalculateDeprAmount(FixedAsset: Record "Fixed Asset"; SkipOnZero: Boolean; DeprBookCode: Code[20]; var Amount: Decimal; BookValue: Decimal; SalvageValue2: Decimal; EndingBookValue: Decimal; FinalRoundingAmount: Decimal; var IsHandled: Boolean; BookValue: Decimal; UntilDate: Date) begin end;

We cannot change this without deprecated the old event and create a new

I trust the two otter events OnAfterCalculateFinalAmount(DeprBook, Amount, IsHandled, FA, UntilDate, BookValue);

   OnAfterCalculateDeprAmount(
      FA, SkipOnZero, DeprBookCode, Amount, Abs(BookValue2), -Abs(SalvageValue2), EndingBookValue, FinalRoundingAmount);

will give you some possibility to change the calculation

JesperSchulz commented 1 day 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: .