Files
plantillas-proyectos/backend/api/v1/router.py
Kevin Rosales 38d86531e8 feat: Add comprehensive A76 modules with database relationships
 New Features:
- Company module: Single company management with comprehensive business info
- Client & Provider module: Manages clients/providers with address/program relationships
- GParts module: Parts/components management for SCAII, SCAF, and WINSAAI systems
- GClass module: Class classifications for SCAII and SCAF with tariff information

🔗 Database Relationships:
- GPart ↔ GClass: Composite key relationship (client_key, part_class ↔ class_code)
- GPart → Country: Foreign key to public.countries (country_of_origin)
- GPart → CurrencyType: Foreign key to public.currency_types (currency_key)
- GClass → MaterialType: Foreign key to public.material_types (material_key)

📊 API Endpoints Added:

Company Module (/company):
- POST / - Create company
- GET / - Get single company

Client & Provider Module (/clients-providers):
- POST / - Create client/provider
- GET / - List all with pagination
- GET /clients - List only clients
- GET /providers - List only providers
- GET /search/rfc/{rfc} - Search by RFC
- GET /{client_id} - Get by ID
- PUT /{client_id} - Update client/provider
- DELETE /{client_id} - Delete client/provider
- PATCH /{client_id}/toggle-status - Toggle status
- GET /{client_id}/address - Get address info
- GET /{client_id}/programs - Get programs info
- GET /{client_id}/basic - Get basic info

GParts Module (/parts):
- POST / - Create part
- GET / - List all with pagination and filters
- GET /client/{client_key} - Get parts by client
- GET /search/fraction/{fraction} - Search by tariff fraction
- GET /search/supplier/{supplier} - Search by supplier
- GET /search/country/{country_code} - Search by country
- GET /statistics - Get parts statistics
- GET /{client_key}/{part_number} - Get specific part
- PUT /{client_key}/{part_number} - Update part
- DELETE /{client_key}/{part_number} - Delete part
- PATCH /{client_key}/{part_number}/toggle-status - Toggle status
- GET /{client_key}/{part_number}/basic - Get basic info
- GET /{client_key}/{part_number}/regulatory - Get regulatory info

GClass Module (/classes):
- POST / - Create class
- GET / - List all with pagination and filters
- GET /client/{client_key} - Get classes by client
- GET /search/fraction/{fraction} - Search by tariff fraction
- GET /search/material/{material_key} - Search by material
- GET /search/unit-measure/{unit_of_measure} - Search by unit of measure
- GET /search/physical-review/{physical_review} - Search by physical review status
- GET /statistics - Get class statistics
- GET /{client_key}/{class_code} - Get specific class
- PUT /{client_key}/{class_code} - Update class
- DELETE /{client_key}/{class_code} - Delete class
- GET /{client_key}/{class_code}/basic - Get basic info
- GET /{client_key}/{class_code}/tariff - Get tariff information

🏗️ Architecture:
- Modular design with models, DTOs, services, and routes for each entity
- English field names with composite primary keys where applicable
- Comprehensive CRUD operations with specialized search endpoints
- SQLAlchemy relationships with proper foreign key constraints
- Type-safe DTOs with Pydantic validation

📝 Documentation:
- RELATIONSHIPS.md: Complete documentation of database relationships
- Detailed type hints and comprehensive service methods
- Consistent patterns across all modules for maintainability
2025-11-04 21:48:05 -06:00

78 lines
3.6 KiB
Python

"""
Router principal de API v1
Agrega todos los módulos de la aplicación
"""
from fastapi import APIRouter
# Importar routers de módulos
from .modules.a76.auth import router as auth_router
from .modules.a76.tenants import router as tenants_router
from .modules.public.reference_data.pedimento_codes.routes import router as pedimento_codes_router
from .modules.public.reference_data.payment_methods.routes import router as payment_methods_router
from .modules.public.reference_data.containers.routes import router as containers_router
from .modules.public.reference_data.countries.routes import router as countries_router
from .modules.public.reference_data.material_types.routes import router as material_types_router
from .modules.public.reference_data.currency_types.routes import router as currency_types_router
from .modules.public.reference_data.states.routes import router as states_router
from .modules.public.reference_data.transport_types.routes import router as transport_types_router
from .modules.public.reference_data.customs_warehouses.routes import router as customs_warehouses_router
from .modules.public.reference_data.valuation_methods.routes import router as valuation_methods_router
from .modules.public.reference_data.sectors.routes import router as sectors_router
from .modules.public.reference_data.transport_modes.routes import router as transport_modes_router
from .modules.public.reference_data.customs_sections.routes import router as customs_sections_router
from .modules.public.reference_data.invoice_types.routes import router as invoice_types_router
from .modules.public.reference_data.code_pedimento_regimens.routes import router as code_pedimento_regimens_router
from .modules.public.reference_data.pedimento_regimens.routes import router as pedimento_regimens_router
from .modules.public.reference_data.incoterms.routes import router as incoterms_router
from .modules.a76.licenses import router as licenses_router
from .modules.a76.company.routes import router as company_router
from .modules.a76.GParts.routes import router as gparts_router
from .modules.a76.GClass.routes import router as gclass_router
# Import module with special character using importlib
import importlib
client_provider_module = importlib.import_module('.modules.a76.client_&_provider.routes', package='api.v1')
client_provider_router = client_provider_module.router
# Router principal
router = APIRouter()
# Registrar módulos
router.include_router(auth_router)
router.include_router(tenants_router)
router.include_router(licenses_router)
router.include_router(company_router)
router.include_router(client_provider_router)
router.include_router(gparts_router)
router.include_router(gclass_router)
router.include_router(pedimento_codes_router)
router.include_router(payment_methods_router)
router.include_router(containers_router)
router.include_router(countries_router)
router.include_router(material_types_router)
router.include_router(currency_types_router)
router.include_router(states_router)
router.include_router(transport_types_router)
router.include_router(customs_warehouses_router)
router.include_router(valuation_methods_router)
router.include_router(sectors_router)
router.include_router(transport_modes_router)
router.include_router(customs_sections_router)
router.include_router(invoice_types_router)
router.include_router(code_pedimento_regimens_router)
router.include_router(pedimento_regimens_router)
router.include_router(incoterms_router)
# Health check
@router.get("/status")
def status():
"""Health check de la API"""
return {
"status": "ok",
"version": "1.0.0",
"api": "v1"
}