feat(1099): carry PayeeId through expense create/update/read
Add int? PayeeId to CreateExpenseRequest (UpdateExpenseRequest inherits) and to ExpenseListItemDto (so it round-trips to the form). Set e.PayeeId unconditionally in CreateAsync and UpdateAsync so 1099 attribution is independent of VendorPayment vs StaffReimbursement type. Map PayeeId in both DTO projections: the paged-list lambda and GetByIdAsync. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,7 @@ public class ExpenseListItemDto
|
||||
public string? ReviewedByName { get; set; } // resolved Member full name, email fallback
|
||||
public DateTimeOffset? ReviewedAt { get; set; }
|
||||
public string? ReviewNotes { get; set; } // reject reason (or approval note)
|
||||
public int? PayeeId { get; set; }
|
||||
}
|
||||
|
||||
public class ExpenseDto : ExpenseListItemDto
|
||||
@@ -66,6 +67,7 @@ public class CreateExpenseRequest
|
||||
[MaxLength(50)] public string? CheckNumber { get; set; }
|
||||
[Required] public DateOnly ExpenseDate { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
public int? PayeeId { get; set; }
|
||||
}
|
||||
public class UpdateExpenseRequest : CreateExpenseRequest { }
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ public class ExpenseService : IExpenseService
|
||||
ReviewedByName = e.ReviewedBy != null ? reviewerNames.GetValueOrDefault(e.ReviewedBy) : null,
|
||||
ReviewedAt = e.ReviewedAt,
|
||||
ReviewNotes = e.ReviewNotes,
|
||||
PayeeId = e.PayeeId,
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
@@ -211,6 +212,7 @@ public class ExpenseService : IExpenseService
|
||||
CheckNumber = e.CheckNumber, Notes = e.Notes, ReviewNotes = e.ReviewNotes,
|
||||
ReviewedByName = reviewerName, ReviewedAt = e.ReviewedAt,
|
||||
SubmittedBy = e.SubmittedBy, SubmittedAt = e.SubmittedAt, PaidAt = e.PaidAt,
|
||||
PayeeId = e.PayeeId,
|
||||
Lines = lineDtos,
|
||||
};
|
||||
}
|
||||
@@ -273,6 +275,7 @@ public class ExpenseService : IExpenseService
|
||||
e.VendorName = null;
|
||||
}
|
||||
|
||||
e.PayeeId = r.PayeeId;
|
||||
_db.Expenses.Add(e);
|
||||
await _db.SaveChangesAsync();
|
||||
return e.Id;
|
||||
@@ -294,7 +297,7 @@ public class ExpenseService : IExpenseService
|
||||
throw new InvalidOperationException("You can only edit your own draft, pending, or rejected reimbursements.");
|
||||
|
||||
e.MinistryId = r.MinistryId; e.Description = r.Description; e.CheckNumber = r.CheckNumber;
|
||||
e.ExpenseDate = r.ExpenseDate; e.Notes = r.Notes;
|
||||
e.ExpenseDate = r.ExpenseDate; e.Notes = r.Notes; e.PayeeId = r.PayeeId;
|
||||
if (e.Type == "VendorPayment") e.VendorName = r.VendorName;
|
||||
|
||||
// Replace the line set wholesale (lines are owned by the header), recompute the total.
|
||||
|
||||
Reference in New Issue
Block a user