HALO CRM research
Real and working
Domain 3 · money · ~3,700 LOC

Referrals + referral invoicing

Pays commission to partners who introduced creators. Uses a temporal-ownership model: commission is computed from links overlapping the queried month, so unlinking stops future earnings without erasing past ones.

What it is and how it feeds the rest

Mechanically

Pays commission to partners who introduced creators. Uses a temporal-ownership model: commission is computed from links overlapping the queried month, so unlinking stops future earnings without erasing past ones.

How it connects

The money-out counterpart to creator invoicing; same settlement spine, opposite direction.

Pages

  • src/pages/Referrals.tsx
  • src/pages/ReferralInvoicing.tsx

Components

  • src/components/referrals/
  • src/components/referral-invoicing/

Convex modules

  • referrals.ts
  • referralInvoicing.ts
  • referralDemo.ts

Tables

  • referralPartners
  • referralPayments
  • referralLinks

Findings that touch this domain

high All money is float64; 2 rounding calls in 11,274 LOC, none in invoicing/referrals/payroll

convex/schema.ts:103,132,153,393,703

high Catastrophic cancellation — a fully-paid invoice can show a non-zero balance

convex/referralInvoicing.ts:138

high Same commission computed two contradictory ways; both displayed, no ledger arbitrates

convex/referrals.ts:534 vs :546

The decision — what we do here

TRANSPLANT+FIX — referral commission becomes a payable in the journal, not a float sum; fixes the two-contradictory-paths bug.

Repos we analyzed for this domain

LIFT flash-oss/medici

Double-entry ledger engine (Node/TS). Port behind PaymentLog; earnings = liability not revenue.

LIFT dinerojs/dinero.js

Integer minor units + allocate() — kills the float/rounding bug across all money math.

LIFT = copy the code into the fork · WRAP = run underneath as a service · STUDY = architecture only. Verdicts from the OFM sourcing campaign.

Open questions

Research priority for this domain is low. Agent findings splice in below this line and survive regeneration.