Files
plantillas-proyectos/backend/api/v1/modules/a76/customs_brokers/models.py
acazares ba40123333 feat: Enhance Pedimentos CRUD operations with related data handling
- Updated PedimentosService to create and update related tables for Pedimentos.
- Added company_id filtering in queries for Pedimentos.
- Improved error handling and logging during creation and update processes.
- Refactored router tags for consistency and clarity.
- Adjusted API endpoints for customs brokers to include company_id in requests.
- Enhanced company selection logic in various components to prioritize active company.
- Implemented event listeners for company changes to reload data dynamically.
- Updated frontend components to handle loading states and errors more effectively.
- Ensured all relevant routes and API calls are aligned with the new company context.
2025-11-14 18:14:33 -06:00

101 lines
4.1 KiB
Python

from api.v1.common.base_models import TenantScopedMixin
from core.database import Base
from sqlalchemy import Column, ForeignKey, ForeignKeyConstraint, Integer, String, UniqueConstraint, PrimaryKeyConstraint
from sqlalchemy.orm import relationship
class CustomsBroker(Base, TenantScopedMixin):
__tablename__ = "customs_brokers"
__table_args__ = (
PrimaryKeyConstraint("id", name="customs_brokers_pkey"),
ForeignKeyConstraint(
["tenant_id"], ["a76.tenants.id"], name="fk_customs_brokers_tenants"
),
ForeignKeyConstraint(
["company_id"], ["a76.company.id"], name="fk_customs_brokers_company"
),
UniqueConstraint("broker_key", "tenant_id", "company_id", name="uq_broker_key_tenant_company"),
{"schema": "a76"},
)
id = Column(Integer, primary_key=True)
type = Column(String(9), nullable=True)
broker_key = Column(String(5), nullable=False)
name = Column(String(80), nullable=True)
address = Column(String(1500), nullable=True)
postal_code = Column(String(15), nullable=True)
city = Column(String(30), nullable=True)
state = Column(String(30), nullable=True)
phone = Column(String(30), nullable=True)
fax = Column(String(30), nullable=True)
email = Column(String(100), nullable=True)
country = Column(String(3), nullable=True)
tax_id = Column(String(30), nullable=True)
personal_id = Column(String(20), nullable=True)
position = Column(String(30), nullable=True)
license = Column(String(4), nullable=True)
company = Column(String(200), nullable=True)
contact = Column(String(80), nullable=True)
vu = relationship(
"CustomsBrokerVU", back_populates="customs_broker", cascade="all, delete"
)
personnel = relationship(
"CustomsBrokerPersonnel", back_populates="customs_broker", cascade="all, delete"
)
class CustomsBrokerVU(Base):
__tablename__ = "customs_brokers_vu"
__table_args__ = {"schema": "a76"}
customs_broker_id = Column(
Integer,
ForeignKey("a76.customs_brokers.id", ondelete="CASCADE"),
primary_key=True,
)
certificate_path = Column(String(1499), nullable=True)
key_path = Column(String(1499), nullable=True)
access_key = Column(String(50), nullable=True)
fiel_format = Column(String(19), nullable=True)
signature_read_path = Column(String(1499), nullable=True)
archive_path = Column(String(1499), nullable=True)
fiel_access_key = Column(String(50), nullable=True)
web_service_user = Column(String(100), nullable=True)
web_service_access_key = Column(String(100), nullable=True)
vu_email = Column(String(800), nullable=True)
vu_figure_type = Column(String(29), nullable=True)
xml_files_path = Column(String(1499), nullable=True)
query_tax_id = Column(String(30), nullable=True)
doda_certificate_path = Column(String(1499), nullable=True)
doda_key_path = Column(String(1499), nullable=True)
doda_web_service_user = Column(String(100), nullable=True)
doda_web_service_access_key = Column(String(100), nullable=True)
doda_fiel_access_key = Column(String(50), nullable=True)
doda_xml_files_path = Column(String(1499), nullable=True)
customs_broker = relationship("CustomsBroker", back_populates="vu")
class CustomsBrokerPersonnel(Base):
__tablename__ = "customs_brokers_personnel"
__table_args__ = {"schema": "a76"}
customs_broker_id = Column(
Integer,
ForeignKey("a76.customs_brokers.id", ondelete="CASCADE"),
primary_key=True,
)
line = Column(Integer, primary_key=True, nullable=False)
name = Column(String(80), nullable=True)
tax_id = Column(String(30), nullable=True)
personal_id = Column(String(20), nullable=True)
position = Column(String(30), nullable=True)
license = Column(String(4), nullable=True)
first_name = Column(String(80), nullable=True)
last_name = Column(String(80), nullable=True)
middle_name = Column(String(80), nullable=True)
email = Column(String(100), nullable=True)
customs_broker = relationship("CustomsBroker", back_populates="personnel")