Exemplo n.º 1
0
        public void CreateMonthlyStatementWithRecurringInformation()
        {
            List <RecurringTransaction> recurringTransactions = new List <RecurringTransaction>()
            {
                new RecurringTransaction("Conta de Luz", -200m, 15, new ClassificationInfo("Moradia", ClassificationInfo.ResponsibleAll, Importance.Essential))
            };

            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(TransactionLineBuilder.BuildExecutedRecurringTransactionLine(-100m, description: "Conta de Luz", day: 15, month: 4))
                                                .Add(-800m, day: 22, month: 4)
                                                .Add(1_000m, day: 07, month: 4)
                                                .Add(-800m, day: 22, month: 6)
                                                .Add(1_000m, day: 07, month: 6)
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(statements,
                                                               new List <IViewerPipeline>()
            {
                new RecurringTransactionsPipeline(recurringTransactions, new YearMonth(2019, 7))
            })
                                        .Build(100m);

            Assert.Equal(4, months.Count);
            ValitadeMonth(months[0], 4, 100m, 200m, 3);
            ValitadeMonth(months[1], 5, 200m, 0m, 1);
            ValitadeMonth(months[2], 6, 0m, 0m, 3);
            ValitadeMonth(months[3], 7, 0m, -200m, 1);
        }
Exemplo n.º 2
0
        public void ProcessBudget_ShouldIgnoreMultiline()
        {
            MultilineTransactionLine line = TransactionLineBuilder.BuildMultilineTransactionLine();

            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-100m, "farmácia", category: "saude"));
            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-300m, "supermercado"));

            MultilineTransactionLine line2 = TransactionLineBuilder.BuildMultilineTransactionLine();

            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-300m, "farmácia", category: "saude"));
            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-500m, "supermercado"));

            ExecutedMultilineTransactionLine executedLine = line2.Consolidate(
                TransactionLineBuilder.BuildExecutedCreditcardTransactionLine(-1_000m));

            List <TransactionLine> lines = TransactionLineBuilder.BuildList()
                                           .Add(-300m, "Eletropaulo", day: 14)
                                           .Add(-500m, "Faculdade", day: 18, category: "Educação")
                                           .Add(line)
                                           .Add(executedLine)
                                           .Add(-800m, "Aluguel", day: 22)
                                           .Build();

            MontlyBudget budget = new MontlyBudget(TransactionLineBuilder.DefaultCategory, 2_000m, 15);

            MontlyBudget processedBudget = budget.Process(lines);

            Assert.Equal(1_100m, processedBudget.Used);
            Assert.Equal(900m, processedBudget.Available);
        }
Exemplo n.º 3
0
        public void CreateMonthlyStatement()
        {
            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(1_000m, "salary", day: 07, category: "Entrada")
                                                .Add(-800m, "aluguel", day: 10, category: "Educação")
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(statements).Build(100m);

            Assert.Single(months);
            ValitadeMonth(months.First(), 4, 100m, 300m, 2);
        }
Exemplo n.º 4
0
        public void CreateMonthlyStatementForMoreMonthsFillingEmptyMonths()
        {
            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(-800m, day: 22, month: 4)
                                                .Add(1_000m, day: 07, month: 4)
                                                .Add(-800m, day: 22, month: 6)
                                                .Add(1_000m, day: 07, month: 6)
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(statements).Build(100m);

            Assert.Equal(3, months.Count);
            ValitadeMonth(months[0], 4, 100m, 300m, 2);
            ValitadeMonth(months[1], 5, 300m, 300m, 0);
            ValitadeMonth(months[2], 6, 300m, 500m, 2);
        }
Exemplo n.º 5
0
        public void CreateMonthlyStatementShouldDiplayOrderedData()
        {
            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(-240m, day: 22)
                                                .Add(1_000m, day: 07)
                                                .Add(-800m, day: 10)
                                                .Add(-90m, day: 09)
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(statements).Build(100m);

            Assert.Equal(DateTime.Parse("2019-04-07"), months.First().Lines[0].TransactionDate);
            Assert.Equal(DateTime.Parse("2019-04-09"), months.First().Lines[1].TransactionDate);
            Assert.Equal(DateTime.Parse("2019-04-10"), months.First().Lines[2].TransactionDate);
            Assert.Equal(DateTime.Parse("2019-04-22"), months.First().Lines[3].TransactionDate);
        }
Exemplo n.º 6
0
        public void CreateRecurringTransactions()
        {
            List <TransactionLine> lines = TransactionLineBuilder.BuildList()
                                           .Add(TransactionLineBuilder.DefaultAmount, month: 4)
                                           .Build();

            RecurringTransaction transaction = TransactionLineBuilder.BuildRecurringTransaction(TransactionLineBuilder.DefaultAmount);

            transaction.IncludeLines(lines, new YearMonth(2019, 4), new YearMonth(2019, 6));

            Assert.Equal(4, lines.Count);

            RecurringTransactionLine line = GetFist <RecurringTransactionLine>(lines);

            TransactionLineBuilder.ValidateTransactionLine(line);
        }
Exemplo n.º 7
0
        public void BudgetShouldNotBeNegative()
        {
            List <TransactionLine> lines = TransactionLineBuilder.BuildList()
                                           .Add(-1_500m, "Eletropaulo", day: 14)
                                           .Add(-800m, "Faculdade", day: 18, category: "Educação")
                                           .Add(-1_000m, "Aluguel", day: 22)
                                           .Build();

            MontlyBudget budget = new MontlyBudget(TransactionLineBuilder.DefaultCategory, 2_000m, 15);

            MontlyBudget processedBudget = budget.Process(lines);

            Assert.Equal(0m, budget.Used);
            Assert.Equal(2_000m, budget.Available);

            Assert.Equal(2_500, processedBudget.Used);
            Assert.Equal(0m, processedBudget.Available);
        }
Exemplo n.º 8
0
        public void CreateRecurringTransactionsConsideringExecutedRecurringTransactions()
        {
            List <TransactionLine> lines = TransactionLineBuilder.BuildList()
                                           .Add(TransactionLineBuilder.BuildExecutedRecurringTransactionLine(TransactionLineBuilder.DefaultAmount, month: 4))
                                           .Add(TransactionLineBuilder.BuildExecutedRecurringTransactionLine(TransactionLineBuilder.DefaultAmount, month: 5))
                                           .Add(TransactionLineBuilder.DefaultAmount, month: 6)
                                           .Add(TransactionLineBuilder.DefaultAmount, month: 7)
                                           .Build();

            RecurringTransaction transaction = TransactionLineBuilder.BuildRecurringTransaction(TransactionLineBuilder.DefaultAmount);

            transaction.IncludeLines(lines, new YearMonth(2019, 4), new YearMonth(2019, 7));

            Assert.Equal(6, lines.Count);

            RecurringTransactionLine line = GetFist <RecurringTransactionLine>(lines);

            TransactionLineBuilder.ValidateTransactionLine(line, date: new DateTime(2019, 6, TransactionLineBuilder.DefaultDay));
        }
Exemplo n.º 9
0
        public void CreateMonthlyStatementWithMonthlyBudget()
        {
            List <MontlyBudget> budgets = new List <MontlyBudget>()
            {
                new MontlyBudget(TransactionLineBuilder.DefaultCategory, 1_000m, 15)
            };

            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(-200m, day: 29, month: 4)
                                                .Add(-800m, day: 22, month: 4)
                                                .Add(1_000m, day: 07, month: 4, category: "Entrada")
                                                .Add(-800m, day: 22, month: 6)
                                                .Add(1_000m, day: 07, month: 6, category: "Entrada")
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(
                statements, new List <IViewerPipeline>()
            {
                new MontlyBudgetPipeline(budgets)
            })
                                        .Build(100m);

            Assert.Equal(3, months.Count);
            ValitadeMonth(months[0], 4, 100m, 100m, 3);
            ValitadeMonth(months[1], 5, 100m, -900m, 1);
            ValitadeMonth(months[2], 6, -900m, -900m, 3);

            Assert.Single(months[0].Budgets);
            Assert.Equal(0m, months[0].Budgets.First().Available);
            Assert.Equal(1_000m, months[0].Budgets.First().Used);

            Assert.Single(months[1].Budgets);
            Assert.Equal(1_000m, months[1].Budgets.First().Available);
            Assert.Equal(0m, months[1].Budgets.First().Used);

            Assert.Single(months[2].Budgets);
            Assert.Equal(200m, months[2].Budgets.First().Available);
            Assert.Equal(800m, months[2].Budgets.First().Used);
        }
Exemplo n.º 10
0
        public void CreateMonthlyStatementWithMonthlyBudgetForMultilineTransactions()
        {
            List <MontlyBudget> budgets = new List <MontlyBudget>()
            {
                new MontlyBudget(TransactionLineBuilder.DefaultCategory, 1_000m, 15)
            };

            var multiline = TransactionLineBuilder.BuildMultilineTransactionLine(month: 5);

            multiline.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-100m, "farmácia", month: 4));
            multiline.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-300m, "supermercado", month: 4));

            List <TransactionLine> statements = TransactionLineBuilder.BuildList()
                                                .Add(-500m, day: 22, month: 4)
                                                .Add(multiline)
                                                .Build();

            List <MonthlyView> months = new MonthlyViewBuilder(
                statements, new List <IViewerPipeline>()
            {
                new MontlyBudgetPipeline(budgets)
            })
                                        .Build(0m);

            Assert.Equal(2, months.Count);
            ValitadeMonth(months[0], 4, 0m, -600m, 2);
            ValitadeMonth(months[1], 5, -600m, -2_000m, 2);

            Assert.Single(months[0].Budgets);
            Assert.Equal(100m, months[0].Budgets.First().Available);
            Assert.Equal(900m, months[0].Budgets.First().Used);

            Assert.Single(months[1].Budgets);
            Assert.Equal(1_000m, months[1].Budgets.First().Available);
            Assert.Equal(0m, months[1].Budgets.First().Used);
        }