feat: Enhance Pedimentos schemas with required fields and operation type enumeration
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user