billing
Your invoice, explained
TL;DR
Draft → Sent → Paid. Once sent, your invoice can’t be silently edited — fixes show as adjustments. Find it in /portal/invoices.
- billing
- invoice
- draft
- sent
Invoice lifecycle
draft → sent → partial → paid (also overdue, void)
- Draft: Staff-only, editable. Not visible to horse owners in
/portal. Add/edit/delete line items. - Sent: Visible in portal. Emailed via Resend if sending email. Uses
security_invoker = trueviews + RLS:TO authenticatedplusclients.user_id = auth.uid()ororganization_membersfor staff. - Partial/Paid: Updated as payments recorded.
- Overdue: Past due date, unpaid balance > 0.
- Void: Cancelled invoice. Requires
owneroradmin. Always logged inaudit_events.
> Invoices are immutable once sent — do not silently edit a sent line. Create adjustment or void+reissue.
Line item anatomy
Each line has: description, horse (horses.id), property (properties.id), service dates, quantity, rate, amount, split % from client_horses, and audit actor/timestamp.
▶Show details for AI/advancedexhaustive reference & AI context
Invoices — Barnflow Billing
Invoice lifecycle
draft → sent → partial → paid (also overdue, void)
- Draft: Staff-only, editable. Not visible to horse owners in
/portal. Add/edit/delete line items. - Sent: Visible in portal. Emailed via Resend if sending email. Uses
security_invoker = trueviews + RLS:TO authenticatedplusclients.user_id = auth.uid()ororganization_membersfor staff. - Partial/Paid: Updated as payments recorded.
- Overdue: Past due date, unpaid balance > 0.
- Void: Cancelled invoice. Requires
owneroradmin. Always logged inaudit_events.
> Invoices are immutable once sent — do not silently edit a sent line. Create adjustment or void+reissue.
Line item anatomy
Each line has: description, horse (horses.id), property (properties.id), service dates, quantity, rate, amount, split % from client_horses, and audit actor/timestamp.
How invoices are generated
- Collect open charges for client (or per-horse split share) in date window (usually monthly).
- Split each line per
client_horsespercentage. - Staff reviews draft at
/app/billing/invoices/[id]→ Send. - Owner sees it at
/portal/invoices/[id]grouped by property → horse.
Splits & invoices
One horse with two owners (50/50) at $600 board → two invoices: $300 each, same period, same horse. Each owner sees only their invoice via RLS.
Offline & idempotency
PWA offline: creation carries client_mutation_id. Replay is last-write-wins; duplicates deduped via audit_events.client_mutation_id.
Keywords: invoice, draft, sent, paid, void, overdue, line item, audit_events, client_mutation_id, RLS, security_invoker
Barn staff: Open a support ticket
Horse owners: Message your barn