internal FixedList <TrialBalanceEntry> GetPostingEntries(bool isComparativeBalance = false)
        {
            var helper = new TrialBalanceHelper(_command);

            TrialBalanceCommandPeriod commandPeriod = new TrialBalanceCommandPeriod();

            if (isComparativeBalance)
            {
                commandPeriod = _command.FinalPeriod;
            }
            else
            {
                commandPeriod = _command.InitialPeriod;
            }

            FixedList <TrialBalanceEntry> postingEntries = helper.GetTrialBalanceEntries(commandPeriod);

            if (_command.ValuateBalances || _command.ValuateFinalBalances)
            {
                postingEntries = helper.ValuateToExchangeRate(postingEntries, commandPeriod);

                if (_command.ConsolidateBalancesToTargetCurrency)
                {
                    postingEntries = helper.ConsolidateToTargetCurrency(postingEntries, commandPeriod);
                }
            }
            return(postingEntries);
        }
        internal TrialBalance Build()
        {
            var helper           = new TrialBalanceHelper(_command);
            var twoColumnsHelper = new TwoCurrenciesBalanceHelper(_command);

            FixedList <TrialBalanceEntry> postingEntries = helper.GetTrialBalanceEntries(_command.InitialPeriod);

            postingEntries = helper.ValuateToExchangeRate(postingEntries, _command.InitialPeriod);

            List <TrialBalanceEntry> summaryEntries = helper.GenerateSummaryEntries(postingEntries);
            List <TrialBalanceEntry> trialBalance   = helper.CombineSummaryAndPostingEntries(summaryEntries,
                                                                                             postingEntries);

            trialBalance = helper.RestrictLevels(trialBalance);

            FixedList <TwoCurrenciesBalanceEntry> twoColumnsEntries =
                twoColumnsHelper.MergeAccountsIntoTwoColumns(trialBalance);

            FixedList <TwoCurrenciesBalanceEntry> summaryGroupEntries =
                twoColumnsHelper.GetTotalSummaryGroup(twoColumnsEntries);

            twoColumnsEntries = twoColumnsHelper.CombineGroupEntriesAndTwoColumnsEntries(
                twoColumnsEntries, summaryGroupEntries);

            List <TwoCurrenciesBalanceEntry> summaryTotalDeptorCreditorEntries =
                twoColumnsHelper.GetTotalDeptorCreditorTwoColumnsEntries(
                    twoColumnsEntries);

            twoColumnsEntries = twoColumnsHelper.CombineTotalDeptorCreditorAndTwoColumnsEntries(
                twoColumnsEntries.ToList(), summaryTotalDeptorCreditorEntries);

            List <TwoCurrenciesBalanceEntry> summaryTwoColumnsBalanceTotal =
                twoColumnsHelper.GenerateTotalSummary(summaryTotalDeptorCreditorEntries);

            twoColumnsEntries = twoColumnsHelper.CombineTotalConsolidatedAndPostingEntries(
                twoColumnsEntries, summaryTwoColumnsBalanceTotal);

            FixedList <ITrialBalanceEntry> twoColumnsBalance = twoColumnsEntries.Select(x => (ITrialBalanceEntry)x)
                                                               .ToList().ToFixedList();

            return(new TrialBalance(_command, twoColumnsBalance));
        }