static internal TrialBalanceCommandData MapToTrialBalanceCommandData(
            this TrialBalanceCommand command,
            TrialBalanceCommandPeriod commandPeriod)
        {
            var helper = new TrialBalanceClausesHelper(command);

            return(helper.GetTrialBalanceCommandData(commandPeriod));
        }
            internal TrialBalanceCommandData GetTrialBalanceCommandData(TrialBalanceCommandPeriod commandPeriod)
            {
                var commandData = new TrialBalanceCommandData();

                var accountsChart = AccountsChart.Parse(_command.AccountsChartUID);

                StoredBalanceSet balanceSet = StoredBalanceSet.GetBestBalanceSet(
                    accountsChart, commandPeriod.FromDate);

                commandData.StoredInitialBalanceSet = balanceSet;
                commandData.FromDate        = commandPeriod.FromDate;
                commandData.ToDate          = commandPeriod.ToDate;
                commandData.InitialFields   = GetInitialFields();
                commandData.Fields          = GetOutputFields();
                commandData.Filters         = GetFilterString();
                commandData.AccountFilters  = GetAccountFilterString();
                commandData.InitialGrouping = GetInitialGroupingClause();
                commandData.Grouping        = GetGroupingClause();
                commandData.Having          = GetHavingClause();
                commandData.Ordering        = GetOrderClause();
                commandData.AccountsChart   = accountsChart;

                return(commandData);
            }