Skip to content

feat(core): support custom per-code referral splits in applyReferral and createCode - #9

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
Echolonius:feat/referral-code-custom-split
Aug 1, 2026
Merged

feat(core): support custom per-code referral splits in applyReferral and createCode#9
ralyodio merged 1 commit into
profullstack:masterfrom
Echolonius:feat/referral-code-custom-split

Conversation

@Echolonius

Copy link
Copy Markdown
Contributor

🚀 Feature: Per-Code Custom Referral Split Overrides

💡 Overview & Problem Statement

Currently, applyReferral applies the global DEFAULT_SPLIT (0.6 affiliate / 0.2 customer) or a caller-provided split option. However, top-tier affiliates or promotional campaigns often require custom commission splits stored directly on the referral code record (e.g. VIP 80% commission split vs standard 60%).

🛠️ Solution Implementation

  1. Types (src/types.ts):
    • Added optional split?: ReferralSplit override field to ReferralCode.
  2. Validation & Calculation (src/core.ts):
    • Updated applyReferral: uses opts.split ?? record.split ?? DEFAULT_SPLIT to evaluate commission calculations.
    • Updated createCode: accepts optional split?: ReferralSplit option.
  3. Unit Tests (tests/core.test.ts):
    • Added unit test verifying applyReferral applies record.split override configured on ReferralCode.

✅ Verification

  • All 20 Vitest unit tests passing cleanly.
  • tsup build clean.
  • Signed with GPG/SSH key.

@ralyodio
ralyodio merged commit 88f2e83 into profullstack:master Aug 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants