Page 99000900 Avail. - Planning Components
src/Layers/W1/BaseApp/Inventory/Planning/AvailPlanningComponents.Page.al282 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Inventory.Planning;using Microsoft.Foundation.Enums;using Microsoft.Inventory.Item;using Microsoft.Inventory.Tracking;page 99000900 "Avail. - Planning Components"{ Caption = 'Avail. - Planning Components'; DataCaptionExpression = CaptionText; DeleteAllowed = false; Editable = false; InsertAllowed = false; ModifyAllowed = false; PageType = List; SourceTable = "Planning Component"; layout { area(content) { repeater(Control1) { ShowCaption = false; field("Location Code"; Rec."Location Code") { ApplicationArea = Location; } field("Due Date"; Rec."Due Date") { ApplicationArea = Planning; } field("Quantity (Base)"; Rec."Quantity (Base)") { ApplicationArea = Planning; ToolTip = 'Specifies the value in the Quantity field on the line.'; } field("Reserved Qty. (Base)"; Rec."Reserved Qty. (Base)") { ApplicationArea = Reservation; Editable = false; ToolTip = 'Specifies the reserved quantity of the item, in base units of measure.'; } field(QtyToReserveBase; QtyToReserveBase) { ApplicationArea = Planning; AutoFormatType = 0; Caption = 'Available Quantity'; DecimalPlaces = 0 : 5; Editable = false; ToolTip = 'Specifies the quantity of the components that is available for reservation.'; } field(ReservedQuantity; GetReservedQtyInLine()) { ApplicationArea = Reservation; AutoFormatType = 0; Caption = 'Current Reserved Quantity'; DecimalPlaces = 0 : 5; ToolTip = 'Specifies the quantity of the item that is reserved for the document type.'; trigger OnDrillDown() begin ReservEntry2.Reset(); Rec.SetReservationFilters(ReservEntry2); ReservEntry2.SetRange("Reservation Status", ReservEntry2."Reservation Status"::Reservation); ReservMgt.MarkReservConnection(ReservEntry2, ReservEntry); PAGE.RunModal(PAGE::"Reservation Entries", ReservEntry2); UpdateReservFrom(); CurrPage.Update(); end; } } } area(factboxes) { systempart(Control1900383207; Links) { ApplicationArea = RecordLinks; Visible = false; } systempart(Control1905767507; Notes) { ApplicationArea = Notes; Visible = false; } } } actions { area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action("&Reserve") { ApplicationArea = Reservation; Caption = '&Reserve'; Image = Reserve; ToolTip = 'Reserve the quantity that is required on the document line that you opened this window for.'; trigger OnAction() begin ReservEntry.LockTable(); UpdateReservMgt(); Rec.GetReservationQty(QtyReserved, QtyReservedBase, QtyToReserve, QtyToReserveBase); ReservMgt.CalculateRemainingQty(NewQtyReserved, NewQtyReservedBase); ReservMgt.CopySign(NewQtyReserved, QtyToReserve); ReservMgt.CopySign(NewQtyReservedBase, QtyToReserveBase); if NewQtyReservedBase <> 0 then if NewQtyReservedBase > QtyToReserveBase then CreateReservation(QtyToReserve, QtyToReserveBase) else CreateReservation(NewQtyReserved, NewQtyReservedBase) else Error(Text000); end; } action("&Cancel Reservation") { AccessByPermission = TableData Item = R; ApplicationArea = Reservation; Caption = '&Cancel Reservation'; Image = Cancel; ToolTip = 'Cancel the reservation that exists for the document line that you opened this window for.'; trigger OnAction() begin if not Confirm(Text001, false) then exit; ReservEntry2.Copy(ReservEntry); Rec.SetReservationFilters(ReservEntry2); if ReservEntry2.Find('-') then begin UpdateReservMgt(); repeat if ReservEntry2."Quantity (Base)" < 0 then Error(Text002); ReservEngineMgt.CancelReservation(ReservEntry2); until ReservEntry2.Next() = 0; UpdateReservFrom(); end; end; } } } } trigger OnAfterGetRecord() begin Rec.GetReservationQty(QtyReserved, QtyReservedBase, QtyToReserve, QtyToReserveBase); end; trigger OnOpenPage() begin ReservEntry.TestField("Source Type"); Rec.SetRange("Item No.", ReservEntry."Item No."); Rec.SetRange("Variant Code", ReservEntry."Variant Code"); Rec.SetRange("Location Code", ReservEntry."Location Code"); Rec.SetFilter("Due Date", ReservMgt.GetAvailabilityFilter(ReservEntry."Shipment Date")); if ReservMgt.IsPositive() then Rec.SetFilter("Quantity (Base)", '<0') else Rec.SetFilter("Quantity (Base)", '>0'); end; var ReservEntry: Record "Reservation Entry"; ReservEntry2: Record "Reservation Entry"; ReservMgt: Codeunit "Reservation Management"; ReservEngineMgt: Codeunit "Reservation Engine Mgt."; SourceRecRef: RecordRef; QtyToReserve: Decimal; QtyToReserveBase: Decimal; QtyReserved: Decimal; QtyReservedBase: Decimal; NewQtyReserved: Decimal; NewQtyReservedBase: Decimal; CaptionText: Text;#pragma warning disable AA0074 Text000: Label 'Fully reserved.'; Text001: Label 'Do you want to cancel the reservation?'; Text002: Label 'Do not close negative reservations manually.';#pragma warning disable AA0470 Text003: Label 'Available Quantity is %1.';#pragma warning restore AA0470#pragma warning restore AA0074 procedure SetSource(CurrentSourceRecRef: RecordRef; CurrentReservEntry: Record "Reservation Entry") var TransferDirection: Enum "Transfer Direction"; begin SetSource(CurrentSourceRecRef, CurrentReservEntry, TransferDirection::Outbound); end; procedure SetSource(CurrentSourceRecRef: RecordRef; CurrentReservEntry: Record "Reservation Entry"; Direction: Enum "Transfer Direction") begin Clear(ReservMgt); SourceRecRef := CurrentSourceRecRef; ReservEntry := CurrentReservEntry; ReservMgt.TestItemType(SourceRecRef); ReservMgt.SetReservSource(SourceRecRef, Direction); CaptionText := ReservMgt.FilterReservFor(SourceRecRef, ReservEntry, Direction); end; local procedure CreateReservation(ReserveQuantity: Decimal; ReserveQuantityBase: Decimal) var TrackingSpecification: Record "Tracking Specification"; begin Rec.CalcFields("Reserved Qty. (Base)"); if Rec."Quantity (Base)" + Rec."Reserved Qty. (Base)" < ReserveQuantityBase then Error(Text003, Rec."Quantity (Base)" + Rec."Reserved Qty. (Base)"); Rec.TestField("Item No.", ReservEntry."Item No."); Rec.TestField("Variant Code", ReservEntry."Variant Code"); Rec.TestField("Location Code", ReservEntry."Location Code"); UpdateReservMgt(); TrackingSpecification.InitTrackingSpecification( Database::"Planning Component", 0, Rec."Worksheet Template Name", Rec."Worksheet Batch Name", Rec."Worksheet Line No.", Rec."Line No.", Rec."Variant Code", Rec."Location Code", Rec."Qty. per Unit of Measure"); ReservMgt.CreateReservation( ReservEntry.Description, Rec."Due Date", ReserveQuantity, ReserveQuantityBase, TrackingSpecification); UpdateReservFrom(); end; local procedure UpdateReservFrom() begin SetSource(SourceRecRef, ReservEntry, ReservEntry.GetTransferDirection()); OnAfterUpdateReservFrom(ReservEntry); end; local procedure UpdateReservMgt() begin Clear(ReservMgt); ReservMgt.SetReservSource(SourceRecRef, ReservEntry.GetTransferDirection()); OnAfterUpdateReservMgt(ReservEntry); end; protected procedure GetReservedQtyInLine(): Decimal begin ReservEntry2.Reset(); Rec.SetReservationFilters(ReservEntry2); ReservEntry2.SetRange("Reservation Status", ReservEntry2."Reservation Status"::Reservation); exit(ReservMgt.MarkReservConnection(ReservEntry2, ReservEntry)); end; [IntegrationEvent(true, false)] local procedure OnAfterUpdateReservFrom(var ReservationEntry: Record "Reservation Entry") begin end; [IntegrationEvent(true, false)] local procedure OnAfterUpdateReservMgt(var ReservationEntry: Record "Reservation Entry") begin end;}