- 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]>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from typing import Protocol
|
|
|
|
from apps.customers.domain.entities import BillingUnit, Contact, Customer
|
|
from apps.customers.domain.value_objects import BusinessId, PersonalIdentityCode
|
|
|
|
|
|
class CustomerRepository(Protocol):
|
|
def get(self, customer_id: int) -> Customer | None: ...
|
|
|
|
def save(self, customer: Customer) -> Customer:
|
|
"""Insert or update. Removes the stored personal identity code when
|
|
``customer.has_personal_id`` is False."""
|
|
...
|
|
|
|
def set_personal_id(self, customer_id: int, code: PersonalIdentityCode) -> None:
|
|
"""Store the code encrypted, with its fingerprint for duplicate checks."""
|
|
...
|
|
|
|
def is_business_id_taken(
|
|
self, business_id: BusinessId, *, exclude_id: int | None = None
|
|
) -> bool: ...
|
|
|
|
def is_personal_id_taken(
|
|
self, code: PersonalIdentityCode, *, exclude_id: int | None = None
|
|
) -> bool: ...
|
|
|
|
def delete(self, customer_id: int) -> None:
|
|
"""Raises CustomerInUse if anything still refers to the customer."""
|
|
...
|
|
|
|
|
|
class ContactRepository(Protocol):
|
|
def get(self, contact_id: int) -> Contact | None: ...
|
|
|
|
def save(self, contact: Contact) -> Contact: ...
|
|
|
|
def delete(self, contact_id: int) -> None:
|
|
"""Raises ContactInUse if a job refers to the contact."""
|
|
...
|
|
|
|
|
|
class BillingUnitRepository(Protocol):
|
|
def get(self, billing_unit_id: int) -> BillingUnit | None: ...
|
|
|
|
def save(self, billing_unit: BillingUnit) -> BillingUnit: ...
|
|
|
|
def delete(self, billing_unit_id: int) -> None:
|
|
"""Raises BillingUnitInUse if a job or invoice refers to the unit."""
|
|
...
|