Page 29 Vendor Ledger Entries
src/Layers/W1/BaseApp/Purchases/Payables/VendorLedgerEntries.Page.al868 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.Bank.Reconciliation;using Microsoft.EServices.EDocument;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Journal;using Microsoft.Finance.GeneralLedger.Ledger;using Microsoft.Finance.GeneralLedger.Reversal;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Foundation.Navigate;using Microsoft.Foundation.Reporting;using Microsoft.Purchases.Remittance;using Microsoft.Purchases.Setup;using System.Diagnostics;using System.Security.User;using System.Utilities;page 29 "Vendor Ledger Entries"{ ApplicationArea = Basic, Suite; Caption = 'Vendor Ledger Entries'; DataCaptionFields = "Vendor No."; DeleteAllowed = false; InsertAllowed = false; PageType = List; AboutTitle = 'About Vendor Ledger Entries'; AboutText = 'Track all financial transactions with vendors, including invoices, payments, credit memos, and refunds, to monitor outstanding balances, payment status, and detailed entry information for each vendor account.'; Permissions = TableData "Vendor Ledger Entry" = m; SourceTable = "Vendor Ledger Entry"; SourceTableView = sorting("Vendor No.", "Posting Date") order(descending); UsageCategory = History; AdditionalSearchTerms = 'Vendor Check, Pay Vendor, Vendor Bills'; layout { area(content) { repeater(Control1) { ShowCaption = false; field("Posting Date"; Rec."Posting Date") { ApplicationArea = Basic, Suite; Editable = false; } field("Document Date"; Rec."Document Date") { ApplicationArea = Basic, Suite; Editable = false; } field("Invoice Received Date"; Rec."Invoice Received Date") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Document Type"; Rec."Document Type") { ApplicationArea = Basic, Suite; Editable = false; StyleExpr = StyleTxt; } field("Document No."; Rec."Document No.") { ApplicationArea = Basic, Suite; Editable = false; StyleExpr = StyleTxt; } field("External Document No."; Rec."External Document No.") { ApplicationArea = Basic, Suite; Editable = false; } field("Vendor No."; Rec."Vendor No.") { ApplicationArea = Basic, Suite; Editable = false; } field("Vendor Name"; Rec."Vendor Name") { ApplicationArea = Basic, Suite; Editable = false; Visible = VendNameVisible; } field("Message to Recipient"; Rec."Message to Recipient") { ApplicationArea = Basic, Suite; Visible = false; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; Editable = true; } field("Global Dimension 1 Code"; Rec."Global Dimension 1 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim1Visible; } field("Global Dimension 2 Code"; Rec."Global Dimension 2 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim2Visible; } field("Vendor Posting Group"; Rec."Vendor Posting Group") { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the vendor''s market type to link business transactions made for the vendor with the appropriate account in the general ledger.'; Visible = false; } field("IC Partner Code"; Rec."IC Partner Code") { ApplicationArea = Intercompany; Editable = false; Visible = false; } field("Purchaser Code"; Rec."Purchaser Code") { ApplicationArea = Suite; Editable = false; Visible = false; } field("Currency Code"; Rec."Currency Code") { ApplicationArea = Suite; Editable = false; } field("Payment Method Code"; Rec."Payment Method Code") { ApplicationArea = Basic, Suite; } field("Payment Reference"; Rec."Payment Reference") { ApplicationArea = Basic, Suite; } field("Creditor No."; Rec."Creditor No.") { ApplicationArea = Basic, Suite; } field("Original Amount"; Rec."Original Amount") { ApplicationArea = Basic, Suite; Editable = false; } field("Original Amt. (LCY)"; Rec."Original Amt. (LCY)") { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the amount that the entry originally consisted of, in LCY.'; Visible = false; } field(Amount; Rec.Amount) { ApplicationArea = Basic, Suite; Editable = false; Visible = AmountVisible; } field("Amount (LCY)"; Rec."Amount (LCY)") { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the amount of the entry in LCY.'; Visible = AmountVisible; } field("Debit Amount"; Rec."Debit Amount") { ApplicationArea = Basic, Suite; Visible = DebitCreditVisible; } field("Debit Amount (LCY)"; Rec."Debit Amount (LCY)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the total of the ledger entries that represent debits, expressed in LCY.'; Visible = DebitCreditVisible; } field("Credit Amount"; Rec."Credit Amount") { ApplicationArea = Basic, Suite; Visible = DebitCreditVisible; } field("Credit Amount (LCY)"; Rec."Credit Amount (LCY)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the total of the ledger entries that represent credits, expressed in LCY.'; Visible = DebitCreditVisible; } field(RunningBalanceLCY; CalcRunningVendBalance.GetVendorBalanceLCY(Rec)) { ApplicationArea = Basic, Suite; Caption = 'Running Balance (LCY)'; ToolTip = 'Specifies the running balance in LCY.'; AutoFormatType = 1; AutoFormatExpression = ''; Visible = false; } field("Remaining Amount"; Rec."Remaining Amount") { ApplicationArea = Basic, Suite; Editable = false; } field("Remaining Amt. (LCY)"; Rec."Remaining Amt. (LCY)") { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the amount that remains to be applied to before the entry is totally applied to.'; } field("Bal. Account Type"; Rec."Bal. Account Type") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Bal. Account No."; Rec."Bal. Account No.") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Due Date"; Rec."Due Date") { ApplicationArea = Basic, Suite; StyleExpr = StyleTxt; } field("Pmt. Discount Date"; Rec."Pmt. Discount Date") { ApplicationArea = Basic, Suite; } field("Pmt. Disc. Tolerance Date"; Rec."Pmt. Disc. Tolerance Date") { ApplicationArea = Basic, Suite; } field("Original Pmt. Disc. Possible"; Rec."Original Pmt. Disc. Possible") { ApplicationArea = Basic, Suite; } field("Remaining Pmt. Disc. Possible"; Rec."Remaining Pmt. Disc. Possible") { ApplicationArea = Basic, Suite; } field("Max. Payment Tolerance"; Rec."Max. Payment Tolerance") { ApplicationArea = Basic, Suite; } field(Open; Rec.Open) { ApplicationArea = Basic, Suite; Editable = false; } field("Dispute Status"; Rec."Dispute Status") { ApplicationArea = Basic, Suite; } field("On Hold"; Rec."On Hold") { ApplicationArea = Basic, Suite; } field("User ID"; Rec."User ID") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; trigger OnDrillDown() var UserMgt: Codeunit "User Management"; begin UserMgt.DisplayUserInformation(Rec."User ID"); end; } field("Source Code"; Rec."Source Code") { ApplicationArea = Suite; Editable = false; Visible = false; } field("Reason Code"; Rec."Reason Code") { ApplicationArea = Suite; Editable = false; Visible = false; } field(Reversed; Rec.Reversed) { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Reversed by Entry No."; Rec."Reversed by Entry No.") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Reversed Entry No."; Rec."Reversed Entry No.") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Entry No."; Rec."Entry No.") { ApplicationArea = Basic, Suite; Editable = false; } field("G/L Register No."; Rec."G/L Register No.") { ApplicationArea = Basic, Suite; Editable = false; } field("Transaction No."; Rec."Transaction No.") { ApplicationArea = Basic, Suite; Editable = false; } field("Exported to Payment File"; Rec."Exported to Payment File") { ApplicationArea = Basic, Suite; Editable = true; trigger OnValidate() var ConfirmManagement: Codeunit "Confirm Management"; begin if not ConfirmManagement.GetResponseOrDefault(ExportToPaymentFileConfirmTxt, true) then Error(''); end; } field("Dimension Set ID"; Rec."Dimension Set ID") { ApplicationArea = Dimensions; Visible = false; } field(RecipientBankAcc; Rec."Recipient Bank Account") { ApplicationArea = Basic, Suite; } field("Shortcut Dimension 3 Code"; Rec."Shortcut Dimension 3 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim3Visible; } field("Shortcut Dimension 4 Code"; Rec."Shortcut Dimension 4 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim4Visible; } field("Shortcut Dimension 5 Code"; Rec."Shortcut Dimension 5 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim5Visible; } field("Shortcut Dimension 6 Code"; Rec."Shortcut Dimension 6 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim6Visible; } field("Shortcut Dimension 7 Code"; Rec."Shortcut Dimension 7 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim7Visible; } field("Shortcut Dimension 8 Code"; Rec."Shortcut Dimension 8 Code") { ApplicationArea = Dimensions; Editable = false; Visible = Dim8Visible; } field("Closed at Date"; Rec."Closed at Date") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Remit-to Code"; Rec."Remit-to Code") { ApplicationArea = Basic, Suite; Visible = true; TableRelation = "Remit Address".Code where("Vendor No." = field("Vendor No.")); } } } area(factboxes) { part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox") { ApplicationArea = Basic, Suite; ShowFilter = false; } systempart(Control1900383207; Links) { ApplicationArea = RecordLinks; Visible = false; } systempart(Control1905767507; Notes) { ApplicationArea = Notes; Visible = false; } part(GLEntriesPart; "G/L Entries Part") { ApplicationArea = Basic, Suite; Caption = 'Related G/L Entries'; ShowFilter = false; SubPageLink = "Posting Date" = field("Posting Date"), "Document No." = field("Document No."); } } } actions { area(navigation) { group("Ent&ry") { Caption = 'Ent&ry'; Image = Entry; action(AppliedEntries) { ApplicationArea = Basic, Suite; Caption = 'Applied E&ntries'; Image = Approve; RunObject = Page "Applied Vendor Entries"; RunPageOnRec = true; Scope = Repeater; ToolTip = 'View the ledger entries that have been applied to this record.'; } action(Dimensions) { AccessByPermission = TableData Dimension = R; ApplicationArea = Dimensions; Caption = 'Dimensions'; Image = Dimensions; Scope = Repeater; 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(SetDimensionFilter) { ApplicationArea = Dimensions; Caption = 'Set Dimension Filter'; Ellipsis = true; Image = "Filter"; ToolTip = 'Limit the entries according to the dimension filters that you specify. NOTE: If you use a high number of dimension combinations, this function may not work and can result in a message that the SQL server only supports a maximum of 2100 parameters.'; trigger OnAction() begin Rec.SetFilter("Dimension Set ID", DimensionSetIDFilter.LookupFilter()); 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"); Scope = Repeater; ShortCutKey = 'Ctrl+F7'; ToolTip = 'View a summary of the all posted entries and adjustments related to a specific vendor ledger entry'; } } } area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action(ActionApplyEntries) { ApplicationArea = Basic, Suite; Caption = 'Apply Entries'; Image = ApplyEntries; Scope = Repeater; ShortCutKey = 'Shift+F11'; ToolTip = 'Select one or more ledger entries that you want to apply this record to so that the related posted documents are closed as paid or refunded.'; trigger OnAction() var VendLedgEntry: Record "Vendor Ledger Entry"; VendEntryApplyPostEntries: Codeunit "VendEntry-Apply Posted Entries"; begin VendLedgEntry.Copy(Rec); VendEntryApplyPostEntries.ApplyVendEntryFormEntry(VendLedgEntry); VendLedgEntry.Get(VendLedgEntry."Entry No."); Rec := VendLedgEntry; CurrPage.Update(); end; } action(UnapplyEntries) { ApplicationArea = Basic, Suite; Caption = 'Unapply Entries'; Ellipsis = true; Image = UnApply; Scope = Repeater; ToolTip = 'Unselect one or more ledger entries that you want to unapply this record.'; trigger OnAction() var VendEntryApplyPostedEntries: Codeunit "VendEntry-Apply Posted Entries"; begin VendEntryApplyPostedEntries.UnApplyVendLedgEntry(Rec."Entry No."); end; } action(ReverseTransaction) { ApplicationArea = Basic, Suite; Caption = 'Reverse Transaction'; Ellipsis = true; Image = ReverseRegister; Scope = Repeater; ToolTip = 'Reverse an erroneous vendor ledger entry.'; trigger OnAction() var ReversalEntry: Record "Reversal Entry"; ReversePaymentRec: Codeunit "Reverse Payment Rec. Journal"; begin ReversePaymentRec.ErrorIfEntryIsNotReversable(Rec); ReversalEntry.ReverseTransaction(Rec."Transaction No."); Clear(CalcRunningVendBalance); end; } action(SendVendorRemittanceAdvice) { ApplicationArea = All; Caption = 'Send Remittance Advice'; Image = SendToMultiple; ToolTip = 'Send the remittance advice before posting a payment journal or after posting a payment. The advice contains vendor invoice numbers, which helps vendors to perform reconciliations.'; trigger OnAction() var VendorLedgerEntry: Record "Vendor Ledger Entry"; begin VendorLedgerEntry := Rec; CurrPage.SetSelectionFilter(VendorLedgerEntry); VendorLedgerEntry.SetRange("Document Type", VendorLedgerEntry."Document Type"::Payment); SendVendorRecords(VendorLedgerEntry); end; } group(IncomingDocument) { Caption = 'Incoming Document'; Image = Documents; action(IncomingDocCard) { ApplicationArea = Basic, Suite; Caption = 'View Incoming Document'; Enabled = HasIncomingDocument; Image = ViewOrder; ToolTip = 'View any incoming document records and file attachments that exist for the entry or document.'; trigger OnAction() var IncomingDocument: Record "Incoming Document"; begin IncomingDocument.ShowCard(Rec."Document No.", Rec."Posting Date"); end; } action(SelectIncomingDoc) { AccessByPermission = TableData "Incoming Document" = R; ApplicationArea = Basic, Suite; Caption = 'Select Incoming Document'; Enabled = not HasIncomingDocument; Image = SelectLineToApply; ToolTip = 'Select an incoming document record and file attachment that you want to link to the entry or document.'; trigger OnAction() var IncomingDocument: Record "Incoming Document"; begin IncomingDocument.SelectIncomingDocumentForPostedDocument(Rec."Document No.", Rec."Posting Date", Rec.RecordId); end; } action(IncomingDocAttachFile) { ApplicationArea = Basic, Suite; Caption = 'Create Incoming Document from File'; Ellipsis = true; Enabled = not HasIncomingDocument; Image = Attach; ToolTip = 'Create an incoming document record by selecting a file to attach, and then link the incoming document record to the entry or document.'; trigger OnAction() var IncomingDocumentAttachment: Record "Incoming Document Attachment"; begin IncomingDocumentAttachment.NewAttachmentFromPostedDocument(Rec."Document No.", Rec."Posting Date"); end; } } } action("&Navigate") { ApplicationArea = Basic, Suite; Caption = 'Find entries...'; Image = Navigate; Scope = Repeater; 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 Document") { ApplicationArea = Basic, Suite; Caption = 'Show Document'; Image = Document; ShortCutKey = 'Return'; 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; } action("Create Payment") { ApplicationArea = Basic, Suite; Caption = 'Create Payment'; Image = SuggestVendorPayments; ToolTip = 'Create a payment journal based on the selected invoices.'; trigger OnAction() var VendorLedgerEntry: Record "Vendor Ledger Entry"; GenJournalBatch: Record "Gen. Journal Batch"; GenJnlManagement: Codeunit GenJnlManagement; CreatePayment: Page "Create Payment"; begin CurrPage.SetSelectionFilter(VendorLedgerEntry); if CreatePayment.RunModal() = ACTION::OK then begin CreatePayment.MakeGenJnlLines(VendorLedgerEntry); GetBatchRecord(GenJournalBatch, CreatePayment); GenJnlManagement.TemplateSelectionFromBatch(GenJournalBatch); Clear(CreatePayment); end else Clear(CreatePayment); end; } action(ShowChangeHistory) { ApplicationArea = Basic, Suite; Caption = 'Show Change History'; Image = History; ToolTip = 'View the history of changes for this entry.'; trigger OnAction() var ChangeLogEntry: Record "Change Log Entry"; begin SetChangeLogEntriesFilter(ChangeLogEntry); Page.RunModal(Page::"Change Log Entries", ChangeLogEntry); end; } } area(Promoted) { group(Category_Process) { Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.'; group(Category_Category4) { Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 3.'; ShowAs = SplitButton; actionref("Show Document_Promoted"; "Show Document") { } actionref(ShowDocumentAttachment_Promoted; ShowDocumentAttachment) { } } group("Category_Apply/Unapply") { Caption = 'Apply/Unapply'; ShowAs = SplitButton; actionref(ActionApplyEntries_Promoted; ActionApplyEntries) { } actionref(UnapplyEntries_Promoted; UnapplyEntries) { } } actionref("&Navigate_Promoted"; "&Navigate") { } actionref("Create Payment_Promoted"; "Create Payment") { } actionref(ReverseTransaction_Promoted; ReverseTransaction) { } } group(Category_Category5) { Caption = 'Entry', Comment = 'Generated from the PromotedActionCategories property index 4.'; actionref(Dimensions_Promoted; Dimensions) { } actionref(SetDimensionFilter_Promoted; SetDimensionFilter) { } actionref(AppliedEntries_Promoted; AppliedEntries) { } actionref("Detailed &Ledger Entries_Promoted"; "Detailed &Ledger Entries") { } } group(Category_Report) { Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.'; } } } trigger OnAfterGetCurrRecord() var IncomingDocument: Record "Incoming Document"; begin HasIncomingDocument := IncomingDocument.PostedDocExists(Rec."Document No.", Rec."Posting Date"); HasDocumentAttachment := Rec.HasPostedDocAttachment(); if GuiAllowed() then CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec); end; trigger OnAfterGetRecord() begin StyleTxt := Rec.SetStyle(); end; trigger OnInit() begin AmountVisible := true; end; trigger OnModifyRecord(): Boolean begin CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", Rec); exit(false); end; trigger OnOpenPage() begin SetControlVisibility(); SetDimVisibility(); if (Rec.GetFilters() <> '') and not Rec.Find() then if Rec.FindFirst() then; end; var CalcRunningVendBalance: Codeunit "Calc. Running Vend. Balance"; Navigate: Page Navigate; DimensionSetIDFilter: Page "Dimension Set ID Filter"; HasIncomingDocument: Boolean; HasDocumentAttachment: Boolean; AmountVisible: Boolean; DebitCreditVisible: Boolean; VendNameVisible: Boolean; ExportToPaymentFileConfirmTxt: Label 'Editing the Exported to Payment File field will change the payment suggestions in the Payment Journal. Edit this field only if you must correct a mistake.\Do you want to continue?'; RemittanceAdviceTxt: Label 'Remittance Advice'; protected var Dim1Visible: Boolean; Dim2Visible: Boolean; Dim3Visible: Boolean; Dim4Visible: Boolean; Dim5Visible: Boolean; Dim6Visible: Boolean; Dim7Visible: Boolean; Dim8Visible: Boolean; StyleTxt: Text; local procedure SetDimVisibility() var DimensionManagement: Codeunit DimensionManagement; begin DimensionManagement.UseShortcutDims(Dim1Visible, Dim2Visible, Dim3Visible, Dim4Visible, Dim5Visible, Dim6Visible, Dim7Visible, Dim8Visible); end; local procedure SetControlVisibility() var GLSetup: Record "General Ledger Setup"; PurchSetup: Record "Purchases & Payables 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"); PurchSetup.Get(); VendNameVisible := PurchSetup."Copy Vendor Name to Entries"; end; local procedure GetBatchRecord(var GenJournalBatch: Record "Gen. Journal Batch"; CreatePayment: Page "Create Payment") var GenJournalTemplate: Record "Gen. Journal Template"; JournalTemplateName: Code[10]; JournalBatchName: Code[10]; begin JournalTemplateName := CreatePayment.GetTemplateName(); JournalBatchName := CreatePayment.GetBatchNumber(); GenJournalTemplate.Get(JournalTemplateName); GenJournalBatch.Get(JournalTemplateName, JournalBatchName); end; local procedure SetChangeLogEntriesFilter(var ChangeLogEntry: Record "Change Log Entry") begin ChangeLogEntry.SetRange("Table No.", Database::"Vendor Ledger Entry"); ChangeLogEntry.SetRange("Primary Key Field 1 Value", Format(Rec."Entry No.", 0, 9)); end; local procedure SendVendorRecords(var VendorLedgerEntry: Record "Vendor Ledger Entry") var DocumentSendingProfile: Record "Document Sending Profile"; DummyReportSelections: Record "Report Selections"; begin if not VendorLedgerEntry.FindSet() then exit; DocumentSendingProfile.SendVendorRecords( DummyReportSelections.Usage::"P.V.Remit.".AsInteger(), VendorLedgerEntry, RemittanceAdviceTxt, Rec."Vendor No.", Rec."Document No.", VendorLedgerEntry.FieldNo("Vendor No."), VendorLedgerEntry.FieldNo("Document No.")); end;}