Exemple #1
0
        public void Budget_balance_can_be_adjusted()
        {
            IBudget b = new Budget();

            b.AddIncome(year: 2016, amount: 12000, paydayForMonth: 16, title: "Lønn Arne");
            b.AddIncome(year: 2016, amount: 24000, paydayForMonth: 16, title: "Lønn Anne");

            var x = new DateTime(2016, 6, 20);

            b.SetBalance(date: x, newBalance: 50000);

            var balanceForFirstOfJuly = b.GetBalanceForDate(new DateTime(2016, 7, 1));

            Assert.AreEqual(expected: 50000, actual: balanceForFirstOfJuly);
        }
Exemple #2
0
        public void Budget_balance_can_be_adjusted_on_a_date_where_there_is_income()
        {
            IBudget b = new Budget();

            b.AddIncome(year: 2016, amount: 12000, paydayForMonth: 15, title: "Lønn Arne");
            b.AddIncome(year: 2016, amount: 24000, paydayForMonth: 15, title: "Lønn Anne");

            var dateForAdjustment = new DateTime(2016, 6, 15); // this day, we will also have income (Lønn Arne & Al)

            b.SetBalance(dateForAdjustment, 0);

            // the balance for next month should be 3000,-
            var balanceForJulyOnNextPayment = b.GetBalanceForDate(new DateTime(2016, 7, 15));

            Assert.AreEqual(expected: 3000, actual: balanceForJulyOnNextPayment);
        }
Exemple #3
0
        public void Budget_balance_next_year()
        {
            IBudget b = new Budget();

            b.AddIncome(year: 2016, amount: 12000, paydayForMonth: 16, title: "Lønn Arne");
            b.AddIncome(year: 2016, amount: 24000, paydayForMonth: 16, title: "Lønn Anne");

            var totalIncome = b.GetTotalIncomeForYear(2016);

            Assert.AreEqual(expected: 36000, actual: totalIncome);

            var firstOfJuly2017        = new DateTime(2017, 6, 1);
            var balanceForJuneNextYear = b.GetBalanceForDate(firstOfJuly2017);

            Assert.AreEqual(expected: 36000, actual: balanceForJuneNextYear);
        }
Exemple #4
0
        public void Budget_add_income_for_a_year_get_correct_balance()
        {
            IBudget b = new Budget();

            b.AddIncome(year: 2016, amount: 300000, paydayForMonth: 15, title: "Lønn");

            Assert.AreEqual(300000, b.GetBalanceForDate(new DateTime(2016, 12, 31)));
        }
Exemple #5
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            int    index   = HomeCDP.Date.ToString().IndexOf(' ');
            string datestr = HomeCDP.Date.ToString().Remove(index);

            string[] datearr = datestr.Split('/');
            string   binName;
            Drawer   drawer     = DrawersCB.SelectedItem as Drawer;
            Goal     goal       = DrawersCB.SelectedItem as Goal;
            string   drawerName = (drawer != null) ? drawer?.Name : goal?.Name;



            if (SplitTSW.Visibility == Visibility.Visible)
            {
                if (SplitTSW.IsOn == true)
                {
                    budget.AddIncome(Convert.ToDecimal(ValueTB.Text), DescriptionTB.Text,
                                     new DateTime(Convert.ToInt16(datearr[2]), Convert.ToInt16(datearr[0]), Convert.ToInt16(datearr[1])), "Split", true);
                }
                else
                {
                    binName = budget.Bins[BinsCB.SelectedIndex].Name;
                    budget.AddIncome(Convert.ToDecimal(ValueTB.Text), DescriptionTB.Text,
                                     new DateTime(Convert.ToInt16(datearr[2]), Convert.ToInt16(datearr[0]), Convert.ToInt16(datearr[1])),
                                     budget.Bins[BinsCB.SelectedIndex].Name, false);
                }
            }
            else
            {
                binName = budget.Bins[BinsCB.SelectedIndex].Name;
                budget.AddExpense(Convert.ToDecimal(ValueTB.Text), DescriptionTB.Text,
                                  new DateTime(Convert.ToInt16(datearr[2]), Convert.ToInt16(datearr[0]), Convert.ToInt16(datearr[1])),
                                  budget.Bins[BinsCB.SelectedIndex].Name, DrawGoalTSW.IsOn, drawerName);
            }

            // clear values
            DescriptionTB.Text = "";
            ValueTB.Text       = "";
            BudgetsignTB.Text  = (budget.MonthlyBudgets[budget.MonthlyBudgets.Count - 1].Value < 0) ? "-" : "+";
        }
Exemple #6
0
        public void Budget_has_income()
        {
            IBudget b = new Budget();

            for (int i = 0; i < 12; i++)
            {
                b.AddIncome(new Income {
                    Amount = 30000,
                    Date   = new DateTime(2016, i + 1, 15)
                });
            }

            decimal totalIncomeFor2016 = b.GetTotalIncomeForYear(2016);

            Assert.AreEqual(expected: 360000, actual: totalIncomeFor2016);
        }
Exemple #7
0
        public void Budget_balance_for_specific_month_is_less_than_zero()
        {
            IBudget b = new Budget();

            var christmas = new DateTime(2016, 12, 24);

            b.AddExpence(new Expence()
            {
                Amount   = 5000,
                Date     = christmas,
                Interval = Interval.None
            });

            b.AddIncome(new Income()
            {
                Amount = 10000,
                Date   = christmas.AddDays(1)
            });

            var expectedBalance = -5000;
            var actualBalance   = b.GetBalanceForDate(date: christmas);

            Assert.AreEqual(expectedBalance, actualBalance);
        }
Exemple #8
0
        static void Main(string[] args)
        {
            Budget budget = new Budget();

            budget.AddBin("Food", "Everything related to food", 0);
            budget.AddBin("Entertainment", "self-explanatory. games, concerts, etc.", .50);
            budget.AddBin("Projects", "fund my mad scientist ideas", .15);
            budget.AddBin("Gas", "fund my ability to be mobile", .20);
            budget.SavingsPercentage(.15);
            budget.CreateMonthlyBudget();

            budget.AddIncome(5000, "Paycheck", DateTime.Now, "Split");
            budget.AddIncome(250, "Grocery Money", DateTime.Now, "Food");

            budget.AddExpense(20.48, "Grocery", new DateTime(2018, 11, 13), "Food");
            budget.AddExpense(33.89, "Gas", new DateTime(2018, 11, 13), "Gas");
            budget.AddExpense(42.14, "Gym Membership", new DateTime(2018, 11, 13), "Entertainment");
            budget.AddExpense(4.93, "Krispy Kreme", new DateTime(2018, 11, 6), "Food");
            budget.AddExpense(31.63, "Gas", new DateTime(2018, 11, 5), "Gas");
            budget.AddExpense(6.87, "Bojangles", new DateTime(2018, 11, 2), "Food");
            budget.AddExpense(36.12, "Gas", new DateTime(2018, 11, 1), "Gas");

            budget.AddIncome(176.45, "Paycheck", new DateTime(2018, 11, 21), "Split");
            budget.AddIncome(10.10, "Tip!", new DateTime(2018, 11, 9), "Split");
            budget.AddIncome(22.00, "Paycheck", new DateTime(2018, 11, 1), "Split");
            budget.AddIncome(48.18, "Paycheck", new DateTime(2018, 11, 1), "Split");
            budget.AddIncome(34.25, "Paycheck", new DateTime(2018, 10, 25), "Split");
            budget.AddIncome(21.87, "Paycheck", new DateTime(2018, 10, 25), "Split");
            budget.AddIncome(171.32, "Paycheck", new DateTime(2018, 11, 6), "Split");
            budget.AddIncome(220.00, "Paycheck", DateTime.Today, "Split");

            budget.TransferFunds("Gas", "Savings", 500, DateTime.Now);
            budget.CalcBinBalance();

            foreach (Bin bin in budget.Bins)
            {
                Console.WriteLine("{1}: {0:C2}", bin.GetBalance(), bin.Name);
            }
            Console.WriteLine("{1}: {0:C2}", budget.Savings.GetBalance(), "Savings");
            Console.WriteLine("Total Balance : {0:C2}", budget.TotalBalance());
            Console.WriteLine("Monthly budget : {0:C2}", budget.MonthlyBudgets[0].Value);
            Console.ReadLine();
            //budget.AddExpense(17.75, "food", new DateTime(2025, 8, 18), "Food");



            /*
             * Bin bin = new Bin();
             * bin.AddExpense();
             * bin.AddExpense();
             * bin.AddExpense();
             * bin.AddExpense(42.14, "Gym Membership", new DateTime(2018, 11, 13));
             * bin.AddExpense(4.93, "Krispy Kreme", new DateTime(2018, 11, 6));
             * bin.AddExpense(31.63, "Gas", new DateTime(2018, 11, 5));
             * bin.AddExpense(6.87, "Bojangles", new DateTime(2018, 11, 2));
             * bin.AddExpense(36.12, "Gas", new DateTime(2018, 11, 1));
             *
             *
             *
             *
             * bin.AddIncome(176.45, "Paycheck", new DateTime(2018, 11, 21));
             * bin.AddIncome(10.10, "Tip!", new DateTime(2018, 11, 9));
             * bin.AddIncome(22.00, "Paycheck", new DateTime(2018, 11, 1));
             * bin.AddIncome(48.18, "Paycheck", new DateTime(2018, 11, 1));
             * bin.AddIncome(34.25, "Paycheck", new DateTime(2018, 10, 25));
             * bin.AddIncome(21.87, "Paycheck", new DateTime(2018, 10, 25));
             * bin.AddIncome(171.32, "Paycheck", new DateTime(2018,11,6));
             * bin.AddIncome(220.00, "Paycheck", DateTime.Today);
             *
             * Console.WriteLine("what is happening");
             *
             *
             * Console.WriteLine("Incomes     Expenses");
             * for(int i = 0; i < bin.ExpenseSize(); i++)
             * {
             *   Console.WriteLine("{0:C}     {1:C}", bin.GetIValue(i), bin.GetEValue(i));
             * }
             *
             * Console.WriteLine("Bin Balance {0:C}", bin.GetBalance());
             *
             * Console.ReadLine();
             * /* Console.WriteLine("{0:C} {1:C} Balance {2:C}", bin.GetIValue(0), bin.GetEValue(0), bin.CalcBalance());
             *
             * string myName = "Jonathan Service";
             * char initial = 'J';
             * initial = myName[1]; */
        }