update detail.
ci-cd-vm / ci-cd (push) Successful in 4m27s

This commit is contained in:
Chris Chen
2026-06-25 09:33:49 -07:00
parent 609ce6a439
commit 8bdb942a49
23 changed files with 698 additions and 271 deletions
@@ -53,17 +53,24 @@ public class FinanceDashboardService : IFinanceDashboardService
DateOnly? from, DateOnly? to, int? ministryId, int? categoryGroupId)
{
var q = PaidApproved(from, to);
if (ministryId.HasValue) q = q.Where(e => e.MinistryId == ministryId.Value);
if (categoryGroupId.HasValue) q = q.Where(e => e.CategoryGroupId == categoryGroupId.Value);
if (ministryId.HasValue) q = q.Where(e => e.MinistryId == ministryId.Value);
// Group by the deepest level whose parent id is supplied.
// Lines belonging to the scoped (Paid+Approved, optionally ministry-filtered) expenses.
var scopedLines = from l in _db.ExpenseLines
join e in q on l.ExpenseId equals e.Id
select l;
// Group by the deepest level whose parent id is supplied. Category levels aggregate
// over LINES (line amounts); the ministry level uses the header total to avoid
// double-counting a multi-line expense across its lines.
List<(int Id, decimal Amount)> grouped;
if (categoryGroupId.HasValue)
grouped = (await q.GroupBy(e => e.SubCategoryId)
grouped = (await scopedLines.Where(l => l.CategoryGroupId == categoryGroupId.Value)
.GroupBy(l => l.SubCategoryId)
.Select(g => new { Id = g.Key, Amount = g.Sum(x => x.Amount) }).ToListAsync())
.Select(x => (x.Id, x.Amount)).ToList();
else if (ministryId.HasValue)
grouped = (await q.GroupBy(e => e.CategoryGroupId)
grouped = (await scopedLines.GroupBy(l => l.CategoryGroupId)
.Select(g => new { Id = g.Key, Amount = g.Sum(x => x.Amount) }).ToListAsync())
.Select(x => (x.Id, x.Amount)).ToList();
else