A $3,000 deal takes credited period sales from $9,000 to $12,000. With a 5% base rate and an 8% accelerator at $10,000, it posts $210.00 under marginal tiers or $510.00 under a retroactive period cliff. Both outcomes show 120.00% attainment against a $10,000 quota.
Calculate the change in earned commission
Under marginal tiers, the first $1,000 of the deal earns 5%, and the next $2,000 earns 8%. Under the retroactive cliff, reaching the threshold reprices every credited cent of the period at 8%. The posting is the after-sale entitlement less the before-sale entitlement.
| Checkpoint | Marginal | Retroactive cliff |
|---|---|---|
| Period entitlement before sale | $450.00 | $450.00 |
| Period entitlement after sale | $660.00 | $960.00 |
| Sale commission posting | $210.00 | $510.00 |
Applying the final rate directly to the new deal yields $240.00. That overstates the marginal posting by $30.00 and understates the cliff posting by $270.00. The cliff takes effect at the exact threshold in this plan.
Round each period entitlement once, half up, then difference the two rounded values. If two one-cent sales earn 50%, the first posts a cent and the second posts zero because the total entitlement ends at one cent. Rounding each incremental deal separately would post two cents.
Split, refund, and net the original posting
Allocate the sales credit and the commission pool as two integer-cent ledgers. Floor each proportional share, then award leftover cents by largest remainder. Stable rep IDs resolve tied remainders. A 62.5% share earns Ada $131.25 of the $210.00 marginal posting, while Sam earns $78.75.
A $1,000 refund reverses one-third of the original payouts, or $43.75 for Ada and $26.25 for Sam. On subsequent refunds, subtract the previous cumulative reversal from the new cumulative reversal before posting. That preserves the original payout total when a full refund arrives in installments.
Ada has $87.50 after the first clawback. She already received a $50.00 recoverable draw and carries a $20.00 opening balance, so $70.00 offsets the draw and $17.50 is due in additional cash. If the remaining $2,000 is refunded in a later run, the original commission has already been settled. That run posts an $87.50 clawback for Ada with $0.00 due in new cash. The two runs bring her net commission on the deal to $0.00. If the clawback exceeds this run's earnings, track the difference in its own balance so it stays attributable to refunds.
Benchmark the ledger pipeline
The five cases exercise marginal and cliff crossings, a sale landing exactly at the cliff with a nonrecoverable draw, a three-cent sale with an odd split cent and a second refund, and a final refund after the original commission was settled. The checks compare expected accruals, split conservation, clawbacks, payouts, closing draw balances, and reconciliation across both refund runs. Timing includes the full ledger path and its input validation.
Run this from the checkout root with Node.js 20 or later. It prints the median of five 48,000-entry runs after warm-up. MIT library source
node --input-type=module <<'JS' import assert from 'node:assert/strict'; import { performance } from 'node:perf_hooks'; import { allocateSplitCredit, calculateClawback, calculateCommission, settleCommission, } from './src/index.js'; const splits = [{ repId: 'Ada', shareBps: 6_250 }, { repId: 'Sam', shareBps: 3_750 }]; const deal = { priorSalesCents: 900_000, saleCents: 300_000, quotaCents: 1_000_000, tiers: [{ thresholdCents: 0, rateBps: 500 }, { thresholdCents: 1_000_000, rateBps: 800 }], splits, refundCents: 100_000, drawCents: 5_000, openingDrawBalanceCents: 2_000, drawType: 'recoverable', }; const finalRefund = { ...deal, priorRefundCents: 100_000, refundCents: 200_000, drawCents: 0, openingDrawBalanceCents: 0, }; const cases = [ [deal, [21_000n, -4_375n, 1_750n, 0n]], [{ ...deal, mode: 'cliff' }, [51_000n, -10_625n, 14_250n, 0n]], [{ ...deal, mode: 'cliff', saleCents: 100_000, refundCents: 0, drawType: 'nonrecoverable', openingDrawBalanceCents: 0, }, [35_000n, 0n, 16_875n, 0n]], [{ saleCents: 3, quotaCents: 3, tiers: [{ thresholdCents: 0, rateBps: 5_000 }], splits: [{ repId: 'Sam', shareBps: 5_000 }, { repId: 'Ada', shareBps: 5_000 }], priorRefundCents: 1, refundCents: 1, drawCents: 1, openingDrawBalanceCents: 2, drawType: 'recoverable', }, [2n, -1n, 0n, 3n]], [finalRefund, [21_000n, -8_750n, 0n, 0n]], ]; function run(input) { const earned = calculateCommission(input); const { saleCents, splits, priorRefundCents = 0, refundCents } = input; const payouts = allocateSplitCredit({ saleCents, splits, commissionCents: earned.commissionCents }); const refund = calculateClawback({ originalSaleCents: saleCents, payouts, priorRefundCents, refundCents }); const adaPosting = payouts[0]; const clawback = refund.reversals[0].clawbackCents; const settlement = settleCommission({ drawType: input.drawType, drawCents: input.drawCents, openingDrawBalanceCents: input.openingDrawBalanceCents, commissionCents: priorRefundCents > 0 ? 0n : adaPosting.commissionCents, clawbackCents: clawback, }); return { earned, payouts, refund, clawback, settlement }; } for (const [input, expected] of cases) { const { earned, payouts, clawback, settlement } = run(input); assert.equal(payouts.reduce((sum, row) => sum + row.salesCreditCents, 0n), BigInt(input.saleCents)); assert.equal(payouts.reduce((sum, row) => sum + row.commissionCents, 0n), earned.commissionCents); assert.deepEqual([ earned.commissionCents, clawback, settlement.payoutCents, settlement.closingDrawBalanceCents, ], expected); } assert.deepEqual(run(cases[3][0]).payouts.map((row) => row.salesCreditCents), [2n, 1n]); const first = run(deal); const last = run(finalRefund); assert.equal(first.earned.commissionCents + first.refund.clawbackCents + last.refund.clawbackCents, 0n); assert.equal(first.settlement.netCommissionCents + last.settlement.netCommissionCents, 0n); assert.equal(last.settlement.unappliedClawbackCents, 8_750n); const finalRateOnSale = BigInt(deal.saleCents) * 800n / 10_000n; assert.equal(finalRateOnSale - first.earned.commissionCents, 3_000n); assert.equal(finalRateOnSale - run(cases[1][0]).earned.commissionCents, -27_000n); for (let i = 0; i < 3_000; i++) run(cases[i % cases.length][0]); const iterations = 48_000; const samples = []; for (let sample = 0; sample < 5; sample++) { let checksum = 0n; const start = performance.now(); for (let i = 0; i < iterations; i++) { checksum += run(cases[i % cases.length][0]).settlement.payoutCents; } samples.push(performance.now() - start); assert.equal(checksum, 315_600_000n); } samples.sort((a, b) => a - b); const median = samples[2]; console.log(JSON.stringify({ node: process.version, platform: process.platform, arch: process.arch, iterations, medianMs: Number(median.toFixed(2)), ledgersPerSecond: Math.round(iterations * 1000 / median), })); JS On arm64 macOS with Node.js 24.14.1, the median for 48,000 ledger entries was 76.88 ms.
Save the original payout rows and the deal's cumulative refunded amount. For each incoming refund, post its adjustment and update that balance in the same transaction. A unique refund ID lets a retried event resolve to its original ledger entry.
Try the same sale with both accelerators and compare the corresponding refund and draw lines. Interactive GitHub Pages demo
For pay-run packs and statement exports, see CommissionPack and StatementPack.
