✨ 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
98 lines
4.1 KiB
Python
98 lines
4.1 KiB
Python
"""
|
|
DTOs (Data Transfer Objects) para módulo de clases SCAII y SCAF
|
|
Reemplaza schemas.py siguiendo enfoque DDD y estilo NestJS
|
|
"""
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class ClassCreateDTO(BaseModel):
|
|
"""DTO para crear una clase"""
|
|
client_key: int = Field(..., description="Client key")
|
|
class_code: str = Field(..., max_length=8, description="Class code")
|
|
description_spanish: Optional[str] = Field(None, max_length=500, description="Description in Spanish")
|
|
description_english: Optional[str] = Field(None, max_length=500, description="Description in English")
|
|
material_key: Optional[str] = Field(None, max_length=10, description="Material key (homologated TIPOMAT/TIPOMATEQUIPO)")
|
|
unit_of_measure: Optional[str] = Field(None, max_length=5, description="Unit of measure (homologated UNIMEDIDA)")
|
|
fraction: Optional[str] = Field(None, max_length=10, description="Mexican tariff fraction")
|
|
us_fraction: Optional[str] = Field(None, max_length=16, description="US tariff fraction")
|
|
sub_key: Optional[str] = Field(None, max_length=5, description="Sub classification key")
|
|
physical_review: Optional[int] = Field(None, description="Physical review indicator")
|
|
iva_exempt_fraction: Optional[str] = Field(None, max_length=4, description="IVA exempt fraction")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ClassUpdateDTO(BaseModel):
|
|
"""DTO para actualizar una clase"""
|
|
description_spanish: Optional[str] = Field(None, max_length=500, description="Description in Spanish")
|
|
description_english: Optional[str] = Field(None, max_length=500, description="Description in English")
|
|
material_key: Optional[str] = Field(None, max_length=10, description="Material key (homologated TIPOMAT/TIPOMATEQUIPO)")
|
|
unit_of_measure: Optional[str] = Field(None, max_length=5, description="Unit of measure (homologated UNIMEDIDA)")
|
|
fraction: Optional[str] = Field(None, max_length=10, description="Mexican tariff fraction")
|
|
us_fraction: Optional[str] = Field(None, max_length=16, description="US tariff fraction")
|
|
sub_key: Optional[str] = Field(None, max_length=5, description="Sub classification key")
|
|
physical_review: Optional[int] = Field(None, description="Physical review indicator")
|
|
iva_exempt_fraction: Optional[str] = Field(None, max_length=4, description="IVA exempt fraction")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ClassResponseDTO(BaseModel):
|
|
"""DTO para respuesta de clase"""
|
|
client_key: int
|
|
class_code: str
|
|
description_spanish: Optional[str] = None
|
|
description_english: Optional[str] = None
|
|
material_key: Optional[str] = None
|
|
unit_of_measure: Optional[str] = None
|
|
fraction: Optional[str] = None
|
|
us_fraction: Optional[str] = None
|
|
sub_key: Optional[str] = None
|
|
physical_review: Optional[int] = None
|
|
iva_exempt_fraction: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ClassBasicDTO(BaseModel):
|
|
"""DTO para información básica de clase"""
|
|
client_key: int
|
|
class_code: str
|
|
description_spanish: Optional[str] = None
|
|
description_english: Optional[str] = None
|
|
material_key: Optional[str] = None
|
|
fraction: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ClassListDTO(BaseModel):
|
|
"""DTO para lista de clases"""
|
|
classes: list[ClassBasicDTO]
|
|
total: int
|
|
page: int
|
|
size: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ClassSearchDTO(BaseModel):
|
|
"""DTO para búsqueda de clases"""
|
|
client_key: Optional[int] = Field(None, description="Filter by client key")
|
|
class_code: Optional[str] = Field(None, description="Search by class code")
|
|
description: Optional[str] = Field(None, description="Search in descriptions")
|
|
material_key: Optional[str] = Field(None, description="Filter by material key")
|
|
fraction: Optional[str] = Field(None, description="Filter by tariff fraction")
|
|
physical_review: Optional[int] = Field(None, description="Filter by physical review indicator")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|