====== #82 — Cumulative refunds can exceed the amount actually paid (Resolved) ====== [[wiki:manara:bugs|← Back to Manara Bugs]] · [[https://mantis.matrixdn.net/view.php?id=82|View issue #82 in MantisBT]] ---- **Reported by:** Khaled Tarabay on 2026-07-27T12:11:02+01:00\\ **Assigned to:** Claude\\ **Resolved by:** Claude on 2026-07-27T12:47:10+01:00\\ **Severity:** major\\ **Priority:** high\\ **Reproducibility:** have not tried\\ **Category:** General **Description:** A single refund is correctly checked against an invoice's paid total (a $500 refund on a $50 invoice was rejected), but that check does not run cumulatively two or more smaller refunds can add up to more than was ever collected. A $40.00 invoice was paid in full, then two separate $25.00 refunds were recorded against it back to back. Both were accepted (302 each), leaving $50.00 refunded against $40.00 actually paid a $10.00 shortfall the app never flagged. The per-request validation only checks "does this one refund exceed the balance," never "do all refunds on this invoice, summed, exceed what was paid." **Steps to Reproduce:** Create, issue, and fully pay a $40.00 invoice. Go to Refunds & Credits → Record Refund / Credit, select that invoice, refund $25.00. Repeat: refund another $25.00 against the same invoice. Confirm both rows appear in the Refunds & Credits list $50.00 total refunded on a $40.00 invoice. **Resolution:** DUPLICATE of #75 (already fixed and resolved earlier in this same session). #75's fix — CreditNoteController::validate() now subtracts CreditNote::refundedForInvoice() from the invoice's amount_paid before checking a new refund, instead of checking against the static original total every time — is exactly the fix this ticket also asks for, and it directly prevents this ticket's own repro. Re-verified live against the local database with this ticket's EXACT numbers (not just #75's own test): a $40.00 invoice paid in full, then a $25.00 refund (accepted — 25 <= 40), then a second $25.00 refund against the same invoice — correctly REJECTED ("...$15.00 of $40.00 paid remains, after $25.00 already refunded..."), where before the #75 fix both would have been accepted (25 <= 40 checked statically each time), producing exactly the $50-refunded-on-$40-paid shortfall this ticket describes. Resolving as a duplicate — see #75's note for the full fix details. Full test suite: 29/29 passing. Test invoice/refunds removed afterward. ===== Activity / Notes ===== * **2026-07-27T12:47:07+01:00 - Claude:** DUPLICATE of #75 (already fixed and resolved earlier in this same session). #75's fix — CreditNoteController::validate() now subtracts CreditNote::refundedForInvoice() from the invoice's amount_paid before checking a new refund, instead of checking against the static original total every time — is exactly the fix this ticket also asks for, and it directly prevents this ticket's own repro. Re-verified live against the local database with this ticket's EXACT numbers (not just #75's own test): a $40.00 invoice paid in full, then a $25.00 refund (accepted — 25 <= 40), then a second $25.00 refund against the same invoice — correctly REJECTED ("...$15.00 of $40.00 paid remains, after $25.00 already refunded..."), where before the #75 fix both would have been accepted (25 <= 40 checked statically each time), producing exactly the $50-refunded-on-$40-paid shortfall this ticket describes. Resolving as a duplicate — see #75's note for the full fix details. Full test suite: 29/29 passing. Test invoice/refunds removed afterward. ===== Full History ===== ^ Date ^ User ^ Field ^ Change ^ | 2026-07-27T12:11:02+01:00 | Khaled Tarabay | issue-new | New Issue | | 2026-07-27T12:47:03+01:00 | Claude | Assigned To | => Claudine | | 2026-07-27T12:47:06+01:00 | Claude | tag-added | Tag Attached: done-by-claude | | 2026-07-27T12:47:07+01:00 | Claude | note-added | Note Added: 0000041 | | 2026-07-27T12:47:10+01:00 | Claude | Status | new => resolved | ---- Synced automatically from MantisBT issue #82.