Page 414 G/L Balance

Base Application, Microsoft.Finance.Analysis

src/Layers/W1/BaseApp/Finance/Analysis/GLBalance.Page.al477 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.Analysis;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Account;using Microsoft.Finance.GeneralLedger.Ledger;using Microsoft.Foundation.Comment;using Microsoft.Foundation.Enums;using Microsoft.Foundation.ExtendedText;using Microsoft.Foundation.Period;using System.Text;using System.Utilities;/// <summary>/// Matrix worksheet for displaying G/L account balances across multiple time periods./// Provides period-based analysis of account balances with flexible date range and dimension filtering./// </summary>page 414 "G/L Balance"{    Caption = 'G/L Balance';    PageType = Worksheet;    SaveValues = true;    SourceTable = "G/L Account";    layout    {        area(content)        {            group(Options)            {                Caption = 'Options';                field(ClosingEntryFilter; ClosingEntryFilter)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Closing Entries';                    OptionCaption = 'Include,Exclude';                    ToolTip = 'Specifies whether the balance shown will include closing entries. If you want to see the amounts on income statement accounts in closed years, you must exclude closing entries.';                    trigger OnValidate()                    begin                        FindPeriod('');                        ClosingEntryFilterOnAfterValid();                    end;                }                field(DebitCreditTotals; DebitCreditTotals)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Debit && Credit Totals';                    ToolTip = 'Specifies that the totals for both debit and credit are displayed in the matrix window.';                    trigger OnValidate()                    begin                        DebitCreditTotalsOnAfterValida();                    end;                }                field(PeriodType; PeriodType)                {                    ApplicationArea = Basic, Suite;                    Caption = 'View by';                    ToolTip = 'Specifies by which period amounts are displayed.';                    trigger OnValidate()                    begin                        if PeriodType = PeriodType::"Accounting Period" then                            AccountingPerioPeriodTypeOnVal();                        if PeriodType = PeriodType::Year then                            YearPeriodTypeOnValidate();                        if PeriodType = PeriodType::Quarter then                            QuarterPeriodTypeOnValidate();                        if PeriodType = PeriodType::Month then                            MonthPeriodTypeOnValidate();                        if PeriodType = PeriodType::Week then                            WeekPeriodTypeOnValidate();                        if PeriodType = PeriodType::Day then                            DayPeriodTypeOnValidate();                    end;                }                field(AmountType; AmountType)                {                    ApplicationArea = Basic, Suite;                    Caption = 'View as';                    ToolTip = 'Specifies how amounts are displayed. Net Change: The net change in the balance for the selected period. Balance at Date: The balance as of the last day in the selected period.';                    trigger OnValidate()                    begin                        if AmountType = AmountType::"Balance at Date" then                            BalanceatDateAmountTypeOnValid();                        if AmountType = AmountType::"Net Change" then                            NetChangeAmountTypeOnValidate();                    end;                }                field(DateFilter; DateFilter)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Date Filter';                    Importance = Promoted;                    ToolTip = 'Specifies the dates that will be used to filter the amounts in the window.';                    trigger OnValidate()                    var                        FilterTokens: Codeunit "Filter Tokens";                    begin                        FilterTokens.MakeDateFilter(DateFilter);                        Rec.SetFilter("Date Filter", DateFilter);                        DateFilter := Rec.GetFilter("Date Filter");                        CurrPage.Update();                    end;                }            }            repeater(Control5)            {                IndentationColumn = NameIndent;                IndentationControls = Name;                ShowCaption = false;                field("No."; Rec."No.")                {                    ApplicationArea = Basic, Suite;                    Style = Strong;                    StyleExpr = Emphasize;                }                field(Name; Rec.Name)                {                    ApplicationArea = Basic, Suite;                    Style = Strong;                    StyleExpr = Emphasize;                }                field("Income/Balance"; Rec."Income/Balance")                {                    ApplicationArea = Basic, Suite;                    Style = Strong;                    StyleExpr = Emphasize;                }                field("Debit Amount"; Rec."Debit Amount")                {                    ApplicationArea = Basic, Suite;                    BlankNumbers = BlankZero;                    Style = Strong;                    StyleExpr = Emphasize;                }                field("Credit Amount"; Rec."Credit Amount")                {                    ApplicationArea = Basic, Suite;                    BlankNumbers = BlankZero;                    Style = Strong;                    StyleExpr = Emphasize;                }                field("Net Change"; Rec."Net Change")                {                    ApplicationArea = Basic, Suite;                    BlankZero = true;                    Style = Strong;                    StyleExpr = Emphasize;                    Visible = false;                }            }        }        area(factboxes)        {            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(navigation)        {            group("A&ccount")            {                Caption = 'A&ccount';                Image = ChartOfAccounts;                action(Card)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Card';                    Image = EditLines;                    RunObject = Page "G/L Account Card";                    RunPageLink = "No." = field("No."),                                  "Date Filter" = field("Date Filter"),                                  "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                  "Global Dimension 2 Filter" = field("Global Dimension 2 Filter"),                                  "Budget Filter" = field("Budget Filter"),                                  "Business Unit Filter" = field("Business Unit Filter");                    ShortCutKey = 'Shift+F7';                    ToolTip = 'View information about general ledger accounts, such as the account number, account name, and whether the account is part of the income statement or balance sheet.';                }                action("Ledger E&ntries")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Ledger E&ntries';                    Image = GLRegisters;                    RunObject = Page "General Ledger Entries";                    RunPageLink = "G/L Account No." = field("No.");                    RunPageView = sorting("G/L Account No.");                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View the history of transactions that have been posted for the selected record.';                }                action("Co&mments")                {                    ApplicationArea = Comments;                    Caption = 'Co&mments';                    Image = ViewComments;                    RunObject = Page "Comment Sheet";                    RunPageLink = "Table Name" = const("G/L Account"),                                  "No." = field("No.");                    ToolTip = 'View or add comments for the record.';                }                action(Dimensions)                {                    ApplicationArea = Dimensions;                    Caption = 'Dimensions';                    Image = Dimensions;                    RunObject = Page "Default Dimensions";                    RunPageLink = "Table ID" = const(15),                                  "No." = field("No.");                    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.';                }                action("E&xtended Texts")                {                    ApplicationArea = Suite;                    Caption = 'E&xtended Texts';                    Image = Text;                    RunObject = Page "Extended Text List";                    RunPageLink = "Table Name" = const("G/L Account"),                                  "No." = field("No.");                    RunPageView = sorting("Table Name", "No.", "Language Code", "All Language Codes", "Starting Date", "Ending Date");                    ToolTip = 'View additional information about a general ledger account, this supplements the Description field.';                }                action("Receivables-Payables")                {                    ApplicationArea = Suite;                    Caption = 'Receivables-Payables';                    Image = ReceivablesPayables;                    RunObject = Page "Receivables-Payables";                    ToolTip = 'View a summary of the receivables and payables for the account, including customer and vendor balance due amounts.';                }            }        }        area(processing)        {            action("Previous Period")            {                ApplicationArea = Basic, Suite;                Caption = 'Previous Period';                Image = PreviousRecord;                ToolTip = 'Show the information based on the previous period. If you set the View by field to Day, the date filter changes to the day before.';                trigger OnAction()                begin                    FindPeriod('<=');                end;            }            action("Next Period")            {                ApplicationArea = Basic, Suite;                Caption = 'Next Period';                Image = NextRecord;                ToolTip = 'Show the information based on the next period. If you set the View by field to Day, the date filter changes to the day before.';                trigger OnAction()                begin                    FindPeriod('>=');                end;            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process';                actionref("Previous Period_Promoted"; "Previous Period")                {                }                actionref("Next Period_Promoted"; "Next Period")                {                }            }        }    }    trigger OnAfterGetRecord()    begin        NameIndent := 0;        if DebitCreditTotals then            Rec.CalcFields("Net Change", "Debit Amount", "Credit Amount")        else begin            Rec.CalcFields("Net Change");            if Rec."Net Change" > 0 then begin                Rec."Debit Amount" := Rec."Net Change";                Rec."Credit Amount" := 0            end else begin                Rec."Debit Amount" := 0;                Rec."Credit Amount" := -Rec."Net Change"            end        end;        FormatLine();    end;    trigger OnNewRecord(BelowxRec: Boolean)    begin        Rec.SetupNewGLAcc(xRec, BelowxRec);    end;    trigger OnOpenPage()    begin        FindPeriod('');    end;    protected var        PeriodType: Enum "Analysis Period Type";        AmountType: Enum "Analysis Amount Type";        ClosingEntryFilter: Option Include,Exclude;        DebitCreditTotals: Boolean;        Emphasize: Boolean;        NameIndent: Integer;        DateFilter: Text;    local procedure FindPeriod(SearchText: Code[10])    var        Calendar: Record Date;        AccountingPeriod: Record "Accounting Period";        PeriodPageMgt: Codeunit PeriodPageManagement;    begin        if Rec.GetFilter("Date Filter") <> '' then begin            Calendar.SetFilter("Period Start", Rec.GetFilter("Date Filter"));            if not PeriodPageMgt.FindDate('+', Calendar, PeriodType) then                PeriodPageMgt.FindDate('+', Calendar, PeriodType::Day);            Calendar.SetRange("Period Start");        end;        PeriodPageMgt.FindDate(SearchText, Calendar, PeriodType);        if AmountType = AmountType::"Net Change" then            if Calendar."Period Start" = Calendar."Period End" then                Rec.SetRange("Date Filter", Calendar."Period Start")            else                Rec.SetRange("Date Filter", Calendar."Period Start", Calendar."Period End")        else            Rec.SetRange("Date Filter", 0D, Calendar."Period End");        if ClosingEntryFilter = ClosingEntryFilter::Exclude then begin            AccountingPeriod.SetCurrentKey("New Fiscal Year");            AccountingPeriod.SetRange("New Fiscal Year", true);            if Rec.GetRangeMin("Date Filter") = 0D then                AccountingPeriod.SetRange("Starting Date", 0D, Rec.GetRangeMax("Date Filter"))            else                if not (Rec.GetRangeMin("Date Filter") = NormalDate(Rec.GetRangeMin("Date Filter"))) then                    AccountingPeriod.SetRange(                      "Starting Date",                      Rec.GetRangeMin("Date Filter") + 1,                      Rec.GetRangeMax("Date Filter"))                else                    AccountingPeriod.SetRange(                      "Starting Date", 0D,                      Rec.GetRangeMin("Date Filter") + 1);            if AccountingPeriod.Find('-') then                repeat                    Rec.SetFilter(                      "Date Filter", Rec.GetFilter("Date Filter") + '&<>%1',                      ClosingDate(AccountingPeriod."Starting Date" - 1));                until AccountingPeriod.Next() = 0;        end else            Rec.SetRange(              "Date Filter",              Rec.GetRangeMin("Date Filter"),              ClosingDate(Rec.GetRangeMax("Date Filter")));        DateFilter := Rec.GetFilter("Date Filter");    end;    local procedure ClosingEntryFilterOnAfterValid()    begin        CurrPage.Update();    end;    local procedure DebitCreditTotalsOnAfterValida()    begin        CurrPage.Update();    end;    local procedure DayPeriodTypeOnPush()    begin        FindPeriod('');    end;    local procedure WeekPeriodTypeOnPush()    begin        FindPeriod('');    end;    local procedure MonthPeriodTypeOnPush()    begin        FindPeriod('');    end;    local procedure QuarterPeriodTypeOnPush()    begin        FindPeriod('');    end;    local procedure YearPeriodTypeOnPush()    begin        FindPeriod('');    end;    local procedure AccountingPerioPeriodTypOnPush()    begin        FindPeriod('');    end;    local procedure BalanceatDateAmountTypeOnPush()    begin        FindPeriod('');    end;    local procedure NetChangeAmountTypeOnPush()    begin        FindPeriod('');    end;    local procedure FormatLine()    begin        NameIndent := Rec.Indentation;        Emphasize := Rec."Account Type" <> Rec."Account Type"::Posting;    end;    local procedure DayPeriodTypeOnValidate()    begin        DayPeriodTypeOnPush();    end;    local procedure WeekPeriodTypeOnValidate()    begin        WeekPeriodTypeOnPush();    end;    local procedure MonthPeriodTypeOnValidate()    begin        MonthPeriodTypeOnPush();    end;    local procedure QuarterPeriodTypeOnValidate()    begin        QuarterPeriodTypeOnPush();    end;    local procedure YearPeriodTypeOnValidate()    begin        YearPeriodTypeOnPush();    end;    local procedure AccountingPerioPeriodTypeOnVal()    begin        AccountingPerioPeriodTypOnPush();    end;    local procedure NetChangeAmountTypeOnValidate()    begin        NetChangeAmountTypeOnPush();    end;    local procedure BalanceatDateAmountTypeOnValid()    begin        BalanceatDateAmountTypeOnPush();    end;}