From 6aef35337ef5ea02509ba7cf15781458a8df2333 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 12 Mar 2026 09:34:00 -0500 Subject: [PATCH] Refactor router imports for clarity and organization --- .../fractions/warning_fractions/models.py | 47 ++++++ .../fractions/warning_fractions/seed.py | 141 ++++++++++++++++++ backend/api/v1/modules/a76/router.py | 14 +- 3 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/models.py create mode 100644 backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/seed.py diff --git a/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/models.py b/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/models.py new file mode 100644 index 00000000..664458fd --- /dev/null +++ b/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/models.py @@ -0,0 +1,47 @@ +""" +Modelos ORM para fracciones de alerta +""" + +from typing import Optional + +from sqlalchemy import Boolean, Integer, PrimaryKeyConstraint, String, UniqueConstraint +from sqlalchemy.orm import Mapped, mapped_column + +from api.v1.common.base_models import TenantScopedMixin, TimestampMixin +from core.database import Base + + +class WarningFraction(Base, TenantScopedMixin, TimestampMixin): + """ + Modelo para fracciones arancelarias con alerta. + Fracciones que requieren atención especial o documentación adicional. + """ + + __tablename__ = "warning_fractions" + __table_args__ = ( + PrimaryKeyConstraint("id", name="warning_fractions_pkey"), + UniqueConstraint( + "fraction", "company_id", name="uq_warning_fractions_fraction_company" + ), + {"schema": "public"}, + ) + + id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) + + # Código de la fracción arancelaria (ej: 01012101) + fraction: Mapped[str] = mapped_column(String(15), nullable=False, index=True) + + # Descripción de la alerta + description: Mapped[Optional[str]] = mapped_column(String(1000)) + + # Tipo de alerta (ej: PERMISO, RESTRICCION, NOM, etc.) + warning_type: Mapped[Optional[str]] = mapped_column(String(50), index=True) + + # Indica si la alerta está activa + is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, server_default="true") + + def __repr__(self) -> str: + return ( + f"" + ) diff --git a/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/seed.py b/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/seed.py new file mode 100644 index 00000000..501ae013 --- /dev/null +++ b/backend/api/v1/modules/a76/general_catalogs/fractions/warning_fractions/seed.py @@ -0,0 +1,141 @@ +seed = [ + ("8701210100", "", "PROCESS"), + ("8702100500", "", "PROCESS"), + ("8702400600", "", "PROCESS"), + ("8703310200", "", "PROCESS"), + ("8703500200", "", "PROCESS"), + ("8704210400", "", "PROCESS"), + ("8704410200", "", "PROCESS"), + ("8705400200", "", "PROCESS"), + ("8711300401", "", "PROCESS"), + ("8711409999", "", "PROCESS"), + ("8711900100", "", "PROCESS"), + ("8716200499", "", "PROCESS"), + ("8716390400", "", "PROCESS"), + ("8716399903", "", "PROCESS"), + ("8716409100", "", "PROCESS"), + ("8716900300", "", "PROCESS"), + ("8716909901", "", "PROCESS"), + ("8716909902", "", "PROCESS"), + ("8716909999", "", "PROCESS"), + ("8711100300", "", "PROCESS"), + ("8711200501", "", "PROCESS"), + ("8711200502", "", "PROCESS"), + ("8711200599", "", "PROCESS"), + ("8711300499", "", "PROCESS"), + ("8711400100", "", "PROCESS"), + ("8711400200", "", "PROCESS"), + ("8711409901", "", "PROCESS"), + ("8711500301", "", "PROCESS"), + ("8711500302", "", "PROCESS"), + ("8711500399", "", "PROCESS"), + ("8711600100", "", "PROCESS"), + ("8711909900", "", "PROCESS"), + ("8716100100", "", "PROCESS"), + ("8716200401", "", "PROCESS"), + ("8716200402", "", "PROCESS"), + ("8703210200", "", "PROCESS"), + ("8703220200", "", "PROCESS"), + ("8703230200", "", "PROCESS"), + ("8703240200", "", "PROCESS"), + ("8716310301", "", "PROCESS"), + ("8716310302", "", "PROCESS"), + ("8716310399", "", "PROCESS"), + ("8716390300", "", "PROCESS"), + ("8703320200", "", "PROCESS"), + ("8703330200", "", "PROCESS"), + ("8703400200", "", "PROCESS"), + ("8703600200", "", "PROCESS"), + ("8703700200", "", "PROCESS"), + ("8703900200", "", "PROCESS"), + ("8716390800", "", "PROCESS"), + ("8716399901", "", "PROCESS"), + ("8716399902", "", "PROCESS"), + ("8701220100", "", "PROCESS"), + ("8701230100", "", "PROCESS"), + ("8701240100", "", "PROCESS"), + ("8701290100", "", "PROCESS"), + ("8704220700", "", "PROCESS"), + ("8704230200", "", "PROCESS"), + ("8704310500", "", "PROCESS"), + ("8704320700", "", "PROCESS"), + ("8704420200", "", "PROCESS"), + ("8704430200", "", "PROCESS"), + ("8704510300", "", "PROCESS"), + ("8704520200", "", "PROCESS"), + ("8716399904", "", "PROCESS"), + ("8716399905", "", "PROCESS"), + ("8716399999", "", "PROCESS"), + ("8702200500", "", "PROCESS"), + ("8702300500", "", "PROCESS") +] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/api/v1/modules/a76/router.py b/backend/api/v1/modules/a76/router.py index 796bf862..0c2dcab6 100644 --- a/backend/api/v1/modules/a76/router.py +++ b/backend/api/v1/modules/a76/router.py @@ -11,7 +11,7 @@ from .customs_brokers.routes import router as customs_broker_router from .general_catalogs.router import router as general_catalogs_router from .invoices.routes import router as invoices_router from .items.routes import router as items_router -from .classes import router as classes_router +from .classes.routes import router as classes_router from .clients_and_providers import router as client_and_provider_router from .layouts_csv.facturas.routes import router as imports_router @@ -20,11 +20,10 @@ from .layouts_csv.cambio_regimen_regularizacion.routes import router as cambio_r from .csv_templates.routes import router as csv_templates_router from .invoice_settings.routes import router as invoice_settings_router from .item_presets.routes import router as item_presets_router -from .general_catalogs.company import router as company_router -from .country_rule_oct.routes import router as country_rule_oct_router from .transportation.drivers.routes import router as drivers_router from .doc_types_dig.routes import router as doc_types_dig_router -from .fraction_rule_octave.routes import router as fraction_rule_octave_router +from .rule_octave.fractions.routes import router as fraction_rule_octave_router +from .rule_octave.country.routes import router as country_rule_oct_router from .parts import router as parts_router from .boms import router as boms_router from .pedmientos.router import router as pedimentos_router @@ -42,14 +41,15 @@ from .reports.exportacion.aviso_consolidado.routes import router as aviso_consol from .reports.movements.invoices.routes import router as movement_invoices_router from .reports.movements.saldos.routes import router as movement_saldos_router from .reports.exportacion.descargo.routes import router as discharge_reports_router -from .manifests.manifest.routes import router as manifests_router -from .manifests.driver.routes import router as manifest_drivers_router -from .manifests.manifiesto_anexo.routes import router as manifest_anexos_router from .reports.exportacion.transmission.MAINX30.routes import router as transmission_router from .reports.importacion.transmission.temporal.MAINX30.routes import router as transmission_temporal_router from .reports.importacion.transmission.definitive.MAINX30.routes import router as transmission_definitive_router from .reports.importacion.winsaai.router import router as winsaai_router +from .manifests.manifest.routes import router as manifests_router +from .manifests.driver.routes import router as manifest_drivers_router +from .manifests.manifiesto_anexo.routes import router as manifest_anexos_router + # Router principal router = APIRouter()