Add customer contacts, billing units and consumer personal identity codes

Customer page and contacts/billing units (phase 1, item 2):
- New customer page (customers.show) with details, contacts and billing
  units; add and edit on their own pages, delete after confirmation.
  Creating or editing a customer now leads to this page.
- Contacts: name, title, phone, email, note. Billing units: name,
  billing address, e-invoice address (12-35 letters/digits), operator
  (required with an e-invoice address) and reference.
- Use cases check that the row belongs to the customer, so ids in the
  URL can't reach another customer's rows.
- EmailAddress moves from Users to Shared so both modules can use it.
- <x-confirm-dialog> (native <dialog>) replaces <x-modal>, whose title,
  close button and focus handling are not accessible; solid red buttons
  use red-700 via published NormalButtonColors for 4.5:1 contrast.

Personal identity code (henkilötunnus) for consumers who are invoiced:
- Validated (date, century sign, check character), stored encrypted
  with an HMAC blind index for duplicate checks; never in
  CustomerSummary, search, logs or Livewire state.
- Admins and management see it in full and may remove it; others enter
  it and see only the masked form. The form never shows the stored code.

Spec, architecture doc and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-23 18:11:06 +02:00
co-authored by Claude Opus 5.5
parent 8dfc02c4e5
commit e0b8f4970f
93 changed files with 3777 additions and 58 deletions
+4 -1
View File
@@ -38,12 +38,15 @@ Accessibility is a contractual acceptance criterion. It covers the whole UI: nav
- `<x-theme-switch>`: unnamed `role="switch"`. Use `resources/views/partials/theme-toggle.blade.php`, which drives `tallstackui_darkTheme({ default: 'system' })` on `<html>` (localStorage `dark-theme`; an inline script in the layout applies it before paint).
- `<tallstackui:script />`: root-relative asset URLs that 404 in a subfolder (local XAMPP). The layout includes `resources/views/partials/tallstackui-script.blade.php` instead.
- `<x-select.native>`: the label is not tied to the control, so also pass `:aria-label` with the same text.
- `<x-modal>`: `aria-labelledby` points at an id its title lacks, the close button has no name, and focus neither moves in nor returns. Use `<x-confirm-dialog>` (`resources/views/components/confirm-dialog.blade.php`, native `<dialog>` + `showModal()`), opened from Livewire with `$this->js("document.getElementById('<id>').showModal()")`; see `customers::show`.
- Solid `color="red"` buttons: white on red-500 is 3.5:1, so the solid red is red-700 in the published `NormalButtonColors`.
- `<x-input>` without `wire:model` (e.g. a read-only value): pass an explicit `id`, or the label is not tied to it. `<x-clipboard>` has an unlabelled input and a button whose name changes; build copy fields from `<x-input readonly>` + `<x-button>` + a `role="status"` message instead (see `users::form`).
- Contrast: the primary palette is one step darker (`resources/css/app.css`); error text, label error and asterisk, and input/select error colours are changed by soft customization in `App\Providers\AppServiceProvider`; light alert and link text colours are in published colour classes `app/View/Components/TallStackUi/Colors/`. `flat` and `outline` buttons have no dark-mode text colour: use `subtle color="black"` for neutral buttons.
- Finnish strings for TallStackUI's own components are in `lang/vendor/ts-ui/fi/messages.php`.
- **Personal identity codes** (*henkilötunnus*, consumer customers) are sensitive personal data: stored encrypted (`encrypted` cast, `$hidden`) with an HMAC blind index for duplicates, never in `CustomerSummary`, search, logs, exception messages or Livewire public properties, and shown in full only behind `customers.view-personal-identity-code` (admin, management) via `CustomerQueries::personalIdentityCodeOf()`; everyone else sees `masked()`.
- Never convey meaning by colour alone. Statuses, priorities (e.g. *kiire* = red), errors and warnings always also have visible text or an icon with text.
- Announce dynamic changes: put status text in `role="status"` / `aria-live="polite"` (errors: `role="alert"`), or a TallStackUI toast (`<x-toast />` must then be added to the layout). Keep button names stable instead of putting changing state in them.
- Make everything work with the keyboard alone, with a visible focus indicator and no focus traps. Use `<x-modal>` for dialogs and check that focus moves in and returns.
- Make everything work with the keyboard alone, with a visible focus indicator and no focus traps. Use `<x-confirm-dialog>` for dialogs (not `<x-modal>`, see above) and check that focus moves in and returns.
- The layout (`resources/views/layouts/app.blade.php`) provides a skip link and a `<main id="main-content">` landmark. Keep them, and add `<nav aria-label="…">` for navigation.
- One `h1` per page, logical heading order, and a descriptive page `#[Title]` on every page component.
- Data tables use `<x-table>` with `headers` (custom cells with `@interact('column_<index>', $row)`). Icon-only buttons need an `aria-label` (a `tooltip` alone is not a name). Decorative images get `alt=""`.