Fix null payee.

This commit is contained in:
Chris Chen
2026-06-20 18:05:22 -07:00
parent 3558c67fd7
commit 2af169fa60
3 changed files with 42 additions and 9 deletions
+10 -5
View File
@@ -141,12 +141,17 @@ public class ExpenseService : IExpenseService
}
else // StaffReimbursement
{
// Finance entering on behalf of a member goes straight to the approval queue;
// a member's own self-service entry stays a Draft until they explicitly Submit it.
e.Status = isFinance ? "PendingApproval" : "Draft";
// Distinguish the two flows by whether a member was explicitly picked, NOT by role:
// - On-behalf: finance picks a member (Expenses page) -> straight into the approval queue.
// - Self-service: no member picked ("My Reimbursements") -> link to the caller's own member
// so the Payee shows their legal name, and keep it a Draft until they explicitly Submit.
// A finance/super_admin user files their own reimbursements through the self-service flow too,
// so keying off the role alone would leave their entries with a null member (empty Payee).
var isOnBehalf = isFinance && r.MemberId.HasValue;
e.Status = isOnBehalf ? "PendingApproval" : "Draft";
e.SubmittedBy = CurrentUserId;
if (isFinance) e.SubmittedAt = DateTimeOffset.UtcNow;
e.MemberId = isFinance ? r.MemberId : await CallerMemberIdAsync();
if (isOnBehalf) e.SubmittedAt = DateTimeOffset.UtcNow;
e.MemberId = isOnBehalf ? r.MemberId : await CallerMemberIdAsync();
e.VendorName = null;
}