microsoft / ALAppExtensions

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

[Event Request] Codeunit 99000774 "Calculate Routing Line" - OnBeforeCheckDatetimes() #26737

Closed aydin81 closed 1 week ago

aydin81 commented 2 weeks ago

Describe the request

 procedure LoadCapForward(CapType: Enum "Capacity Type"; CapNo: Code[20]; TimeType: Enum "Routing Time Type"; Write: Boolean)
    var
        TotalAvailCapacity: Decimal;
        LoadFactor: Decimal;
        IsHandled: Boolean;
    SkipError: Boolean;
    begin
        IsHandled := false;
        OnBeforeLoadCapForward(ProdOrderRoutingLine, CapType, CapNo, TimeType, ProdStartingDate, ProdStartingTime, IsHandled, RemainNeedQty);
        if IsHandled then
            exit;

        ProdOrderRoutingLine."Ending Date" := ProdStartingDate;
        ProdOrderRoutingLine."Ending Time" := ProdStartingTime;

        CalendarEntry.SetCapacityFilters(CapType, CapNo);
        CalendarEntry.SetFilter("Starting Date-Time", '>=%1', CreateDateTime(ProdStartingDate - 1, ProdStartingTime));
        if TimeType = TimeType::"Wait Time" then
            CalendarEntry.SetFilter("Ending Date-Time", '>=%1', CreateDateTime(ProdStartingDate, 000000T))
        else
            CalendarEntry.SetFilter("Ending Date-Time", '>=%1', CreateDateTime(ProdStartingDate, ProdStartingTime));

        if ProdOrderRoutingLine."Schedule Manually" and (TimeType = TimeType::"Run Time") then begin
        **OnBeforeCheckDateTimes(ProdOrderRoutingLine, CapType, CapNo, TimeType, ProdStartingDate, ProdStartingTime, RemainNeedQty, RunStartingDateTime,  RunEndingDateTime , SkipError)
        if not SkipError then** 
                if (RunEndingDateTime < RunStartingDateTime) or
                ((RunEndingDateTime = RunStartingDateTime) and
                    (ProdOrderRoutingLine."Run Time" <> 0) and
                    (ProdOrderRoutingLine."Input Quantity" <> 0))
                then
                    Error(Text005);
            TotalAvailCapacity :=
              AvailableCapacity(CapType, CapNo, RunStartingDateTime, RunEndingDateTime);
            if TotalAvailCapacity = 0 then begin
                TestForError(Text006, Text002, DT2Date(RunEndingDateTime));
                LoadFactor := 0;
            end else
                LoadFactor := Round(RemainNeedQty / TotalAvailCapacity, Workcenter."Calendar Rounding Precision", '>');
        end else
            LoadFactor := 1;

        CreateLoadForward(TimeType, Write, LoadFactor);

        if RemainNeedQty = 0 then
            exit;

        TestForError(Text003, Text004, ProdOrderRoutingLine."Ending Date");
    end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCheckDateTimes(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; CapType: Enum "Capacity Type"; CapNo: Code[20]; TimeType: Enum "Routing Time Type"; var ProdStartingDate: Date; var ProdStartingTime: Time; RemainNeedQty: Decimal, var RunStartingDateTime: DateTime, var RunEndingDateTime: DateTime, var skipError: Boolean; )
    begin
    end;

Additional context

We need this new Event "OnBeforeCheckDateTimes" because we import over background processing DateTime fields of Prod. Order Routing Line as Schedule Manually.

You can see in the MS Call with the ID: 2404040050001190 Internal work item: AB#539363

aydin81 commented 2 weeks ago

Please added at the "OnBeforeCheckDateTimes" (name is for example) the follow global Variable per var in the new Event.

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