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.""" ...