Page 253 Sales Journal

Base Application, Microsoft.Finance.GeneralLedger.Journal

src/Layers/W1/BaseApp/Finance/GeneralLedger/Journal/SalesJournal.Page.al1,772 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.Journal;using Microsoft.EServices.EDocument;using Microsoft.Finance.AllocationAccount;using Microsoft.Finance.Currency;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Posting;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Finance.ReceivablesPayables;using Microsoft.Finance.VAT.Calculation;using Microsoft.Foundation.Reporting;using Microsoft.Sales.Setup;using Microsoft.Utilities;using System.Automation;using System.Environment;using System.Environment.Configuration;using System.Integration;using System.Threading;/// <summary>/// Sales journal page for entering sales transactions and customer-related general journal entries./// Provides specialized interface for sales postings with customer account focus and simplified data entry./// </summary>/// <remarks>/// Specialized sales journal with customer-focused transaction entry interface./// Features dual view modes: simple view (customer-focused) and detailed view (full general journal functionality)./// Key capabilities: Customer payment processing, sales invoice corrections, customer adjustments, VAT handling./// Integration: Direct posting to customer ledger entries, automatic account validation, dimension processing./// </remarks>page 253 "Sales Journal"{    // // This page has two view modes based on global variable 'IsSimplePage' as :-    // // Show more columns action (IsSimplePage = FALSE)    // // - Default page layout before simple view was introduced.    // // Show less columns action (IsSimplePage = TRUE)    // // Hide amount, account type columns and set default account type to Customer.    // // Show a new column named document amount where user will enter amount for the line    // // By DEFAULT this page opens up in simple page layout.    ApplicationArea = Basic, Suite;    AutoSplitKey = true;    Caption = 'Sales Journals';    DataCaptionExpression = Rec.DataCaption();    DelayedInsert = true;    PageType = Worksheet;    AboutTitle = 'About Sales Journals';    AboutText = 'Record and post sales-related transactions such as invoices, payments, and credit memos, manage account allocations, and apply VAT and dimensions for accurate financial reporting.';    SaveValues = true;    SourceTable = "Gen. Journal Line";    UsageCategory = Tasks;    layout    {        area(content)        {            group(Contro2)            {                ShowCaption = false;                field(CurrentJnlBatchName; CurrentJnlBatchName)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Batch Name';                    Lookup = true;                    ToolTip = 'Specifies the name of the journal batch, a personalized journal layout, that the journal is based on.';                    trigger OnLookup(var Text: Text): Boolean                    begin                        CurrPage.SaveRecord();                        GenJnlManagement.LookupName(CurrentJnlBatchName, Rec);                        GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Sales Journal", CurrentJnlBatchName);                        SetControlAppearanceFromBatch();                        CurrPage.Update(false);                    end;                    trigger OnValidate()                    begin                        GenJnlManagement.CheckName(CurrentJnlBatchName, Rec);                        CurrentJnlBatchNameOnAfterVali();                        GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Sales Journal", CurrentJnlBatchName);                    end;                }                field(GenJnlBatchApprovalStatus; GenJnlBatchApprovalStatus)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Approval Status';                    Editable = false;                    Visible = EnabledGenJnlBatchWorkflowsExist;                    ToolTip = 'Specifies the approval status for general journal batch.';                }            }            repeater(Control1)            {                ShowCaption = false;                field("Posting Date"; Rec."Posting Date")                {                    ApplicationArea = Basic, Suite;                }                field("VAT Reporting Date"; Rec."VAT Reporting Date")                {                    ApplicationArea = VAT;                    Editable = VATDateEnabled;                    Visible = VATDateEnabled;                }                field("Document Date"; Rec."Document Date")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Document Type"; Rec."Document Type")                {                    ApplicationArea = Basic, Suite;                    trigger OnValidate()                    begin                        // Update amount based on doc type                        if (Rec."Document Type" = Rec."Document Type"::" ") and (Rec.Amount <> 0) then                            Error(EmptyDocumentTypeErr, Rec."Document No.");                        if xRec."Document Type" <> Rec."Document Type" then                            if (Rec."Document Type" = Rec."Document Type"::Payment) or (Rec."Document Type" = Rec."Document Type"::"Credit Memo") then begin                                if Rec.Amount > 0 then                                    Rec.Validate(Amount, -1 * Rec.Amount)                            end else                                Rec.Validate(Amount, Abs(Rec.Amount))                    end;                }                field("Document No."; Rec."Document No.")                {                    ApplicationArea = Basic, Suite;                    ShowMandatory = true;                }                field("Incoming Document Entry No."; Rec."Incoming Document Entry No.")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                    trigger OnAssistEdit()                    begin                        if Rec."Incoming Document Entry No." > 0 then                            HyperLink(Rec.GetIncomingDocumentURL());                    end;                }                field("External Document No."; Rec."External Document No.")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Account Type"; Rec."Account Type")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                    trigger OnValidate()                    begin                        GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);                        EnableApplyEntriesAction();                        CurrPage.SaveRecord();                    end;                }                field("Account No."; Rec."Account No.")                {                    ApplicationArea = Basic, Suite;                    trigger OnValidate()                    begin                        GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);                        Rec.ShowShortcutDimCode(ShortcutDimCode);                        CurrPage.SaveRecord();                    end;                }                field("<Customer Name>"; AccName)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Customer Name';                    Editable = false;                    ToolTip = 'Specifies the name of the customer.';                }                field(GenJnlLineApprovalStatus; GenJnlLineApprovalStatus)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Approval Status';                    Editable = false;                    Visible = EnabledGenJnlLineWorkflowsExist;                    ToolTip = 'Specifies the approval status for general journal line.';                }                field(Description; Rec.Description)                {                    ApplicationArea = Basic, Suite;                }                field("Salespers./Purch. Code"; Rec."Salespers./Purch. Code")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Campaign No."; Rec."Campaign No.")                {                    ApplicationArea = RelationshipMgmt;                    Visible = false;                }                field("Currency Code"; Rec."Currency Code")                {                    ApplicationArea = Suite;                    AssistEdit = true;                    Visible = false;                    trigger OnAssistEdit()                    begin                        ChangeExchangeRate.SetParameter(Rec."Currency Code", Rec."Currency Factor", Rec."Posting Date");                        if ChangeExchangeRate.RunModal() = ACTION::OK then                            Rec.Validate("Currency Factor", ChangeExchangeRate.GetParameter());                        Clear(ChangeExchangeRate);                    end;                }                field("Gen. Posting Type"; Rec."Gen. Posting Type")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the customer''s trade type to link transactions made for this customer with the appropriate general ledger account according to the general posting setup.';                    Visible = not IsSimplePage;                }                field("Gen. Prod. Posting Group"; Rec."Gen. Prod. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("VAT Bus. Posting Group"; Rec."VAT Bus. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("VAT Prod. Posting Group"; Rec."VAT Prod. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field(DocumentAmount; DocumentAmount)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 1;                    AutoFormatExpression = Rec."Currency Code";                    Caption = 'Document Amount';                    ToolTip = 'Specifies the total amount (including VAT) that the journal line consists of.';                    trigger OnValidate()                    begin                        // Document amount can not be less than 0                        if DocumentAmount < 0 then                            Error(NegativeDocAmountErr);                        // Validate amount based on document type                        if Rec."Document Type" = Rec."Document Type"::" " then                            Error(EmptyDocumentTypeErr, Rec."Document No.");                        if (Rec."Document Type" = Rec."Document Type"::Payment) or                           (Rec."Document Type" = Rec."Document Type"::"Credit Memo")                        then                            Rec.Validate(Amount, DocumentAmount * -1)                        else                            Rec.Validate(Amount, DocumentAmount);                    end;                }                field(Amount; Rec.Amount)                {                    ApplicationArea = Basic, Suite;                    Visible = AmountVisible;                    trigger OnValidate()                    begin                        DocumentAmount := Abs(Rec.Amount);                    end;                }                field("Amount (LCY)"; Rec."Amount (LCY)")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the total amount in local currency (including VAT) that the journal line consists of.';                    Visible = AmountVisible;                }                field("Debit Amount"; Rec."Debit Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = DebitCreditVisible;                    trigger OnValidate()                    begin                        DocumentAmount := Abs(Rec."Debit Amount");                    end;                }                field("Credit Amount"; Rec."Credit Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = DebitCreditVisible;                    trigger OnValidate()                    begin                        DocumentAmount := Abs(Rec."Credit Amount");                    end;                }                field("Tax Liable"; Rec."Tax Liable")                {                    ApplicationArea = SalesTax;                    Visible = false;                }                field("Tax Area Code"; Rec."Tax Area Code")                {                    ApplicationArea = SalesTax;                    Visible = false;                }                field("Tax Group Code"; Rec."Tax Group Code")                {                    ApplicationArea = SalesTax;                    Visible = false;                }                field("VAT Amount"; Rec."VAT Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("VAT Difference"; Rec."VAT Difference")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Bal. VAT Amount"; Rec."Bal. VAT Amount")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Bal. VAT Difference"; Rec."Bal. VAT Difference")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Bal. Account Type"; Rec."Bal. Account Type")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                    trigger OnValidate()                    begin                        EnableApplyEntriesAction();                    end;                }                field("Bal. Account No."; Rec."Bal. Account No.")                {                    ApplicationArea = Basic, Suite;                    trigger OnValidate()                    begin                        GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);                        Rec.ShowShortcutDimCode(ShortcutDimCode);                    end;                }                field("Bal. Gen. Posting Type"; Rec."Bal. Gen. Posting Type")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Bal. Gen. Bus. Posting Group"; Rec."Bal. Gen. Bus. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Bal. Gen. Prod. Posting Group"; Rec."Bal. Gen. Prod. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Bal. VAT Bus. Posting Group"; Rec."Bal. VAT Bus. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Bal. VAT Prod. Posting Group"; Rec."Bal. VAT Prod. Posting Group")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Deferral Code"; Rec."Deferral Code")                {                    ApplicationArea = Suite;                    Visible = not IsSimplePage;                    trigger OnAssistEdit()                    begin                        CurrPage.SaveRecord();                        Commit();                        Rec.ShowDeferralSchedule();                    end;                }                field("Posting Group"; Rec."Posting Group")                {                    ApplicationArea = Basic, Suite;                    Editable = IsPostingGroupEditable;                    Visible = IsPostingGroupEditable;                }                field("Allocation Account No."; Rec."Selected Alloc. Account No.")                {                    ApplicationArea = All;                    Caption = 'Allocation Account No.';                    Visible = UseAllocationAccountNumber;                    trigger OnValidate()                    var                        GenJournalAllocAccMgt: Codeunit "Gen. Journal Alloc. Acc. Mgt.";                    begin                        GenJournalAllocAccMgt.VerifySelectedAllocationAccountNo(Rec);                    end;                }                field("Bill-to/Pay-to No."; Rec."Bill-to/Pay-to No.")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Ship-to/Order Address Code"; Rec."Ship-to/Order Address Code")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Sales/Purch. (LCY)"; Rec."Sales/Purch. (LCY)")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the line''s net amount (the amount excluding VAT) if you are using this journal line for an invoice. The field is important for customer and vendor statistics, but it has no significance for posting. You can either fill in the field or it will be calculated automatically once you fill in the Account No. and Bal. Account No. fields';                    Visible = false;                }                field("Profit (LCY)"; Rec."Profit (LCY)")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the line''s profit amount if you are using this journal line for an invoice.';                    Visible = false;                }                field("Inv. Discount (LCY)"; Rec."Inv. Discount (LCY)")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the amount of the invoice discount if you are using this journal line for an invoice.';                    Visible = false;                }                field("Payment Terms Code"; Rec."Payment Terms Code")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Due Date"; Rec."Due Date")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Pmt. Discount Date"; Rec."Pmt. Discount Date")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Payment Discount %"; Rec."Payment Discount %")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Applies-to Doc. Type"; Rec."Applies-to Doc. Type")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Applies-to Doc. No."; Rec."Applies-to Doc. No.")                {                    ApplicationArea = Basic, Suite;                    Visible = not IsSimplePage;                }                field("Applies-to ID"; Rec."Applies-to ID")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("On Hold"; Rec."On Hold")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Reason Code"; Rec."Reason Code")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field(Correction; Rec.Correction)                {                    ApplicationArea = Basic, Suite;                }                field(Comment; Rec.Comment)                {                    ApplicationArea = Comments;                    Visible = false;                }                field("Direct Debit Mandate ID"; Rec."Direct Debit Mandate ID")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }                field("Job Queue Status"; Rec."Job Queue Status")                {                    ApplicationArea = All;                    Importance = Additional;                    Visible = JobQueuesUsed;                    trigger OnDrillDown()                    var                        JobQueueEntry: Record "Job Queue Entry";                    begin                        if Rec."Job Queue Status" = Rec."Job Queue Status"::" " then                            exit;                        JobQueueEntry.ShowStatusMsg(Rec."Job Queue Entry ID");                    end;                }                field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible1;                }                field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible2;                }                field(ShortcutDimCode3; ShortcutDimCode[3])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,3';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(3),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible3;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(3, ShortcutDimCode[3]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 3);                    end;                }                field(ShortcutDimCode4; ShortcutDimCode[4])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,4';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(4),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible4;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(4, ShortcutDimCode[4]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 4);                    end;                }                field(ShortcutDimCode5; ShortcutDimCode[5])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,5';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(5),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible5;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(5, ShortcutDimCode[5]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 5);                    end;                }                field(ShortcutDimCode6; ShortcutDimCode[6])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,6';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(6),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible6;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(6, ShortcutDimCode[6]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 6);                    end;                }                field(ShortcutDimCode7; ShortcutDimCode[7])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,7';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(7),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible7;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(7, ShortcutDimCode[7]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 7);                    end;                }                field(ShortcutDimCode8; ShortcutDimCode[8])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,8';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(8),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible8;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(8, ShortcutDimCode[8]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 8);                    end;                }            }            group(Control28)            {                ShowCaption = false;                fixed(Control1902205001)                {                    ShowCaption = false;                    group("Number of Lines")                    {                        Caption = 'Number of Lines';                        field(NumberOfJournalRecords; NumberOfRecords)                        {                            ApplicationArea = All;                            AutoFormatType = 1;                            ShowCaption = false;                            Editable = false;                            ToolTip = 'Specifies the number of lines in the current journal batch.';                        }                    }                    group("Account Name")                    {                        Caption = 'Account Name';                        Visible = false;                        field(AccName; AccName)                        {                            ApplicationArea = Basic, Suite;                            Editable = false;                            ShowCaption = false;                            ToolTip = 'Specifies the name of the account.';                        }                    }                    group("Bal. Account Name")                    {                        Caption = 'Bal. Account Name';                        Visible = false;                        field(BalAccName; BalAccName)                        {                            ApplicationArea = Basic, Suite;                            Caption = 'Bal. Account Name';                            Editable = false;                            ToolTip = 'Specifies the name of the balancing account that has been entered on the journal line.';                        }                    }                    group(Control1903866901)                    {                        Caption = 'Balance';                        field(Balance; Balance)                        {                            ApplicationArea = All;                            AutoFormatType = 1;                            AutoFormatExpression = '';                            Caption = 'Balance';                            Editable = false;                            ToolTip = 'Specifies the balance that has accumulated in the sales journal on the line where the cursor is.';                            Visible = BalanceVisible;                        }                    }                    group("Total Balance")                    {                        Caption = 'Total Balance';                        field(TotalBalance; TotalBalance)                        {                            ApplicationArea = All;                            AutoFormatType = 1;                            AutoFormatExpression = '';                            Caption = 'Total Balance';                            Editable = false;                            ToolTip = 'Specifies the total balance in the sales journal.';                            Visible = TotalBalanceVisible;                        }                    }                }            }        }        area(factboxes)        {            part(JournalErrorsFactBox; "Journal Errors FactBox")            {                ApplicationArea = Basic, Suite;                Visible = BackgroundErrorCheck;                SubPageLink = "Journal Template Name" = field("Journal Template Name"),                              "Journal Batch Name" = field("Journal Batch Name"),                              "Line No." = field("Line No.");            }            part(JournalLineDetails; "Journal Line Details FactBox")            {                ApplicationArea = Basic, Suite;                SubPageLink = "Journal Template Name" = field("Journal Template Name"),                              "Journal Batch Name" = field("Journal Batch Name"),                              "Line No." = field("Line No.");            }            part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox")            {                ApplicationArea = Basic, Suite;                ShowFilter = false;            }            part(Control1900919607; "Dimension Set Entries FactBox")            {                ApplicationArea = Basic, Suite;                SubPageLink = "Dimension Set ID" = field("Dimension Set ID");                Visible = false;            }            part(WorkflowStatusBatch; "Workflow Status FactBox")            {                ApplicationArea = Suite;                Caption = 'Batch Workflows';                Editable = false;                Enabled = false;                ShowFilter = false;                Visible = ShowWorkflowStatusOnBatch;            }            part(WorkflowStatusLine; "Workflow Status FactBox")            {                ApplicationArea = Suite;                Caption = 'Line Workflows';                Editable = false;                Enabled = false;                ShowFilter = false;                Visible = ShowWorkflowStatusOnLine;            }            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(navigation)        {            group("&Line")            {                Caption = '&Line';                Image = Line;                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();                        CurrPage.SaveRecord();                    end;                }                action(IncomingDoc)                {                    AccessByPermission = TableData "Incoming Document" = R;                    ApplicationArea = Basic, Suite;                    Caption = 'Incoming Document';                    Image = Document;                    Scope = Repeater;                    ToolTip = 'View or create an incoming document record that is linked to the entry or document.';                    trigger OnAction()                    var                        IncomingDocument: Record "Incoming Document";                    begin                        Rec.Validate("Incoming Document Entry No.", IncomingDocument.SelectIncomingDocument(Rec."Incoming Document Entry No.", Rec.RecordId));                    end;                }            }            group("A&ccount")            {                Caption = 'A&ccount';                Image = ChartOfAccounts;                action(Card)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Card';                    Image = EditLines;                    RunObject = Codeunit "Gen. Jnl.-Show Card";                    ShortCutKey = 'Shift+F7';                    ToolTip = 'View or change detailed information about the record on the document or journal line.';                }                action("Ledger E&ntries")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Ledger E&ntries';                    Image = GLRegisters;                    RunObject = Codeunit "Gen. Jnl.-Show Entries";                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View the history of transactions that have been posted for the selected record.';                }            }        }        area(processing)        {            group("F&unctions")            {                Caption = 'F&unctions';                Image = "Action";                action("Renumber Document Numbers")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Renumber Document Numbers';                    Image = EditLines;                    ToolTip = 'Resort the numbers in the Document No. column to avoid posting errors because the document numbers are not in sequence. Entry applications and line groupings are preserved.';                    trigger OnAction()                    begin                        Rec.RenumberDocumentNo();                    end;                }                action("Apply Entries")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Apply Entries';                    Ellipsis = true;                    Enabled = ApplyEntriesActionEnabled;                    Image = ApplyEntries;                    RunObject = Codeunit "Gen. Jnl.-Apply";                    ShortCutKey = 'Shift+F11';                    ToolTip = 'Apply the payment amount on a journal line to a sales or purchase document that was already posted for a customer or vendor. This updates the amount on the posted document, and the document can either be partially paid, or closed as paid or refunded.';                }                action("Insert Conv. LCY Rndg. Lines")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Insert Conv. LCY Rndg. Lines';                    Image = InsertCurrency;                    RunObject = Codeunit "Adjust Gen. Journal Balance";                    ToolTip = 'Insert a rounding correction line in the journal. This rounding correction line will balance in LCY when amounts in the foreign currency also balance. You can then post the journal.';                }                action(DeferralSchedule)                {                    ApplicationArea = Suite;                    Caption = 'Deferral Schedule';                    Image = PaymentPeriod;                    ToolTip = 'View or edit the deferral schedule that governs how expenses or revenue are deferred to different accounting periods when the journal line is posted.';                    trigger OnAction()                    begin                        Rec.ShowDeferralSchedule();                    end;                }            }            group("P&osting")            {                Caption = 'P&osting';                Image = Post;                action(Reconcile)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Reconcile';                    Image = Reconcile;                    ShortCutKey = 'Ctrl+F11';                    ToolTip = 'View the balances on bank accounts that are marked for reconciliation, usually liquid accounts.';                    trigger OnAction()                    var                        GLReconciliation: Page Reconciliation;                    begin                        GLReconciliation.SetGenJnlLine(Rec);                        GLReconciliation.Run();                    end;                }                action("Test Report")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Test Report';                    Ellipsis = true;                    Image = TestReport;                    ToolTip = 'View a test report so that you can find and correct any errors before you perform the actual posting of the journal or document.';                    trigger OnAction()                    var                        TestReportPrint: Codeunit "Test Report-Print";                    begin                        TestReportPrint.PrintGenJnlLine(Rec);                    end;                }                action(Post)                {                    ApplicationArea = Basic, Suite;                    Caption = 'P&ost';                    Image = PostOrder;                    ShortCutKey = 'F9';                    ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';                    trigger OnAction()                    begin                        Rec.SendToPosting(Codeunit::"Gen. Jnl.-Post");                        CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");                        SetJobQueueVisibility();                        CurrPage.Update(false);                    end;                }                action(Preview)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Preview Posting';                    Image = ViewPostedOrder;                    ShortCutKey = 'Ctrl+Alt+F9';                    ToolTip = 'Review the different types of entries that will be created when you post the document or journal.';                    trigger OnAction()                    var                        GenJnlPost: Codeunit "Gen. Jnl.-Post";                    begin                        GenJnlPost.Preview(Rec);                    end;                }                action("Post and &Print")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Post and &Print';                    Image = PostPrint;                    ShortCutKey = 'Shift+F9';                    ToolTip = 'Finalize and prepare to print the document or journal. The values and quantities are posted to the related accounts. A report request window where you can specify what to include on the print-out.';                    trigger OnAction()                    begin                        Rec.SendToPosting(Codeunit::"Gen. Jnl.-Post+Print");                        CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");                        SetJobQueueVisibility();                        CurrPage.Update(false);                    end;                }                action("Remove From Job Queue")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Remove From Job Queue';                    Image = RemoveLine;                    ToolTip = 'Remove the scheduled processing of this record from the job queue.';                    Visible = JobQueueVisible;                    trigger OnAction()                    begin                        Rec.CancelBackgroundPosting();                        SetJobQueueVisibility();                        CurrPage.Update(false);                    end;                }                action(RedistributeAccAllocations)                {                    ApplicationArea = All;                    Caption = 'Redistribute Account Allocations';                    Image = EditList;#pragma warning disable AA0219                    ToolTip = 'Use this action to redistribute the account allocations for this line.';#pragma warning restore AA0219                    trigger OnAction()                    var                        AllocAccManualOverride: Page "Redistribute Acc. Allocations";                    begin                        if (Rec."Account Type" <> Rec."Account Type"::"Allocation Account") and (Rec."Bal. Account Type" <> Rec."Bal. Account Type"::"Allocation Account") and (Rec."Selected Alloc. Account No." = '') then                            Error(ActionOnlyAllowedForAllocationAccountsErr);                        AllocAccManualOverride.SetParentSystemId(Rec.SystemId);                        AllocAccManualOverride.SetParentTableId(Database::"Gen. Journal Line");                        AllocAccManualOverride.RunModal();                    end;                }                action(ReplaceAllocationAccountWithLines)                {                    ApplicationArea = All;                    Caption = 'Generate lines from Allocation Account Line';                    Image = CreateLinesFromJob;#pragma warning disable AA0219                    ToolTip = 'Use this action to replace the Allocation Account line with the actual lines that would be generated from the line itself.';#pragma warning restore AA0219                    trigger OnAction()                    var                        BackupRec: Record "Gen. Journal Line";                        GenJournalAllocAccMgt: Codeunit "Gen. Journal Alloc. Acc. Mgt.";                    begin                        if (Rec."Account Type" <> Rec."Account Type"::"Allocation Account") and (Rec."Bal. Account Type" <> Rec."Bal. Account Type"::"Allocation Account") and (Rec."Selected Alloc. Account No." = '') then                            Error(ActionOnlyAllowedForAllocationAccountsErr);                        BackupRec.Copy(Rec);                        BackupRec.SetRecFilter();                        GenJournalAllocAccMgt.CreateLines(BackupRec);                        Rec.Delete();                        CurrPage.Update(false);                    end;                }            }            group("Page")            {                Caption = 'Page';                action(EditInExcel)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Edit in Excel';                    Image = Excel;                    ToolTip = 'Send the data in the journal to an Excel file for analysis or editing.';                    Visible = IsSaaSExcelAddinEnabled;                    AccessByPermission = System "Allow Action Export To Excel" = X;                    trigger OnAction()                    var                        ODataUtility: Codeunit ODataUtility;                    begin                        ODataUtility.EditJournalWorksheetInExcel(CurrPage.Caption, CurrPage.ObjectId(false), Rec."Journal Batch Name", Rec."Journal Template Name");                    end;                }                action(ClassicView)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Show more columns';                    Image = SetupColumns;                    ToolTip = 'Adds additional fields to the journal for a full view of the journal data.';                    Visible = IsSimplePage;                    trigger OnAction()                    begin                        // set journal preference for this page to be NOT simple view (classic view)                        CurrPage.Close();                        GenJnlManagement.SetJournalSimplePageModePreference(false, PAGE::"Sales Journal");                        GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Sales Journal", CurrentJnlBatchName);                        PAGE.Run(PAGE::"Sales Journal");                    end;                }                action(SimpleView)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Show fewer columns';                    Image = SetupList;                    ToolTip = 'Hides many of the less used fields from the journal for better productivity. The fields are still there but not shown.';                    Visible = not IsSimplePage;                    trigger OnAction()                    begin                        // set journal preference for this page to be simple view                        CurrPage.Close();                        GenJnlManagement.SetJournalSimplePageModePreference(true, PAGE::"Sales Journal");                        GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Sales Journal", CurrentJnlBatchName);                        PAGE.Run(PAGE::"Sales Journal");                    end;                }                group(Errors)                {                    Image = ErrorLog;                    Visible = BackgroundErrorCheck;                    action(ShowLinesWithErrors)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Show Lines with Issues';                        Image = Error;                        Visible = BackgroundErrorCheck;                        Enabled = not ShowAllLinesEnabled;                        ToolTip = 'View a list of journal lines that have issues before you post the journal.';                        trigger OnAction()                        begin                            Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);                        end;                    }                    action(ShowAllLines)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Show All Lines';                        Image = ExpandAll;                        Visible = BackgroundErrorCheck;                        Enabled = ShowAllLinesEnabled;                        ToolTip = 'View all journal lines, including lines with and without issues.';                        trigger OnAction()                        begin                            Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);                        end;                    }                }            }            group("Request Approval")            {                Caption = 'Request Approval';                group(SendApprovalRequest)                {                    Caption = 'Send Approval Request';                    Image = SendApprovalRequest;                    action(SendApprovalRequestJournalBatch)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Journal Batch';                        Enabled = not OpenApprovalEntriesOnBatchOrAnyJnlLineExist and CanRequestFlowApprovalForBatchAndAllLines and EnabledGenJnlBatchWorkflowsExist;                        Image = SendApprovalRequest;                        ToolTip = 'Send all journal lines for approval, also those that you may not see because of filters.';                        trigger OnAction()                        var                            ApprovalsMgmt: Codeunit "Approvals Mgmt.";                        begin                            ApprovalsMgmt.TrySendJournalBatchApprovalRequest(Rec);                            SetControlAppearanceFromBatch();                            SetControlAppearance();                        end;                    }                    action(SendApprovalRequestJournalLine)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Selected Journal Lines';                        Enabled = not OpenApprovalEntriesOnBatchOrCurrJnlLineExist and CanRequestFlowApprovalForBatchAndCurrentLine and EnabledGenJnlLineWorkflowsExist;                        Image = SendApprovalRequest;                        ToolTip = 'Send selected journal lines for approval.';                        trigger OnAction()                        var                            [SecurityFiltering(SecurityFilter::Filtered)]                            GenJournalLine: Record "Gen. Journal Line";                            ApprovalsMgmt: Codeunit "Approvals Mgmt.";                        begin                            GetCurrentlySelectedLines(GenJournalLine);                            ApprovalsMgmt.SendJournalLinesApprovalRequests(GenJournalLine);                            SetControlAppearanceFromBatch();                        end;                    }                }                group(CancelApprovalRequest)                {                    Caption = 'Cancel Approval Request';                    Image = Cancel;                    action(CancelApprovalRequestJournalBatch)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Journal Batch';                        Enabled = CanCancelApprovalForJnlBatch or CanCancelFlowApprovalForBatch;                        Image = CancelApprovalRequest;                        ToolTip = 'Cancel sending all journal lines for approval, also those that you may not see because of filters.';                        trigger OnAction()                        var                            ApprovalsMgmt: Codeunit "Approvals Mgmt.";                        begin                            ApprovalsMgmt.TryCancelJournalBatchApprovalRequest(Rec);                            SetControlAppearance();                            SetControlAppearanceFromBatch();                        end;                    }                    action(CancelApprovalRequestJournalLine)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Selected Journal Lines';                        Enabled = CanCancelApprovalForJnlLine or CanCancelFlowApprovalForLine;                        Image = CancelApprovalRequest;                        ToolTip = 'Cancel sending selected journal lines for approval.';                        trigger OnAction()                        var                            [SecurityFiltering(SecurityFilter::Filtered)]                            GenJournalLine: Record "Gen. Journal Line";                            ApprovalsMgmt: Codeunit "Approvals Mgmt.";                        begin                            GetCurrentlySelectedLines(GenJournalLine);                            ApprovalsMgmt.TryCancelJournalLineApprovalRequests(GenJournalLine);                        end;                    }                }            }            group(Approval)            {                Caption = 'Approval';                action(Approve)                {                    ApplicationArea = All;                    Caption = 'Approve';                    Image = Approve;                    ToolTip = 'Approve the requested changes.';                    Visible = OpenApprovalEntriesExistForCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.ApproveGenJournalLineRequest(Rec);                    end;                }                action(Reject)                {                    ApplicationArea = All;                    Caption = 'Reject';                    Image = Reject;                    ToolTip = 'Reject the approval request.';                    Visible = OpenApprovalEntriesExistForCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.RejectGenJournalLineRequest(Rec);                    end;                }                action(Delegate)                {                    ApplicationArea = All;                    Caption = 'Delegate';                    Image = Delegate;                    ToolTip = 'Delegate the approval to a substitute approver.';                    Visible = OpenApprovalEntriesExistForCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.DelegateGenJournalLineRequest(Rec);                    end;                }                action(Comments)                {                    ApplicationArea = All;                    Caption = 'Comments';                    Image = ViewComments;                    ToolTip = 'View or add comments for the record.';                    Visible = OpenApprovalEntriesExistForCurrUser or ApprovalEntriesExistSentByCurrentUser;                    trigger OnAction()                    var                        GenJournalBatch: Record "Gen. Journal Batch";                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        if OpenApprovalEntriesOnJnlLineExist then                            ApprovalsMgmt.GetApprovalComment(Rec)                        else                            if OpenApprovalEntriesOnJnlBatchExist then                                if GenJournalBatch.Get(Rec."Journal Template Name", Rec."Journal Batch Name") then                                    ApprovalsMgmt.GetApprovalComment(GenJournalBatch);                    end;                }            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.';                group(Category_Category5)                {                    Caption = 'Post/Print', Comment = 'Generated from the PromotedActionCategories property index 4.';                    ShowAs = SplitButton;                    actionref(Post_Promoted; Post)                    {                    }                    actionref(Preview_Promoted; Preview)                    {                    }                    actionref("Post and &Print_Promoted"; "Post and &Print")                    {                    }                }                actionref("Renumber Document Numbers_Promoted"; "Renumber Document Numbers")                {                }                actionref(Reconcile_Promoted; Reconcile)                {                }                actionref("Apply Entries_Promoted"; "Apply Entries")                {                }            }            group(Category_Category8)            {                Caption = 'Approve', Comment = 'Generated from the PromotedActionCategories property index 7.';                actionref(Approve_Promoted; Approve)                {                }                actionref(Reject_Promoted; Reject)                {                }                actionref(Comments_Promoted; Comments)                {                }                actionref(Delegate_Promoted; Delegate)                {                }            }            group("Category_Request Approval")            {                Caption = 'Request Approval';                group("Category_Send Approval Request")                {                    Caption = 'Send Approval Request';                    actionref(SendApprovalRequestJournalBatch_Promoted; SendApprovalRequestJournalBatch)                    {                    }                    actionref(SendApprovalRequestJournalLine_Promoted; SendApprovalRequestJournalLine)                    {                    }                }                group("Category_Cancel Approval Request")                {                    Caption = 'Cancel Approval Request';                    actionref(CancelApprovalRequestJournalBatch_Promoted; CancelApprovalRequestJournalBatch)                    {                    }                    actionref(CancelApprovalRequestJournalLine_Promoted; CancelApprovalRequestJournalLine)                    {                    }                }            }            group(Category_Category6)            {                Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 5.';                actionref(Dimensions_Promoted; Dimensions)                {                }                actionref(IncomingDoc_Promoted; IncomingDoc)                {                }            }            group(Category_Category7)            {                Caption = 'Account', Comment = 'Generated from the PromotedActionCategories property index 6.';            }            group(Category_Category4)            {                Caption = 'Page', Comment = 'Generated from the PromotedActionCategories property index 3.';                actionref(SimpleView_Promoted; SimpleView)                {                }                actionref(ClassicView_Promoted; ClassicView)                {                }                actionref(EditInExcel_Promoted; EditInExcel)                {                }                actionref(ShowLinesWithErrors_Promoted; ShowLinesWithErrors)                {                }                actionref(ShowAllLines_Promoted; ShowAllLines)                {                }            }            group(Category_Report)            {                Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';            }        }    }    trigger OnAfterGetCurrRecord()    begin        GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);        UpdateBalance();        EnableApplyEntriesAction();        SetControlAppearance();        SetApprovalStateForBatch();        CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec);        SetJobQueueVisibility();        ApprovalMgmt.GetGenJnlBatchApprovalStatus(Rec, GenJnlBatchApprovalStatus, EnabledGenJnlBatchWorkflowsExist);    end;    trigger OnAfterGetRecord()    begin        Rec.ShowShortcutDimCode(ShortcutDimCode);        DocumentAmount := Abs(Rec.Amount);        GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);        CurrPage.IncomingDocAttachFactBox.PAGE.SetCurrentRecordID(Rec.RecordId);        ApprovalMgmt.GetGenJnlLineApprovalStatus(Rec, GenJnlLineApprovalStatus, EnabledGenJnlLineWorkflowsExist);    end;    trigger OnInit()    begin        TotalBalanceVisible := true;        BalanceVisible := true;        AmountVisible := true;        // Get simple / classic mode for this page except when called from a webservices (SOAP or ODATA)        if ClientTypeManagement.GetCurrentClientType() in [CLIENTTYPE::SOAP, CLIENTTYPE::OData, CLIENTTYPE::ODataV4]        then            IsSimplePage := false        else            IsSimplePage := GenJnlManagement.GetJournalSimplePageModePreference(PAGE::"Sales Journal");        GeneralLedgerSetup.Get();        SetJobQueueVisibility();    end;    trigger OnInsertRecord(BelowxRec: Boolean): Boolean    begin        CurrPage.IncomingDocAttachFactBox.PAGE.SetCurrentRecordID(Rec.RecordId);    end;    trigger OnNewRecord(BelowxRec: Boolean)    begin        UpdateBalance();        EnableApplyEntriesAction();        Rec.SetUpNewLine(xRec, Balance, BelowxRec);        Clear(DocumentAmount);        // Setting account type to Customer and doc type to invoice on new line when in simple page mode        if IsSimplePage then begin            Rec.Validate("Account Type", Rec."Account Type"::Customer);            Rec.Validate("Document Type", Rec."Document Type"::Invoice);        end;        Clear(ShortcutDimCode);        Clear(GenJnlLineApprovalStatus);    end;    trigger OnOpenPage()    var        AllocationAccountMgt: Codeunit "Allocation Account Mgt.";        ServerSetting: Codeunit "Server Setting";        VATReportingDateMgt: Codeunit "VAT Reporting Date Mgt";        JnlSelected: Boolean;        LastGenJnlBatch: Code[10];        IsHandled: Boolean;    begin        IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();        VATDateEnabled := VATReportingDateMgt.IsVATDateEnabled();        UseAllocationAccountNumber := AllocationAccountMgt.UseAllocationAccountNoField();        if ClientTypeManagement.GetCurrentClientType() = CLIENTTYPE::ODataV4 then            exit;        BalAccName := '';        SetControlVisibility();        SetDimensionsVisibility();        if Rec.IsOpenedFromBatch() then begin            CurrentJnlBatchName := Rec."Journal Batch Name";            GenJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);            SetControlAppearanceFromBatch();            exit;        end;        IsHandled := false;        OnOpenPageOnBeforeTemplateSelection(CurrentJnlBatchName, GenJnlManagement, IsHandled);        if not IsHandled then begin            GenJnlManagement.TemplateSelection(PAGE::"Sales Journal", "Gen. Journal Template Type"::Sales, false, Rec, JnlSelected);            if not JnlSelected then                Error('');        end;        LastGenJnlBatch := GenJnlManagement.GetLastViewedJournalBatchName(PAGE::"Sales Journal");        if LastGenJnlBatch <> '' then            CurrentJnlBatchName := LastGenJnlBatch;        GenJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);        SetControlAppearanceFromBatch();        OnAfterOpenPage(CurrentJnlBatchName);    end;    trigger OnModifyRecord(): Boolean    begin        ApprovalMgmt.CleanGenJournalApprovalStatus(Rec, GenJnlBatchApprovalStatus, GenJnlLineApprovalStatus);    end;    var        GeneralLedgerSetup: Record "General Ledger Setup";        SalesReceivablesSetup: Record "Sales & Receivables Setup";        GenJnlManagement: Codeunit GenJnlManagement;        ClientTypeManagement: Codeunit "Client Type Management";        JournalErrorsMgt: Codeunit "Journal Errors Mgt.";        BackgroundErrorHandlingMgt: Codeunit "Background Error Handling Mgt.";        ApprovalMgmt: Codeunit "Approvals Mgmt.";        ChangeExchangeRate: Page "Change Exchange Rate";        GenJnlBatchApprovalStatus: Text[20];        GenJnlLineApprovalStatus: Text[20];        Balance: Decimal;        TotalBalance: Decimal;        NumberOfRecords: Integer;        ShowBalance: Boolean;        ShowTotalBalance: Boolean;        ApplyEntriesActionEnabled: Boolean;        BalanceVisible: Boolean;        TotalBalanceVisible: Boolean;        IsPostingGroupEditable: Boolean;        AmountVisible: Boolean;        DebitCreditVisible: Boolean;        BackgroundErrorCheck: Boolean;        ShowAllLinesEnabled: Boolean;        IsSaaSExcelAddinEnabled: Boolean;        IsSimplePage: Boolean;        DocumentAmount: Decimal;        EmptyDocumentTypeErr: Label 'You must specify a document type for %1.', Comment = '%1 = Document number.';        NegativeDocAmountErr: Label 'You must specify a positive amount as the document amount. If the journal line is for a document type that has a negative amount, the amount will be tracked correctly.';        ActionOnlyAllowedForAllocationAccountsErr: Label 'This action is only available for lines that have Allocation Account set as Account Type or Balancing Account Type.';        UseAllocationAccountNumber: Boolean;        JobQueuesUsed: Boolean;        JobQueueVisible: Boolean;        VATDateEnabled: Boolean;        OpenApprovalEntriesOnBatchOrAnyJnlLineExist: Boolean;        ShowWorkflowStatusOnBatch: Boolean;        ShowWorkflowStatusOnLine: Boolean;        EnabledGenJnlLineWorkflowsExist: Boolean;        EnabledGenJnlBatchWorkflowsExist: Boolean;        CanRequestFlowApprovalForBatchAndAllLines: Boolean;        OpenApprovalEntriesOnJnlBatchExist: Boolean;        CanRequestFlowApprovalForBatch: Boolean;        CanCancelApprovalForJnlBatch: Boolean;        CanCancelFlowApprovalForBatch: Boolean;        CanCancelApprovalForJnlLine: Boolean;        CanCancelFlowApprovalForLine: Boolean;        OpenApprovalEntriesOnJnlLineExist: Boolean;        OpenApprovalEntriesExistForCurrUser: Boolean;        ApprovalEntriesExistSentByCurrentUser: Boolean;        OpenApprovalEntriesOnBatchOrCurrJnlLineExist: Boolean;        CanRequestFlowApprovalForBatchAndCurrentLine: Boolean;    protected var        ShortcutDimCode: array[8] of Code[20];        DimVisible1: Boolean;        DimVisible2: Boolean;        DimVisible3: Boolean;        DimVisible4: Boolean;        DimVisible5: Boolean;        DimVisible6: Boolean;        DimVisible7: Boolean;        DimVisible8: Boolean;        CurrentJnlBatchName: Code[10];        AccName: Text[100];        BalAccName: Text[100];    local procedure UpdateBalance()    var        IsHandled: Boolean;    begin        IsHandled := false;        OnBeforeUpdateBalance(Rec, xRec, Balance, TotalBalance, ShowBalance, ShowTotalBalance, IsHandled);        if not IsHandled then            GenJnlManagement.CalcBalance(              Rec, xRec, Balance, TotalBalance, ShowBalance, ShowTotalBalance);        BalanceVisible := ShowBalance;        TotalBalanceVisible := ShowTotalBalance;        if ShowTotalBalance then            NumberOfRecords := Rec.Count();    end;    local procedure EnableApplyEntriesAction()    begin        ApplyEntriesActionEnabled :=          (Rec."Account Type" in [Rec."Account Type"::Customer, Rec."Account Type"::Vendor]) or          (Rec."Bal. Account Type" in [Rec."Bal. Account Type"::Customer, Rec."Bal. Account Type"::Vendor]);    end;    local procedure CurrentJnlBatchNameOnAfterVali()    begin        CurrPage.SaveRecord();        GenJnlManagement.SetName(CurrentJnlBatchName, Rec);        SetControlAppearanceFromBatch();        CurrPage.Update(false);    end;    local procedure SetControlAppearanceFromBatch()    begin        SetApprovalStateForBatch();        BackgroundErrorCheck := BackgroundErrorHandlingMgt.BackgroundValidationFeatureEnabled();        ShowAllLinesEnabled := true;        Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);        JournalErrorsMgt.SetFullBatchCheck(true);    end;    local procedure SetApprovalStateForBatch()    var        GenJournalBatch: Record "Gen. Journal Batch";    begin        if ClientTypeManagement.GetCurrentClientType() = CLIENTTYPE::ODataV4 then            exit;        if not GenJournalBatch.Get(Rec.GetRangeMax("Journal Template Name"), CurrentJnlBatchName) then            exit;        ShowWorkflowStatusOnBatch := CurrPage.WorkflowStatusBatch.PAGE.SetFilterOnWorkflowRecord(GenJournalBatch.RecordId);        SetApprovalStateForBatch(GenJournalBatch, Rec, OpenApprovalEntriesExistForCurrUser, OpenApprovalEntriesOnJnlBatchExist, OpenApprovalEntriesOnBatchOrAnyJnlLineExist, CanCancelApprovalForJnlBatch, CanRequestFlowApprovalForBatch, CanCancelFlowApprovalForBatch, CanRequestFlowApprovalForBatchAndAllLines, ApprovalEntriesExistSentByCurrentUser, EnabledGenJnlBatchWorkflowsExist, EnabledGenJnlLineWorkflowsExist);    end;    local procedure SetControlVisibility()    begin        GeneralLedgerSetup.GetRecordOnce();        // Hide amount when open in simple page mode.        if IsSimplePage then begin            AmountVisible := false;            DebitCreditVisible := false;        end else begin            AmountVisible := not (GeneralLedgerSetup."Show Amounts" = GeneralLedgerSetup."Show Amounts"::"Debit/Credit Only");            DebitCreditVisible := not (GeneralLedgerSetup."Show Amounts" = GeneralLedgerSetup."Show Amounts"::"Amount Only");        end;        SalesReceivablesSetup.GetRecordOnce();        IsPostingGroupEditable := SalesReceivablesSetup."Allow Multiple Posting Groups";    end;    local procedure SetDimensionsVisibility()    var        DimensionManagement: Codeunit DimensionManagement;    begin        DimVisible1 := false;        DimVisible2 := false;        DimVisible3 := false;        DimVisible4 := false;        DimVisible5 := false;        DimVisible6 := false;        DimVisible7 := false;        DimVisible8 := false;        if not IsSimplePage then            DimensionManagement.UseShortcutDims(              DimVisible1, DimVisible2, DimVisible3, DimVisible4, DimVisible5, DimVisible6, DimVisible7, DimVisible8);        Clear(DimensionManagement);        OnAfterSetDimensionsVisibility();    end;    protected procedure SetJobQueueVisibility()    begin        JobQueueVisible := Rec."Job Queue Status" = Rec."Job Queue Status"::"Scheduled for Posting";        JobQueuesUsed := GeneralLedgerSetup.JobQueueActive();    end;    /// <summary>    /// Sets the current journal batch name for the sales journal page.    /// Updates the active batch context for journal processing and display.    /// </summary>    /// <param name="NewCurrentJnlBatchName">Journal batch name to set as current active batch.</param>    procedure SetCurrentJnlBatchName(NewCurrentJnlBatchName: code[10])    begin        CurrentJnlBatchName := NewCurrentJnlBatchName;    end;    /// <summary>    /// Retrieves the current journal batch name from the sales journal page.    /// Returns the active batch name currently being used for journal processing.    /// </summary>    /// <returns>Current journal batch name code.</returns>    procedure GetCurrentJnlBatchName(): Code[10]    begin        exit(CurrentJnlBatchName);    end;    local procedure GetCurrentlySelectedLines(var GenJournalLine: Record "Gen. Journal Line"): Boolean    begin        CurrPage.SetSelectionFilter(GenJournalLine);        exit(GenJournalLine.FindSet());    end;    local procedure SetControlAppearance()    begin        SetApprovalState(Rec.RecordId, OpenApprovalEntriesOnJnlBatchExist, CanRequestFlowApprovalForBatch, CanCancelFlowApprovalForLine, OpenApprovalEntriesExistForCurrUser, OpenApprovalEntriesOnJnlLineExist, OpenApprovalEntriesOnBatchOrCurrJnlLineExist, CanCancelApprovalForJnlLine, CanRequestFlowApprovalForBatchAndCurrentLine);        ShowWorkflowStatusOnLine := CurrPage.WorkflowStatusLine.PAGE.SetFilterOnWorkflowRecord(Rec.RecordId);    end;    internal procedure SetApprovalState(RecordId: RecordId; OpenApprovalEntriesOnJournalBatchExist: Boolean; LocalCanRequestFlowApprovalForBatch: Boolean; var LocalCanCancelFlowApprovalForLine: Boolean; var OpenApprovalEntriesExistForCurrentUser: Boolean; var OpenApprovalEntriesOnJournalLineExist: Boolean; var OpenApprovalEntriesOnBatchOrCurrentJournalLineExist: Boolean; var CanCancelApprovalForJournalLine: Boolean; var LocalCanRequestFlowApprovalForBatchAndCurrentLine: Boolean)    var        ApprovalsMgmt: Codeunit "Approvals Mgmt.";        WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";        CanRequestFlowApprovalForLine: Boolean;    begin        OpenApprovalEntriesExistForCurrentUser := OpenApprovalEntriesExistForCurrentUser or ApprovalsMgmt.HasOpenApprovalEntriesForCurrentUser(RecordId);        OpenApprovalEntriesOnJournalLineExist := ApprovalsMgmt.HasOpenApprovalEntries(RecordId);        OpenApprovalEntriesOnBatchOrCurrentJournalLineExist := OpenApprovalEntriesOnJournalBatchExist or OpenApprovalEntriesOnJournalLineExist;        CanCancelApprovalForJournalLine := ApprovalsMgmt.CanCancelApprovalForRecord(RecordId);        WorkflowWebhookManagement.GetCanRequestAndCanCancel(RecordId, CanRequestFlowApprovalForLine, LocalCanCancelFlowApprovalForLine);        LocalCanRequestFlowApprovalForBatchAndCurrentLine := LocalCanRequestFlowApprovalForBatch and CanRequestFlowApprovalForLine;    end;    internal procedure SetApprovalStateForBatch(GenJournalBatch: Record "Gen. Journal Batch"; GenJournalLine: Record "Gen. Journal Line"; var OpenApprovalEntriesExistForCurrentUser: Boolean; var OpenApprovalEntriesOnJournalBatchExist: Boolean; var OpenApprovalEntriesOnBatchOrAnyJournalLineExist: Boolean; var CanCancelApprovalForJournalBatch: Boolean; var LocalCanRequestFlowApprovalForBatch: Boolean; var LocalCanCancelFlowApprovalForBatch: Boolean; var LocalCanRequestFlowApprovalForBatchAndAllLines: Boolean; var LocalApprovalEntriesExistSentByCurrentUser: Boolean; var EnabledGeneralJournalBatchWorkflowsExist: Boolean; var EnabledGeneralJournalLineWorkflowsExist: Boolean)    var        ApprovalsMgmt: Codeunit "Approvals Mgmt.";        WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";        WorkflowEventHandling: Codeunit "Workflow Event Handling";        WorkflowManagement: Codeunit "Workflow Management";        CanRequestFlowApprovalForAllLines: Boolean;    begin        OpenApprovalEntriesExistForCurrentUser := OpenApprovalEntriesExistForCurrentUser or ApprovalsMgmt.HasOpenApprovalEntriesForCurrentUser(GenJournalBatch.RecordId);        OpenApprovalEntriesOnJournalBatchExist := ApprovalsMgmt.HasOpenApprovalEntries(GenJournalBatch.RecordId);        OpenApprovalEntriesOnBatchOrAnyJournalLineExist := OpenApprovalEntriesOnJournalBatchExist or ApprovalsMgmt.HasAnyOpenJournalLineApprovalEntries(GenJournalLine."Journal Template Name", GenJournalLine."Journal Batch Name");        CanCancelApprovalForJournalBatch := ApprovalsMgmt.CanCancelApprovalForRecord(GenJournalBatch.RecordId);        WorkflowWebhookManagement.GetCanRequestAndCanCancelJournalBatch(GenJournalBatch, LocalCanRequestFlowApprovalForBatch, LocalCanCancelFlowApprovalForBatch, CanRequestFlowApprovalForAllLines);        LocalCanRequestFlowApprovalForBatchAndAllLines := LocalCanRequestFlowApprovalForBatch and CanRequestFlowApprovalForAllLines;        LocalApprovalEntriesExistSentByCurrentUser := ApprovalsMgmt.HasApprovalEntriesSentByCurrentUser(GenJournalBatch.RecordId) or ApprovalsMgmt.HasApprovalEntriesSentByCurrentUser(Rec.RecordId);        EnabledGeneralJournalLineWorkflowsExist := WorkflowManagement.EnabledWorkflowExist(DATABASE::"Gen. Journal Line", WorkflowEventHandling.RunWorkflowOnSendGeneralJournalLineForApprovalCode());        EnabledGeneralJournalBatchWorkflowsExist := WorkflowManagement.EnabledWorkflowExist(DATABASE::"Gen. Journal Batch", WorkflowEventHandling.RunWorkflowOnSendGeneralJournalBatchForApprovalCode());    end;    /// <summary>    /// Integration event raised after validating shortcut dimension code changes for sales journal lines.    /// Enables custom processing after dimension validation and dimension set updates.    /// </summary>    /// <param name="GenJournalLine">Journal line record for which shortcut dimension was validated.</param>    /// <param name="ShortcutDimCode">Array of shortcut dimension codes with updated values.</param>    /// <param name="DimIndex">Index indicating which shortcut dimension was validated.</param>    [IntegrationEvent(false, false)]    local procedure OnAfterValidateShortcutDimCode(var GenJournalLine: Record "Gen. Journal Line"; var ShortcutDimCode: array[8] of Code[20]; DimIndex: Integer)    begin    end;    /// <summary>    /// Integration event raised after setting dimension field visibility for sales journal.    /// Enables custom control of dimension field display based on setup and context.    /// </summary>    [IntegrationEvent(true, false)]    local procedure OnAfterSetDimensionsVisibility()    begin    end;    /// <summary>    /// Integration event raised after opening the sales journal page.    /// Enables custom initialization and setup logic after standard page opening procedures.    /// </summary>    /// <param name="CurrentJnlBatchName">Current journal batch name that was opened.</param>    [IntegrationEvent(true, false)]    local procedure OnAfterOpenPage(var CurrentJnlBatchName: Code[10])    begin    end;    /// <summary>    /// Integration event raised before template selection during sales journal opening.    /// Enables custom template selection logic and override of standard template handling.    /// </summary>    /// <param name="CurrentJnlBatchName">Current journal batch name being processed.</param>    /// <param name="GenJnlManagement">Journal management codeunit handling template operations.</param>    /// <param name="IsHandled">Set to true to skip standard template selection logic.</param>    [IntegrationEvent(false, false)]    local procedure OnOpenPageOnBeforeTemplateSelection(var CurrentJnlBatchName: Code[10]; GenJnlManagement: Codeunit GenJnlManagement; var IsHandled: Boolean)    begin    end;    /// <summary>    /// Integration event raised before updating balance calculations for sales journal.    /// Enables custom balance calculation logic and modification of balance values.    /// </summary>    /// <param name="GenJournalLine">Current journal line record for balance calculation.</param>    /// <param name="xGenJournalLine">Previous version of journal line record for comparison.</param>    /// <param name="Balance">Current balance amount (can be modified).</param>    /// <param name="TotalBalance">Total balance amount (can be modified).</param>    /// <param name="ShowBalance">Boolean indicating if balance should be shown (can be modified).</param>    /// <param name="ShowTotalBalance">Boolean indicating if total balance should be shown (can be modified).</param>    /// <param name="IsHandled">Set to true to skip standard balance update logic.</param>    [IntegrationEvent(false, false)]    local procedure OnBeforeUpdateBalance(var GenJournalLine: Record "Gen. Journal Line"; xGenJournalLine: Record "Gen. Journal Line"; var Balance: Decimal; var TotalBalance: Decimal; var ShowBalance: Boolean; var ShowTotalBalance: Boolean; var IsHandled: Boolean)    begin    end;}