A ground-up rebuild of the digital service form, replacing Luxtronic-Digital-ServiceForm's
one-long-page intake with a step-by-step wizard (1–2 questions per page) that matches how the
job actually gets written up in the shop.
The old system's intake page (service-form.html) is a single scroll of ~25 fields across four
card sections. It works, but it's not fast to fill out on a tablet mid-repair. This rebuild keeps
the same underlying data (customer, device, issue, diagnosis, cost) but delivers it as a guided
flow, and simplifies the job-status model to match actual shop workflow (no "pending/cancelled"
states that don't get used).
This is a new, standalone project — own repo, own Postgres database, own deployment — not a new frontend bolted onto the old backend. The old app keeps running as-is; there is no data migration.
- Technician inspects the machine first (before touching this app) and works out the fix and the price.
- Technician fills out the form in one sitting: customer details, device details, reported
issue, diagnosis, parts + labour cost. Saving it sets status
started. - The form is printed — it doubles as a quotation + disclaimer. The customer signs the printed copy (physical signature, pen and paper) to approve the job before work proceeds.
- Technician does the repair. Occasionally reopens the record to add a part/cost that came up mid-job — the record stays editable at any time, no locking.
- When the repair is done and the device is ready for pickup, technician marks it
finished. - Actual invoicing/receipt happens separately in Odoo — out of scope for this app. This app's printed output is the quotation/disclaimer only, not a tax invoice.
In scope (v1):
- Step-by-step intake wizard (see flow below), auto-saving as a draft per step so a closed tab / tablet reboot mid-fill doesn't lose progress.
- Final review/summary page before committing to
started— lists every answer with a per-section "Edit" link back into the wizard. - Search / records list (find by customer name, phone, form ID; filter by status and date range).
- A "Complete Job" action from a record's detail view to flip
started→finished(no separate wizard needed for this — see Status model below). - Photo upload attached to a record (device condition photos).
- Printable quotation + disclaimer page (browser print, no PDF pipeline — matches
LUXTRONIC-API-CONVENTIONS.md's printable-document pattern). - Analytics dashboard (adapted from the old one — see Analytics section).
Explicitly out of scope for v1 (per your answers — flag to revisit later if wanted):
- The clickable SVG damage-diagram — replaced by free-text damage notes + photos.
- Any staff login/auth — LAN-only, no-login, same trust model as every sibling app.
- Data migration from the old system.
- Invoicing/receipts — stays in Odoo.
- E-signature capture — the printed form is signed on paper.
Three states (simpler than the old pending/in progress/completed/cancelled):
| Status | Meaning |
|---|---|
draft |
Wizard in progress, not yet reviewed/submitted. Auto-saved step by step. Not shown in normal search results (or shown in a separate "Drafts" filter) since it's not a real job yet. |
started |
Quotation written up, customer has approved, repair in progress. |
finished |
Repair complete, device ready for / already at pickup. |
No cancelled — per your note it essentially never happens; if it's ever needed later, add it as a
fourth CHECK value (cheap migration, per LUXTRONIC-DATABASE-CONVENTIONS.md's "enum via CHECK"
convention).
Any record, in any status, stays editable — no read-only locking.
As built — the authoritative version is docker/init-scripts/001_schema.sql.
-- name/phone nullable: the customer row is created when the wizard starts,
-- before step 1 has been answered. "Required" is enforced on submit instead.
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
phone VARCHAR(20),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE service_forms (
id VARCHAR(12) PRIMARY KEY, -- e.g. "SF-2026-0001"
year INTEGER NOT NULL,
seq_number INTEGER NOT NULL,
customer_id INTEGER NOT NULL REFERENCES customers (id),
status VARCHAR(10) NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'started', 'finished')),
-- device (nullable while status = 'draft'; validated by POST /:id/submit)
service_type VARCHAR(20) CHECK (service_type IN ('new', 'rma', 'repeat')),
brand VARCHAR(100),
model VARCHAR(100),
serial_number VARCHAR(100),
liquid_damaged BOOLEAN,
accessories JSONB NOT NULL DEFAULT '[]', -- e.g. ["charger", "usb_drive"]
accessories_other TEXT,
-- reported issue (customer-facing symptoms)
reported_issues JSONB NOT NULL DEFAULT '[]', -- e.g. ["no_display", "no_charging"]
issue_notes TEXT,
-- technician diagnosis + quotation (written up in the same sitting)
diagnosis_notes TEXT,
inspection_tests JSONB NOT NULL DEFAULT '[]', -- e.g. ["memtest", "hdd_test"]; added by 003_add_inspection_tests.sql
parts_cost DECIMAL(10,2) NOT NULL DEFAULT 0,
labour_cost DECIMAL(10,2) NOT NULL DEFAULT 0,
total_cost DECIMAL(10,2) NOT NULL DEFAULT 0, -- parts_cost + labour_cost, kept as a real column (not purely computed) so a printed quote never silently reflows if cost logic changes later
parts JSONB NOT NULL DEFAULT '[]', -- line items [{"description", "cost"}]; added by 004_add_parts_line_items.sql
parts_breakdown TEXT, -- UNUSED since 004 (old free-text parts; migrated into `parts`)
wizard_step INTEGER NOT NULL DEFAULT 1, -- resume point while status = 'draft'
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (year, seq_number)
);
CREATE INDEX idx_service_forms_customer ON service_forms (customer_id);
CREATE INDEX idx_service_forms_status ON service_forms (status);
CREATE TABLE service_photos (
id SERIAL PRIMARY KEY,
form_id VARCHAR(12) NOT NULL REFERENCES service_forms (id) ON DELETE CASCADE,
filename VARCHAR(255) NOT NULL,
original_name VARCHAR(255),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_service_photos_form ON service_photos (form_id);
CREATE TABLE sequence_counter (
year INTEGER PRIMARY KEY,
current_value INTEGER NOT NULL DEFAULT 0
);Notes:
reported_issues/accessoriesas JSONB checklists rather than a comma-joined string (the old system'sissue TEXT/accessory VARCHARapproach) — per the DB conventions' JSONB-for-flexible- attributes guidance, and it's trivial to re-render as checkboxes when editing.total_costis stored (not view-computed) since it's the number printed on a customer-signed quotation — it must not silently change if the cost formula changes later. Recomputed and re-saved server-side any timeparts_cost/labour_costchange.parts_costis the sum of thepartsline items, set by the server wheneverpartsis saved (summed in integer cents). The API ignores anyparts_costorparts_breakdowna client sends, so the stored subtotal always matches the items printed on the quote. Each item needs a description (≤200 chars) and a cost ≥ 0; max 30 items.- Keeps the old system's year+sequence ID scheme. Instead of a stored procedure, the next number
is issued by a single atomic upsert on
sequence_counter(src/utils/formId.js). Deleted records leave gaps in the numbering — IDs are never reused. - Known limit:
VARCHAR(12)fits up toSF-YYYY-9999; the 10,000th form in one year would fail to insert. Not a realistic concern at current volume, but widen the column if that changes.
Each step below is one page. Every step's answer auto-saves immediately (PATCH on the draft
record) so navigating away and back resumes at wizard_step.
- Customer name + phone number
- Service type — New / RMA / Repeat Service
- Brand + Model
- Serial number + Liquid damaged? (Y/N)
- Accessories received — checklist (charger, USB/HDD, other + free text)
- Reported issue(s) — checklist (no display, no charging, no post, blue screen, overheating, needs fan clean, network issue, OS issue, other) — same set as the old form
- Issue notes — free text, optional elaboration
- Tests run (Memtest / HDD / Power / Display — from the paper form's office-use section) + Diagnosis — what the technician found, in their own words
- Parts — a list, one row per part with its own cost (Add part / × to remove), live subtotal. A row with a cost but no description blocks Next.
- Labour cost — total auto-calculated and shown live
- Photos (optional, multiple)
- Review — every answer listed by section, each with an "Edit" link back to that step
- Submit → status flips
draft→startedand the page redirects to the service-detail page, which has the Print Service Form button top-right (same layout as Rental-NEO'srental-detail)
Back/Next navigation on every step; a progress indicator (e.g. "Step 4 of 12") and a Delete Draft button next to it, so an abandoned draft can be removed from inside the wizard. Drafts are only reachable through the wizard (Records → Drafts filter, or Dashboard → Continue).
- Records (
/records): list of service forms, filter by status (All excl. drafts / Drafts / In Progress / Finished), search by customer name/phone/form ID/model, date range, paginated. Clicking a draft opens the wizard; anything else opens service-detail. - Service detail (
/service-detail?id=…): read-only view by default; Edit reveals a single-page edit form (customer, device, notes, cost) with Save/Cancel; Delete next to it. Print Service Form top-right, photo gallery with Add Photo(s), and a Status panel with Mark as Finished / Reopen Job. - Print / Quotation view (
/print-form?id=…):@media printpage, filled fromGET /api/service-forms/:id+GET /api/config. The quotation table has one row per part, then Labour, then Total. Print margins: the safe margin (0.35in ≈ 9 mm) is padding on the page itself, with@page { margin: 0 }, so output is identical whichever Margins option is chosen in Chrome's print dialog (Default or Minimum). Chrome's "Minimum" discards the@pagemargin and printed text ~2 mm from the edge, which Brother printers clip. Padding repeats on every printed page (box-decoration-break: clone). Measured 2026-10-10 with real Chrome PDF output and a couple of lines of issue notes: up to 8 parts fit on one A4 page on Default margins and 7 on Minimum (the printer's own margin takes a few mm); beyond that the acknowledgement and signatures move together to page 2. The Terms & Disclaimer bullets come fromSERVICE_FORM_DISCLAIMERin.env(pipe-separated; a point wrapped in[brackets]renders bold without a bullet), followed by the paper form's "I UNDERSTAND AND AGREE … authorise Luxtronic Pty Ltd to proceed" statement above the signatures. The terms are the shop's paper-form wording, grammar-tidied (2026-09-26). - Paper-form items deliberately not carried over: payment method (Cash/Card/Direct Debit — done in Odoo) and the pickup date/signature line. A separate "Note" box is covered by issue notes and diagnosis.
- Analytics dashboard: same shape as the old one (
analytics.js) — total services (30-day, % change), average daily services, most popular brand/device, monthly trend, popular service days, activity heatmap, brand/model distribution — recomputed against the new schema. Drop anything that specifically depended on the old 4-state status; a "started vs finished" split can replace a "pending/cancelled" breakdown if useful, but not required for v1.
- Node.js (ESM) + Express, raw
pg(no ORM) —LUXTRONIC-API-CONVENTIONS.md. - Plain HTML/CSS/JS frontend, no build step, no framework. The wizard is one page
(
views/service-form.html) with JS-driven steps (public/js/serviceForm.js). - Folder layout, response shape (
{success, ...}/{success:false, message}), and transaction pattern for multi-table writes: exactly as inLUXTRONIC-API-CONVENTIONS.md. - Design: amber/cream theme, two-row header+nav, dark-mode toggle, Font Awesome icons — copy
Luxtronic-Rental-NEO/public/css/style.css+common.jsas the starting point, perLUXTRONIC-DESIGN-GUIDELINES.md. Since this is used on a tablet at the counter, keep touch targets on wizard Next/Back buttons and checklist options generously sized (bigger than the old form's default Bootstrap checkboxes). - No authentication — LAN-only trust model, consistent with
LUXTRONIC-PRIVACY-DATA-GUIDELINES.md(valid only as long as this never gets exposed off the shop LAN). - Photos live in
uploads/, gitignored, never logged; customer PII never leaves the LAN Postgres DB — per the privacy guidelines.
Deployed 2026-09-16.
| Setting | Local dev | Production |
|---|---|---|
| App | localhost:8004 |
192.168.68.255:8004 (LAN server, /root/Luxtronic-Service-NEO) |
| Postgres | Docker, 127.0.0.1:5435 |
192.168.68.222:5436 (separate DB host) |
| Postgres DB name | luxtronic_service_neo_db |
same |
| pm2 process | — | luxtronic-service-neo (in pm2 dump; pm2-root systemd unit enabled, so it survives reboot) |
| Docker Compose project | luxtronic-service-neo |
not used — DB is external |
DB schema on production: Docker only runs init-scripts/ on a brand-new volume, and
production isn't Docker-managed, so each schema file is run by hand, in order. Never run
002_seed.sql there — it inserts fake demo customers.
| File | Production |
|---|---|
001_schema.sql |
applied 2026-09-16 |
003_add_inspection_tests.sql |
applied 2026-09-26 |
004_add_parts_line_items.sql |
applied 2026-10-01 (backup taken first: /root/service-neo-backup-20261001.sql on the LAN server) |
005_add_portal_notification_id.sql |
applied 2026-10-10 |
psql -h 192.168.68.222 -p 5436 -U luxtronic_user -d luxtronic_service_neo_db \
-v ON_ERROR_STOP=1 -f docker/init-scripts/003_add_inspection_tests.sqlMigrations after go-live are forward-only (ADD COLUMN IF NOT EXISTS, safe to re-run); don't edit
001_schema.sql in place. An existing local Docker DB also needs them run by hand
(docker exec -i luxtronic_service_neo_db psql -U luxtronic_user -d luxtronic_service_neo_db < file).
Updates: on the LAN server, git pull && npm ci --omit=dev && pm2 restart luxtronic-service-neo.
Local .env must point at the local Docker DB (DB_HOST=127.0.0.1, DB_PORT=5435), never
at 192.168.68.222. If it points at production, local testing writes to and deletes from live
data — this happened once on 2026-09-17 (only empty drafts were affected).
While a job is In Progress (started), the Luxtronic Portal's bell shows a "Service in
progress" notification linking to its service-detail page (Portal API: Luxtronic-Portal/API.md).
| Event | Portal |
|---|---|
| Submit (draft → started) or Reopen | notification created; its id is stored in service_forms.portal_notification_id |
| Mark as Finished, or delete the job | notification removed |
| App (re)start | any started job without a notification gets one (catches pre-existing jobs and jobs started while the portal was down) |
- Opt-in: nothing is sent unless
PORTAL_NOTIFICATIONS_URLis set (andPUBLIC_BASE_URLfor the link). Keep both commented out in local.envso tests can't post to the live portal; set them only in the production.env. - Best-effort: calls time out after 3 s, run after the response is sent, and never throw, so a down or hanging portal can't slow or break submit/finish/delete. Failures are logged with the error message only (no customer details).
- The notification text is written when the job starts; later edits to the customer/device on the detail page don't update it (same as Rental-NEO). It's removed when the job finishes.
- Production setup: add
PORTAL_NOTIFICATIONS_URL=http://192.168.68.255/api/notificationsandPUBLIC_BASE_URL=http://192.168.68.255:8004to the LAN server's.env, then restart. On the first start with this set, every job already in progress gets a notification at once.
Verified 2026-09-26. Items 1–5 should be done before staff rely on this for real jobs.
Must do
Deploy the real terms.Done 2026-09-26 — production.envnow has the shop's paper-form terms (previous.envkept as.env.bak-20260926on the server — delete it, it holds the DB password).Harden photo uploads.Fixed 2026-09-26 (path escape via a crafted:id, any file type accepted and served back as HTML, no size limit). Now::id/:photoIdvalidated withrouter.parambefore any handler runs; the form must exist before files are accepted; only JPEG/PNG/WebP/GIF, max 15 MB each and 10 per upload; the saved extension comes from the MIME type, never the client's filename; a rejected batch leaves nothing on disk;/uploadsis served withX-Content-Type-Options: nosniffandContent-Security-Policy: sandbox. Both pages now show the rejection message. Verified against each original attack.- Set up backups. No
pg_dumpjob exists on the LAN server, and uploaded photos live only on the LAN server's disk (/root/Luxtronic-Service-NEO/uploads). Per the privacy guidelines, a printed customer-approved quotation may be the only record of that approval. Schedule a dailypg_dumpofluxtronic_service_neo_dbplus a copy ofuploads/, to a machine other than192.168.68.222/.255. - Point local
.envback at the local Docker DB (see Deployment above). - Stop empty drafts from piling up. Every visit to New Service without a stored draft inserts a customer + service-form row and uses up an ID number, even if nothing is typed. Production already had three such rows. On a shared tablet, New Service also resumes whichever draft that device opened last, which may be a different customer's. Fix: only create the draft on the first successful Next from step 1, and make the nav's New Service always start fresh (drafts stay resumable from Records/Dashboard).
Should do
- Guard status transitions.
POST /:id/submiton a finished job silently reverts it tostarted(confirmed);POST /:id/finishworks on a draft and skips submit validation. AddAND status = '<expected>'to eachUPDATEand return 409 otherwise. - Detail-page edit gaps. The Edit form can't change the reported-issue or accessory checklists (only the "other" free text; the tests checklist is editable), and Liquid Damaged shows "No" when it was never answered.
- Surface errors. Mark as Finished, Reopen, photo delete, and photo upload (wizard and detail page) have no error handling — a failure does nothing visible.
- Remove
app.use(cors()). The pages are same-origin, so it isn't needed; with it, any website opened on a shop PC can read and write this API (no auth) from that browser. - Change the production DB password. Production uses
luxtronic_password, the same value committed in.env.example. Ship the pending work.Done 2026-09-26 — Delete Draft, tests checklist, acknowledgement statement and real terms are live (commit6298300).
Housekeeping
- Add this service to the
lan-portal-deployskill's service table and to the port registry inLUXTRONIC-INFRA-GUIDELINES.md(app8004; DB192.168.68.222:5436). - The LAN server runs Node 18, which is end-of-life;
npm ciwarns about one dependency wanting Node 20+. Works today, but plan an upgrade.npm auditreports 2 moderate issues.
Verified OK: all SQL is parameterized (the dynamic PATCH columns come from a fixed
whitelist); multi-table writes use transactions; user text is escaped before innerHTML (or set via
textContent on the print page); production schema matches 001_schema.sql; the service is online
with 0 restarts and is in the pm2 dump.
- Reported-issue and accessory checklist options — carried over verbatim from the old form; confirm with staff after some real use.
service_typelabels — New / RMA / Repeat Service; confirm these still cover it.