Exemplo 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);
        }
Exemplo n.º 2
0
        public void AddLinesToMultilineTransactionLine()
        {
            MultilineTransactionLine line = TransactionLineBuilder.BuildMultilineTransactionLine();

            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-300));
            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-500, "supermercado"));

            Assert.Equal(2, line.Lines.Count);
            Assert.Equal(-800m, line.Amount);
        }
Exemplo n.º 3
0
        public void ConsolidateMultilineTransactionLine()
        {
            MultilineTransactionLine line = TransactionLineBuilder.BuildMultilineTransactionLine();

            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-300));
            line.Add(TransactionLineBuilder.BuildMultilineDetailTransactionLine(-500, "supermercado"));

            ExecutedTransactionLine statementLine = TransactionLineBuilder.BuildExecutedCreditcardTransactionLine(-1_000m);

            ExecutedMultilineTransactionLine executedLine = line.Consolidate(statementLine);

            Assert.Equal(2, executedLine.Lines.Count);

            Assert.Equal(statementLine.Amount, executedLine.Amount);
            Assert.Equal(statementLine.TransactionDate, executedLine.TransactionDate);

            Assert.Equal(line.Description, executedLine.Description);
            Assert.Equal(200m, executedLine.Difference);
        }
Exemplo n.º 4
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);
        }