[Event Change Request] Codeunit 5611 "Calculate Normal Depreciation" - OnBeforeSetHalfYearConventionMethod()
Why do you need this change?
It's related to the issue #28082. Although the integration event allows us to apply our own logic when calculating depreciation with Use Half-Year Convention, the NewYearDate parameter is currently passed by value. As a result, any modifications made by the subscriber are not reflected in the subsequent depreciation calculation, and Business Central continues to use its original NewYearDate value. Passing NewYearDate by reference would enable extensions to override the calculated date as intended and ensure the depreciation calculation uses the updated value.
Describe the request
Please update the NewYearDate parameter to be passed by reference.
Example:
[IntegrationEvent(false, false)]
local procedure OnBeforeSetHalfYearConventionMethod(FADeprBook: Record "FA Depreciation Book"; DeprMethod: Enum "FA Depr. Method Internal"; Year365Days: Boolean; FirstDeprDate: Date; var NewYearDate: Date; var Result: Boolean; var IsHandled: Boolean)
begin
end;
Internal work item: AB#646465
✅ Analysis complete - ready for further processing
Implementation:
Update SetHalfYearConventionMethod() so NewYearDate is passed by reference in OnBeforeSetHalfYearConventionMethod, allowing subscriber changes to be used by the subsequent depreciation calculation.
Location in SetHalfYearConventionMethod() procedure:
IsHandled := false;
NewYearDate := 0D;
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, DeprBook."Use Accounting Period"));
AccountingPeriod.FindFirst();
if NewYearDate = 0D then
NewYearDate := AccountingPeriod."Starting Date";
if FirstDeprDate >= NewYearDate then
exit(false);
Event Publisher (add at the end of the codeunit with other events):
[IntegrationEvent(false, false)]
local procedure OnBeforeSetHalfYearConventionMethod(FADeprBook: Record "FA Depreciation Book"; DeprMethod: Enum "FA Depr. Method Internal"; Year365Days: Boolean; FirstDeprDate: Date; var NewYearDate: Date; var Result: Boolean; var IsHandled: Boolean)
begin
end;
File: CalculateNormalDepreciation.Codeunit.al
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Not accurate? Reply with
/not-accurate(optional: add a short explanation). Your feedback improves future responses.
Fixed