End-to-end flow
Appointment → visit → sales order → invoice
How a booking becomes money owed. The appointment is the booking, the visit is the encounter, the sales order collects charges at the desk, and the clinic invoice freezes them under the Legal Entity. Payments, credit notes, tips, and commissions follow the invoice.
Overview
| Record | Code | Statuses | Scope |
|---|---|---|---|
Appointment | — | scheduled | checked-in | canceled | no-show | Location |
Deposit | DEP-000123 | pending | partially_paid | paid | waived | voided | Location (+ Legal Entity) |
Visit | VI-000123 | checked_in → in_room ⇄ waiting → ready_to_bill → completed | Location |
TreatmentPlan | TP-000123 | draft → pending_approval → approved | rejected | Patient, origin Location |
LabWork | via DX-000123 | requested … completed | cancelled | Diagnostic order |
SalesOrder | SO-000123 | open | merged | voided | invoiced | Location (one Legal Entity, one currency) |
Invoice | INV-000123 | issued → partially_paid → paid | credited | Legal Entity header, Location attribution |
1. Book
- Front desk books an
Appointmenton the Schedule: patient, time, optional type, staff, and rooms/equipment. Recurring series create virtual slots until they are touched. - Walk-in = an appointment with no patient yet (Walk-In (no patient yet) in the popover). Single appointments only; labelled “Walk-In” on the calendar and whiteboard Upcoming.
- A type with a deposit creates a
pendingdeposit; the popover can collect it now or skip (Deposits). canceledandno-showare terminal and never create a visit. With paid deposit credit, staff invoice a no-show / cancellation fee, keep it as credit, or refund.- An appointment carries no charges.
2. Arrive
- Check-in (Schedule popover, whiteboard Upcoming drag, or mobile): requires a patient and no open deposit (paid or waived). Appointment →
checked-in; creates aVisitinchecked_in, waiting room,arrived_atnow, staff and type copied; opens/reuses the visit's home order and charges the type's catalog item as the first visit service. Links live deposits to the visit and order. Idempotent. - No visit-only walk-ins: visits are only created by checking in an appointment (
POST /app/visitsno longer exists). A walk-in gets a patient on the booking first. - One visit per patient. A client with two pets is two visits.
- Undo check-in only while the visit is still
checked_inin the waiting room (popover, whiteboardPATCH /app/visits/:id/undo_check_in, or API statusscheduled). It unlinks deposits, releases visit-sourced lines, destroys the visit (and its emptied open order), and returns the appointment toscheduled. Cancel / no-show on a waiting checked-in appointment undoes first.
3. Care
The visit moves across the Whiteboard (in_room in any room; waiting when seen and sent back). These sources become sales order lines, appended to the visit's open home order when one exists, otherwise picked up at checkout:
| Source | Billable when | Price |
|---|---|---|
| Visit service (type fee from check-in, or added on the visit) | Item sellable at the Location (typed: type enabled there) | Patient price; a bundle is one line at the bundle price |
| Treatment plan (visit-linked) | approved by the owner (email link / QR) or staff | Each item at the price snapshotted on the plan (patient group price at the issuing Location); plus an adjustment line when the final price was overridden (price − items_total, may be negative) |
| Lab work on a visit-linked diagnostic order | Has a catalog item and is not cancelled | Patient price for the visit's patient at the Location when charged |
| SOAP note | Never | Clinical record only |
Draft, pending, and rejected plans are never charged. Chart-origin plans and orders (no visit) are not charged. Cancelling a lab work or removing a visit service removes its line from an open order.
4. Ready to bill
- Staff set the visit to
ready_to_bill. The room is cleared, the card leaves Floor and stays on Pipeline.ready_to_bill_atis stamped. - The card (and the visit page) shows Checkout for Staff with
checkout.managewhen the plan includescheckout.
5. Checkout (sales order)
POST /app/visits/:id/checkout picks the target order, appends every visit charge not already on an order, and redirects to it.
- The visit’s linked open sales order (home), else
- an open order at this Location that already holds lines for the visit, else
- a new open order (payer = primary pet parent,
opened_by= current Staff).
Each visit gets its own order by default; staff merge or split at the desk. After a partial split a visit may span several open orders: automatic charges stay on the home order; the visit cart can add a line to another associated open order. A full split or merge retargets the home. Lines are grouped by patient and show the visit code.
Keeping the order in sync
| Event | Effect on open orders |
|---|---|
| Checkout clicked again | Appends only charges added since (idempotent) |
| Visit-linked plan approved, diagnostic order issued, or visit service added | Lines appended to the visit's open home order |
| Lab work cancelled / visit service removed | Its line is removed from any open order |
| Catalog price changed | Existing lines keep their snapshotted price |
There is no separate “Sync charges” action; re-run Checkout instead.
At the desk
- Manual lines: catalog items sellable at the Location (granted, enabled, priced, sellable) at the patient price for the line's patient (standard price without one). Staff may edit the unit price of an item line on an open order.
- Discounts: per line and per order (percent or amount). The order discount is spread over item lines; totals are computed, not stored.
- Stock: inventoried lines allocate quantity while open (bundles allocate their stocked components); batch lines keep a preferred lot. Oversell warns but never blocks. Stock moved to Reserved for the order returns to available on void or invoice and moves with merge (Inventory).
- Deposits: apply / unapply paid deposits of the client at this Legal Entity.
- Split: move selected lines to a new order, optionally for another payer. Neither side may go negative. Deposits stay on the original.
- Merge: pull other open orders at the same Location into one; sources become
merged; deposits and reserved stock move to the target. - Void: deletes the lines (sources can be charged again), unlinks deposits, releases allocation and reserved stock.
Split and merge keep the combined total to the cent. Details: docs/functional/checkout.md.
6. Invoice Built
invoices.*). BillingInvoice / Settings → Billing / billing.* remain SaaS (TaskPaws charging the clinic).
- Preview (
GET /app/checkout/:id/preview_invoice), then issue from anopenorder with lines (POST /app/checkout/:id/invoice); the order becomesinvoicedand locks. - Numbering per Legal Entity (
INV-000123). Issuer snapshot: legal name, tax ID, currency. Bill-to = payer; ship-to = a payer candidate; notes frozen. - Lines, snapshotted prices, line and order discounts are frozen. Taxes use each item's tax group and the rates effective (inherited or overridden) at the order's Location on the issue date.
- Platform fee line when the org charges clients; usage credits are spent on issue (SaaS billing).
- Staff commissions are calculated per provider line from their commission group.
- Reserved stock is released and inventory consumed (bundles consume components);
invoice_issuedposts to the client ledger; linked deposit credit is applied. - Optional non-taxable staff tip (percent or amount, split or direct) — see Clinic tips.
7. Collect and correct
- Payments (record-only): multi-tender, partial, payor shares, client credit, refunds, voids,
RCP-/RFD-receipts.balance_due = net_total + tip_total − amount_paid. - Credit notes (
CN-): credit invoice lines by quantity or add new lines; lowernet_total, restock flagged lines, release overpaid allocations, and reverse commissions. - Tips can be added at collect or later; shares are paid out, voided, or transferred.
See Billing and finance.
8. Complete
- Staff set the visit to
completed(Pipeline).completed_atis stamped; it is hidden from Floor and, by default, from Pipeline. - Completing a visit does not touch its order, and invoicing does not complete the visit. The two are independent.
Key rules
- Charges belong to the visit, never to the appointment.
- One source, one line: each visit service, plan item, overridden plan, and lab work sits on exactly one line across all orders (unique index). Moving a line keeps its source, so re-running checkout never duplicates it.
- Prices are snapshotted (patient price) when the line is created and never change on split or merge.
- New lines must be sellable at the Location; unsellable services are not charged.
- Location comes from the workspace, never from params. Orders from another Location or Organization return 404.
- Only
openorders change.merged,voided, andinvoicedare read-only; issued invoices change only through payments, tips, and credit notes.
Who does what
| Role | Book | Check-in / move visit | Approve plan | Checkout | Invoices | Payments |
|---|---|---|---|---|---|---|
| Organization administrator | Yes | Yes | Yes | Manage | Manage | Manage |
| Location administrator | Yes | Yes | Yes | Manage | Manage | Manage |
| Receptionist | Yes | Yes | No | Manage | Manage | Manage |
| Veterinarian | No | Yes | Yes | Read (edits visit cart) | Read | Read |
Plan approval by staff needs soap.manage; owners approve from the emailed link without a session. Veterinarians edit the visit cart with visits.manage but not desk checkout. Full grants: RBAC.
Related: Appointments · Visits · SOAP notes · Catalog and pricing · Inventory · Billing and finance · Clinic tips · Clinic commissions.