ReviewOS

stacks/smakelo

B2.8: Payouts and ledger

#11
Closed chris opened this 9 days ago ·
9 days ago

Part of #1.

  • LedgerEntry as the single money-movement record: order revenue split (merchant net, platform fee, courier fee, tips), refund reversals
  • PayoutAccount per merchant/courier (Stripe Connect account id from the upstream connect module); balances = ledger aggregation
  • Payout simulation: listPayouts from Stripe sandbox + transfer creation for merchant balances; courier payout statement view data
  • Tests: split math invariants (sum of parts equals charge), refund reversal symmetry
9 days ago

Follow-up on the payouts work: seeding real order history through placeOrder() immediately exposed that the ledger did not conserve.

Every order charged the customer sales tax, but only the merchant, courier and platform got rows. Across the seeded history that left 7,478 cents with no owner. Fixed in b4b772e:

  • tax is now a party in its own right. California makes the marketplace the facilitator, so the platform holds the tax and remits it; folding it into the platform's balance would mix what it earned with what it merely holds.
  • On an inclusive market (Berlin, 19% VAT) the tax is carved back out of the merchant's share with a negative tax_withheld row, since it was never theirs.
  • Two unit tests now assert the invariant in both tax modes, so it cannot drift.

Fresh database: 86,199 cents charged, 86,199 accounted for.

Live: https://smakelo.stacksjs.com/earnings

Sign in to comment on this issue.