feat(payouts): implement settlement reconciliation and payout statements (#245) - #253
Draft
s6pa1rta3n-lab wants to merge 1 commit into
Draft
feat(payouts): implement settlement reconciliation and payout statements (#245)#253s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
…nts (Prompt-Hash-Stellar#245) - Implement creator payout statement model with balancing formula: gross - fees (5%) - refunds + carryover = net - Add support for partial-period filtering, prior-period refund clawbacks, and negative carryover propagation - Add RFC-4180 CSV export with summary metadata block and itemized transaction ledger - Add structured JSON export - Add API endpoints for statement previews, exports, generation, and status lifecycle updates - Mount /api/payouts and /api/reconciliation routers in Express server - Add PayoutStatementsCard frontend component to PayoutSettingsPage and profile created tab - Add full unit/integration test coverage across server reconciliation and frontend components - Add comprehensive documentation in docs/payout-statements.md
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
Closes #245.
This PR implements comprehensive settlement reconciliation and creator payout statements for PromptHash, resolving all requirements outlined in #245.
Key Changes
netSettlementAmount = grossAmount - platformFeeAmount - refundAmount + previousBalanceCarryoverwith 500 bps (5.00%) platform fee calculation and 7 decimal place Stellar stroop precision.closingBalanceCarryover = netSettlementAmountwhen negative,payableAmount = 0) propagated into subsequent billing periods.GET /api/payouts/statements/:walletAddress: List statements or calculate on-the-fly preview reconciliation for custom date ranges.GET /api/payouts/statements/:walletAddress/:statementId: Fetch single statement details with line items.GET /api/payouts/statements/:walletAddress/:statementId/export?format=csv|json: Download statement file.POST /api/payouts/statements/generate: Generate and persist statement record.PATCH /api/payouts/statements/:statementId/status: Update settlement status (pending,settledwithpayoutTxHash,failedwithfailureReason).PayoutStatementsCard): Integrated into/profile/payouts(PayoutSettingsPage) and the profile Created inventory tab, displaying summary metrics, status badges, carryover notices, date range filters, RFC-4180 CSV / JSON download buttons, and an itemized transaction ledger.docs/payout-statements.mdand updateddocs/api-reference.md.server/src/tests/payoutStatement.test.tsand component test insrc/components/profile/PayoutStatementsCard.test.tsx. All 22 backend test suites (210 tests) and 44 frontend test suites (336 tests) pass with 0 errors.Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC