Exemple #1
0
        public void ClassifySingleTransaction()
        {
            SingleTransactionLine line = new SingleTransactionLine(TransactionLineBuilder.BuildDefaultTransactionInfo());

            line.Classify(TransactionLineBuilder.BuildDefaultClssification());

            TransactionLineBuilder.ValidateTransactionLine(line);
        }
Exemple #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);
        }
Exemple #3
0
        public void CreateRecurringTransactionsRespectingEndDate()
        {
            List <TransactionLine> lines       = new List <TransactionLine>();
            RecurringTransaction   transaction = TransactionLineBuilder.BuildRecurringTransaction(TransactionLineBuilder.DefaultAmount);

            transaction.EndYearMonth = new YearMonth(2019, 2);

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

            Assert.Equal(2, lines.Count);
        }
        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);
        }
Exemple #5
0
        public void CreateRealizedTransactionLineFromSingleTransaction()
        {
            ExecutedTransactionLine statementLine = new ExecutedTransactionLine(TransactionLineBuilder.BuildDefaultTransactionInfo());

            TransactionLineInfo   lineInfo = new TransactionLineInfo(new DateTime(2019, 4, 12), 2_000m, "transaction description");
            SingleTransactionLine singleTransactionLine = new SingleTransactionLine(lineInfo);

            singleTransactionLine.Classify(TransactionLineBuilder.BuildDefaultClssification());

            ExecutedTransactionLine line = singleTransactionLine.Consolidate(statementLine);

            TransactionLineBuilder.ValidateTransactionLine(line, description: lineInfo.Description);
            Assert.Equal(900m, line.Difference);
        }
        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);
        }
        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);
        }
Exemple #8
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);
        }
        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);
        }
Exemple #10
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);
        }
Exemple #11
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));
        }
        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);
        }
        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);
        }
Exemple #14
0
 public TransactionListBuilder Add(decimal amount, string description = "farmácia", int day = 10, int month = 4, string category = "Moradia")
 {
     transactionList.Add(TransactionLineBuilder.BuildSingleTransactionLine(amount, description, day, month, category));
     return(this);
 }