Skip to content

v1.0.2 — Per-referral 12mo earnings net of adjustments

Choose a tag to compare

@makowskid makowskid released this 30 Apr 10:58
· 3 commits to main since this release

Fixes per-referral "Earned (12 mo)" column so it reconciles with the partner-level "Total earned" tile.

What changed

  • Per-referral 12mo earnings are now net of attributable adjustments (previously gross only). Each (year, month) adjustment is distributed across that month's referrals proportionally to each referral's share of the month's gross commission.
  • Adjustments in months where no commissions exist remain at the partner level (cannot be attributed to a specific referral) and only affect total_earned_cents.
  • Per-referral display caps at zero (the partner-level tile still reflects negatives).

Historical fidelity

Aggregations always use stored affiliate_commissions.commission_amount_cents and the row-snapshotted affiliate_adjustments.commission_rate_bp via AffiliateAdjustment::commissionAmountCents(). The partner's current revenue_share_bp is never used in historical totals — pinned by a regression test that mutates the partner's current rate and asserts identical output.

Tests

tests/Feature/PartnerStatisticsAdjustmentsTest.php covers distribution and the no-commissions edge case. tests/Feature/PartnerStatisticsHistoricalRatesTest.php covers historical-rate fidelity.