Functional contract

Clinic commissions

Staff earn a commission on the invoice lines they provide. The percent comes from the staff member's commission group on the invoice's issue date, per catalog item. Commissions are calculated when the invoice is issued, reversed by credit notes, and tracked as pending payout, paid out, or voided like tips (no transfers).

Shipped 3 Nov 2026

Concepts

TermMeaning
Commission groupCommissionGroup: name, code, description, enabled, and an owner — the Organization, a Location group, or a Location. Holds one rate per catalog item. It may only rate items available in its scope, and its scope cannot change while staff are assigned
RateCommissionGroupRate: catalog item, percent (0–100), and before_discounts. An item without a rate in one group falls back to the provider's next group; with no rate anywhere it earns nothing. Each group can rate the same item differently
OverridesGroup enabled and rate percent / before discounts are overridable per Location and Location group, with lock levels (see below)
MembershipStaffCommissionMembership: staff, group, starts_on, ends_on (inclusive, blank = ongoing). At most one group per scope (Organization, each Location group, each Location) on any date; periods in a scope never overlap
CommissionInvoiceCommission (Location): one per invoice line and provider, or a negative reversal from a credit note
BasePer rate. Default (after discounts): net − order_discount_share, before tax. before_discounts on: gross

Calculation (on issue)

Sales::CommissionCalculator.for_invoice! runs inside invoice issue, after the lines are created.

Consult $150, 10% line discount, "Vets" 10% after discounts → base $135 → $13.50 Nail trim $50, 10% line discount, "Techs" 5% before discounts → base $50 → $2.50 Nail trim $50, 10% line discount, "Vets" 5% after discounts → base $45 → $2.25

Location and group overrides

Commission groups and rates follow the shared inherit-or-override model.

Commission lookup

Staff record → Commission lookup: pick an item and a Location to see, for today, each ranked group's outcome (applies, skipped because disabled, skipped for no rate, not reached), the resulting percent and base, a Fallback badge when a more specific group was skipped, and the rate's source badges and level trails. It uses the same Commissions::Resolution as the calculation.

Credit notes

Issuing a credit note runs Sales::CommissionReversal, which creates negative, pending rows linked to the original commission and the credit note.

Memberships

Settings → Staff → edit → Commission group: current group per scope, a change form (scope, group, effective date, default today), and the period history with who made each change.

Payout status

FromTo
Pending payoutPaid out, Voided
Paid outPending payout, Voided
VoidedPending payout

Set in bulk on the Commissions list with an optional reference or reason. Each change records who and when; restoring to pending clears the stamps. A voided row must go back to pending before it can be paid out. Reversal rows follow the same rules.

Screens

ScreenPathWhat you see
Settings → Commission groups/app/commission_groups (list, show, new, edit, delete)Groups with per-item rates. A Location workspace lists only groups available there. A group with memberships or commissions cannot be deleted; disable it instead
Staff record → Commission groupPOST /app/staffs/:staff_id/commission_membershipAssign or end a group from a date
Clinic → CommissionsGET /app/commissions, PATCH /app/commissions/payoutFilters (status, default Pending payout; staff; From / To on invoice issue date), totals, per-staff summary; rows with issue date, invoice ("Reversed by CN-…"), staff, item, group, base, percent, status, amount; bulk status update
Settings → Staff → edit—Commissions section per readable Location: pending / paid-out / voided totals, the 10 most recent rows, link to the filtered list
No commission? Check that the line has a provider and catalog item, the provider had a membership on the issue date in a group available and enabled at that Location, and some group rates the item. The staff record's Commission lookup shows each step.

Permissions

Rolecommissions.readcommissions.manage (payout)commissiongroups.manage
Organization administratorYesYesYes
Location group administratorGroup's LocationsGroup's LocationsNo (own group's groups via locationgroups.manage)
Location administratorYesYesNo
ReceptionistYesNoNo
VeterinarianNoNoNo

commissions.read / .manage are Location-scoped; commissiongroups.manage is Organization-scoped. Commission groups are readable with commissiongroups.manage or any commissions.read; editable with commissiongroups.manage, or locationgroups.manage for groups owned by that Location group. Plan features commissions and settings.commission_groups are on wherever invoices are (Business + Elite).

For developers

ConcernWhere
ModelsCommissionGroup, CommissionGroupRate, StaffCommissionMembership, InvoiceCommission, Staff#assign_commission_group! / #ranked_commission_groups_at / #commission_group_on
OverridesCommissions::EffectiveGroup, Commissions::EffectiveRate (on Hierarchy::EffectiveRecord), Commissions::Policy (on Hierarchy::Policy)
CalculationSales::CommissionCalculator (called by Sales::InvoiceIssuer), Commissions::Resolution (shared with Commission lookup)
Credit note reversalSales::CommissionReversal (called by CreditNotes::Issuer)
PayoutSales::CommissionPayout
ControllersApp::CommissionGroupsController, App::CommissionsController, App::StaffCommissionMembershipsController, App::StaffsController#load_staff_commissions
Routes/app/commission_groups, /app/commissions, /app/commissions/payout, /app/staffs/:staff_id/commission_membership

Full contract: docs/functional/clinic-commissions.md.

Acceptance

Out of scope: recalculating after back-dated membership, rate, or override changes, commissions on tips or deposits, payroll export, mobile API.

Related: Clinic tips, Billing and finance, Appointment to invoice, RBAC, Staff access.