Refactor and enhance CRUD operations for Seal, Trailer, Transporter, Vehicle, and Customs Broker modules

- Updated SealService to support tenant and company filtering with pagination and enhanced CRUD methods.
- Refactored TrailerService to include tenant and company support, added filtering capabilities, and improved CRUD methods.
- Introduced TenantCRUDRoutes for Trailer and Transporter routes to streamline API endpoint creation and management.
- Enhanced TransporterService with tenant and company filtering, pagination, and improved CRUD operations.
- Added Customs Broker module with DTOs, models, services, and routes for managing customs broker data.
- Implemented CRUD operations for Customs Broker, including personnel and VU management.
- Improved data validation and descriptions in DTOs for better API documentation.
This commit is contained in:
2025-11-11 18:20:39 -06:00
parent b68c4316ff
commit 962f43fe62
39 changed files with 1488 additions and 1366 deletions

View File

@@ -0,0 +1,95 @@
from api.v1.common.base_models import TenantScopedMixin
from core.database import Base
from sqlalchemy import Column, ForeignKey, ForeignKeyConstraint, Integer, String
from sqlalchemy.orm import relationship
class CustomsBroker(Base, TenantScopedMixin):
__tablename__ = "customs_brokers"
__table_args__ = (
ForeignKeyConstraint(
["tenant_id"], ["a76.tenants.id"], name="fk_customs_brokers_tenants"
),
ForeignKeyConstraint(
["company_id"], ["a76.company.id"], name="fk_customs_brokers_company"
),
{"schema": "a76"},
)
type = Column(String(9), nullable=True)
broker_key = Column(String(5), primary_key=True, 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"
broker_key = Column(
String(5),
ForeignKey("a76.customs_brokers.broker_key", 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"
broker_key = Column(
String(5),
ForeignKey("a76.customs_brokers.broker_key", 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")