fix: folio reversal loop + payment refund UI (closes #166)#170
Merged
Conversation
…e in dashboard (#166) Prevent reverse-of-reversal deadlocks in reverseCharge/postCharge, fix dashboard Reverse gating to use isReversal/originalChargeId, and wire the existing payment refund API into Folios with toast error feedback. Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
3 tasks
telivity-otaip
marked this pull request as ready for review
July 22, 2026 23:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #166 (contributor Gugabit): folio charge Reverse could be clicked repeatedly (including on reversal rows), creating a negative-balance deadlock, and captured payments had no refund action in the dashboard.
Root causes
Backend hole:
reverseChargeblocked a second reverse of the same original, but never rejected reversing a row that itself hadisReversal: true. Reversing reversalRcreatedR2 = -R, thenR3, indefinitely. The same hole existed on the directpostChargepath when postingisReversal: trueagainst a reversal row.UI gating bug: Folios used a phantom
c.isReversedfield that is not in the schema/API (onlyisReversal+originalChargeIdexist), so Reverse showed on every unlocked open-folio row.Missing refund UI:
POST /v1/payments/:id/refundalready existed with full/partial refund support. The Folios payments list simply rendered no action button. Negative direct payments stay rejected by design (CreatePaymentDtopositive-only); refunds are the sanctioned path.Changes
API
reverseChargeand inpostChargewhenisReversaltargets another reversal (Cannot reverse a reversal transaction).Dashboard
isReversal+originalChargeId; hide Reverse on reversal rows and already-reversed charges; strikethrough originals that have been reversed.captured/settled/partially_refunded(excludes negative refund-child rows).Tests / docs
docs/test-stats.jsonto 1153 tests (fixes CI “README test counts are stale”).folios.refund(+ confirm/success/failure keys) in en / pt-BR; minimalfolioskeys in de.Verification
pnpm readme:sync-tests→ 1153 / 139Closes #166