- Added service layer for handling client and provider operations including creation, retrieval, updating, and deletion. - Introduced DTOs for data transfer and validation. - Implemented filtering and pagination for client/provider listing. - Added logging for better traceability of operations. feat: Create parts management module - Developed a complete module for managing parts/components including creation, retrieval, updating, and deletion. - Introduced DTOs for parts with detailed attributes and validation. - Implemented search and filtering capabilities for parts based on various criteria. - Added endpoints for regulatory information retrieval and parts statistics. - Integrated logging for error handling and operational insights.
109 lines
4.5 KiB
Python
109 lines
4.5 KiB
Python
"""
|
|
Modelos ORM para gestión de clientes y proveedores
|
|
"""
|
|
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, SmallInteger, Numeric, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from core.database import Base
|
|
import enum
|
|
|
|
|
|
class ClientProvider(Base):
|
|
"""
|
|
Modelo para la tabla GClientesPro - Información de clientes y proveedores
|
|
"""
|
|
__tablename__ = "client_provider"
|
|
__table_args__ = {"schema": "a76"}
|
|
|
|
# Primary key
|
|
client_id = Column(String(8), primary_key=True, nullable=False)
|
|
|
|
# Basic information
|
|
type_nat_foreign = Column(String(1), nullable=True) # TIPO NACIONAL/EXTRANJERO
|
|
name = Column(String(256), nullable=True)
|
|
short_name = Column(String(10), nullable=True)
|
|
rfc = Column(String(30), nullable=True)
|
|
curp = Column(String(19), nullable=True)
|
|
client_or_provider = Column(String(1), nullable=True)
|
|
linking = Column(String(1), nullable=True)
|
|
transform_subassembly = Column(String(1), nullable=True)
|
|
extra_information = Column(String(399), nullable=True)
|
|
web_key = Column(String(40), nullable=True)
|
|
responsible = Column(String(80), nullable=True)
|
|
position = Column(String(30), nullable=True)
|
|
incoterm = Column(String(19), nullable=True)
|
|
is_national_provider = Column(String(2), nullable=True)
|
|
enabled_disabled = Column(SmallInteger, nullable=True)
|
|
|
|
# Relationships
|
|
address = relationship("GClientProviderAddress", back_populates="client_provider", uselist=False, cascade="all, delete-orphan")
|
|
programs = relationship("GClientProviderPrograms", back_populates="client_provider", uselist=False, cascade="all, delete-orphan")
|
|
|
|
|
|
class GClientProviderAddress(Base):
|
|
"""
|
|
Modelo para la tabla GClientesPro_Direccion - Dirección de clientes y proveedores
|
|
"""
|
|
__tablename__ = "gclient_provider_address"
|
|
__table_args__ = {"schema": "a76"}
|
|
|
|
# Primary key (foreign key)
|
|
client_id = Column(String(8), ForeignKey('a76.client_provider.client_id', ondelete='CASCADE'), primary_key=True, nullable=False)
|
|
|
|
# Address information
|
|
municipality = Column(String(150), nullable=True)
|
|
streets = Column(String(100), nullable=True)
|
|
neighborhood = Column(String(40), nullable=True)
|
|
interior_number = Column(String(20), nullable=True)
|
|
exterior_number = Column(String(20), nullable=True)
|
|
postal_code = Column(String(15), nullable=True)
|
|
city = Column(String(30), nullable=True)
|
|
state = Column(String(30), nullable=True)
|
|
country = Column(String(3), nullable=True)
|
|
phone = Column(String(30), nullable=True)
|
|
fax_number = Column(String(30), nullable=True)
|
|
email = Column(String(100), nullable=True)
|
|
contact = Column(String(50), nullable=True)
|
|
reference = Column(String(250), nullable=True)
|
|
|
|
# Relationship
|
|
client_provider = relationship("ClientProvider", back_populates="address")
|
|
|
|
|
|
class GClientProviderPrograms(Base):
|
|
"""
|
|
Modelo para la tabla GClientesPro_Programas - Programas de clientes y proveedores
|
|
"""
|
|
__tablename__ = "gclient_provider_programs"
|
|
__table_args__ = {"schema": "a76"}
|
|
|
|
# Primary key (foreign key)
|
|
client_id = Column(String(8), ForeignKey('a76.client_provider.client_id', ondelete='CASCADE'), primary_key=True, nullable=False)
|
|
|
|
# Program information
|
|
program = Column(String(7), nullable=True)
|
|
program_number = Column(String(40), nullable=True)
|
|
prosec = Column(SmallInteger, nullable=True)
|
|
prosec_authorization = Column(String(20), nullable=True)
|
|
secon_auth_date = Column(Integer, nullable=True)
|
|
manufacturer_id = Column(String(25), nullable=True)
|
|
tax_id = Column(String(30), nullable=True)
|
|
broker = Column(String(6), nullable=True)
|
|
import_broker = Column(String(6), nullable=True)
|
|
transfer_key = Column(String(8), nullable=True)
|
|
secon_authorization = Column(String(20), nullable=True)
|
|
applied_proportion = Column(Numeric(7, 2), nullable=True)
|
|
is_certified_company = Column(String(1), nullable=True)
|
|
certified_company_registry = Column(String(40), nullable=True)
|
|
donation_auth_number = Column(String(50), nullable=True)
|
|
ctpat_svi = Column(String(100), nullable=True)
|
|
tax_registry_number = Column(String(40), nullable=True)
|
|
subassembly_service = Column(SmallInteger, nullable=True)
|
|
autse_dates = Column(Integer, nullable=True)
|
|
autse_number = Column(String(300), nullable=True)
|
|
|
|
# Relationship
|
|
client_provider = relationship("ClientProvider", back_populates="programs")
|
|
|
|
|