Page 2670 Allocation Account, source in 29

Source29

src/Layers/W1/BaseApp/Finance/AllocationAccount/AllocationAccount.page.al104 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.AllocationAccount;

using System.Telemetry;

/// <summary>
/// Main configuration interface for allocation accounts with support for both fixed and variable distribution methods.
/// Provides integrated setup for allocation rules, destination accounts, and distribution parameters.
/// </summary>
page 2670 "Allocation Account"
{
    PageType = ListPlus;
    SourceTable = "Allocation Account";
    Caption = 'Allocation Account';
    AboutTitle = 'About Allocation Accounts';
    AboutText = 'Manage allocation accounts to automatically split amounts across multiple destination accounts Define fixed or variable allocation methods, set destination accounts, and control how values are distributed during posting. Use allocation accounts in journals and documents to apply consistent allocation rules without manual line splitting.';

    layout
    {
        area(Content)
        {
            group(General)
            {
                Caption = 'General';
                field("No."; Rec."No.")
                {
                    ApplicationArea = All;
                    Caption = 'No.';
                }

                field(Name; Rec.Name)
                {
                    ApplicationArea = All;
                    Caption = 'Name';
                }

                field("Account Type"; Rec."Account Type")
                {
                    ApplicationArea = All;
                    Caption = 'Account Type';

                    trigger OnValidate()
                    begin
                        UpdateVisibility();
                    end;
                }

                field(DocumentLinesSplit; Rec."Document Lines Split")
                {
                    ApplicationArea = All;
                    Caption = 'Document Line Split';
                }

                group(DistributionAccountTypeGroup)
                {
                    ShowCaption = false;
                    Visible = VariableAccountVisible;
                }
            }

            part(VariableAccountDistribution; "Variable Account Distribution")
            {
                ApplicationArea = Dimensions;
                Caption = 'Variable Account Distribution';
                SubPageLink = "Allocation Account No." = field("No."), "Account Type" = const(Variable);
                Visible = VariableAccountVisible;
            }

            part(FixedAccountDistribution; "Fixed Account Distribution")
            {
                ApplicationArea = Dimensions;
                Caption = 'Fixed Account Distribution';
                SubPageLink = "Allocation Account No." = field("No."), "Account Type" = const(Fixed);
                Visible = not VariableAccountVisible;
            }
        }
    }

    trigger OnOpenPage()
    var
        FeatureTelemetry: Codeunit "Feature Telemetry";
        AllocAccTelemetry: Codeunit "Alloc. Acc. Telemetry";
    begin
        FeatureTelemetry.LogUptake('0000KYA', AllocAccTelemetry.GetFeatureTelemetryName(), Enum::"Feature Uptake Status"::Discovered);
        UpdateVisibility();
    end;

    trigger OnAfterGetCurrRecord()
    begin
        UpdateVisibility();
    end;

    local procedure UpdateVisibility()
    begin
        VariableAccountVisible := Rec."Account Type" = Rec."Account Type"::Variable;
    end;

    var
        VariableAccountVisible: Boolean;
}