microsoft / ALAppExtensions

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

[Event Request] Codeunit 5720 "Item Reference Management" - OnPlanItemNextStateMatchDatesOnBeforeCalcNewSupplyDate #27040

Closed 1languste closed 2 months ago

1languste commented 2 months ago

Describe the request

I want to set the NewSupplyDate based on my own business logic. Therefore, I request the following event:

local procedure PlanItemNextStateMatchDates(var DemandInvtProfile: Record "Inventory Profile"; var SupplyInvtProfile: Record "Inventory Profile"; var TempReminderInvtProfile: Record "Inventory Profile" temporary; var WeAreSureThatDatesMatch: Boolean; IsReorderPointPlanning: Boolean; var LastProjectedInventory: Decimal; var LatestBucketStartDate: Date; var ROPHasBeenCrossed: Boolean; var NewSupplyHasTakenOver: Boolean)
var
    OriginalSupplyDate: Date;
    NewSupplyDate: Date;
    CanBeRescheduled: Boolean;
    DemandDueDate: Date;
    LimitedHorizon: Boolean;
    IsHandled: Boolean;
    //NEW BEGIN
    ShouldCalcNewSupplyDate: Boolean;
    //NEW END
begin
    IsHandled := false;
    OnBeforePlanItemNextStateMatchDates(DemandInvtProfile, SupplyInvtProfile, NextState, IsHandled);
    if IsHandled then
        exit;
    //NEW BEGIN
    ShouldCalcNewSupplyDate := true;
    OnPlanItemNextStateMatchDatesOnBeforeCalcNewSupplyDate(NewSupplyDate, ShouldCalcNewSupplyDate, SupplyInvtProfile, DemandInvtProfile, LotAccumulationPeriodStartDate);
    if ShouldCalcNewSupplyDate then
    //NEW END
        if FromLotAccumulationPeriodStartDate(LotAccumulationPeriodStartDate, DemandInvtProfile."Due Date") then begin
            NewSupplyDate := LotAccumulationPeriodStartDate;
            SupplyInvtProfile."Fixed Date" := NewSupplyDate;
        end else begin
            NewSupplyDate := SupplyInvtProfile."Due Date";
            LotAccumulationPeriodStartDate := 0D;
        end;

    DemandDueDate := DemandInvtProfile."Due Date";
    if TempSKU."Replenishment System" = TempSKU."Replenishment System"::Purchase then
        DemandDueDate := GetPrevAvailDateFromCompanyCalendar(DemandInvtProfile."Due Date");
    // ...

[IntegrationEvent(false, false)]
local procedure OnPlanItemNextStateMatchDatesOnBeforeCalcNewSupplyDate(var NewSupplyDate: Date; ShouldCalcNewSupplyDate: Boolean; var SupplyInvtProfile: Record "Inventory Profile"; var DemandInvtProfile: Record "Inventory Profile"; LotAccumulationPeriodStartDate: Date)
begin
end;

Additional context

I want the NewSupplyDate to always be set to the InventoryProfile."Due Date". Internal work item: AB#544563

JakovljevicDusan commented 2 months ago

New parameter ShouldCalcNewSupplyDate added to OnBeforePlanItemNextStateMatchDates

JesperSchulz commented 2 months 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: 23752.