Exemple #1
0
        public void Load()
        {
            StartingBalance = 0m;
            foreach (Account account in Company.Accounts)
            {
                if (Handler.IncludeAccount(account))
                {
                    foreach (Register reg in account.Registers)
                    {
                        StartingBalance += reg.EndingBalance(StartDate.AddDays(-1d));
                        foreach (BaseTrx trx in reg.GetDateRange <BaseTrx>(StartDate, EndDate))
                        {
                            LoadTrx(trx);
                        }
                    }
                }
            }

            // This must be done before adding each detail row
            // to the income or expense list, or it won't know
            // which list the row belongs to.
            ComputeDetailRowTotals();

            BudgetedIncome   = new List <BudgetDetailRow>();
            BudgetedExpenses = new List <BudgetDetailRow>();
            foreach (var row in BudgetDetailRows.Values)
            {
                if (row.RowTotal.CellAmount > 0)
                {
                    BudgetedIncome.Add(row);
                }
                else
                {
                    BudgetedExpenses.Add(row);
                }
            }
            BudgetedIncome.Sort(DataRowComparer);
            BudgetedExpenses.Sort(DataRowComparer);

            UnbudgetedIncome   = new List <SplitDetailRow>();
            UnbudgetedExpenses = new List <SplitDetailRow>();
            foreach (var row in SplitDetailRows.Values)
            {
                if (row.RowTotal.CellAmount > 0)
                {
                    UnbudgetedIncome.Add(row);
                }
                else
                {
                    UnbudgetedExpenses.Add(row);
                }
            }
            UnbudgetedIncome.Sort(DataRowComparer);
            UnbudgetedExpenses.Sort(DataRowComparer);

            TotalIncome    = new TotalRow(PeriodCount, "", "Total Credits", "");
            TotalExpense   = new TotalRow(PeriodCount, "", "Total Debits", "");
            NetProfit      = new TotalRow(PeriodCount, "", "Net Debits/Credits", "");
            RunningBalance = new TotalRow(PeriodCount, "", "Running Balance", "");

            // This has to wait until the very end, so everything is assigned
            // to the correct section.
            ComputeSectionTotals();
        }