fix: split pay-in booking into fund base and platform fee#1655
Draft
jdijkstra-eyra wants to merge 1 commit into
Draft
fix: split pay-in booking into fund base and platform fee#1655jdijkstra-eyra wants to merge 1 commit into
jdijkstra-eyra wants to merge 1 commit into
Conversation
do_complete_transaction re-derived the booked amount as subject_count * live subject_reward, which (1) used the current reward, so changing it between payment and confirmation credited the wrong amount (BUG 5), and (2) never booked the partner fee anywhere (BUG 1). Persist partner_fee on the transaction and split the completion entry using the immutable paid amount: debit the ledger inbound the full total, credit the fund the base (total - fee) it can pay participants with, and credit the fee to a new per-currency ledger margin account as platform revenue. Adds the margin account to currency_ledger (backfilled for existing ledgers). Fixes Flux 10088720661. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jdijkstra-eyra
force-pushed
the
fix/pay-in-book-paid-amount
branch
from
July 16, 2026 08:29
0b10582 to
cd295a9
Compare
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.
Draft — money bookkeeping change (adds a migration + a new ledger account); worth a careful look before merge.
do_complete_transactionre-derived the credited amount assubject_count × live subject_reward, which had two problems:subject_reward, so lowering the reward between payment and confirmation credited the wrong amount.Corrected accounting (per review): the researcher pays
total = base + partner_fee. The fund'savailablemay only be credited base — what they can pay participants with — and the fee is platform revenue that the ledger must record.Changes:
partner_feeon the transaction (migration), so completion books the immutable paid amount instead of re-deriving from the live reward.marginaccount tocurrency_ledger(backfilled for existing ledgers), hanging off the ledger alongsideinbound/outbound.partner_feeis 0 the margin line is omitted.partner_fee_percentagedefaults to0, so with no fee configured this is purely the BUG 5 immutability fix; the split only diverges once a fee is set.Fixes Flux 10088720661. Surfaced by the money-flow assurance audit (BUG 1 + BUG 5).
🤖 Generated with Claude Code