internal TrialBalance Build()
        {
            var helper = new TrialBalanceHelper(_command);

            List <TrialBalanceEntry> trialBalance = helper.GetSummaryAndPostingEntries();

            List <TrialBalanceEntry> summarySubsidiaryEntries = BalancesBySubsidiaryAccounts(trialBalance);

            trialBalance = CombineTotalSubsidiaryEntriesWithSummaryAccounts(summarySubsidiaryEntries);

            trialBalance = helper.RestrictLevels(trialBalance);

            var returnBalance = new FixedList <ITrialBalanceEntry>(trialBalance.Select(x => (ITrialBalanceEntry)x));

            return(new TrialBalance(_command, returnBalance));
        }
        internal TrialBalance Build()
        {
            var helper = new TrialBalanceHelper(_command);

            FixedList <TrialBalanceEntry> postingEntries = helper.GetPostingEntries();

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

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

            FixedList <TrialBalanceEntry> summaryGroupEntries = helper.GenerateTotalSummaryGroups(postingEntries);

            trialBalance = helper.CombineGroupEntriesAndPostingEntries(trialBalance, summaryGroupEntries);

            List <TrialBalanceEntry> summaryTotalDebtorCreditorEntries =
                helper.GenerateTotalSummaryDebtorCreditor(postingEntries.ToList());

            trialBalance = helper.CombineDebtorCreditorAndPostingEntries(trialBalance,
                                                                         summaryTotalDebtorCreditorEntries);

            List <TrialBalanceEntry> summaryTotalCurrencies = helper.GenerateTotalSummaryCurrency(
                summaryTotalDebtorCreditorEntries);

            trialBalance = helper.CombineCurrencyTotalsAndPostingEntries(trialBalance, summaryTotalCurrencies);

            List <TrialBalanceEntry> summaryTotalConsolidatedByLedger =
                helper.GenerateTotalSummaryConsolidatedByLedger(summaryTotalCurrencies);

            trialBalance = helper.CombineTotalConsolidatedByLedgerAndPostingEntries(
                trialBalance, summaryTotalConsolidatedByLedger);

            List <TrialBalanceEntry> summaryTrialBalanceConsolidated = helper.GenerateTotalSummaryConsolidated(
                summaryTotalCurrencies);

            trialBalance = helper.CombineTotalConsolidatedAndPostingEntries(
                trialBalance, summaryTrialBalanceConsolidated);

            trialBalance = helper.RestrictLevels(trialBalance);

            var returnBalance = new FixedList <ITrialBalanceEntry>(trialBalance.Select(x => (ITrialBalanceEntry)x));

            return(new TrialBalance(_command, returnBalance));
        }
        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));
        }