Example #1
0
        private Dictionary <MonthAndYear, Ledger> CreateMonthlyLedgers(Dictionary <MonthAndYear, IncomeExpensesAndTax> monthlyIncomeExpensesAndTax, MonthlyAccountCategorySums monthlyAccountCategorySums)
        {
            var monthlyLedgers = new Dictionary <MonthAndYear, Ledger>();

            foreach (var pair in monthlyIncomeExpensesAndTax)
            {
                var monthAndYear         = pair.Key;
                var incomeExpensesAndTax = pair.Value;

                var income         = pair.Value.Income;
                var expenses       = pair.Value.Expenses;
                var tax            = pair.Value.Tax;
                var ownPension     = monthlyAccountCategorySums.GetOwnPensionSavings(monthAndYear);
                var summedFortunes = monthlyAccountCategorySums.GetFortunesWithoutPension(monthAndYear);
                var values         = new Ledger
                {
                    Income = income,
                    IncomeWithoutTaxAndPension = income - tax - ownPension,
                    Expenses           = expenses,
                    ExpensesWithoutTax = expenses - tax,
                    Tax                = tax,
                    OwnPension         = ownPension,
                    Fortune            = summedFortunes,
                    FortuneIncrease    = monthlyAccountCategorySums.GetFortune(monthAndYear),
                    InvestmentIncrease = monthlyAccountCategorySums.GetInvestment(monthAndYear),
                };

                monthlyLedgers.Add(monthAndYear, values);
            }

            return(monthlyLedgers);
        }
Example #2
0
        public void GetOwnPensionSavings_DifferentScenarios_ShouldReturnCorrectValue(Dictionary <MonthAndYear, Dictionary <string, double> > dictionary, MonthAndYear monthAndYear, double expectedPension)
        {
            var sut = new MonthlyAccountCategorySums(dictionary);

            var ownPension = sut.GetOwnPensionSavings(monthAndYear);

            Assert.AreEqual(expectedPension, ownPension);
        }