public async Task <ActionResult> MontlyReport(int year, int month) { var accounts = await _accountRepo.FindAll(); var archivedTransactions = await ArchiveTransactions(); var monthlyTransactions = await _transactionRepo.GetMontlyTransactions(month, year); var expenseAccounts = await _accountRepo.GetAccountByType(AccountType.Expense); var incomeAccounts = await _accountRepo.GetAccountByType(AccountType.Income); var monthlyExpenseReports = CreateReports(AccountType.Expense, monthlyTransactions, expenseAccounts); var montlyIncomeReports = CreateReports(AccountType.Income, monthlyTransactions, incomeAccounts); var reportViewModel = new ListReportVM() { Accounts = accounts, IncomeReports = montlyIncomeReports, ExpenseReports = monthlyExpenseReports, Archives = archivedTransactions }; //use the same view as no need for different return(View(nameof(Index), reportViewModel)); }
// GET: ReportController public async Task <ActionResult> Index() { //Archive all transactions in months and years to create a report navigation bar //The user then can view transactions by months and years var archivedTransactions = await ArchiveTransactions(); //Get the list of all accounts for the view var accounts = await _accountRepo.FindAll(); //Get the date of the last Friday, because I am getting paid on fridays //and I would like my short term Reports to be from Friday to Thursday DateTime lastFridayDate = GetLastFriday(); //Get all the transactions since last friday //This is for the weekly report, only available for this week for now var thisWeeksTransactions = await _transactionRepo.FilterTransacations(lastFridayDate); var expenseAccounts = await _accountRepo.GetAccountByType(AccountType.Expense); var incomeAccounts = await _accountRepo.GetAccountByType(AccountType.Income); //Create this weeks reports var thisWeeksExpenseReports = CreateReports(AccountType.Expense, thisWeeksTransactions, expenseAccounts); var thisWeeksIncomeReports = CreateReports(AccountType.Income, thisWeeksTransactions, incomeAccounts); //create a report viewModel var reportViewModel = new ListReportVM() { Accounts = accounts, IncomeReports = thisWeeksIncomeReports, ExpenseReports = thisWeeksExpenseReports, Archives = archivedTransactions }; return(View(reportViewModel)); }