Functional contract
Catalog and pricing
Shipped. The Organization owns one master catalog. Each Location Group and Location inherits master values unless it has an explicit override, and the Organization may lock individual attributes. Prices live in pricing groups; patient groups give per-patient prices. Do not copy the whole catalog per Location.
Master catalog
Organization-scoped list of services, products, procedures, packages, and memberships. Staff open /app/catalog (catalog.read). Organization administrators create and edit master items (catalog.manage). Location administrators override unlocked attributes at granted Locations (catalog.override).
| Attribute | Role |
|---|---|
| Name, SKU | Shared identity across the group (code column; labeled SKU in the UI) |
| Description | Optional notes; overridable; included in search |
| Category | Platform category (Procedure, Service, Package, Product, Membership, Wellness plan) with a kind: regular, bundle, or subscription. Bundles include other items with quantities (nesting allowed); the form shows each component's unit price, line total, and a reference total, and the bundle price is entered separately. Subscriptions use benefits instead (below) |
| Pricing group | Required. The pricing group that holds the item's prices |
| Standard price | Stored on the pricing group sheet (row with no patient group); inherited by Locations with no override |
| Price group rule | lowest (default) or highest: which patient group price wins when several match |
| Enabled | Offered by default (disabled_at). Retires everywhere; not overridable |
| Sellable | Offered for sale by default; overridable |
| Tax group | Optional; overridable. See Taxes |
lock_sellable, lock_tax_group, lock_description | Per-attribute lock level. lock_price lives on each pricing group row |
lock_grants | When true, Location group administrators cannot grant or revoke the item |
stock_control | none, quantity, or batch. Organization-owned, not overridable. New items inherit the category default. Bundles are always none; their stock is derived from components. See Inventory |
batch_strategy | For batch: fifo (default), lifo, or fefo (every lot needs expires_on) |
Overridable today: price, sellable, tax group, description. Not-sellable-at-Location is an override; it does not remove the item from the master catalog.
Lock levels
| Level | Who may override |
|---|---|
none | Location Groups and Locations (“Anyone can override”) |
locations | Only Location Groups (“Only location groups can override”) |
everywhere | Nobody (“Nobody can override”). Master value only; group and Location overrides are rejected and stale ones ignored |
- A group override may also lock an unlocked attribute for its own Locations (
lock_*on the group row;lock_priceon group price overrides). - When every attribute is locked, the item page hides the Change link.
- Only Organization administrators set lock levels. Without Location Groups (or off Elite), pickers offer only “Anyone can override” and “Nobody can override”; a record already at
locationskeeps it.
Location and group overrides
A Location or Location Group stores only differences, not a second catalog. Each attribute resolves independently.
| Item | Organization | Location A (Manhattan) | Location B (suburb) |
|---|---|---|---|
| General consult | $100 | $150 (override) | $100 (inherited) |
| Rabies vaccine | $25 | $25 (inherited) | $20 (override) |
| Thoracic radiograph | $180, price locked | $180 (locked) | $180 (locked) |
Resolving an attribute at a Location:
- No master item → not sellable (unless location-exclusive).
- Locked
everywhere→ master value. - Locked for Locations (master
locations, or the group locks it) → group override, else master (“Group locked”). Location override ignored. - Location override → use it.
- Group override (
group_overridden, shown “Group”) → use it. - Otherwise master value.
| Override | Storage | Set by |
|---|---|---|
| Location sellable, tax group, description | location_catalog_overrides | Location admin (catalog.override), group admin, Organization admin |
| Group sellable, tax group, description | location_group_catalog_overrides | Organization admin (any workspace) or Location group admin from a member Location (scope bar or All sites tab) |
| Location / group price | location_pricing_group_price_overrides, location_group_pricing_group_price_overrides (per pricing group row) | Same actors, on the item page “Prices” section |
At a Location each attribute and price row shows its value, source badge, and one action, with the chain in the Manage inheritance drawer (Editing overrides). How taxes resolve here follows the chain: effective tax group → whether it is enabled at the Location → each rate's effective percentage and enabled flag, each with its source.
Editing overrides
Same screens for catalog items, prices, patient groups, taxes, tax groups, commission groups and rates, and appointment types.
- Default view: at a Location, one row per field: value, source badge in plain words (“Organization default”, “Belgrano override”, “Locked by North region”, “Set by the organization”), and one action: Reset (this Location overrides it; clears just that field) or Override (opens the drawer for that field), or none when locked.
- Manage inheritance drawer: the inheritance icon by each field shows the chain from owner to Location (value, lock, Applies / Inherits / Not used, “You are here”) and the viewer's actions: Override or Reset here, Change (or lock) at the group, Edit for all locations, Change who can override. Built from
Hierarchy::EffectiveRecord#trace. - Override drawer: side panel (
/app/hierarchy_override/edit,App::HierarchyOverridesController) with a scope trail header (Organization › group › Location), current values with badges and trails, the form, and Clear override. Posts to the record's existing override routes. Locked fields read “Set by the organization” or “Set by your location group”. - Override or own record: for tax rates, tax groups, patient groups, and commission groups the drawer first offers “Change it at {site}” or “{site} has its own …”, which opens the new form with Scope preset (
owner_key). - Scope bar: “Change at: Organization › North region › Belgrano” under the header. Levels you may change are links (Organization → master form; group or Location → drawer); others are greyed with a lock and a reason. Permissions decide, the workspace only picks the default levels.
- Scoped labels: “Edit for all locations” (or “Edit for {owner}”), “Change at {site}”, “Save for {site}”, “Remove {site}'s override”.
- Master notice: the master form says how many Locations it reaches and which keep their own value.
- Lock badges: “· you can change it” when the viewer set the lock's level.
- All sites tab: Details / All sites (
?view=sites) for Organization admins (any workspace) and Location group admins: each Location and group with value, source, and Change. Group rows link to the Location group page. - By role: group admins see “Lock for my locations”; Organization admins “Lock for this group's locations”. Location admins see no lock controls and no lock icons in trails.
Pricing groups and patient groups
All prices live in pricing groups (Catalog → Pricing groups, /app/pricing_groups, catalog.manage). Organization-owned. The item form has no price field. A pricing group is a price sheet:
- Items are added to the sheet (each starts at its current standard price, or 0).
- One required standard price and lock level (
lock_price) per item. - One optional price and lock level per item for each attached patient group. A blank cell removes that price; detaching a patient group removes its prices.
- An item may be on many sheets but uses one pricing group at a time (
catalog_items.pricing_group_id). Assign from the sheet (“Save and assign selected”) or the item form (only groups whose sheet prices the item). - An item with no assigned pricing group is not priced and not sellable.
- New Organizations get a “General” group; existing items were moved into it.
- An item cannot leave the sheet it is assigned to; a pricing group with assigned items cannot be deleted. Price overrides belong to each sheet row and return when the item is reassigned.
Patient groups (Catalog → Patient groups, /app/patient_groups) are reusable criteria any pricing group may attach:
| Criterion | Match |
|---|---|
| Species | Patient species in the list |
| Breeds | Patient breed in the list (case-insensitive) |
| Hair types | Patient hair type in the list |
| Weight range | min_weight_kg <= weight < max_weight_kg, entered in the Organization's measurement system. No weight → no match |
- Every set criterion must match; any value in a list matches; at least one criterion is required.
- Owned by the Organization, a Location Group, or a Location, with an overridable, lockable enabled flag (
location_patient_group_overrides,location_group_patient_group_overrides). Applies only where available and enabled. catalog.managecreates them for any owner; Location group administrators manage those owned by their group.
Price for a patient at a Location:
- Take the item's patient group prices whose group is available, enabled, and matches the patient.
- Resolve each one's effective price at the Location (lock, Location, group, master).
- No match → effective standard price. Otherwise lowest or highest per the item's rule (standard price not compared).
Treatment plan items, sales-order lines, and visit lab charges snapshot this price when created. Lines without a patient use the standard price. Visit cart and treatment plan pickers show the patient price.
Taxes and tax groups
Settings → Taxes (Tax groups and Tax rates tabs; /app/tax_groups, /app/taxes). Same inherit-or-override model as catalog items.
| Aspect | Rule |
|---|---|
| Ownership | Tax rates and tax groups are owned by the Organization, a Location Group, or a Location (Scope on the form). A tax group only includes rates available in its scope. Narrowing scope is rejected while something outside uses it |
| Permissions | taxes.read views; taxes.manage manages any owner; Location group admins manage group-owned records; taxes.override sets Location overrides |
| Overridable | Tax rate percentage and enabled; tax group enabled. Disabled rate is skipped; disabled group applies no taxes |
| Location overrides | location_tax_overrides, location_tax_group_overrides: Location admins, group admins for their Locations, Organization admins |
| Group overrides | location_group_tax_overrides, location_group_tax_group_overrides: group admins or Organization admins (any workspace) |
| Locks | none / locations / everywhere; groups may lock for their Locations. A group row with only locks is kept; empty rows are removed. Only records owned above the override's scope can be overridden |
| Calculation | Invoice and credit-note previews and the platform fee resolve rates at the order's Location. Issued invoice lines snapshot the effective rate |
| Disabled is a hard off | A tax rate, tax group, patient group, commission group, or appointment type disabled on its own record is off everywhere (“Disabled at organization”). Overrides may only turn an enabled record off; new “enabled” overrides on a disabled record are rejected and older ones ignored |
| Override or scoped record? | Use an override when the same record needs a different value at a site. Create a Location- or group-owned record when only that site has it |
Tax group on an item: a master item may only use Organization tax groups. An exclusive item may use a narrower tax group only when every grant falls inside its scope; granting outside, promoting, or narrowing the tax group is rejected while the mismatch exists.
Who may change what
| Actor | Master catalog | Lock | Override |
|---|---|---|---|
| Organization admin | Create, edit; pricing groups, patient groups | Set or clear per attribute, per price row, and for grants | Any Location's or group's override for unlocked attributes |
| Location group administrator | No | Group lock on attributes not locked everywhere, for their group's Locations | Unlocked attributes for their group and its Locations; grants within the group unless grants are locked |
| Location administrator | No (except exclusive items when the policy is on) | No | Unlocked attributes, only at granted Locations |
| Staff | No | No | No |
Workspace scope decides what the catalog shows, including for Organization administrators:
- Location workspace: only items visible at the current Location (
visible_at). Location-only staff see no other Location names or grants. An Organization administrator may still edit, promote, or override the current Location, and keeps the All sites tab and group values. - Organization workspace: the master list, every exclusive item, and all Location names (overrides and grants). Location-only staff pick a Location first.
Location administrators do not see other Locations' prices or the master editor.
Location-exclusive items
Default: Location administrators cannot create items. Organization policy allow_location_exclusive_items (off by default; Settings → Hierarchy):
- Off: new items only on the master catalog by an Organization admin.
- On: a Location administrator may create an item that exists only at granted Locations. Other sites do not inherit it until an Organization admin promotes it (or grants extra Locations).
- Elite: an Organization administrator may grant an exclusive item to a Location Group (
catalog_item_location_groups); it is visible at every Location currently in the group. Location group admins may grant items visible in their group to the group unless grants are locked. - An exclusive item needs at least one grant of either kind; promote removes both.
Tags
- Organization tag: created in the Organization workspace; visible everywhere.
- Location tag: created in a Location workspace; visible only there. Cannot reuse an Organization tag's name (case-insensitive).
- A new tag takes the current workspace scope. Saving only changes tags available in that workspace.
- Staff with
catalog.overridemay add or remove their Location's tags on an item they cannot edit; never Organization tags. - The list shows visible tags; search matches them. The item page ends with a collapsed Change history timeline (including tags).
Subscriptions
Catalog definition for memberships and wellness plans ships. Patient enrollments, renewals, payments, and redemptions are not built. Not to be confused with SaaS plans (SaaS billing).
| Kind | Components | Seeded categories |
|---|---|---|
regular | None | Service, Product |
bundle | Included items with quantities (BOM) | Procedure, Package |
subscription | Benefits with use limits and discounts | Membership, Wellness plan |
- The subscription fee is the standard price on the item's pricing group. Default stock control
none. Cannot be a component of a bundle or another subscription. - Category rules (SuperUser,
/admin/catalog_item_categories; read-only in clinic): benefits require payment, expires if not renewed, max active per patient (blank = unlimited). Seeded: Membership (no / yes / unlimited), Wellness plan (yes / yes / unlimited). - Duration (item):
months(N ≥ 1) oruntil_date. - Benefit (component):
usage_limitper period (blank = unlimited),discount_kindpercent(0–100) oramount,rollover. BOM quantity stays 1. - Intended enrollment: several per client/patient up to the category max; snapshot rules and terms at sale; payment gating, renewal, rollover, and expiry enforced there.
Acceptance
- An item at a Location with no override uses the master price.
- Saving an override at A does not change B or the master price. Clearing it returns A to the inherited (group or master) value.
- A locked price rejects price overrides and ignores stale rows; other unlocked attributes stay overridable. With every attribute locked, no override can be saved.
- A patient matching one patient group pays that group's price; several, the lowest or highest per the rule; none, the standard price. A disabled or unavailable patient group changes nothing at that Location.
- With grants locked, a Location group administrator cannot grant or revoke the item but may still override unlocked attributes.
- With the exclusive-items policy off, a Location administrator has no “create item” action. With it on, an item created at A does not appear at B until promoted or granted.
- In a Location workspace, even an Organization administrator lists only that Location's catalog; All sites on the item page still shows every Location.
- A Location tag is not visible at other Locations or in the Organization workspace.
- Sales-order and invoice lines store
unit_priceso later catalog edits do not rewrite history.
Out of scope: quantities and lots (Inventory), invoice legal header (Billing), subscription enrollment.