Page 20 General Ledger Entries
src/Layers/W1/BaseApp/Finance/GeneralLedger/Ledger/GeneralLedgerEntries.Page.al850 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.Finance.GeneralLedger.Ledger;using Microsoft.EServices.EDocument;using Microsoft.Finance.Dimension;using Microsoft.Finance.Dimension.Correction;using Microsoft.Finance.GeneralLedger.Account;using Microsoft.Finance.GeneralLedger.Reversal;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Finance.SpendRequest;using Microsoft.Finance.VAT.Calculation;using Microsoft.Foundation.Navigate;using Microsoft.Inventory.Item;using System.Diagnostics;using System.Security.User;/// <summary>/// Displays general ledger entries with filtering, navigation, and analysis capabilities./// Provides read-only access to G/L entries with dimension details and related document navigation./// </summary>/// <remarks>/// Primary data source: G/L Entry table. Supports filtering by G/L account, document type, and posting dates./// Navigation: Related documents, dimensions, reversals, and source journal entries./// Extensibility: OnBeforeCheckEntryPostedFromJournal, OnBeforeGetCaption, OnBeforeOnModifyRecord events available./// </remarks>page 20 "General Ledger Entries"{ AdditionalSearchTerms = 'G/L Transactions, Accounting Entries, Financial Entries, Bookkeeping Records, Account Records, G/L Entries, Account Lines, GL Entries'; ApplicationArea = Basic, Suite; Caption = 'General Ledger Entries'; DataCaptionExpression = GetCaption(); DeleteAllowed = false; InsertAllowed = false; PageType = List; AboutTitle = 'About General Ledger Entries'; AboutText = 'Review, filter, and analyze all posted general ledger entries to track financial transactions, reconcile accounts, investigate discrepancies, and support accurate financial reporting.'; Permissions = TableData "G/L Entry" = m; SourceTable = "G/L Entry"; SourceTableView = sorting("G/L Account No.", "Posting Date") order(descending); UsageCategory = History; layout { area(content) { repeater(Control1) { ShowCaption = false; field("Posting Date"; Rec."Posting Date") { ApplicationArea = Basic, Suite; Editable = false; } field("Document Type"; Rec."Document Type") { ApplicationArea = Basic, Suite; Editable = false; } field("Document No."; Rec."Document No.") { ApplicationArea = Basic, Suite; Editable = false; } field("G/L Account No."; Rec."G/L Account No.") { ApplicationArea = Basic, Suite; Editable = false; } field("G/L Account Name"; Rec."G/L Account Name") { ApplicationArea = Basic, Suite; DrillDown = false; Editable = false; Visible = false; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; } field("Job No."; Rec."Job No.") { ApplicationArea = Jobs; Editable = false; Visible = false; } 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("IC Partner Code"; Rec."IC Partner Code") { ApplicationArea = Intercompany; Editable = false; Visible = false; } field("Gen. Posting Type"; Rec."Gen. Posting Type") { ApplicationArea = Basic, Suite; Editable = false; } field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group") { ApplicationArea = Basic, Suite; Editable = false; } field("Gen. Prod. Posting Group"; Rec."Gen. Prod. Posting Group") { ApplicationArea = Basic, Suite; Editable = false; } field("VAT Bus. Posting Group"; Rec."VAT Bus. Posting Group") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("VAT Prod. Posting Group"; Rec."VAT Prod. Posting Group") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field(Quantity; Rec.Quantity) { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field(Amount; Rec.Amount) { ApplicationArea = Basic, Suite; Editable = false; Visible = AmountVisible; } field("Source Currency Code"; Rec."Source Currency Code") { ApplicationArea = Basic, Suite; Editable = false; } field("Source Currency Amount"; Rec."Source Currency Amount") { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the source currency amount for general ledger entries.'; } field("Source Currency VAT Amount"; Rec."Source Currency VAT Amount") { ApplicationArea = VAT; Editable = false; ToolTip = 'Specifies the source currency VAT amount for general ledger entries.'; } field("Src. Curr. Non-Ded. VAT Amount"; Rec."Src. Curr. Non-Ded. VAT Amount") { ApplicationArea = VAT; Editable = false; } field("Debit Amount"; Rec."Debit Amount") { ApplicationArea = Basic, Suite; Editable = false; Visible = DebitCreditVisible; } field("Credit Amount"; Rec."Credit Amount") { ApplicationArea = Basic, Suite; Editable = false; Visible = DebitCreditVisible; } field(RunningBalance; CalcRunningGLAccBalance.GetGLAccBalance(Rec)) { ApplicationArea = Basic, Suite; Caption = 'Running Balance'; ToolTip = 'Specifies the running balance in LCY.'; AutoFormatType = 1; AutoFormatExpression = ''; Visible = false; } field("Additional-Currency Amount"; Rec."Additional-Currency Amount") { ApplicationArea = Suite; Editable = false; Visible = false; } field(RunningBalanceACY; CalcRunningGLAccBalance.GetGLAccBalanceACY(Rec)) { ApplicationArea = Basic, Suite; Caption = 'Running Balance (ACY)'; ToolTip = 'Specifies the running balance in additional reporting currency.'; AutoFormatType = 1; AutoFormatExpression = Rec.GetAdditionalReportingCurrencyCode(); Visible = false; } field("VAT Amount"; Rec."VAT Amount") { ApplicationArea = VAT; Editable = false; Visible = false; } field(NonDeductibleVATAmount; Rec."Non-Deductible VAT Amount") { ApplicationArea = Basic, Suite; Editable = false; Visible = false; } field("Bal. Account Type"; Rec."Bal. Account Type") { ApplicationArea = Basic, Suite; Editable = false; } field("Bal. Account No."; Rec."Bal. Account No.") { ApplicationArea = Basic, Suite; Editable = false; } field("VAT Reporting Date"; Rec."VAT Reporting Date") { ApplicationArea = VAT; ToolTip = 'Specifies the VAT date on the VAT entry. This is either the date that the document was created or posted, depending on your setting on the General Ledger Setup page.'; Editable = false; Visible = IsVATDateEnabled; } 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("Source Type"; Rec."Source Type") { ApplicationArea = Suite; Editable = false; Visible = false; } field("Source No."; Rec."Source No.") { 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("FA Entry Type"; Rec."FA Entry Type") { ApplicationArea = FixedAssets; Editable = false; Visible = false; } field("FA Entry No."; Rec."FA Entry No.") { ApplicationArea = FixedAssets; 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("Dimension Set ID"; Rec."Dimension Set ID") { ApplicationArea = Dimensions; Editable = false; Visible = false; } field("External Document No."; Rec."External Document No.") { ApplicationArea = Basic, Suite; Editable = false; } field("Business Unit Code"; Rec."Business Unit Code") { ApplicationArea = Basic, Suite; Visible = false; } 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; } } } area(factboxes) { part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox") { ApplicationArea = Basic, Suite; ShowFilter = false; UpdatePropagation = Both; SubPageLink = "Posting Date" = field("Posting Date"), "Document No." = field("Document No."); } 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."); } 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; 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(); CurrPage.SaveRecord(); 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(GLDimensionOverview) { AccessByPermission = TableData Dimension = R; ApplicationArea = Dimensions; Caption = 'G/L Dimension Overview'; Image = Dimensions; ToolTip = 'View an overview of general ledger entries and dimensions.'; trigger OnAction() var GLEntriesDimensionOverview: Page "G/L Entries Dimension Overview"; begin if Rec.IsTemporary then begin GLEntriesDimensionOverview.SetTempGLEntry(Rec); GLEntriesDimensionOverview.Run(); end else PAGE.Run(PAGE::"G/L Entries Dimension Overview", Rec); end; } action(ChangeDimensions) { ApplicationArea = All; Image = ChangeDimensions; Caption = 'Correct Dimensions'; ToolTip = 'Correct dimensions for the selected general ledger entries.'; trigger OnAction() var GLEntry: Record "G/L Entry"; DimensionCorrection: Record "Dimension Correction"; DimensionCorrectionMgt: Codeunit "Dimension Correction Mgt"; begin CurrPage.SetSelectionFilter(GLEntry); if GLEntry.Count() > 1000 then Error(TooManyGLEntriesSelectedErr); DimensionCorrectionMgt.CreateCorrectionFromSelection(GLEntry, DimensionCorrection); Page.Run(PAGE::"Dimension Correction Draft", DimensionCorrection); end; } action(DimensionChangeHistory) { ApplicationArea = All; Image = History; Caption = 'History of Dimension Corrections'; ToolTip = 'View a list of corrections that were made to selected ledger entries.'; trigger OnAction() var DimCorrectionEntryLog: Record "Dim Correction Entry Log"; DimensionCorrection: Record "Dimension Correction"; begin DimCorrectionEntryLog.SetCurrentKey("Dimension Correction Entry No."); DimCorrectionEntryLog.Ascending(true); DimCorrectionEntryLog.SetFilter("Start Entry No.", '<=%1', Rec."Entry No."); DimCorrectionEntryLog.SetFilter("End Entry No.", '>=%1', Rec."Entry No."); if DimCorrectionEntryLog.FindFirst() then repeat if DimensionCorrection.Get(DimCorrectionEntryLog."Dimension Correction Entry No.") then DimensionCorrection.Mark(true); DimCorrectionEntryLog.SetFilter("Dimension Correction Entry No.", '>%1', DimCorrectionEntryLog."Dimension Correction Entry No."); until not DimCorrectionEntryLog.FindFirst(); DimensionCorrection.MarkedOnly(true); Page.Run(Page::"Dimension Corrections", DimensionCorrection); end; } action("Value Entries") { AccessByPermission = TableData Item = R; ApplicationArea = Basic, Suite; Caption = 'Value Entries'; Image = ValueLedger; Scope = Repeater; ToolTip = 'View all amounts relating to an item.'; trigger OnAction() begin Rec.ShowValueEntries(); end; } action("Spend Request To G/L Link") { ApplicationArea = Basic, Suite; Caption = 'Spend Requests'; Image = ProjectExpense; Scope = Repeater; ToolTip = 'View the spend requests linked to this entry.'; RunObject = page "Spend Request To G/L Link"; RunPageLink = "G/L Entry No." = field("Entry No."); } } } area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action(ReverseTransaction) { ApplicationArea = Basic, Suite; Caption = 'Reverse Transaction'; Ellipsis = true; Image = ReverseRegister; Scope = Repeater; ToolTip = 'Reverse a posted general ledger entry.'; trigger OnAction() var ReversalEntry: Record "Reversal Entry"; begin Clear(ReversalEntry); if Rec.Reversed then ReversalEntry.AlreadyReversedEntry(Rec.TableCaption, Rec."Entry No."); CheckEntryPostedFromJournal(); Rec.TestField("Transaction No."); ReversalEntry.ReverseTransaction(Rec."Transaction No.") 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; 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() var Navigate: Page Navigate; begin Navigate.SetDoc(Rec."Posting Date", Rec."Document No."); Navigate.Run(); end; } action(DocsWithoutIC) { ApplicationArea = Basic, Suite; Caption = 'Posted Documents without Incoming Document'; Image = Documents; ToolTip = 'View posted purchase and sales documents under the G/L account that do not have related incoming document records.'; trigger OnAction() var PostedDocsWithNoIncBuf: Record "Posted Docs. With No Inc. Buf."; begin Rec.CopyFilter("G/L Account No.", PostedDocsWithNoIncBuf."G/L Account No. Filter"); PAGE.Run(PAGE::"Posted Docs. With No Inc. Doc.", PostedDocsWithNoIncBuf); 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.'; actionref("&Navigate_Promoted"; "&Navigate") { } actionref(ReverseTransaction_Promoted; ReverseTransaction) { } actionref(ChangeDimensions_Promoted; ChangeDimensions) { } group(Category_Category4) { Caption = 'Entry', Comment = 'Generated from the PromotedActionCategories property index 3.'; actionref(Dimensions_Promoted; Dimensions) { } actionref("Value Entries_Promoted"; "Value Entries") { } actionref(SpendReqToGLLink_Promoted; "Spend Request To G/L Link") { } actionref(GLDimensionOverview_Promoted; GLDimensionOverview) { } actionref(SetDimensionFilter_Promoted; SetDimensionFilter) { } } } group(Category_Report) { Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.'; } } } trigger OnAfterGetCurrRecord() var IncomingDocument: Record "Incoming Document"; begin if GuiAllowed then HasIncomingDocument := IncomingDocument.PostedDocExists(Rec."Document No.", Rec."Posting Date"); end; trigger OnInit() begin AmountVisible := true; end; trigger OnModifyRecord() Result: Boolean var IsHandled: Boolean; begin IsHandled := false; OnBeforeOnModifyRecord(Rec, Result, IsHandled); if IsHandled then exit(Result); CODEUNIT.Run(CODEUNIT::"G/L Entry-Edit", Rec); exit(false); end; trigger OnOpenPage() var VATReportingDateMgt: Codeunit "VAT Reporting Date Mgt"; begin SetControlVisibility(); SetDimVisibility(); IsVATDateEnabled := VATReportingDateMgt.IsVATDateEnabled(); if (Rec.GetFilters() <> '') and not Rec.Find() then if Rec.FindFirst() then; end; var GLAcc: Record "G/L Account"; CalcRunningGLAccBalance: Codeunit "Calc. Running GL. Acc. Balance"; DimensionSetIDFilter: Page "Dimension Set ID Filter"; HasIncomingDocument: Boolean; AmountVisible: Boolean; DebitCreditVisible: Boolean; IsVATDateEnabled: Boolean; protected var Dim1Visible: Boolean; Dim2Visible: Boolean; Dim3Visible: Boolean; Dim4Visible: Boolean; Dim5Visible: Boolean; Dim6Visible: Boolean; Dim7Visible: Boolean; Dim8Visible: Boolean; local procedure SetDimVisibility() var DimensionManagement: Codeunit DimensionManagement; begin DimensionManagement.UseShortcutDims(Dim1Visible, Dim2Visible, Dim3Visible, Dim4Visible, Dim5Visible, Dim6Visible, Dim7Visible, Dim8Visible); end; local procedure GetCaption(): Text var IsHandled: Boolean; RetCaption: Text; begin IsHandled := false; OnBeforeGetCaption(Rec, GLAcc, RetCaption, IsHandled); if IsHandled then exit(RetCaption); GLAcc.SecurityFiltering := GLAcc.SecurityFiltering::Filtered; GLAcc.SetLoadFields("No.", Name); if GLAcc."No." <> Rec."G/L Account No." then if not GLAcc.Get(Rec."G/L Account No.") then if Rec.GetFilter("G/L Account No.") <> '' then if GLAcc.Get(Rec.GetRangeMin("G/L Account No.")) then; exit(StrSubstNo('%1 %2', GLAcc."No.", GLAcc.Name)); 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"); end; local procedure CheckEntryPostedFromJournal() var ReversalEntry: Record "Reversal Entry"; IsHandled: Boolean; begin IsHandled := false; OnBeforeCheckEntryPostedFromJournal(Rec, IsHandled); if IsHandled then exit; if Rec."Journal Batch Name" = '' then ReversalEntry.TestFieldError(); end; local procedure SetChangeLogEntriesFilter(var ChangeLogEntry: Record "Change Log Entry") begin ChangeLogEntry.SetRange("Table No.", DATABASE::"G/L Entry"); ChangeLogEntry.SetRange("Primary Key Field 1 Value", Format(Rec."Entry No.", 0, 9)); end; /// <summary> /// Integration event raised before checking if G/L entry was posted from a journal. /// </summary> /// <param name="GLEntry">G/L Entry record being checked.</param> /// <param name="IsHandled">Boolean indicating if the check has been handled by the subscriber.</param> [IntegrationEvent(false, false)] local procedure OnBeforeCheckEntryPostedFromJournal(var GLEntry: Record "G/L Entry"; var IsHandled: Boolean) begin end; var TooManyGLEntriesSelectedErr: Label 'You have selected too many G/L entries. Split the change to select fewer entries, or go to the Dimension Correction page and use filters to select the entries.'; /// <summary> /// Integration event raised before getting the page caption. /// </summary> /// <param name="GLEntry">G/L Entry record for caption context.</param> /// <param name="GLAccount">G/L Account record for caption context.</param> /// <param name="RetCaption">Text variable for the resulting caption.</param> /// <param name="IsHandled">Boolean indicating if caption generation has been handled by the subscriber.</param> [IntegrationEvent(false, false)] local procedure OnBeforeGetCaption(GLEntry: Record "G/L Entry"; GLAccount: Record "G/L Account"; var RetCaption: Text; var IsHandled: Boolean) begin end; /// <summary> /// Integration event raised before modifying a G/L entry record. /// </summary> /// <param name="GLEntry">G/L Entry record being modified.</param> /// <param name="Result">Boolean indicating the result of the modification.</param> /// <param name="IsHandled">Boolean indicating if the modification has been handled by the subscriber.</param> [IntegrationEvent(false, false)] local procedure OnBeforeOnModifyRecord(GLEntry: Record "G/L Entry"; var Result: Boolean; var IsHandled: Boolean) begin end;}