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.
This commit is contained in:
2025-11-14 18:14:33 -06:00
parent aa35635397
commit ba40123333
19 changed files with 739 additions and 149 deletions

View File

@@ -1,23 +1,26 @@
from api.v1.common.base_models import TenantScopedMixin
from core.database import Base
from sqlalchemy import Column, ForeignKey, ForeignKeyConstraint, Integer, String
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), primary_key=True, nullable=False)
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)
@@ -44,10 +47,11 @@ class CustomsBroker(Base, TenantScopedMixin):
class CustomsBrokerVU(Base):
__tablename__ = "customs_brokers_vu"
__table_args__ = {"schema": "a76"}
broker_key = Column(
String(5),
ForeignKey("a76.customs_brokers.broker_key", ondelete="CASCADE"),
customs_broker_id = Column(
Integer,
ForeignKey("a76.customs_brokers.id", ondelete="CASCADE"),
primary_key=True,
)
certificate_path = Column(String(1499), nullable=True)
@@ -75,10 +79,11 @@ class CustomsBrokerVU(Base):
class CustomsBrokerPersonnel(Base):
__tablename__ = "customs_brokers_personnel"
__table_args__ = {"schema": "a76"}
broker_key = Column(
String(5),
ForeignKey("a76.customs_brokers.broker_key", ondelete="CASCADE"),
customs_broker_id = Column(
Integer,
ForeignKey("a76.customs_brokers.id", ondelete="CASCADE"),
primary_key=True,
)
line = Column(Integer, primary_key=True, nullable=False)