microsoft / ALAppExtensions

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

[Event Request] Codeunit 99000845 "Reservation Management" #26783

Closed Mariangela-DeMaio-EOS closed 4 days ago

Mariangela-DeMaio-EOS commented 5 days ago

Describe the request

Hello, we need an event in the Codeunit 99000845 "Reservation Management" in the procedure DeleteReservEntries: procedure DeleteReservEntries(DeleteAll: Boolean; DownToQuantity: Decimal; var ReservEntry: Record "Reservation Entry")

We need the event to modify the parameter "ReservEntry" when the Reservation Status is "Surplus".

`

 procedure DeleteReservEntries(DeleteAll: Boolean; DownToQuantity: Decimal; var ReservEntry: Record "Reservation Entry")
var
    .....
begin
    IsHandled := false;
    OnBeforeDeleteReservEntries(ReservEntry, DownToQuantity, CalcReservEntry, CalcReservEntry2, IsHandled, ItemTrackingHandling);
    if IsHandled then
        exit;

    ReservEntry.SetRange("Reservation Status");
    if ReservEntry.IsEmpty() then
        exit;
  ...

  for ReservStatus := ReservStatus::Prospect downto ReservStatus::Reservation do begin
        ReservEntry.SetRange("Reservation Status", ReservStatus);
        if ReservEntry.FindSet() and (QtyToRelease <> 0) then
            case ReservStatus of
                Enum::"Reservation Status"::Prospect:
                    repeat
                      ......
                    until (ReservEntry.Next() = 0) or ((not DeleteAll) and (QtyToRelease = 0));
                Enum::"Reservation Status"::Surplus:
                    repeat
                        if CalcReservEntry4.Get(ReservEntry."Entry No.", not ReservEntry.Positive) then // Find related entry
                            Error(Text007);
                        if (Abs(ReservEntry."Quantity (Base)") <= Abs(QtyToRelease)) or DeleteAll then begin
                            ReservEngineMgt.CloseReservEntry(ReservEntry, false, DeleteAll);
                            SaveTrackingSpecification(ReservEntry, ReservEntry."Quantity (Base)");
                            QtyToRelease := QtyToRelease - ReservEntry."Quantity (Base)";
                            if not DeleteAll and CalcReservEntry4.TrackingExists() then begin
                                CalcReservEntry4."Reservation Status" := CalcReservEntry4."Reservation Status"::Surplus;
                                CalcReservEntry4.Insert();
                            end;
                            ModifyActionMessage(ReservEntry."Entry No.", 0, true); // Delete action messages
                        end else begin
                            ReservEntry.Validate("Quantity (Base)", ReservEntry."Quantity (Base)" - QtyToRelease);
                            ReservEntry.Modify();

                            // Start Event
                                OnAfterModifyReservEntryReservationStatusSurplus(ReservEntry, QtyToRelease);
                           //  End Event

                            SaveTrackingSpecification(ReservEntry, QtyToRelease);
                            ModifyActionMessage(ReservEntry."Entry No.", QtyToRelease, false); // Modify action messages
                            QtyToRelease := 0;
                        end;
                    until (ReservEntry.Next() = 0) or ((not DeleteAll) and (QtyToRelease = 0));
                Enum::"Reservation Status"::Tracking,
                Enum::"Reservation Status"::Reservation:
                    for Release := Release::"Non-Inventory" to Release::Inventory do begin
                        // Release non-inventory reservations in first cycle
                        repeat
                            .......
                        until (ReservEntry.Next() = 0) or ((not DeleteAll) and (QtyToRelease = 0));
                        if not ReservEntry.FindFirst() then // Rewind for second cycle
                            Release := Release::Inventory;
                    end;
            end;
    end;`

Event

[IntegrationEvent(false, false)] local procedure OnAfterModifyReservEntryReservationStatusSurplus(var ReservationEntry: Record "Reservation Entry"; QtyReleased: Decimal) begin end;

Additional context

. Internal work item: AB#540085

JesperSchulz commented 4 days 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: 21513.