Exemple #1
0
        private void RecurseAddLines(List <AnnualReportLine> list, int renderNodeId)
        {
            foreach (FinancialAccount account in this._treeMap[renderNodeId])
            {
                AnnualReportLine newLine = new AnnualReportLine();
                newLine.AccountId         = account.Identity;
                newLine.AccountName       = account.Name;
                newLine.AccountType       = account.AccountType;
                newLine.AccountValues     = CreateAnnualReportNode(account.Identity, this._singleLookups);
                newLine.AccountTreeValues = CreateAnnualReportNode(account.Identity, this._treeLookups);

                if (this._treeMap.ContainsKey(account.Identity))
                {
                    RecurseAddLines(newLine.Children, account.Identity);
                }

                list.Add(newLine);
            }
        }
Exemple #2
0
        private void AggregateAccounts()
        {
            const int assetIdentity  = 1000000001;
            const int debtIdentity   = 1000000002;
            const int incomeIdentity = 1000000003;
            const int costIdentity   = 1000000004;

            Dictionary <FinancialAccountType, AnnualReportLine> remapLookup =
                new Dictionary <FinancialAccountType, AnnualReportLine>();

            List <AnnualReportLine> newRootLevel = new List <AnnualReportLine>();

            int equityIdentity = this._treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity;

            if (this._accountType == FinancialAccountType.Balance)
            {
                AnnualReportLine assetLine = new AnnualReportLine
                {
                    AccountId = assetIdentity, AccountName = "%ASSET_ACCOUNTGROUP%", AccountType = FinancialAccountType.Asset
                };
                AnnualReportLine debtLine = new AnnualReportLine
                {
                    AccountId = debtIdentity, AccountName = "%DEBT_ACCOUNTGROUP%", AccountType = FinancialAccountType.Debt
                };
                remapLookup[FinancialAccountType.Asset] = assetLine;
                remapLookup[FinancialAccountType.Debt]  = debtLine;

                newRootLevel.Add(assetLine);
                newRootLevel.Add(debtLine);
            }
            else if (this._accountType == FinancialAccountType.Result)
            {
                AnnualReportLine incomeLine = new AnnualReportLine
                {
                    AccountId = incomeIdentity, AccountName = "%INCOME_ACCOUNTGROUP%"
                };
                AnnualReportLine costLine = new AnnualReportLine
                {
                    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 AnnualReport.AggregateAccounts()");
            }

            foreach (AnnualReportLine reportLine in this.ReportLines)
            {
                if (reportLine.AccountId == equityIdentity)
                {
                    newRootLevel.Add(reportLine);
                }
                else
                {
                    AnnualReportLine aggregateLine = remapLookup[reportLine.AccountType];
                    if (aggregateLine.Children == null)
                    {
                        aggregateLine.Children = new List <AnnualReportLine>();
                    }

                    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;
                    aggregateLine.AccountTreeValues.ThisYearBudget += reportLine.AccountTreeValues.ThisYearBudget;
                }
            }

            this.ReportLines = newRootLevel;
        }