Commit graph

17 commits

Author SHA1 Message Date
2b04d99fd6 Fix mobile overflow on reconciliation, safe count, and settings tables
Tables with multiple columns now scroll horizontally within their cards
instead of overflowing off-screen on mobile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 11:59:15 +00:00
82348bc834 Mobile-responsive layout and camera upload improvements
- Hamburger menu with slide-in nav for viewports < 700px; auto-closes on route change
- PhotoUploader: separate camera trigger on mobile (capture="environment"), file input hidden on mobile; useCallback to fix stale-closure reset
- Add .gitignore to exclude compiled JS artefacts and package-lock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 08:57:54 +00:00
37453ddfda Return 200+null instead of 404 when no cash up found for date — eliminates browser console error 2026-07-07 20:56:34 +00:00
8b2dc4ad78 Cashup: preserve orphaned card machine data when settings name is removed
applyLoaded now appends any DB machines whose name is no longer in the
current settings list, rather than silently dropping them. This prevents
their amounts being deleted from the database the next time the record
is saved (backend does DELETE + re-insert on every save).

Orphaned machines render with a red 'Removed from settings' badge, a
pink border, and read-only inputs so the data is visible but can't be
accidentally edited. They are still included in totalPdq and the save
payload, so nothing is lost.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 11:38:12 +00:00
dcb450bd99 Cashup: configurable card machines — settings + inline Z-report layout
Settings: add Card Machines section to configure number of PDQ terminals
and their names (1–6 machines, defaults to Front Desk + Restaurant / Bar).
Names are stored under the 'card_machines' settings key.

DailyCashUp: machine names now load from settings instead of hardcoded
const. Card Machines section changed from a 2-column grid to a vertical
list; each machine row shows the amount inputs on the left and its PDQ
Z-report photo uploader on the right. Separate PDQ Z-Reports card removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 11:32:37 +00:00
13f1b524b0 Cashup: show Newbook reported cash target + variance in Cash Takings section
Mirrors the float count variance pattern — once Newbook data is loaded,
shows the reported cash amount and the counted vs reported variance
directly beneath the Cash Takings header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 11:26:19 +00:00
2f9b876d0d Fix cashup bugs: PDQ totals, WET placeholder, print styles, cash summary
Issue #1: Parse card machine amounts as floats in applyLoaded — pg returns
DECIMAL as strings which caused JS string concatenation in totalPdq and
reconciliation banked amounts. After draft save, reload cashUp to get the
persisted ID so PDQ Z-report uploads work on first save.

Issue #2: Guard empty gl_code in sales breakdown name-matching — an empty
column code caused gName.includes('') to always be true, making placeholder
columns (like WET 5%) match the first available GL group (dry dept).

Issue #3: Move Cash Summary above Safe Count in sidebar nav. Extend
cash-summary endpoint with per-day breakdown. Rewrite CashSummary.tsx
with a daily cash takings table above the denomination summary.

Issue #4: Add @media print CSS — hide sidebar nav, force colour printing,
style disabled inputs as plain text, and keep tables/cards intact on paper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 11:25:27 +00:00
d03371dca1 Auto-save drafts, reorder float/takings, 5-col reconciliation table
- Auto-save: every 60s while editing, silently saves draft if form has data.
  Status "Auto-saved at HH:MM" appears next to the Save Draft button briefly.
- Float Count moved above Cash Takings and defaults to open so staff count
  the float first before counting takings.
- Reconciliation table gains a fifth "Card Total" column: PDQ Visa/MC and
  PDQ Amex rows share a rowspan=2 cell showing the combined PDQ variance.
  If the per-category rows are red but the combined is green it means only
  the Visa/Amex split was mis-allocated, not an actual cash discrepancy
  (labelled "split only"). Gateway rows similarly grouped (always auto 0).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:55:05 +00:00
fb66dcd6bf Save transaction checks, till float variance, fix image upload
- Persist transaction breakdown checked state in cash_ups.checked_transactions
  (JSONB column); saved on each draft/final save and restored on page load.
  Re-fetching Newbook no longer resets the checked items.
- Add till_float_target setting; Float Count card shows target and variance
  so staff can see at a glance whether the till balances.
- Compress images client-side (max 1600px, 85% JPEG) before upload to avoid
  504 gateway timeouts from NPM when uploading large mobile photos.
- File input accepts image/* only (was image/*+PDF which confuses mobile pickers).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:46:52 +00:00
be670f724d Enforce granular capabilities across cashup
Backend (server-side enforcement, not just UI):
- auth.js: read caps from JWT; hasCap() + requireCap() helpers;
  legacy-token fallback (full access minus settings) so existing
  sessions keep working until re-login
- finalise: submit final, delete draft, bulk-finalise, attachments
- reports: multiday report, cash summary, debtors
- floats: float management + safe count
- settings: settings mutations (was is_admin)
- count: draft save, newbook fetch

Frontend:
- can(user, cap) helper; User.caps from /verify
- Nav items, routes and actions (Submit Final, delete, bulk-finalise)
  gated on capabilities; non-finalisers see a draft-only hint

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 14:19:30 +00:00
43c332be9b Add photo upload for PDQ Z-reports and receipt evidence
DB:
- Add attachment_type ('pdq_z_report' | 'receipt_error' | 'other') and
  label columns to cash_count_attachments; migrate existing rows via
  ALTER TABLE IF NOT EXISTS (no data loss)

Backend:
- Upload route now reads attachment_type and label from multipart form
  fields alongside the file, stores them in the DB

Frontend:
- PhotoUploader component: thumbnail grid, upload button (images + PDF),
  spinner during upload, ✕ delete button on each photo, click opens in
  new tab
- DailyCashUp: PDQ Z-Reports card (one section per machine — Front Desk /
  Restaurant Bar) appears after Card Machines when a cash up exists
- DailyCashUp: Receipt Evidence card at bottom for any discrepancy photos;
  stays editable even on final cash ups so receipts can be added later

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 09:22:22 +00:00
4caf307fd1 Auto-fetch Newbook on date load; add transaction breakdown checklist
- Newbook payments now fetched automatically when a date loads (in
  parallel with the cash up fetch), not just on button click
- Refresh button still available for manual re-fetch
- Transaction breakdown section below reconciliation table: three
  collapsible groups (Reception Manual, Reception Gateway, Restaurant/Bar)
  each showing individual transactions with click-to-tick checkboxes
  for tracking down discrepancies — local state, clears on refresh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 22:15:42 +00:00
53c8938c2f Fix denomination total wrong when loaded from DB
PostgreSQL NUMERIC columns return as strings in node-postgres. denomTotal
was doing 0 + "40.00" + "30.00" → "040.0030.00", and parseFloat in
fmtGBP read only the first portion, giving a wrong total (£40.00 instead
of £78.80 etc).

Fix: coerce total_amount and value_entered to numbers in applyLoaded;
make denomTotal's reducer defensively use Number() so strings can't
silently break the sum again.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 22:06:03 +00:00
e6188fb337 Add proper state machine flow to DailyCashUp
- On mount/date change: auto-fetch existing cash up
  - Draft found → auto-load into editing state
  - Finalised → auto-load into locked state (read-only + banner)
  - Not found → show 'Start Cash Up' prompt
- Removed manual 'Load Existing' / 'New' buttons
- Submitting final transitions immediately to locked state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 21:30:22 +00:00
4cbe68ebf7 Vertical tab order in denomination grids
Tab now moves down the Qty column first (£50→£20→...→1p), then down
the Value Override column, for both takings and float grids.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 21:24:41 +00:00
577e98e6b1 Fix TypeScript compile errors blocking Docker build
- Add vite-env.d.ts for import.meta.env type support
- Remove unused imports: ChevronRight, useCallback (x2), today
- Silence unused attachments state read (keep setter for future use)
- Fix FloatManagement changeTinTargets reducer: drop unused k, fix v type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 20:11:01 +00:00
63a5a72fa3 Wire Newbook credentials to settings service 2026-07-01 19:33:16 +00:00