private void RecurseAddLines(List <YearlyReportLine> list, int renderNodeId) { foreach (FinancialAccount account in _treeMap[renderNodeId]) { YearlyReportLine newLine = new YearlyReportLine(); newLine.AccountId = account.Identity; newLine.AccountName = account.Name; newLine.AccountType = account.AccountType; newLine.AccountValues = CreateYearlyReportNode(account.Identity, _singleLookups); newLine.AccountTreeValues = CreateYearlyReportNode(account.Identity, _treeLookups); if (_treeMap.ContainsKey(account.Identity)) { RecurseAddLines(newLine.Children, account.Identity); } list.Add(newLine); } }
private void AggregateAccounts() { const int assetIdentity = 1000000001; const int debtIdentity = 1000000002; const int incomeIdentity = 1000000003; const int costIdentity = 1000000004; Dictionary<FinancialAccountType, YearlyReportLine> remapLookup = new Dictionary<FinancialAccountType, YearlyReportLine>(); List<YearlyReportLine> newRootLevel = new List<YearlyReportLine>(); int equityIdentity = _treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity; if (_accountType == FinancialAccountType.Balance) { YearlyReportLine assetLine = new YearlyReportLine {AccountId = assetIdentity, AccountName = "%ASSET_ACCOUNTGROUP%"}; YearlyReportLine debtLine = new YearlyReportLine {AccountId = debtIdentity, AccountName = "%DEBT_ACCOUNTGROUP%"}; remapLookup[FinancialAccountType.Asset] = assetLine; remapLookup[FinancialAccountType.Debt] = debtLine; newRootLevel.Add(assetLine); newRootLevel.Add(debtLine); } else if (_accountType == FinancialAccountType.Result) { YearlyReportLine incomeLine = new YearlyReportLine {AccountId = incomeIdentity, AccountName = "%INCOME_ACCOUNTGROUP%"}; YearlyReportLine costLine = new YearlyReportLine {AccountId = costIdentity, AccountName = "%COST_ACCOUNTGROUP%"}; remapLookup[FinancialAccountType.Income] = incomeLine; remapLookup[FinancialAccountType.Cost] = costLine; newRootLevel.Add(incomeLine); newRootLevel.Add(costLine); } else { throw new InvalidOperationException("AccountType other than Balance or Result passed to YearlyReport.AggregateAccounts()"); } foreach (YearlyReportLine reportLine in ReportLines) { if (reportLine.AccountId == equityIdentity) { newRootLevel.Add(reportLine); } else { YearlyReportLine aggregateLine = remapLookup[reportLine.AccountType]; if (aggregateLine.Children == null) { aggregateLine.Children = new List<YearlyReportLine>(); } aggregateLine.Children.Add(reportLine); aggregateLine.AccountTreeValues.PreviousYear += reportLine.AccountTreeValues.PreviousYear; for (int quarter = 0; quarter < 4; quarter++) { aggregateLine.AccountTreeValues.Quarters[quarter] += reportLine.AccountTreeValues.Quarters[quarter]; } aggregateLine.AccountTreeValues.ThisYear += reportLine.AccountTreeValues.ThisYear; } } this.ReportLines = newRootLevel; }
private void RecurseAddLines (List<YearlyReportLine> list, int renderNodeId) { foreach (FinancialAccount account in _treeMap[renderNodeId]) { YearlyReportLine newLine = new YearlyReportLine(); newLine.AccountId = account.Identity; newLine.AccountName = account.Name; newLine.AccountType = account.AccountType; newLine.AccountValues = CreateYearlyReportNode(account.Identity, _singleLookups); newLine.AccountTreeValues = CreateYearlyReportNode(account.Identity, _treeLookups); if (_treeMap.ContainsKey(account.Identity)) { RecurseAddLines(newLine.Children, account.Identity); } list.Add(newLine); } }
private void AggregateAccounts() { const int assetIdentity = 1000000001; const int debtIdentity = 1000000002; const int incomeIdentity = 1000000003; const int costIdentity = 1000000004; Dictionary <FinancialAccountType, YearlyReportLine> remapLookup = new Dictionary <FinancialAccountType, YearlyReportLine>(); List <YearlyReportLine> newRootLevel = new List <YearlyReportLine>(); int equityIdentity = _treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity; if (_accountType == FinancialAccountType.Balance) { YearlyReportLine assetLine = new YearlyReportLine { AccountId = assetIdentity, AccountName = "%ASSET_ACCOUNTGROUP%" }; YearlyReportLine debtLine = new YearlyReportLine { AccountId = debtIdentity, AccountName = "%DEBT_ACCOUNTGROUP%" }; remapLookup[FinancialAccountType.Asset] = assetLine; remapLookup[FinancialAccountType.Debt] = debtLine; newRootLevel.Add(assetLine); newRootLevel.Add(debtLine); } else if (_accountType == FinancialAccountType.Result) { YearlyReportLine incomeLine = new YearlyReportLine { AccountId = incomeIdentity, AccountName = "%INCOME_ACCOUNTGROUP%" }; YearlyReportLine costLine = new YearlyReportLine { AccountId = costIdentity, AccountName = "%COST_ACCOUNTGROUP%" }; remapLookup[FinancialAccountType.Income] = incomeLine; remapLookup[FinancialAccountType.Cost] = costLine; newRootLevel.Add(incomeLine); newRootLevel.Add(costLine); } else { throw new InvalidOperationException("AccountType other than Balance or Result passed to YearlyReport.AggregateAccounts()"); } foreach (YearlyReportLine reportLine in ReportLines) { if (reportLine.AccountId == equityIdentity) { newRootLevel.Add(reportLine); } else { YearlyReportLine aggregateLine = remapLookup[reportLine.AccountType]; if (aggregateLine.Children == null) { aggregateLine.Children = new List <YearlyReportLine>(); } aggregateLine.Children.Add(reportLine); aggregateLine.AccountTreeValues.PreviousYear += reportLine.AccountTreeValues.PreviousYear; for (int quarter = 0; quarter < 4; quarter++) { aggregateLine.AccountTreeValues.Quarters[quarter] += reportLine.AccountTreeValues.Quarters[quarter]; } aggregateLine.AccountTreeValues.ThisYear += reportLine.AccountTreeValues.ThisYear; } } this.ReportLines = newRootLevel; }