Alinea el dominio al spec de catálogos: - accounts (Clientes/Prospectos): tipo registro/persona, CURP, clasificación comercial, bloque fiscal (régimen, CFDI, pago, crédito), auditoría, notas internas - suppliers (Proveedores): clasificación múltiple, cobertura, países/puertos/ aeropuertos/aduanas (JSON), fiscal - addresses y documents: tablas compartidas con FK a cliente o proveedor - contacts enriquecidos (extensión, whatsapp, área, flags "recibe…", supplier_id) - migración a7b8c9d0e1f2 (ALTER + CREATE) con downgrade completo - permisos supplier/address/document; seed de datos actualizado - 39 tests pytest en verde Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
|
|
|
|
|
class ContactBase(BaseModel):
|
|
account_id: int | None = None
|
|
supplier_id: int | None = None
|
|
first_name: str = Field(..., min_length=1, max_length=120)
|
|
last_name: str | None = Field(None, max_length=120)
|
|
job_title: str | None = Field(None, max_length=120)
|
|
department: str | None = Field(None, max_length=120)
|
|
area: str | None = Field(None, max_length=120)
|
|
email: EmailStr | None = None
|
|
phone: str | None = Field(None, max_length=40)
|
|
extension: str | None = Field(None, max_length=20)
|
|
mobile: str | None = Field(None, max_length=40)
|
|
whatsapp: str | None = Field(None, max_length=40)
|
|
is_primary: bool = False
|
|
receives_quotes: bool = False
|
|
receives_invoices: bool = False
|
|
receives_commercial_info: bool = False
|
|
status: str = Field("active", max_length=20)
|
|
owner_user_id: str | None = Field(None, max_length=64)
|
|
notes: str | None = None
|
|
|
|
|
|
class ContactCreate(ContactBase):
|
|
pass
|
|
|
|
|
|
class ContactUpdate(BaseModel):
|
|
account_id: int | None = None
|
|
supplier_id: int | None = None
|
|
first_name: str | None = Field(None, min_length=1, max_length=120)
|
|
last_name: str | None = Field(None, max_length=120)
|
|
job_title: str | None = Field(None, max_length=120)
|
|
department: str | None = Field(None, max_length=120)
|
|
area: str | None = Field(None, max_length=120)
|
|
email: EmailStr | None = None
|
|
phone: str | None = Field(None, max_length=40)
|
|
extension: str | None = Field(None, max_length=20)
|
|
mobile: str | None = Field(None, max_length=40)
|
|
whatsapp: str | None = Field(None, max_length=40)
|
|
is_primary: bool | None = None
|
|
receives_quotes: bool | None = None
|
|
receives_invoices: bool | None = None
|
|
receives_commercial_info: bool | None = None
|
|
status: str | None = Field(None, max_length=20)
|
|
owner_user_id: str | None = Field(None, max_length=64)
|
|
notes: str | None = None
|
|
|
|
|
|
class ContactResponse(ContactBase):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
tenant_id: int
|
|
company_id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|