Files
CRM_AGENTES_CARGA/backend/api/v1/modules/crm/leads/dto.py
Ernesto Herrera 8431132b10 feat(crm): Prospecto — medio de contacto preferido + fix visualización de documentos (Fase C)
- Prospecto (lead): se conserva "Origen" y se agrega "Medio de contacto preferido"
  (catálogo medio_contacto). Backend leads.preferred_contact_method + migración
  f0a1b2c3d4e5 reversible.
- Bug documentos: endpoint proxy GET /v1/crm/uploads/download transmite el archivo
  por el backend (valida aislamiento tenant/company) — evita la URL prefirmada al
  host interno minio:9000. RelatedManager.openDoc usa blob→objectURL.

Suite backend en verde (109). svelte-check sin errores nuevos.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-07 07:37:30 -06:00

74 lines
2.4 KiB
Python

from datetime import datetime
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class LeadCreate(BaseModel):
name: str = Field(..., min_length=1, max_length=255)
contact_name: str | None = Field(None, max_length=160)
email: EmailStr | None = None
phone: str | None = Field(None, max_length=40)
company_name: str | None = Field(None, max_length=255)
source: str | None = Field(None, max_length=60)
preferred_contact_method: str | None = Field(None, max_length=20)
status: str = Field("new", max_length=20)
estimated_value: Decimal | None = Field(None, ge=0, max_digits=14, decimal_places=2)
owner_user_id: str | None = Field(None, max_length=64)
notes: str | None = None
class LeadUpdate(BaseModel):
name: str | None = Field(None, min_length=1, max_length=255)
contact_name: str | None = Field(None, max_length=160)
email: EmailStr | None = None
phone: str | None = Field(None, max_length=40)
company_name: str | None = Field(None, max_length=255)
source: str | None = Field(None, max_length=60)
preferred_contact_method: str | None = Field(None, max_length=20)
status: str | None = Field(None, max_length=20)
estimated_value: Decimal | None = Field(None, ge=0, max_digits=14, decimal_places=2)
owner_user_id: str | None = Field(None, max_length=64)
notes: str | None = None
class LeadConvert(BaseModel):
"""Parámetros de conversión de un prospecto."""
create_opportunity: bool = True
opportunity_name: str | None = Field(None, max_length=255)
pipeline_id: int | None = None
stage_id: int | None = None
amount: Decimal | None = Field(None, ge=0, max_digits=14, decimal_places=2)
class LeadResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
name: str
contact_name: str | None
email: str | None
phone: str | None
company_name: str | None
source: str | None
preferred_contact_method: str | None = None
status: str
estimated_value: Decimal | None
owner_user_id: str | None
converted_account_id: int | None
converted_contact_id: int | None
converted_opportunity_id: int | None
notes: str | None
tenant_id: int
company_id: int
created_at: datetime
updated_at: datetime
class LeadConvertResult(BaseModel):
lead: LeadResponse
account_id: int
contact_id: int | None
opportunity_id: int | None