Vaihe 1/2: asiakkaat, yhteyshenkilöt ja laskutusyksiköt

- customers-moduuli Clean Architecture -kerroksin: asiakas (yritys/kuluttaja),
  Y-tunnuksen tarkiste ja yksilöllisyys, yhteyshenkilöt, laskutusyksiköt
  (verkkolaskuosoite vaatii välittäjätunnuksen)
- henkilötunnus salattuna (Fernet) ja HMAC-tiiviste päällekkäisyyksiin;
  pääkäyttäjä ja johto näkevät ja poistavat, muut näkevät peitettynä
- sisäinen asiakas data-migraatiolla, ei poistettavissa
- yleinen poistonesto käänteisten relaatioiden perusteella (tulevat
  PROTECT-viiteavaimet estävät poiston automaattisesti)
- asiakkaan sivu: lisäys ja muokkaus dialogissa HTMX:llä, fokuksen hallinta
  ja ruudunlukijailmoitukset; HTMX näyttää nyt 422-validointivirheet
- testit: domain, application, integraatio ja selaintestit (axe);
  yhteiset fixturet apps/conftest.py:hin, FakeUnitOfWork shared-moduuliin
- import-linter: moduulien riippumattomuussäännöt
- dokumentit päivitetty

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-29 13:47:09 +02:00
co-authored by Claude Opus 5.5
parent e7b2745916
commit a81c073d6a
68 changed files with 3470 additions and 144 deletions
+26 -2
View File
@@ -7,10 +7,23 @@
localStorage.setItem(THEME_KEY, theme);
};
// Forms answer validation errors with 422; HTMX must swap those too so errors are shown.
if (window.htmx) {
window.htmx.config.responseHandling = [
{ code: "204", swap: false },
{ code: "[23]..", swap: true },
{ code: "422", swap: true },
{ code: "[45]..", swap: false, error: true },
{ code: "...", swap: true },
];
}
// After a swap: focus the first invalid field, else an element marked data-autofocus.
document.addEventListener("htmx:afterSettle", function (event) {
const target = event.detail.target;
if (!target) return;
const focusable = target.querySelector("[data-autofocus]");
if (!target || !target.isConnected) return;
const focusable =
target.querySelector("[aria-invalid='true']") || target.querySelector("[data-autofocus]");
if (focusable) {
focusable.focus();
}
@@ -21,6 +34,17 @@
window.notify(event.detail.value || event.detail.message || "");
});
// A dialog form saved: the server re-rendered the section (HX-Trigger-After-Settle "itemSaved").
document.body.addEventListener("itemSaved", function (event) {
const detail = event.detail || {};
document.querySelectorAll("dialog[open]").forEach(function (d) { d.close(); });
if (detail.focus) {
const el = document.querySelector(detail.focus);
if (el) el.focus();
}
if (detail.message) window.notify(detail.message);
});
window.notify = function (message) {
const live = document.getElementById("live-region");
if (live) {