Esempio n. 1
0
        public static BudgetRow BuildAllocationHeader1(Enums.AllocationType allocationType)
        {
            BudgetRow retRow = new BudgetRow();

            retRow.Column1      = allocationType.ToDisplayName();
            retRow.RowType      = Enums.TableRowType.header1;
            retRow.AllocationId = (int)allocationType;
            return(retRow);
        }
        /// <summary>
        /// Gets a single row from the table fulfilling the criteria.
        /// </summary>
        /// <param name="wID">A ID as criteria.</param>
        /// <returns>The row fulfilling the criteria</returns>
        public BudgetRow GetSingleRow(int wID, bool canBeNull)
        {
            BudgetRow ret = mTable.GetSingleRow(wID);

            if (ret.IsNull && !canBeNull)
            {
                UnexpectedNull(MethodBase.GetCurrentMethod(), wID);
            }
            return(ret);
        }
Esempio n. 3
0
        public static BudgetRow BuildSummaryRow(List <BudgetRow> retList)
        {
            BudgetRow retRow = new BudgetRow();

            retRow.Column1 = "Balance";
            //retRow.Column3 = "";
            retRow.MoneyCol1 = FindBalance(retList, 1);
            retRow.MoneyCol2 = FindBalance(retList, 2);
            retRow.RowType   = Enums.TableRowType.total;
            return(retRow);
        }
Esempio n. 4
0
        public static void BuildTotalLine(List <BudgetRow> retList)
        {
            BudgetRow retRow = new BudgetRow();

            retRow.Column1 = "Total";
            decimal?budgetBal        = retList.Find(x => x.Column1.Contains("Bal")).MoneyCol1;
            decimal?actualBal        = retList.Find(x => x.Column1.Contains("Bal")).MoneyCol2;
            decimal?budgetLoans      = retList.Find(x => x.Column1.Contains("Loan")).MoneyCol1;
            decimal?actualLoans      = retList.Find(x => x.Column1.Contains("Loan")).MoneyCol2;
            decimal?budgetSaveInvest = retList.Find(x => x.Column1.Contains("Save")).MoneyCol1;
            decimal?actualSaveInvest = retList.Find(x => x.Column1.Contains("Save")).MoneyCol2;

            retRow.MoneyCol1 = budgetBal - (budgetLoans + budgetSaveInvest);
            retRow.MoneyCol2 = actualBal - (actualLoans + actualSaveInvest);
            retRow.RowType   = Enums.TableRowType.total;
            retList.Add(retRow);
        }
 /// <summary>
 /// Updates the given single row on the table.
 /// </summary>
 /// <param name="row">The prefilled row.</param>
 public void UpdateSingleRow(BudgetRow row)
 {
     mTable.UpdateSingleRow(row.IDKonto, row.Bezeichnung, row.ID);
 }
 /// <summary>
 /// Inserts the given row and returns its id.
 /// </summary>
 /// <param name="row">The prefilled row to insert.</param>
 /// <returns>The inserted row</returns>
 public int InsertRow(BudgetRow row)
 {
     return(mTable.InsertRow(row.IDKonto, row.Bezeichnung));
 }
 /// <summary>
 /// Deletes the given row.
 /// </summary>
 /// <param name="row">The row to delete</param>
 public void DeleteSingleRow(BudgetRow row)
 {
     mTable.DeleteSingleRow(row.ID);
 }
Esempio n. 8
0
        public override void Generate(IReportWriter writer)
        {
            writer.WriteHeading("Budget Report");

            this.rows = new Dictionary <string, BudgetRow>();

            this.columns = new Dictionary <DateTime, BudgetColumn>();

            foreach (Category rc in money.Categories.GetRootCategories())
            {
                if (rc.Type != CategoryType.Expense)
                {
                    continue;
                }
                string rowHeader = rc.Name;
                this.CategoryFilter = rc;


                // Add column for the budget itself.
                BudgetColumn budgetColumn;
                if (!columns.TryGetValue(DateTime.MinValue, out budgetColumn))
                {
                    budgetColumn = new BudgetColumn()
                    {
                        Name = BudgetColumnHeader,
                    };
                    columns[DateTime.MinValue] = budgetColumn;
                }
                budgetColumn.Total += rc.Budget;

                foreach (BudgetData b in this.Compute())
                {
                    BudgetRow row = null;
                    if (!rows.TryGetValue(rowHeader, out row))
                    {
                        row = new BudgetRow()
                        {
                            Name   = rowHeader,
                            Budget = rc.Budget
                        };
                        rows[rowHeader] = row;
                    }

                    DateTime budgetDate = new DateTime(b.BudgetDate.Year, b.BudgetDate.Month, 1);
                    row.Actuals.Add((decimal)b.Actual);
                    row.Headers.Add(b.Name);

                    // Add column for this BudgetData
                    BudgetColumn col;
                    if (!columns.TryGetValue(budgetDate, out col))
                    {
                        col = new BudgetColumn()
                        {
                            Date = budgetDate,
                            Name = b.Name
                        };
                        columns[budgetDate] = col;
                    }
                    col.Total += (decimal)b.Actual;
                }
            }

            writer.StartTable();

            writer.StartColumnDefinitions();
            writer.WriteColumnDefinition("300", 300, 300); // category names
            foreach (var pair in from p in columns orderby p.Key select p)
            {
                writer.WriteColumnDefinition("Auto", 100, double.MaxValue); // decimal values.
            }
            writer.WriteColumnDefinition("Auto", 100, double.MaxValue);     // total.
            writer.EndColumnDefinitions();

            // write table headers
            List <string> master = new List <string>();

            writer.StartHeaderRow();
            writer.StartCell();
            writer.EndCell();
            foreach (var pair in from p in columns orderby p.Key select p)
            {
                BudgetColumn c    = pair.Value;
                string       name = c.Name;
                if (name != BudgetColumnHeader)
                {
                    master.Add(name); // list of all columns we have found (not including "Budget" column)
                }
                writer.StartCell();
                writer.WriteNumber(name);
                writer.EndCell();
            }
            writer.StartCell();
            writer.WriteNumber("Balance");
            writer.EndCell();
            writer.EndRow();

            Brush   overBudgetBrush = Brushes.Red;
            decimal totalBalance    = 0;

            // Now write out the rows.
            foreach (BudgetRow row in from r in rows.Values orderby r.Name select r)
            {
                writer.StartRow();
                writer.StartCell();
                writer.WriteParagraph(row.Name);
                writer.EndCell();

                writer.StartCell();
                decimal budget = row.Budget;
                writer.WriteNumber(budget.ToString("C"));
                writer.EndCell();

                decimal balance = 0;

                foreach (string col in master)
                {
                    writer.StartCell();
                    int i = row.Headers.IndexOf(col);
                    if (i >= 0)
                    {
                        decimal actual = row.Actuals[i];
                        writer.WriteNumber(actual.ToString("C"), FontStyles.Normal, FontWeights.Normal,
                                           actual > budget ? overBudgetBrush : null);

                        balance += (row.Budget - actual);
                    }
                    writer.EndCell();
                }

                totalBalance += balance;

                writer.StartCell();
                writer.WriteNumber(balance.ToString("C"));
                writer.EndCell();

                writer.EndRow();
            }

            // Now write out the totals.
            writer.StartHeaderRow();
            writer.StartCell();
            writer.EndCell();
            foreach (var pair in from p in columns orderby p.Key select p)
            {
                BudgetColumn c = pair.Value;
                writer.StartCell();
                writer.WriteNumber(c.Total.ToString("C"));
                writer.EndCell();
            }
            writer.StartCell();
            writer.WriteNumber(totalBalance.ToString("C"));
            writer.EndCell();

            writer.EndRow();

            writer.EndTable();

            writer.WriteParagraph("Generated on " + DateTime.Today.ToLongDateString(), System.Windows.FontStyles.Italic, System.Windows.FontWeights.Normal, System.Windows.Media.Brushes.Gray);
        }
Esempio n. 9
0
 internal BudgetVm(KontoVm aKontoVm, BudgetRow aRow)
 {
     this.Row      = aRow;
     this.mKontoVm = aKontoVm;
 }
Esempio n. 10
0
 internal BudgetVm(KontoVm aKontoVm)
 {
     this.Row         = BudgetRow.InitEmpty();
     this.mKontoVm    = aKontoVm;
     this.Row.IDKonto = this.mKontoVm.Id;
 }