fix: revert payment amount when switching away from Paid in Full

Switching from PAID to Pending/Partially Paid now calls revert-full-claim
first to undo the collected amount, then updates the status — so the
report totals stay accurate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-06 20:43:45 -04:00
parent f3008aed7d
commit c5af6c1fa6

View File

@@ -724,6 +724,19 @@ export default function PaymentsRecentTable({
const val = e.target.value as PaymentStatus; const val = e.target.value as PaymentStatus;
if (val === "PAID") { if (val === "PAID") {
handlePayAbsoluteFullDue(payment.id); handlePayAbsoluteFullDue(payment.id);
} else if (payment.status === "PAID") {
// revert the full payment amount, then set the new status
fullPaymentMutation.mutate(
{ paymentId: payment.id, type: "revert" },
{
onSuccess: () => {
updatePaymentStatusMutation.mutate({
paymentId: payment.id,
status: val,
});
},
}
);
} else { } else {
updatePaymentStatusMutation.mutate({ updatePaymentStatusMutation.mutate({
paymentId: payment.id, paymentId: payment.id,