Ejemplo 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);
        }
Ejemplo n.º 2
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);
        }