feat: add Pedimento relationship and update invoice handling for improved data management
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Optional, List
|
||||
from typing import Optional, List, TYPE_CHECKING
|
||||
from sqlalchemy import (
|
||||
BigInteger,
|
||||
Boolean,
|
||||
@@ -16,6 +16,9 @@ from core.database import Base
|
||||
from datetime import datetime
|
||||
from ....common.base_models import TenantScopedMixin, TimestampMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class Currency(str, Enum):
|
||||
FOREIGN = "foreign"
|
||||
@@ -379,8 +382,11 @@ class InvoiceComplianceMx(Base, TenantScopedMixin, TimestampMixin):
|
||||
Integer
|
||||
) # SEM / ID SEM (de SFacEntradaSM/SFacSalidaSM)
|
||||
|
||||
# Relationship
|
||||
# Relationships
|
||||
header: Mapped["InvoiceHeader"] = relationship(back_populates="compliance_mx")
|
||||
pedimento: Mapped[Optional["Pedimentos"]] = relationship(
|
||||
foreign_keys=[pedimento_id], lazy="joined"
|
||||
)
|
||||
|
||||
|
||||
# --- 3. Financials (invoice_financials) ---
|
||||
|
||||
@@ -461,10 +461,24 @@ class InvoiceHeaderUpdate(InvoiceHeaderBase):
|
||||
# --- Response Schemas ---
|
||||
|
||||
|
||||
class PedimentoBasicInfo(BaseModel):
|
||||
"""Basic Pedimento information for Invoice response"""
|
||||
|
||||
pedimento_number: Optional[str] = None
|
||||
pedimento_code: Optional[str] = None
|
||||
customs_office: Optional[str] = None
|
||||
license: Optional[str] = None
|
||||
year: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class InvoiceComplianceMxResponse(InvoiceComplianceMxBase):
|
||||
"""Schema for Compliance MX response"""
|
||||
|
||||
invoice_id: int
|
||||
pedimento: Optional[PedimentoBasicInfo] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
Reference in New Issue
Block a user