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:
@@ -0,0 +1,38 @@
|
||||
from collections.abc import Sequence
|
||||
from typing import Protocol
|
||||
|
||||
from apps.customers.application.dto import (
|
||||
BillingUnitView,
|
||||
ContactView,
|
||||
CustomerDetails,
|
||||
CustomerSummary,
|
||||
)
|
||||
from apps.customers.domain.enums import CustomerType
|
||||
|
||||
|
||||
class CustomerQueries(Protocol):
|
||||
"""Public read interface of the customers module."""
|
||||
|
||||
def list_customers(
|
||||
self, *, search: str = "", type: CustomerType | None = None
|
||||
) -> Sequence[CustomerSummary]:
|
||||
"""Search by name or business ID (never by personal identity code); internal first."""
|
||||
...
|
||||
|
||||
def search(self, term: str, *, limit: int = 20) -> Sequence[CustomerSummary]:
|
||||
"""Autocomplete for other modules (e.g. job intake)."""
|
||||
...
|
||||
|
||||
def get_summary(self, customer_id: int) -> CustomerSummary | None: ...
|
||||
|
||||
def get_details(
|
||||
self, customer_id: int, *, include_full_personal_id: bool = False
|
||||
) -> CustomerDetails | None: ...
|
||||
|
||||
def contacts(self, customer_id: int) -> Sequence[ContactView]: ...
|
||||
|
||||
def billing_units(self, customer_id: int) -> Sequence[BillingUnitView]: ...
|
||||
|
||||
def is_deletable(self, customer_id: int) -> bool:
|
||||
"""Not internal and nothing (contacts, billing units, jobs, sales …) refers to it."""
|
||||
...
|
||||
Reference in New Issue
Block a user