27 · Business auditability & invoicing

What owners/managers can use today to prove sales, follow money, and review staff actions — how Core Invoicing is the backbone, how tickets become billable invoices, and where the product is still only partially instrumented.

Invoices = sales truth Ticket bill → service invoice Audit coverage is real but not universal

What management actually needs

Business questionGPE surface
How much did we sell today / this period?Reports sales · Business Hub metrics · invoice aggregates
Show me one sale end-to-endInvoice + payments + cart timeline + receipt
Who rang / voided / refunded this?Audit logs (financial) · register shift · staff on invoice
Cash drawer accountabilityRegister open/close + shift history · cash tenders on invoices
Service job billed and paid?Ticket bill + checkout → invoice · mark-paid
Crypto / gift / loyalty on a sale?Payment lines on cart/invoice · gift/loyalty txns
Export for accountant / disputeAudit export · reports · invoice list

Three layers of “truth” (do not mix them blindly)

flowchart TB
  subgraph MONEY["1 · Money truth — canonical"]
    INV[(Invoices + line items
tenant main)] PAY[Payments / tenders linked] end subgraph OPS["2 · Operational timeline"] CART[pos_carts + cart events] TT[transaction tracking timeline] REG[register_shifts] end subgraph COMP["3 · Compliance / security audit"] AL[(audit_logs · analytics DB)] HR[hr_audit_log write-only] end POS[POS finalize] --> INV POS --> CART POS --> AL TIX[Ticket bill checkout] --> INV INV --> PAY
LayerQuestion it answersWhere stored
1. Invoicing What was sold, for how much, paid how, void/refund? Tenant main · Invoices / line items
2. Transaction tracking Cart lifecycle events (created, items, finalized) Tracking service / timeline APIs
3. Audit logs Who did security-sensitive / financial actions? Tenant analytics · audit_logs
Owner playbook For a disputed sale: start at invoice → payments → receipt → register shift for that device/time → audit log filter Financial & POS → optional cart timeline. Do not treat reports widgets alone as legal evidence without the invoice.

Core Invoicing system

Deliberate backbone: POS, kiosk, crypto, inventory adjustments, and service tickets are supposed to create invoices through CoreInvoicingService — single money language (cents, org, source, type).

Factory methods

MethodSource / typeUsed by
createInvoicegenericCore builder
createPOSSaleInvoicesource pos · type salePOS cart finalize
createKioskOrderInvoicekioskKiosk checkout paths
createServiceTicketInvoicesource service_ticket · type service · metadata.ticketIdTicket bill checkout
createCryptoInvoicecrypto-linkedCrypto payment flows
createInventoryAdjustmentinventory adjustment docInventory accounting-style docs
processPaymentpayment against invoicePartial/full pay
voidInvoice · refundInvoicefinancial controlsAdmin transaction management / API

HTTP API — /api/core-invoicing

POST /invoice · /payment · /pos-sale · /kiosk-order · /crypto-invoice · /service-ticket · /inventory-adjustment · /void-invoice · /refund-invoice · sales/inventory analytics GETs

Also

  • /api/invoices — list/create/get/update + payments on invoice
  • Receipts hang off invoice IDs (DocHub 23)
  • Void/refund should emit financial audit events (taxonomy includes INVOICE_VOID / INVOICE_REFUND)

Ticketing ↔ invoicing (billable tickets)

Bill API is first-class; Core link is incomplete Service businesses can attach a bill to a ticket (line items, amount, status). Checkout calls optional posInvoicing.createPosInvoiceForTicket — that module does not exist on disk today, so many checkouts create no Core Invoice. Mark-paid and crypto-invoice paths still work partially. Full readiness: DocHub 28.
flowchart TD
  T[Service ticket]
  B[bill.items · amountCts · status]
  C[POST .../bill/checkout]
  I[CoreInvoicingService.createServiceTicketInvoice]
  INV[(Invoice source=service_ticket)]
  P[Payments / mark-paid]
  CRYPTO[POST .../invoice crypto]

  T --> B
  B --> C --> I --> INV
  INV --> P
  T --> CRYPTO
          

Ticket bill API (scopes tickets:read/write)

EndpointPurpose
GET /api/tickets/:id/billRead bill snapshot
POST …/bill/itemsSet full item list
POST …/bill/add-item · remove-item · clearEdit lines
POST …/bill/checkoutCreate/reuse invoice from bill (POS invoice helper / service ticket)
POST …/bill/mark-paidMark bill paid with optional invoiceId
POST …/invoiceCrypto invoice for ticket amount

Appointment create can also spawn a ticket with ticketId/ticketNumber (DocHub 16) — that ticket can then be billed the same way if the business uses invoice-style service work.

Bill shape (conceptual)

status: none | unpaid | paid · items[] · amountCts · currency · invoiceId · paidAt

Transaction & sales visibility (owner UI)

SurfaceWhat it is
/payments/transactions Payment/transaction list + detail drill-down
/admin/transactions TransactionManagement Manager tools: view, filter, void / refund actions
/reports/sales/* Period sales analytics (summary, items, teams, …)
/business-hub Aggregated ops/payment/transaction health for owners
/admin/open-registers · shift history Cashier accountability / EOD
/admin/audit-logs Filterable audit + financial/security summaries + export

Backend list APIs (multiple — intentional stress point)

  • /api/transactions — primary list + get by id
  • /api/unified/transactions — unified listing
  • /api/simple simple transactions — read-only convenience
  • /api/transaction-tracking — timeline, entity trail, stats, search
  • /api/v1/transactions — payments-engine style
Not fully “one screen to rule them all” Several parallel read models exist (same class of problem as dual reporting paths). For ownership confidence, define a canonical story: Invoice is money; tracking is cart timeline; audit is who/when for sensitive actions; reports are aggregates.

Audit system (compliance layer)

Storage

General audit_logs live in tenant analytics DB (high-volume, off the hot POS path). Categories enum: authentication, authorization, data_access, configuration, financial, system, general.

API /api/audit (session + tenant)

EndpointOwner use
GET /taxonomyFilter presets + event vocabulary
GET /logsFiltered log list
GET /financial · /security · /complianceRole-oriented summaries
GET /summary/event-type · /userAggregate by type/user
POST /entity-trailAll events for one entity
GET /exportExport for external review
POST /recordWrite path (scoped)

UI /admin/audit-logs

Presets: Financial & POS, Staff, Register shifts, Sign-in, Authorization, Configuration, Catalogs. Tabs/helpers pull employee activity, time/attendance, transaction audit reports, security/financial summaries.

What is actually written today (honest)

AreaInstrumentation
Register open/close/admin-closeAuditService
POS tip/recalc (some)partial
POS finalizetracking + financial audit attempt
Master admin tenant mutationsaudited
Catalog / staff mutationstaxonomy exists; not every route emits
Inventory adjust / gift void / ticket bill checkoutverify per-path — not guaranteed universal
HR mutationsSeparate hr_audit_log write-only (limited viewer)
OAO / coverage map already admits this Audit “grows as more events call AuditService.” Taxonomy and query UI are strong; coverage completeness is the open product work — not inventing an audit product from scratch.

Register & shift (cash accountability)

Open/close ceremony + admin force close create auditable register_shift rows and audit events. Shift history CSV export supports EOD. See DocHub 14 / Appendix B.

Maturity assessment (ownership lens)

CapabilityGradeNotes
Invoice as sale backbone Strong POS + service ticket paths designed around Core Invoicing
Ticket billable workflow Strong design Full bill CRUD + checkout + crypto; UI/product polish may vary by tenant use
Owner sales reports Good Broad report tree; dual DB paths need reconciliation discipline
Transaction management void/refund Present Admin UI exists; always re-verify against live invoice after void
Audit log product Infrastructure strong / coverage partial Filters, export, presets ready; not every mutation audited yet
Single “transaction history” UX Fragmented Multiple APIs and screens; owners need a guided path
End-to-end re-verify gift/loyalty/ticket bill Deferred in audit Should be staged test scripts before “compliance ready” claims

What “fully thought through” still needs

  1. Instrumentation matrix — spreadsheet of every money-moving and permission-changing endpoint → must emit audit event type X (close taxonomy gaps).
  2. Canonical owner “Sale detail” page — one UI that joins invoice + tenders + cart timeline + audit entity trail + receipt link.
  3. Ticket billing UX polish — service desk bill editor → checkout → paid status visible next to ticket; appointment-created tickets auto-open bill when appropriate.
  4. Reconciliation report — invoices total vs payments vs register cash vs reports for a date range (detect dual-path drift).
  5. Retention & export policy — how long audit_logs / invoices kept; scheduled export.
  6. Role matrix for who can void/refund/export — permission sets, not only admin role.
  7. Automated tests — POS sale → invoice → audit row; ticket bill checkout → service invoice.

File anchors

ConcernPath
Core invoicingcoreInvoicing.service.js · coreInvoicing.routes.js
Invoices CRUDinvoices.routes.js
POS finalizepos.routes.js finalize + tracking + audit
Ticket billtickets.routes.js /bill/* · checkout · invoice
Auditaudit.service.js · audit.routes.js · auditTaxonomy.js
Audit UIAuditLogs.jsx · api/audit.js
Transactions UITransactionManagement.jsx · payments Transactions
TrackingtransactionTracking.service.js · routes
OAO05 Invoicing · 20 Audit · 06 POS · 13 Tickets

Related DocHub