feat: Enhance PROSEC service and router with additional query parameters for sector and articulo

This commit is contained in:
2026-02-05 12:57:33 -06:00
parent 0440543f24
commit c92d0a3e16
3 changed files with 38 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
"""Fracciones Schemas"""
from decimal import Decimal
from typing import Optional
from pydantic import BaseModel, Field
@@ -8,13 +9,30 @@ class FraccionesResponse(BaseModel):
"""Fracciones arancelarias mexicanas"""
FRACCION: Optional[str] = Field(None, max_length=10)
FRACCIONPUNTO: Optional[str] = Field(None, max_length=10)
DESCRIPCION: Optional[str] = None
UMT: Optional[str] = Field(None, max_length=2)
UMC: Optional[str] = Field(None, max_length=2)
IMPUESTO_EXP: Optional[str] = Field(None, max_length=19)
IMPUESTO_IMP: Optional[str] = Field(None, max_length=19)
NICO: Optional[str] = Field("", max_length=2)
SYSID: int
UMCLAVE: Optional[str] = Field(None, max_length=2)
UMABREVIACION: Optional[str] = Field(None, max_length=4)
ADVIMPOTXT: Optional[str] = Field(None, max_length=19)
ADVIMPONUM: Optional[Decimal] = None
TIPOTASAADVIMPO: Optional[int] = None
ADVEXPOTXT: Optional[str] = Field(None, max_length=19)
ADVEXPONUM: Optional[Decimal] = None
TIPOTASAADVEXPO: Optional[int] = None
TASAIVAFRANJA: Optional[Decimal] = None
TASAIVAINTERIOR: Optional[Decimal] = None
TASAISAN: Optional[Decimal] = None
ARANCELMIXTO: Optional[str] = Field(None, max_length=1)
TASAMIXTA: Optional[Decimal] = None
DOF: Optional[str] = Field(None, max_length=8)
NOTAS: Optional[str] = None
HISTORICO: Optional[str] = None
ARANCELESPECIFICO: Optional[str] = Field(None, max_length=1)
TIPOVEHICULO: Optional[str] = Field(None, max_length=1)
APLICAISAN: Optional[str] = Field(None, max_length=1)
APLICAIEPS: Optional[str] = Field(None, max_length=1)
NIVEL: Optional[int] = None
NICO: Optional[str] = Field(None, max_length=14)
class Config:
from_attributes = True

View File

@@ -13,6 +13,8 @@ router = APIRouter()
async def search_prosec(
fraccion: Optional[str] = Query(None),
nico: Optional[str] = Query(None),
sector: Optional[str] = Query(None),
articulo: Optional[str] = Query(None),
skip: int = Query(0, ge=0),
limit: int = Query(100, ge=1, le=1000),
current_user: dict = Depends(get_current_user),
@@ -20,7 +22,12 @@ async def search_prosec(
try:
service = ProsecService.get_instance()
return await service.search(
fraccion=fraccion, nico=nico, skip=skip, limit=limit
fraccion=fraccion,
nico=nico,
sector=sector,
articulo=articulo,
skip=skip,
limit=limit,
)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error: {str(e)}")

View File

@@ -20,6 +20,8 @@ class ProsecService(SitarAPIBaseService):
self,
fraccion: Optional[str] = None,
nico: Optional[str] = None,
sector: Optional[str] = None,
articulo: Optional[str] = None,
skip: int = 0,
limit: int = 100,
) -> List[ProsecResponse]:
@@ -28,6 +30,10 @@ class ProsecService(SitarAPIBaseService):
params["fraccion"] = fraccion
if nico:
params["nico"] = nico
if sector:
params["sector"] = sector
if articulo:
params["articulo"] = articulo
data = await self._make_request("GET", "/api/v1/prosec/", params=params)
return [ProsecResponse(**item) for item in data]