From 6d42b0976cb3b257583c420fef17fc5e5ecdab15 Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 7 Nov 2025 15:26:31 -0600 Subject: [PATCH] feat: Enhance Pedimentos schemas with required fields and operation type enumeration --- .../modules/a76/pedmientos/dtos/pedimentos.py | 24 +++++++------ .../a76/pedmientos/models/pedimentos.py | 34 ++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/backend/api/v1/modules/a76/pedmientos/dtos/pedimentos.py b/backend/api/v1/modules/a76/pedmientos/dtos/pedimentos.py index b9a2e45f..d6e7fb9c 100644 --- a/backend/api/v1/modules/a76/pedmientos/dtos/pedimentos.py +++ b/backend/api/v1/modules/a76/pedmientos/dtos/pedimentos.py @@ -1,8 +1,12 @@ +from enum import IntEnum from pydantic import BaseModel, Field, ConfigDict from typing import Optional from decimal import Decimal from datetime import datetime +class OperationType(IntEnum): + EXPORTACION = 1 + IMPORTACION = 2 class PedimentosBase(BaseModel): """Base schema for Pedimentos""" @@ -29,16 +33,16 @@ class PedimentosCreate(PedimentosBase): class PedimentosUpdate(BaseModel): """Schema for updating a Pedimento""" - year: Optional[str] = Field(None, max_length=2) - customs_office: Optional[str] = Field(None, max_length=2) - license: Optional[str] = Field(None, max_length=4) - pedimento_number: Optional[str] = Field(None, max_length=7) - client_id: Optional[int] = None - operation_type: Optional[int] = None - pedimento_type: Optional[int] = None - pedimento_code: Optional[str] = Field(None, max_length=2) - regime: Optional[str] = Field(None, max_length=3) - status: Optional[str] = Field(None, max_length=30) + year: Optional[str] = Field(..., max_length=2) + customs_office: Optional[str] = Field(..., max_length=2) + license: Optional[str] = Field(..., max_length=4) + pedimento_number: Optional[str] = Field(..., max_length=7) + client_id: Optional[int] + operation_type: Optional[OperationType] + pedimento_type: Optional[int] + pedimento_code: Optional[str] = Field(..., max_length=2) + regime: Optional[str] = Field(..., max_length=3) + status: Optional[str] = Field(..., max_length=30) usd_value: Optional[Decimal] = None paid_price: Optional[Decimal] = None gross_weight: Optional[Decimal] = None diff --git a/backend/api/v1/modules/a76/pedmientos/models/pedimentos.py b/backend/api/v1/modules/a76/pedmientos/models/pedimentos.py index 0b2b79cf..2933faab 100644 --- a/backend/api/v1/modules/a76/pedmientos/models/pedimentos.py +++ b/backend/api/v1/modules/a76/pedmientos/models/pedimentos.py @@ -1,8 +1,10 @@ -from typing import TYPE_CHECKING +from decimal import Decimal +from typing import TYPE_CHECKING, Optional from sqlalchemy import DateTime, ForeignKeyConstraint, Index, Integer, Numeric, PrimaryKeyConstraint, String, func, text from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.orm.base import Mapped from datetime import datetime +from enum import IntEnum from core.database import Base if TYPE_CHECKING: @@ -37,22 +39,22 @@ class Pedimentos(Base): {'schema': 'a76'} ) - id = mapped_column(Integer) - tenant_id = mapped_column(Integer, nullable=False, index=True) - year = mapped_column(String(2)) - customs_office = mapped_column(String(2)) - license = mapped_column(String(4)) - pedimento_number = mapped_column(String(7)) - client_id = mapped_column(Integer) - operation_type = mapped_column(Integer) - pedimento_type = mapped_column(Integer) + id: Mapped[int] = mapped_column(Integer) + tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True) + year: Mapped[str] = mapped_column(String(2)) + customs_office: Mapped[str] = mapped_column(String(2)) + license: Mapped[str] = mapped_column(String(4)) + pedimento_number: Mapped[str] = mapped_column(String(7)) + client_id: Mapped[int] = mapped_column(Integer) + operation_type: Mapped[int] = mapped_column(Integer) + pedimento_type: Mapped[int] = mapped_column(Integer) pedimento_code = mapped_column(String(2)) - regime = mapped_column(String(3)) - status = mapped_column(String(30)) - usd_value = mapped_column(Numeric(17, 6)) - paid_price = mapped_column(Numeric(17, 6)) - gross_weight = mapped_column(Numeric(19, 3)) - exchange_rate = mapped_column(Numeric(9, 5)) + regime: Mapped[str] = mapped_column(String(3)) + status: Mapped[str] = mapped_column(String(30)) + usd_value: Mapped[Optional[Decimal]] = mapped_column(Numeric(17, 6)) + paid_price: Mapped[Optional[Decimal]] = mapped_column(Numeric(17, 6)) + gross_weight: Mapped[Optional[Decimal]] = mapped_column(Numeric(19, 3)) + exchange_rate: Mapped[Optional[Decimal]] = mapped_column(Numeric(9, 5)) # Timestamps created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())