Skip to content

No refund/chargeback clawback for manual payouts already marked paid #498

Description

@guillermoscript

Part of #493 (Phase 2 — payout money-accuracy).

Problem

markPayoutPaid is a one-way ratchet — once a payout is recorded, nothing re-checks whether the underlying transactions it was based on later flip to refunded/failed. If a PayPal sale gets refunded after you've already paid the school their share, /platform/payouts has no way to reflect that you're now effectively owed money back — it'll just show $0 owed going forward for that tenant, silently absorbing the loss with no record of it.

Wanted

When computing netOwed in computeOwedBalances, subtract refunded-transaction amounts (scaled by the split, same as any other transaction) from grossCollected/grossOwed, so a refund after payout is reflected as a negative adjustment on the next payout cycle rather than disappearing. Surface it in the UI (e.g. a "clawback" line) rather than silently netting it into netOwed.

Acceptance

  • A refund on a transaction that was already included in a paid-out payout reduces what's owed on the next cycle.
  • The clawback is visible on the payouts page, not just silently absorbed into the running total.
  • Unit test: transaction refunded after being paid out → next computeOwedBalances call reflects the clawback.

Metadata

Metadata

Labels

Sub-taskbugSomething isn't workingpaymentsPayment provider / billing related

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions