public AnnualBudgetReport(IMoneyCalculator calculator, IEnumerable <MonthlyBudgetReport> months)
        {
            Months = months.ToList();

            Income  = FinancialStats.GetTotal(calculator, Months.Select(n => n.Income));
            Expense = FinancialStats.GetTotal(calculator, Months.Select(n => n.Expense));

            Balance = FinancialStats.GetBalance(calculator, Income, Expense);
        }
Esempio n. 2
0
        public FinancialStats GetStats()
        {
            FinancialStats stats       = new FinancialStats();
            var            foodSold    = _foodRepo.GetAllSold();
            var            ticketsSold = _ticketRepo.GetAllSold();

            //Calculate Average Stats
            stats.AverageTicketProfit   = ticketsSold.Sum(x => x.Profit) / ticketsSold.Sum(x => x.Quantity);
            stats.AverageFoodItemProfit = foodSold.Sum(x => x.Profit) / foodSold.Sum(x => x.Quantity);

            return(stats);
        }
Esempio n. 3
0
        public MonthLog(BudgetLogType log,
                        YearMonth when,
                        IMoneyCalculator calculator,
                        IEnumerable <Transaction> actual = null,
                        IEnumerable <Forecast> forecast  = null)
        {
            When         = when;
            Transactions = actual?.Where(n => n.Log == log).ToList() ?? new List <Transaction>();
            Forecasts    = forecast?.Where(n => n.Log == log).ToList() ?? new List <Forecast>();

            Total = FinancialStats.GetTotal(calculator,
                                            Transactions.Select(n => n.Amount),
                                            Forecasts.Select(n => n.Amount));
        }
Esempio n. 4
0
        public ExpenseCategoryReport(Category category,
                                     IMoneyCalculator calculator,
                                     MonthLog expenseLog)
        {
            CategoryKey = category.Key;
            Title       = category.Title;
            Description = category.Description;

            Total = FinancialStats.GetTotal(calculator,
                                            expenseLog.Transactions
                                            .Where(n => category.IsSameOrParentOf(n.CategoryKey))
                                            .Select(n => n.Amount),
                                            expenseLog.Forecasts
                                            .Where(n => category.IsSameOrParentOf(n.CategoryKey))
                                            .Select(n => n.Amount)
                                            );
        }
Esempio n. 5
0
        public MonthlyBudgetReport(YearMonth when, IMoneyCalculator calculator,
                                   IEnumerable <Category> categories,
                                   MonthLog incomeLog,
                                   MonthLog expenseLog)
        {
            if (incomeLog.Log != BudgetLogType.Incomes)
            {
                throw new ArgumentException(nameof(incomeLog));
            }
            if (expenseLog.Log != BudgetLogType.Expenses)
            {
                throw new ArgumentException(nameof(expenseLog));
            }

            When = when;

            Income  = incomeLog.Total;
            Expense = expenseLog.Total;
            Balance = FinancialStats.GetBalance(calculator, Income, Expense);

            Expenses = GetExpensesReport(calculator, categories, expenseLog);
        }