Page 62 Applied Vendor Entries

Base Application, Microsoft.Purchases.Payables

src/Layers/W1/BaseApp/Purchases/Payables/AppliedVendorEntries.Page.al377 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.Payables;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Foundation.Navigate;using System.Security.User;page 62 "Applied Vendor Entries"{    Caption = 'Applied Vendor Entries';    DataCaptionExpression = Heading;    Editable = false;    PageType = List;    SourceTable = "Vendor Ledger Entry";    layout    {        area(content)        {            repeater(Control1)            {                ShowCaption = false;                field("Posting Date"; Rec."Posting Date")                {                    ApplicationArea = Basic, Suite;                }                field("Document Type"; Rec."Document Type")                {                    ApplicationArea = Basic, Suite;                }                field("Document No."; Rec."Document No.")                {                    ApplicationArea = Basic, Suite;                }                field(Description; Rec.Description)                {                    ApplicationArea = Basic, Suite;                }                field("External Document No."; Rec."External Document No.")                {                    ApplicationArea = Basic, Suite;                    Visible = true;                }                field("Global Dimension 1 Code"; Rec."Global Dimension 1 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible1;                }                field("Global Dimension 2 Code"; Rec."Global Dimension 2 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible2;                }                field("Purchaser Code"; Rec."Purchaser Code")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Currency Code"; Rec."Currency Code")                {                    ApplicationArea = Suite;                }                field("Original Amount"; Rec."Original Amount")                {                    ApplicationArea = Basic, Suite;                }                field(Amount; Rec.Amount)                {                    ApplicationArea = Basic, Suite;                    Visible = AmountVisible;                }                field("Debit Amount"; Rec."Debit Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = DebitCreditVisible;                }                field("Credit Amount"; Rec."Credit Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = DebitCreditVisible;                }                field("Closed by Amount"; Rec."Closed by Amount")                {                    ApplicationArea = Basic, Suite;                }                field("Closed by Currency Code"; Rec."Closed by Currency Code")                {                    ApplicationArea = Suite;                }                field("Closed by Currency Amount"; Rec."Closed by Currency Amount")                {                    ApplicationArea = Suite;                    AutoFormatExpression = Rec."Closed by Currency Code";                    AutoFormatType = 1;                }                field("User ID"; Rec."User ID")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                    trigger OnDrillDown()                    var                        UserMgt: Codeunit "User Management";                    begin                        UserMgt.DisplayUserInformation(Rec."User ID");                    end;                }                field("Source Code"; Rec."Source Code")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Reason Code"; Rec."Reason Code")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Entry No."; Rec."Entry No.")                {                    ApplicationArea = Basic, Suite;                }            }        }        area(factboxes)        {            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(navigation)        {            group("Ent&ry")            {                Caption = 'Ent&ry';                Image = Entry;                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("Detailed &Ledger Entries")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Detailed &Ledger Entries';                    Image = View;                    RunObject = Page "Detailed Vendor Ledg. Entries";                    RunPageLink = "Vendor Ledger Entry No." = field("Entry No."),                                  "Vendor No." = field("Vendor No.");                    RunPageView = sorting("Vendor Ledger Entry No.", "Posting Date");                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View a summary of the all posted entries and adjustments related to a specific vendor ledger entry.';                }            }        }        area(processing)        {            action("&Navigate")            {                ApplicationArea = Basic, Suite;                Caption = 'Find entries...';                Image = Navigate;                ShortCutKey = 'Ctrl+Alt+Q';                ToolTip = 'Find entries and documents that exist for the document number and posting date on the selected document. (Formerly this action was named Navigate.)';                trigger OnAction()                begin                    Navigate.SetDoc(Rec."Posting Date", Rec."Document No.");                    Navigate.Run();                end;            }            action("Show Posted Document")            {                ApplicationArea = Basic, Suite;                Caption = 'Show Posted Document';                Image = Document;                ToolTip = 'Show details for the posted payment, invoice, or credit memo.';                trigger OnAction()                begin                    Rec.ShowDoc();                end;            }            action(ShowDocumentAttachment)            {                ApplicationArea = Basic, Suite;                Caption = 'Show Document Attachment';                Enabled = HasDocumentAttachment;                Image = Attach;                ToolTip = 'View documents or images that are attached to the posted invoice or credit memo.';                trigger OnAction()                begin                    Rec.ShowPostedDocAttachment();                end;            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process';                actionref("&Navigate_Promoted"; "&Navigate")                {                }            }            group(Category_Category4)            {                Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 3.';                ShowAs = SplitButton;                actionref("Show Posted Document_Promoted"; "Show Posted Document")                {                }                actionref(ShowDocumentAttachment_Promoted; ShowDocumentAttachment)                {                }            }            group(Category_Category5)            {                Caption = 'Entry', Comment = 'Generated from the PromotedActionCategories property index 4.';                actionref(Dimensions_Promoted; Dimensions)                {                }                actionref("Detailed &Ledger Entries_Promoted"; "Detailed &Ledger Entries")                {                }            }            group(Category_Report)            {                Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';            }        }    }    trigger OnAfterGetCurrRecord()    begin        HasDocumentAttachment := Rec.HasPostedDocAttachment();    end;    trigger OnInit()    begin        AmountVisible := true;    end;    trigger OnOpenPage()    begin        Rec.Reset();        SetControlVisibility();        if Rec."Entry No." <> 0 then begin            CreateVendLedgEntry := Rec;            if CreateVendLedgEntry."Document Type" = CreateVendLedgEntry."Document Type"::" " then                Heading := Text000            else                Heading := Format(CreateVendLedgEntry."Document Type");            Heading := Heading + ' ' + CreateVendLedgEntry."Document No.";            FindApplnEntriesDtldtLedgEntry();            Rec.SetCurrentKey("Entry No.");            Rec.SetRange("Entry No.");            if CreateVendLedgEntry."Closed by Entry No." <> 0 then begin                Rec."Entry No." := CreateVendLedgEntry."Closed by Entry No.";                Rec.Mark(true);            end;            Rec.SetCurrentKey("Closed by Entry No.");            Rec.SetRange("Closed by Entry No.", CreateVendLedgEntry."Entry No.");            if Rec.Find('-') then                repeat                    Rec.Mark(true);                until Rec.Next() = 0;            Rec.SetCurrentKey("Entry No.");            Rec.SetRange("Closed by Entry No.");        end;        Rec.MarkedOnly(true);    end;    var        CreateVendLedgEntry: Record "Vendor Ledger Entry";        Navigate: Page Navigate;        Heading: Text[50];        AmountVisible: Boolean;        DebitCreditVisible: Boolean;        DimVisible1: Boolean;        DimVisible2: Boolean;        HasDocumentAttachment: Boolean;#pragma warning disable AA0074        Text000: Label 'Document';#pragma warning restore AA0074    local procedure FindApplnEntriesDtldtLedgEntry()    var        DtldVendLedgEntry1: Record "Detailed Vendor Ledg. Entry";        DtldVendLedgEntry2: Record "Detailed Vendor Ledg. Entry";    begin        DtldVendLedgEntry1.SetCurrentKey("Vendor Ledger Entry No.");        DtldVendLedgEntry1.SetRange("Vendor Ledger Entry No.", CreateVendLedgEntry."Entry No.");        DtldVendLedgEntry1.SetRange(Unapplied, false);        if DtldVendLedgEntry1.Find('-') then            repeat                if DtldVendLedgEntry1."Vendor Ledger Entry No." =                   DtldVendLedgEntry1."Applied Vend. Ledger Entry No."                then begin                    DtldVendLedgEntry2.Init();                    DtldVendLedgEntry2.SetCurrentKey("Applied Vend. Ledger Entry No.", "Entry Type");                    DtldVendLedgEntry2.SetRange(                      "Applied Vend. Ledger Entry No.", DtldVendLedgEntry1."Applied Vend. Ledger Entry No.");                    DtldVendLedgEntry2.SetRange("Entry Type", DtldVendLedgEntry2."Entry Type"::Application);                    DtldVendLedgEntry2.SetRange(Unapplied, false);                    if DtldVendLedgEntry2.Find('-') then                        repeat                            if DtldVendLedgEntry2."Vendor Ledger Entry No." <>                               DtldVendLedgEntry2."Applied Vend. Ledger Entry No."                            then begin                                Rec.SetCurrentKey("Entry No.");                                Rec.SetRange("Entry No.", DtldVendLedgEntry2."Vendor Ledger Entry No.");                                if Rec.Find('-') then                                    Rec.Mark(true);                            end;                        until DtldVendLedgEntry2.Next() = 0;                end else begin                    Rec.SetCurrentKey("Entry No.");                    Rec.SetRange("Entry No.", DtldVendLedgEntry1."Applied Vend. Ledger Entry No.");                    if Rec.Find('-') then                        Rec.Mark(true);                end;            until DtldVendLedgEntry1.Next() = 0;    end;    procedure GetCreateVendorLedgerEntry(): Record "Vendor Ledger Entry"    begin        exit(CreateVendLedgEntry);    end;    local procedure SetControlVisibility()    var        GLSetup: Record "General Ledger Setup";    begin        GLSetup.Get();        AmountVisible := not (GLSetup."Show Amounts" = GLSetup."Show Amounts"::"Debit/Credit Only");        DebitCreditVisible := not (GLSetup."Show Amounts" = GLSetup."Show Amounts"::"Amount Only");        DimVisible1 := GLSetup."Global Dimension 1 Code" <> '';        DimVisible2 := GLSetup."Global Dimension 2 Code" <> '';    end;}