You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sims-hq/apps/hq/test
Thomas Joise 400abc224f fix(funnel): review fixes — stop-chase on convert/cancel/lost, scoped ?status=, send guards, F3/F4 convert hardening
Review findings on the quote-to-close slice, each verified against the code:

- convertDocument: ANY conversion now flips the source to 'invoiced' (previously
  only ->INVOICE), so a QT->PI quote leaves the daily scan's 'sent' set and the
  pipeline's Quoted/Waiting — the chase never resumes after convert (spec 7 stop
  conditions). Scan additionally excludes quotes with a live forward child
  (covers rows converted before this fix) and quotes of lost clients.
- convertDocument rule-4 guard (spec 8 F4): a live non-cancelled forward child
  blocks re-convert — one sale, one legal document; cancelling the child
  re-opens the path. Rule-2 fix (spec 8 F3): ->INVOICE recomputes the carried
  lines through computeBill on the invoice's own doc_date (mirrors
  createCreditNote); QT->PI stays copy-only (both non-legal).
- cancelDocument dismisses a cancelled quotation's open follow-up nudges in the
  same transaction, per-row audited — dead paper is not chased.
- GET /reminders?status= no longer bypasses the owner scope and pagination: the
  status param narrows the same scoped listQueue view. Web badge (Layout) now
  uses the honest scoped total instead of an unscoped flat list length.
- listQueue/queueCounts staff scope keeps doc-less reminders (renewal_due,
  amc_expiring, follow_up, email_bounced) visible — they have no derived owner
  and are shared work; previously they vanished for every staff viewer.
- sendReminder resolves the recipient BEFORE minting a public share (a send
  that can never succeed leaves no live artifact) and refuses quote_followup
  sends loudly when share.base_url is unset instead of emailing a dead relative
  link. The scheduler auto-drain parks a hard-failing send as 'failed' with its
  reason instead of crashing the scan.
- reminderContext takes an injectable today (threaded from deps.now in the send
  path) so dated schedule text resolves deterministically.
- Pipeline: quote-less lost clients (client.status=lost) now appear under
  filter=lost (spec 9); Dashboard queue table marks first-page truncation
  honestly (rule 8).

Typecheck clean; 270 tests green (255 before, +15 covering each fix).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 days ago
..
fixtures feat(hq): seed + apex csv importer with verification and series seeding (HQ-1 task 13) 2 weeks ago
amc.test.ts feat(hq): amc contracts with renewal invoice and derived paid state 2 weeks ago
auth.test.ts feat(hq): staff auth with sessions and owner gate (HQ-1 task 3) 2 weeks ago
aws-costs.test.ts feat(hq): aws cost explorer ingestion — sigv4 signer and monthly tag-grouped pull 2 weeks ago
aws-pull-route.test.ts feat(hq): schedule monthly aws cost pull and owner-gated manual pull route 2 weeks ago
aws-repo.test.ts feat(hq): aws usage repo — upsert/list, cross-client cost ranking, routes 2 weeks ago
bounces.test.ts feat(hq): mailbox bounce detection with email_bounced reminders 2 weeks ago
client-modules.test.ts feat(hq): client-module lifecycle tracking (HQ-1 task 6) 2 weeks ago
client-owner.test.ts feat(clients): account-owner plumbing — client.owner_id, audited owner route, role gate 5 days ago
clients.test.ts feat(hq): client registry with GSTIN validation (HQ-1 task 4) 2 weeks ago
dashboard.test.ts feat(hq): dashboard money view and 6-hourly scheduler wiring 2 weeks ago
db.test.ts feat(hq): sqlite schema + audit log (HQ-1 task 2) 2 weeks ago
documents.test.ts fix(funnel): review fixes — stop-chase on convert/cancel/lost, scoped ?status=, send guards, F3/F4 convert hardening 5 days ago
e2e.test.ts feat(hq): server assembly, build script and e2e smoke (HQ-1 task 14) 2 weeks ago
employees-routes.test.ts fix(employees): purge sessions on password reset; reject empty patches and duplicate emails cleanly 5 days ago
employees.test.ts fix(employees): purge sessions on password reset; reject empty patches and duplicate emails cleanly 5 days ago
gmail-connect.test.ts feat(hq): one-time gmail oauth connect script (HQ-1 task 12) 2 weeks ago
gmail.test.ts feat(hq): gmail send with token-death handling and email log (HQ-1 task 11) 2 weeks ago
health.test.ts feat(hq): app skeleton with health endpoint (HQ-1 task 1) 2 weeks ago
hq2-schema.test.ts feat(hq): hq-2 schema — recurring/amc/interaction/reminder tables + bounce column + seeds 2 weeks ago
hq3-schema.test.ts feat(hq): hq-3a schema — aws_usage table (per client per month) 2 weeks ago
import.test.ts feat(hq): seed + apex csv importer with verification and series seeding (HQ-1 task 13) 2 weeks ago
interactions.test.ts feat(hq): interaction log with types, follow-ups and routes 2 weeks ago
isolation.test.ts feat(hq): HQ-1.5 — module quote content, pack pick-lists, bundle isolation check 2 weeks ago
modules.test.ts feat(hq): HQ-1.5 — module quote content, pack pick-lists, bundle isolation check 2 weeks ago
payments.test.ts feat(hq): payments with allocation, TDS and advances (HQ-1 task 9) 2 weeks ago
pdf-download.test.ts feat(hq): attachment download filename on GET /documents/:id/pdf?download=1 1 week ago
pipeline.test.ts fix(funnel): review fixes — stop-chase on convert/cancel/lost, scoped ?status=, send guards, F3/F4 convert hardening 5 days ago
prepare-draft.test.ts feat(hq): extract pure prepareDraft from createDraft (permissive preview path) 1 week ago
preview-fidelity.test.ts test(hq): golden fidelity — preview HTML byte-identical to the PDF's HTML 1 week ago
preview-route.test.ts feat(hq): POST /documents/preview — permissive live preview, persists nothing 1 week ago
preview-sample.test.ts feat(hq): screen paper styles + documentHtmlSample + POST /previews/sample 1 week ago
public-share.test.ts feat(hq): public GET /share/:token document view route 1 week ago
quote-followup.test.ts fix(funnel): review fixes — stop-chase on convert/cancel/lost, scoped ?status=, send guards, F3/F4 convert hardening 5 days ago
receipt.test.ts feat(hq): payment receipts — own RCT/ series, zero-GST acknowledgment PDF 2 weeks ago
recurring.test.ts feat(hq): recurring plan repo and owner-gated routes 2 weeks ago
reminder-preview.test.ts feat(hq): GET /reminders/:id/preview — exact email via shared reminderContext 1 week ago
reminder-schedule.test.ts fix(reminders): deterministic tie-break in resolveSchedule on equal effective_from 5 days ago
reminders.test.ts feat(reminders): escalating quote follow-up (Phase 6, spec §7) 5 days ago
reports.test.ts feat(hq): reports — dues aging, module revenue, client profitability with margin 2 weeks ago
scheduler-recurring.test.ts feat(hq): recurring invoice generation with at-most-once auto-send 2 weeks ago
scheduler-scan.test.ts feat(hq): daily scan detection rules with idempotent reminders 2 weeks ago
send-reminder.test.ts feat(hq): reminder email send reusing gmail, plus manual-queue routes 2 weeks ago
series.test.ts feat(hq): seedable per-FY document series (HQ-1 task 7) 2 weeks ago
settings-company.test.ts feat(hq): company profile settings — owner-gated GET/PUT, audited 2 weeks ago
settings-template.test.ts feat(hq): GET/PUT /settings/template + logo upload (owner-gated, audited) 1 week ago
shares.test.ts feat(hq): shareable document link backend (mint/validate/revoke/list) 1 week ago
template-accent.test.ts feat(hq): beautify document template — "Slate Ledger" visual system + template.accent 1 week ago
template-render.test.ts feat(hq): render editable template.* letterhead fields with default fallback 1 week ago
templates.test.ts feat(hq): HQ-1.5 — module quote content, pack pick-lists, bundle isolation check 2 weeks ago