@@ -36,9 +36,9 @@ public class Form990ReportServiceTests
|
||||
|
||||
private static Expense Exp(int min, int sub, decimal amt, string status, string? fc = null) => new()
|
||||
{
|
||||
MinistryId = min, CategoryGroupId = 1, SubCategoryId = sub, Type = "VendorPayment",
|
||||
MinistryId = min, Type = "VendorPayment",
|
||||
Status = status, Amount = amt, Description = "x", ExpenseDate = new DateOnly(2026, 5, 10),
|
||||
FunctionalClass = fc,
|
||||
Lines = { new ExpenseLine { CategoryGroupId = 1, SubCategoryId = sub, Amount = amt, FunctionalClass = fc } },
|
||||
};
|
||||
|
||||
[Fact]
|
||||
@@ -82,4 +82,31 @@ public class Form990ReportServiceTests
|
||||
var stmt = await svc.GetFunctionalExpenseStatementAsync(new DateOnly(2026, 5, 1), new DateOnly(2026, 5, 31));
|
||||
Assert.Equal(100m, stmt.GrandTotal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Statement_SplitsOneExpenseAcrossLines()
|
||||
{
|
||||
// One invoice with two lines of different categories must land on two different 990 lines.
|
||||
using var db = BuildDb();
|
||||
await SeedAsync(db);
|
||||
db.Expenses.Add(new Expense
|
||||
{
|
||||
MinistryId = 2, Type = "VendorPayment", Status = "Paid", Amount = 70m,
|
||||
Description = "mixed", ExpenseDate = new DateOnly(2026, 5, 10),
|
||||
Lines =
|
||||
{
|
||||
new ExpenseLine { CategoryGroupId = 1, SubCategoryId = 1, Amount = 50m }, // sub→line 7
|
||||
new ExpenseLine { CategoryGroupId = 1, SubCategoryId = 2, Amount = 20m }, // sub unmapped→group fallback line 24
|
||||
},
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
var svc = new Form990ReportService(db);
|
||||
|
||||
var stmt = await svc.GetFunctionalExpenseStatementAsync(null, null);
|
||||
|
||||
Assert.Equal(50m, stmt.Rows.Single(r => r.LineCode == "7").Program); // ministry 2 default = Program
|
||||
Assert.Equal(20m, stmt.Rows.Single(r => r.LineCode == "24").Program);
|
||||
Assert.Equal(70m, stmt.GrandTotal);
|
||||
Assert.Equal(1, stmt.UnmappedExpenseCount); // one unmapped line
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user