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
+14 -1
View File
@@ -40,6 +40,19 @@ public class DisbursementService : IDisbursementService
var memberIds = rows.Where(r => r.MemberId != null).Select(r => r.MemberId!.Value).ToHashSet();
var members = await _db.Members.AsNoTracking().Where(m => memberIds.Contains(m.Id)).ToDictionaryAsync(m => m.Id);
// Category label per expense: the single line's category, or "Multiple" when it spans several.
var expenseIds = rows.Select(r => r.Id).ToList();
var lineGroups = await _db.ExpenseLines.AsNoTracking()
.Where(l => expenseIds.Contains(l.ExpenseId))
.OrderBy(l => l.Id)
.Select(l => new { l.ExpenseId, l.CategoryGroupId })
.ToListAsync();
var categoryByExpense = lineGroups.GroupBy(l => l.ExpenseId).ToDictionary(
g => g.Key,
g => g.Select(l => l.CategoryGroupId).Distinct().Count() > 1
? "Multiple / 多類別"
: grpNames.GetValueOrDefault(g.First().CategoryGroupId, ""));
var groups = new Dictionary<string, PayeeGroupDto>();
foreach (var e in rows)
{
@@ -77,7 +90,7 @@ public class DisbursementService : IDisbursementService
ExpenseId = e.Id, ExpenseDate = e.ExpenseDate.ToString("yyyy-MM-dd"),
Description = e.Description, Amount = e.Amount,
MinistryName = minNames.GetValueOrDefault(e.MinistryId, ""),
CategoryName = grpNames.GetValueOrDefault(e.CategoryGroupId, ""),
CategoryName = categoryByExpense.GetValueOrDefault(e.Id, ""),
});
g.TotalAmount += e.Amount;
}