public IActionResult Index(DateTime?month, int budgetId = 1) { if (month == null) { month = DateTime.UtcNow; } ViewBag.month = month; ViewBag.budgetId = budgetId; var budgets = budgetDac.Get().ToList(); budgets.Add(new Budget { Id = 0, Name = "ภาษี ณ ที่จ่าย", }); ViewBag.budgets = budgets.OrderBy(x => x.Name); var partners = partnerDac.Get(); var transactions = budgetId switch { 0 => transactionDac.GetTeackVat(month.Value).OrderBy(x => x.IssueDate).ThenBy(x => x.Id).Select(x => new Transaction { Id = x.Id, IssueDate = x.IssueDate, Title = $"รับเงินภาษี ณ ที่จ่ายจาก {partners.FirstOrDefault(p => p.Id == x.PartnerId)?.Name}", Amount = x.VatInclude.Value, }).ToList(), _ => transactionDac.Get(month.Value, budgetId).OrderBy(x => x.IssueDate).ThenBy(x => x.Id).ToList(), }; var bringForword = bringForwardDac.Get(month.Value, budgetId); if (bringForword != null) { transactions.Insert(0, new Transaction { IssueDate = new DateTime(month.Value.Year, month.Value.Month, 1), Title = "ยอดยกมา", Amount = bringForword?.Amount ?? 0, BudgetId = bringForword.BudgetId, }); } return(View(transactions)); }