diff --git a/Logic/Financial/YearlyReport.cs b/Logic/Financial/YearlyReport.cs index 6f13b4a7..9b25b5ae 100644 --- a/Logic/Financial/YearlyReport.cs +++ b/Logic/Financial/YearlyReport.cs @@ -37,6 +37,17 @@ namespace Activizr.Logic.Financial } } + // Aggregate accounts, if appropriate + + int rootLevelAccounts = accounts.Count(account => account.ParentFinancialAccountId == 0); + + if (rootLevelAccounts > 3) + { + // regroup list + + report.AggregateAccounts(); + } + // Build tree (there should be a template for this) report._treeMap = new Dictionary>(); @@ -52,13 +63,6 @@ namespace Activizr.Logic.Financial } - if (report._treeMap[0].Count > 3) - { - // regroup list - - report.AggregateAccounts(); - } - FinancialAccounts orderedList = new FinancialAccounts(); // This list is guaranteed to have parents before children report.PopulateOrderedList(orderedList, 0); // recursively add nodes parents-first