Page 5856 Get Post.Doc - P.RcptLn Sbfrm

Base Application, Microsoft.Purchases.History

src/Layers/W1/BaseApp/Purchases/History/GetPostDocPRcptLnSbfrm.Page.al428 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.Purchases.History;using Microsoft.Finance.Dimension;using Microsoft.Inventory.Item.Catalog;page 5856 "Get Post.Doc - P.RcptLn Sbfrm"{    Caption = 'Lines';    Editable = false;    LinksAllowed = false;    PageType = ListPart;    SaveValues = true;    SourceTable = "Purch. Rcpt. Line";    layout    {        area(content)        {            repeater(Control1)            {                ShowCaption = false;                field("Document No."; Rec."Document No.")                {                    ApplicationArea = SalesReturnOrder;                    HideValue = DocumentNoHideValue;                    Lookup = false;                    StyleExpr = 'Strong';                    ToolTip = 'Specifies the receipt number.';                }                field("Expected Receipt Date"; Rec."Expected Receipt Date")                {                    ApplicationArea = SalesReturnOrder;                    ToolTip = 'Specifies the date the items were expected.';                }                field("Pay-to Vendor No."; Rec."Pay-to Vendor No.")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Buy-from Vendor No."; Rec."Buy-from Vendor No.")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field(Type; Rec.Type)                {                    ApplicationArea = SalesReturnOrder;                }                field("No."; Rec."No.")                {                    ApplicationArea = SalesReturnOrder;                }                field("Item Reference No."; Rec."Item Reference No.")                {                    AccessByPermission = tabledata "Item Reference" = R;                    ApplicationArea = Suite, ItemReferences;                }                field("Variant Code"; Rec."Variant Code")                {                    ApplicationArea = Planning;                    Visible = false;                }                field(Nonstock; Rec.Nonstock)                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field(Description; Rec.Description)                {                    ApplicationArea = SalesReturnOrder;                }                field("Description 2"; Rec."Description 2")                {                    ApplicationArea = SalesReturnOrder;                    Importance = Additional;                    Visible = false;                }                field("Return Reason Code"; Rec."Return Reason Code")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Location Code"; Rec."Location Code")                {                    ApplicationArea = SalesReturnOrder;                    ToolTip = 'Specifies the code for the location where the receipt line is registered.';                    Visible = false;                }                field("Bin Code"; Rec."Bin Code")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")                {                    ApplicationArea = Dimensions;                    Visible = false;                }                field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")                {                    ApplicationArea = Dimensions;                    Visible = false;                }                field("Unit of Measure Code"; Rec."Unit of Measure Code")                {                    ApplicationArea = SalesReturnOrder;                }                field(Quantity; Rec.Quantity)                {                    ApplicationArea = SalesReturnOrder;                }                field("Qty. Rcd. Not Invoiced"; Rec."Qty. Rcd. Not Invoiced")                {                    ApplicationArea = SalesReturnOrder;                    ToolTip = 'Specifies the quantity of the returned item that has been posted as received but that has not yet been posted as invoiced.';                }                field(RemainingQty; RemainingQty)                {                    ApplicationArea = SalesReturnOrder;                    AutoFormatType = 0;                    Caption = 'Remaining Quantity';                    DecimalPlaces = 0 : 5;                    ToolTip = 'Specifies the quantity from the posted document line that remains in inventory.';                }                field(AppliedQty; GetAppliedQty())                {                    ApplicationArea = SalesReturnOrder;                    AutoFormatType = 0;                    Caption = 'Applied Quantity';                    DecimalPlaces = 0 : 5;                    ToolTip = 'Specifies the quantity of the item in the line that has been used for outbound transactions.';                }                field("Unit of Measure"; Rec."Unit of Measure")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Unit Cost (LCY)"; Rec."Unit Cost (LCY)")                {                    ApplicationArea = SalesReturnOrder;                    ToolTip = 'Specifies the cost, in LCY, of one unit of the item or resource on the line.';                    Visible = false;                }                field(RevUnitCostLCY; RevUnitCostLCY)                {                    ApplicationArea = SalesReturnOrder;                    AutoFormatType = 2;                    AutoFormatExpression = '';                    Caption = 'Reverse Unit Cost (LCY)';                    ToolTip = 'Specifies the unit cost that will appear on the new document lines.';                    Visible = false;                }                field("Job No."; Rec."Job No.")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Blanket Order No."; Rec."Blanket Order No.")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }                field("Blanket Order Line No."; Rec."Blanket Order Line No.")                {                    ApplicationArea = SalesReturnOrder;                    Visible = false;                }            }        }    }    actions    {        area(processing)        {            group("&Line")            {                Caption = '&Line';                Image = Line;                action("Show Document")                {                    ApplicationArea = SalesReturnOrder;                    Caption = 'Show Document';                    Image = View;                    ShortCutKey = 'Shift+F7';                    ToolTip = 'Open the document that the selected line exists on.';                    trigger OnAction()                    begin                        ShowDocument();                    end;                }                action(Dimensions)                {                    AccessByPermission = TableData Dimension = R;                    ApplicationArea = Dimensions;                    Caption = 'Dimensions';                    Image = Dimensions;                    ShortCutKey = 'Alt+D';                    ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';                    trigger OnAction()                    begin                        Rec.ShowDimensions();                    end;                }                action("Item &Tracking Lines")                {                    ApplicationArea = ItemTracking;                    Caption = 'Item &Tracking Lines';                    Image = ItemTrackingLines;                    ShortCutKey = 'Ctrl+Alt+I';                    ToolTip = 'View or edit serial, lot and package numbers that are assigned to the item on the document or journal line.';                    trigger OnAction()                    begin                        ItemTrackingLines();                    end;                }            }        }    }    trigger OnAfterGetRecord()    begin        DocumentNoHideValue := false;        DocumentNoOnFormat();    end;    trigger OnFindRecord(Which: Text): Boolean    var        IsHandled: Boolean;        Result: Boolean;    begin        if not Visible then            exit(false);        IsHandled := false;        OnFindRecordOnBeforeFind(Rec, Which, Result, IsHandled);        if IsHandled then            exit(Result);        if Rec.Find(Which) then begin            PurchRcptLine := Rec;            while true do begin                ShowRec := IsShowRec(Rec);                if ShowRec then                    exit(true);                if Rec.Next(1) = 0 then begin                    Rec := PurchRcptLine;                    if Rec.Find(Which) then                        while true do begin                            ShowRec := IsShowRec(Rec);                            if ShowRec then                                exit(true);                            if Rec.Next(-1) = 0 then                                exit(false);                        end;                end;            end;        end;        exit(false);    end;    trigger OnNextRecord(Steps: Integer): Integer    var        RealSteps: Integer;        NextSteps: Integer;    begin        if Steps = 0 then            exit;        PurchRcptLine := Rec;        repeat            NextSteps := Rec.Next(Steps / Abs(Steps));            ShowRec := IsShowRec(Rec);            if ShowRec then begin                RealSteps := RealSteps + NextSteps;                PurchRcptLine := Rec;            end;        until (NextSteps = 0) or (RealSteps = Steps);        Rec := PurchRcptLine;        Rec.Find();        exit(RealSteps);    end;    trigger OnOpenPage()    begin    end;    var        PurchRcptLine: Record "Purch. Rcpt. Line";        TempPurchRcptLine: Record "Purch. Rcpt. Line" temporary;        RemainingQty: Decimal;        RevUnitCostLCY: Decimal;        RevQtyFilter: Boolean;        FillExactCostReverse: Boolean;        Visible: Boolean;        ShowRec: Boolean;        DocumentNoHideValue: Boolean;    local procedure IsFirstDocLine(): Boolean    var        PurchRcptLine2: Record "Purch. Rcpt. Line";        RemainingQty2: Decimal;        RevUnitCostLCY2: Decimal;    begin        TempPurchRcptLine.Reset();        TempPurchRcptLine.CopyFilters(Rec);        TempPurchRcptLine.SetRange("Document No.", Rec."Document No.");        if not TempPurchRcptLine.FindFirst() then begin            RemainingQty2 := RemainingQty;            RevUnitCostLCY2 := RevUnitCostLCY;            PurchRcptLine2.CopyFilters(Rec);            PurchRcptLine2.SetRange("Document No.", Rec."Document No.");            if not PurchRcptLine2.FindSet() then                exit(false);            repeat                ShowRec := IsShowRec(PurchRcptLine2);                if ShowRec then begin                    TempPurchRcptLine := PurchRcptLine2;                    TempPurchRcptLine.Insert();                end;            until (PurchRcptLine2.Next() = 0) or ShowRec;            RemainingQty := RemainingQty2;            RevUnitCostLCY := RevUnitCostLCY2;        end;        exit(Rec."Line No." = TempPurchRcptLine."Line No.");    end;    local procedure IsShowRec(PurchRcptLine2: Record "Purch. Rcpt. Line") Result: Boolean    var        IsHandled: Boolean;    begin        IsHandled := false;        OnBeforeIsShowRec(PurchRcptLine2, RevQtyFilter, Result, IsHandled, RemainingQty, RevUnitCostLCY, FillExactCostReverse);        if IsHandled then            exit(Result);        RemainingQty := 0;        if RevQtyFilter and (PurchRcptLine2.Type = PurchRcptLine2.Type::" ") then            exit(PurchRcptLine2."Attached to Line No." = 0);        if PurchRcptLine2.Type <> PurchRcptLine2.Type::Item then            exit(true);        if (PurchRcptLine2."Job No." <> '') or PurchRcptLine2.IsProdOrder() then            exit(not RevQtyFilter);        IsHandled := false;        OnIsShowRecOnBeforeCalcReceivedPurchNotReturned(PurchRcptLine2, RevQtyFilter, IsHandled);        if IsHandled then            exit(not RevQtyFilter);        PurchRcptLine2.CalcReceivedPurchNotReturned(RemainingQty, RevUnitCostLCY, FillExactCostReverse);        if not RevQtyFilter then            exit(true);        exit(RemainingQty > 0);    end;    local procedure GetAppliedQty(): Decimal    begin        if (Rec.Type = Rec.Type::Item) and (Rec.Quantity - RemainingQty > 0) then            exit(Rec.Quantity - RemainingQty);        exit(0);    end;    procedure Initialize(NewRevQtyFilter: Boolean; NewFillExactCostReverse: Boolean; NewVisible: Boolean)    begin        RevQtyFilter := NewRevQtyFilter;        FillExactCostReverse := NewFillExactCostReverse;        Visible := NewVisible;        if Visible then begin            TempPurchRcptLine.Reset();            TempPurchRcptLine.DeleteAll();        end;    end;    procedure GetSelectedLine(var FromPurchRcptLine: Record "Purch. Rcpt. Line")    begin        FromPurchRcptLine.Copy(Rec);        CurrPage.SetSelectionFilter(FromPurchRcptLine);    end;    local procedure ShowDocument()    var        PurchRcptHeader: Record "Purch. Rcpt. Header";    begin        if not PurchRcptHeader.Get(Rec."Document No.") then            exit;        PAGE.Run(PAGE::"Posted Purchase Receipt", PurchRcptHeader);    end;    local procedure ItemTrackingLines()    var        FromPurchRcptLine: Record "Purch. Rcpt. Line";    begin        GetSelectedLine(FromPurchRcptLine);        FromPurchRcptLine.ShowItemTrackingLines();    end;    local procedure DocumentNoOnFormat()    begin        if not IsFirstDocLine() then            DocumentNoHideValue := true;    end;    [IntegrationEvent(false, false)]    local procedure OnBeforeIsShowRec(PurchRcptLine: Record "Purch. Rcpt. Line"; var RevQtyFilter: Boolean; var Result: Boolean; var IsHandled: Boolean; var RemainingQty: Decimal; var RevUnitCostLCY: Decimal; FillExactCostReverse: Boolean)    begin    end;    [IntegrationEvent(false, false)]    local procedure OnIsShowRecOnBeforeCalcReceivedPurchNotReturned(PurchRcptLine2: Record "Purch. Rcpt. Line"; var RevQtyFilter: Boolean; var IsHandled: Boolean)    begin    end;    [IntegrationEvent(false, false)]    local procedure OnFindRecordOnBeforeFind(var PurchRcptLine: Record "Purch. Rcpt. Line"; var Which: Text; var Result: Boolean; var IsHandled: Boolean)    begin    end;}