Esempio n. 1
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);
        }
Esempio n. 2
0
        public IActionResult AddBudget(BudgetDto budget)
        {
            var recurrence = new MontlyBudget(
                budget.Category,
                budget.Amount,
                budget.Day);

            montlyBudgetRepository.Add(recurrence);

            return(Ok());
        }
Esempio n. 3
0
        public IActionResult UpdateBudget(BudgetDto dto)
        {
            MontlyBudget budget =
                dto.Id == 0
                ? montlyBudgetRepository.GetByCategory(dto.Category)
                : montlyBudgetRepository.GetById(dto.Id);

            budget.Category     = dto.Category;
            budget.Available    = dto.Amount;
            budget.ExecutionDay = dto.Day;

            return(Ok());
        }
Esempio n. 4
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);
        }