Page 157 Item Availability by Periods

Base Application, Microsoft.Inventory.Availability

src/Layers/W1/BaseApp/Inventory/Availability/ItemAvailabilitybyPeriods.Page.al260 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.Availability;using Microsoft.Foundation.Enums;using Microsoft.Inventory.Item;using System.Utilities;page 157 "Item Availability by Periods"{    Caption = 'Item Availability by Periods';    DeleteAllowed = false;    InsertAllowed = false;    LinksAllowed = false;    ModifyAllowed = false;    PageType = ListPlus;    RefreshOnActivate = false;    SaveValues = true;    SourceTable = Item;    layout    {        area(content)        {            group(Options)            {                Caption = 'Options';                field(PeriodType; PeriodType)                {                    ApplicationArea = Basic, Suite;                    Caption = 'View by';                    ToolTip = 'Specifies by which period amounts are displayed.';                    trigger OnValidate()                    begin                        if PeriodType = PeriodType::"Accounting Period" then                            PeriodPeriodTypeOnValidate();                        if PeriodType = PeriodType::Year then                            YearPeriodTypeOnValidate();                        if PeriodType = PeriodType::Quarter then                            QuarterPeriodTypeOnValidate();                        if PeriodType = PeriodType::Month then                            MonthPeriodTypeOnValidate();                        if PeriodType = PeriodType::Week then                            WeekPeriodTypeOnValidate();                        if PeriodType = PeriodType::Day then                            DayPeriodTypeOnValidate();                    end;                }                field(AmountType; AmountType)                {                    ApplicationArea = Basic, Suite;                    Caption = 'View as';                    ToolTip = 'Specifies how amounts are displayed. Net Change: The net change in the balance for the selected period. Balance at Date: The balance as of the last day in the selected period.';                    trigger OnValidate()                    begin                        if AmountType = AmountType::"Balance at Date" then                            BalanceatDateAmountTypeOnValid();                        if AmountType = AmountType::"Net Change" then                            NetChangeAmountTypeOnValidate();                    end;                }            }            part(ItemAvailLines; "Item Availability Lines")            {                ApplicationArea = Basic, Suite;            }        }    }    actions    {        area(navigation)        {            group("&Item")            {                Caption = '&Item';                Image = Item;                group("&Item Availability by")                {                    Caption = '&Item Availability by';                    Image = ItemAvailability;                    action("Event")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Event';                        Image = "Event";                        ToolTip = 'View how the actual and the projected available balance of an item will develop over time according to supply and demand events.';                        trigger OnAction()                        begin                            ItemAvailFormsMgt.ShowItemAvailabilityFromItem(Rec, "Item Availability Type"::"Event");                        end;                    }                    action(Variant)                    {                        ApplicationArea = Planning;                        Caption = 'Variant';                        Image = ItemVariant;                        RunObject = Page "Item Availability by Variant";                        RunPageLink = "No." = field("No."),                                      "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                      "Global Dimension 2 Filter" = field("Global Dimension 2 Filter"),                                      "Location Filter" = field("Location Filter"),                                      "Drop Shipment Filter" = field("Drop Shipment Filter"),                                      "Variant Filter" = field("Variant Filter");                        ToolTip = 'View or edit the item''s variants. Instead of setting up each color of an item as a separate item, you can set up the various colors as variants of the item.';                    }                    action(Location)                    {                        ApplicationArea = Location;                        Caption = 'Location';                        Image = Warehouse;                        RunObject = Page "Item Availability by Location";                        RunPageLink = "No." = field("No."),                                      "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                      "Global Dimension 2 Filter" = field("Global Dimension 2 Filter"),                                      "Location Filter" = field("Location Filter"),                                      "Drop Shipment Filter" = field("Drop Shipment Filter"),                                      "Variant Filter" = field("Variant Filter");                        ToolTip = 'View the actual and projected quantity of the item per location.';                    }                    action("BOM Level")                    {                        ApplicationArea = Assembly;                        Caption = 'BOM Level';                        Image = BOMLevel;                        ToolTip = 'View availability figures for items on bills of materials that show how many units of a parent item you can make based on the availability of child items.';                        trigger OnAction()                        begin                            ItemAvailFormsMgt.ShowItemAvailabilityFromItem(Rec, "Item Availability Type"::BOM);                        end;                    }                }            }        }    }    trigger OnAfterGetRecord()    begin        Rec.SetRange("Drop Shipment Filter", false);        UpdateSubForm();    end;    trigger OnQueryClosePage(CloseAction: Action): Boolean    begin        if CloseAction = ACTION::LookupOK then            LookupOKOnPush();    end;    var        ItemAvailFormsMgt: Codeunit "Item Availability Forms Mgt";        PeriodType: Enum "Analysis Period Type";        AmountType: Enum "Analysis Amount Type";        LastDate: Date;    protected procedure UpdateSubForm()    begin        CurrPage.ItemAvailLines.PAGE.SetLines(Rec, PeriodType, AmountType);    end;    procedure GetLastDate(): Date    begin        exit(LastDate);    end;    local procedure DayPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure WeekPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure MonthPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure QuarterPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure YearPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure PeriodPeriodTypeOnPush()    begin        UpdateSubForm();    end;    local procedure BalanceatDateAmountTypeOnPush()    begin        UpdateSubForm();    end;    local procedure NetChangeAmountTypeOnPush()    begin        UpdateSubForm();    end;    local procedure LookupOKOnPush()    var        Date: Record Date;    begin        CurrPage.ItemAvailLines.PAGE.GetRecord(Date);        LastDate := Date."Period Start";    end;    local procedure DayPeriodTypeOnValidate()    begin        DayPeriodTypeOnPush();    end;    local procedure WeekPeriodTypeOnValidate()    begin        WeekPeriodTypeOnPush();    end;    local procedure MonthPeriodTypeOnValidate()    begin        MonthPeriodTypeOnPush();    end;    local procedure QuarterPeriodTypeOnValidate()    begin        QuarterPeriodTypeOnPush();    end;    local procedure YearPeriodTypeOnValidate()    begin        YearPeriodTypeOnPush();    end;    local procedure PeriodPeriodTypeOnValidate()    begin        PeriodPeriodTypeOnPush();    end;    local procedure NetChangeAmountTypeOnValidate()    begin        NetChangeAmountTypeOnPush();    end;    local procedure BalanceatDateAmountTypeOnValid()    begin        BalanceatDateAmountTypeOnPush();    end;}