Table of Contents
#116 — A fully refunded invoice leaves the reseller commission Pending and payable (Resolved)
← Back to Manara Bugs · View issue #116 in MantisBT
Reported by: Khaled Tarabay on 2026-07-28T10:36:20+01:00
Assigned to: Claude
Resolved by: Claude on 2026-07-28T12:01:01+01:00
Severity: major
Priority: high
Reproducibility: always
Category: General
Description: Refunding 100% of an invoice does not reverse, void, or flag the commission generated from it — the reseller remains owed commission on a sale where every cent was returned to the customer. Built the full chain on fresh records: created reseller “Xmod Refund Chain …”, created a customer, raised invoice LG-INV-93 for $300.00, issued it, and collected $300.00 through the real Record Payment form. A commission correctly appeared: $300.00 basis, $105.00 commission, status Pending. I then recorded a full $300.00 refund against that invoice through the real Refunds & Credits form. The invoice reacted correctly — it now reads Status: Refunded with a REFUNDED $300.00 of $300.00 paid banner — but re-checking /commissions shows the row completely unchanged: still $105.00, still Pending, still payable, with nothing indicating the underlying sale was reversed. What makes this a clear defect rather than a design choice is that the app already models the dependency in the other direction: this same audit confirmed that a commission on an unpaid invoice now correctly sits in an “Unearned · invoice not yet paid” state and flips to Pending the moment payment is collected. So commission status genuinely does track invoice payment state — the linkage simply isn't wired for the refund direction. The fix should treat a refund as the inverse of the payment event that earned the commission: a full refund must move the commission back out of Pending (either to the existing Voided state or back to Unearned, with an explicit note tying it to the refund), and a partial refund should proportionally reduce the commission basis and amount. Commissions already Paid out should not be silently rewritten — those need to surface as a clawback/negative-adjustment entry so the money owed back is visible rather than erased.
Steps to Reproduce: Create a reseller and a customer, raise an invoice against both, add a charge (e.g. $300.00), set it to Issued. Record a full payment for the invoice. Confirm /commissions shows a Pending commission for it. Go to Refunds & Credits → Record Refund, select that invoice, refund the full amount. Confirm the invoice now shows Status: Refunded / REFUNDED $300.00 of $300.00 paid. Reload /commissions — the commission is still Pending at its full original amount — this is the bug; expected is the commission reversing, voiding, or otherwise being flagged as no longer earned.
Resolution: FIXED (part of the commission net-collected redesign - see #120/#121). What: a fully-refunded invoice left its reseller commission Pending and fully payable.
Where: app/classes/Billing/Commission.php (syncForInvoice()), app/controllers/CreditNoteController.php (calls syncForInvoice after a refund).
Fix: commission basis is now NET COLLECTED (payments - refunds), not the invoice total, and syncForInvoice() is now invoked after a refund is recorded (nothing re-synced commission when money moved before). When a once-paid invoice is fully refunded (net collected back to 0), its pending commission is VOIDED outright - kept visible under the Voided filter and written to the Activity Log - matching how voiding the invoice already voids its commission.
Verified live (transaction, rolled back): 400 invoice @25%, fully paid → 100 Pending commission; full 400 refund → commission Voided (1 voided row, no live payable entry).
Activity / Notes
- 2026-07-28T12:00:56+01:00 - Claude: FIXED (part of the commission net-collected redesign - see #120/#121). What: a fully-refunded invoice left its reseller commission Pending and fully payable.
Where: app/classes/Billing/Commission.php (syncForInvoice()), app/controllers/CreditNoteController.php (calls syncForInvoice after a refund).
Fix: commission basis is now NET COLLECTED (payments - refunds), not the invoice total, and syncForInvoice() is now invoked after a refund is recorded (nothing re-synced commission when money moved before). When a once-paid invoice is fully refunded (net collected back to 0), its pending commission is VOIDED outright - kept visible under the Voided filter and written to the Activity Log - matching how voiding the invoice already voids its commission.
Verified live (transaction, rolled back): 400 invoice @25%, fully paid → 100 Pending commission; full 400 refund → commission Voided (1 voided row, no live payable entry).
Full History
| Date | User | Field | Change |
|---|---|---|---|
| 2026-07-28T10:36:20+01:00 | Khaled Tarabay | issue-new | New Issue |
| 2026-07-28T12:00:50+01:00 | Claude | Assigned To | ⇒ Claudine |
| 2026-07-28T12:00:54+01:00 | Claude | tag-added | Tag Attached: done-by-claude |
| 2026-07-28T12:00:56+01:00 | Claude | note-added | Note Added: 0000075 |
| 2026-07-28T12:01:01+01:00 | Claude | Status | new ⇒ resolved |
Synced automatically from MantisBT issue #116.
