Merge pull request 'feat: Implement multi-tenancy support in middleware and security layers' (#15) from feature/security into development
Reviewed-on: ADUANASOFT/anexo76#15
This commit is contained in:
@@ -11,7 +11,7 @@ class PortBase(BaseModel):
|
||||
location_description: Optional[str] = Field(
|
||||
None, max_length=20, description="Location Description")
|
||||
port_type: PortType = Field(
|
||||
default=PortType.ENTRY, description="Port Type (ENTRY, EXIT, BOTH)")
|
||||
server_default=PortType.ENTRY, description="Port Type (ENTRY, EXIT, BOTH)")
|
||||
|
||||
|
||||
class PortCreate(PortBase):
|
||||
|
||||
@@ -32,4 +32,4 @@ class Port(Base, TenantScopedMixin, TimestampMixin):
|
||||
|
||||
# New column requested
|
||||
port_type: Mapped[PortType] = mapped_column(
|
||||
String(15), nullable=False, default=PortType.ENTRY)
|
||||
String(15), nullable=False, server_default=PortType.ENTRY)
|
||||
|
||||
@@ -13,8 +13,6 @@ from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
|
||||
from core.database import Base
|
||||
|
||||
# 1. GUniMedACE
|
||||
|
||||
|
||||
class UnitOfMeasureACE(Base, TimestampMixin):
|
||||
__tablename__ = "unit_of_measure_ace"
|
||||
__table_args__ = (
|
||||
@@ -28,8 +26,6 @@ class UnitOfMeasureACE(Base, TimestampMixin):
|
||||
|
||||
|
||||
# 2. GUMOMA
|
||||
|
||||
|
||||
class UnitOfMeasureOMA(Base, TimestampMixin):
|
||||
__tablename__ = "unit_of_measure_oma"
|
||||
__table_args__ = (
|
||||
@@ -43,8 +39,6 @@ class UnitOfMeasureOMA(Base, TimestampMixin):
|
||||
|
||||
|
||||
# 3. GUMAme
|
||||
|
||||
|
||||
class UnitOfMeasureAmerican(Base, TimestampMixin):
|
||||
__tablename__ = "unit_of_measure_american"
|
||||
__table_args__ = (
|
||||
@@ -58,8 +52,6 @@ class UnitOfMeasureAmerican(Base, TimestampMixin):
|
||||
|
||||
|
||||
# 4. GUMAduana
|
||||
|
||||
|
||||
class UnitOfMeasureCustoms(Base, TimestampMixin):
|
||||
__tablename__ = "unit_of_measure_customs"
|
||||
__table_args__ = (
|
||||
@@ -68,52 +60,15 @@ class UnitOfMeasureCustoms(Base, TimestampMixin):
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
code: Mapped[str] = mapped_column(String(2), nullable=False) # CLAVE
|
||||
description: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
||||
scaii_unit_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(5), nullable=True
|
||||
) # UNIDADSCAII
|
||||
code: Mapped[str] = mapped_column(Integer, nullable=False) # CLAVE
|
||||
description: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
||||
|
||||
|
||||
# 5. GUniMedida (Main)
|
||||
|
||||
|
||||
class UnitOfMeasure(Base, TenantScopedMixin, TimestampMixin):
|
||||
__tablename__ = "units_of_measure"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("code", "tenant_id", "company_id", name="uq_uom_code"),
|
||||
ForeignKeyConstraint(
|
||||
["customs_code"],
|
||||
[
|
||||
"a76.unit_of_measure_customs.code"
|
||||
],
|
||||
use_alter=True,
|
||||
name="fk_uom_customs",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["american_code"],
|
||||
[
|
||||
"a76.unit_of_measure_american.code"
|
||||
],
|
||||
use_alter=True,
|
||||
name="fk_uom_american",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["ace_code"],
|
||||
[
|
||||
"a76.unit_of_measure_ace.code"
|
||||
],
|
||||
use_alter=True,
|
||||
name="fk_uom_ace",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["oma_code"],
|
||||
[
|
||||
"a76.unit_of_measure_oma.code"
|
||||
],
|
||||
use_alter=True,
|
||||
name="fk_uom_oma",
|
||||
),
|
||||
UniqueConstraint("code", "tenant_id", "company_id", name="uq_uom_code"),
|
||||
{"schema": "a76", "extend_existing": True},
|
||||
)
|
||||
|
||||
@@ -122,35 +77,19 @@ class UnitOfMeasure(Base, TenantScopedMixin, TimestampMixin):
|
||||
description: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
description_en: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
|
||||
customs_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(2), nullable=True
|
||||
) # CLAVE_AMEX
|
||||
american_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(3), nullable=True
|
||||
) # CLAVE_AAMER
|
||||
ace_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(4), nullable=True
|
||||
) # CLAVEACE
|
||||
oma_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(10), nullable=True
|
||||
) # CLAVEOMA
|
||||
customs_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_customs.code"), nullable=True) # CLAVE_AMEX
|
||||
american_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_american.code"), nullable=True) # CLAVE_AAMER
|
||||
ace_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_ace.code"), nullable=True) # CLAVEACE
|
||||
oma_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_oma.code"), nullable=True) # CLAVEOMA
|
||||
|
||||
# Relationships omitted for simplicity or need explicit primaryjoin
|
||||
customs_unit: Mapped[Optional["UnitOfMeasureCustoms"]] = relationship()
|
||||
american_unit: Mapped[Optional["UnitOfMeasureAmerican"]] = relationship(
|
||||
overlaps="customs_unit"
|
||||
)
|
||||
ace_unit: Mapped[Optional["UnitOfMeasureACE"]] = relationship(
|
||||
overlaps="american_unit,customs_unit"
|
||||
)
|
||||
oma_unit: Mapped[Optional["UnitOfMeasureOMA"]] = relationship(
|
||||
overlaps="ace_unit,american_unit,customs_unit"
|
||||
)
|
||||
american_unit: Mapped[Optional["UnitOfMeasureAmerican"]] = relationship(overlaps="customs_unit")
|
||||
ace_unit: Mapped[Optional["UnitOfMeasureACE"]] = relationship(overlaps="american_unit,customs_unit")
|
||||
oma_unit: Mapped[Optional["UnitOfMeasureOMA"]] = relationship(overlaps="ace_unit,american_unit,customs_unit")
|
||||
|
||||
|
||||
# 6. GUniMed (General/Conversion)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneral(Base, TenantScopedMixin, TimestampMixin):
|
||||
__tablename__ = "units_of_measure_general"
|
||||
__table_args__ = (
|
||||
@@ -178,14 +117,10 @@ class UnitOfMeasureGeneral(Base, TenantScopedMixin, TimestampMixin):
|
||||
)
|
||||
mexico_unit: Mapped[Optional[str]] = mapped_column(String(5), nullable=True)
|
||||
# UNIDAD_AME (Note: GUniMed has UNIDAD_AME varchar(5), but GUMAme has CLAVE varchar(3). Keeping as string for now)
|
||||
american_unit_code: Mapped[Optional[str]] = mapped_column(String(5), nullable=True)
|
||||
american_unit_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_american.code"), nullable=True)
|
||||
|
||||
customs_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(2), nullable=True
|
||||
) # CLAVE_ADUANA
|
||||
ace_code: Mapped[Optional[str]] = mapped_column(
|
||||
String(4), nullable=True
|
||||
) # CLAVEACE
|
||||
customs_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_customs.code"), nullable=True) # CLAVE_ADUANA
|
||||
ace_code: Mapped[Optional[str]] = mapped_column(ForeignKey("a76.unit_of_measure_ace.code"), nullable=True) # CLAVEACE
|
||||
|
||||
customs_unit: Mapped[Optional["UnitOfMeasureCustoms"]] = relationship()
|
||||
ace_unit: Mapped[Optional["UnitOfMeasureACE"]] = relationship(
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
seed = [
|
||||
('KGS', 'Kilo'),
|
||||
('KW', 'Kilowatt'),
|
||||
('MILLR', 'Millar'),
|
||||
('JGO', 'Juego'),
|
||||
('KWH', 'Kilowatt/Hora'),
|
||||
('TON', 'Tonelada'),
|
||||
('BARR', 'Barril'),
|
||||
('GRN', 'Gramo Neto'),
|
||||
('DEC', 'Decenas'),
|
||||
('CIEN', 'Cientos'),
|
||||
('DOCE', 'Decenas (Docenas)'),
|
||||
('GR', 'Gramo'),
|
||||
('CAJA', 'Caja'),
|
||||
('PZA', 'Botella'),
|
||||
('CARAT', 'Carat'),
|
||||
('MT', 'Metro Lineal'),
|
||||
('M2', 'Metro Cuadrado'),
|
||||
('M3', 'Metro Cubico'),
|
||||
('PZA', 'Pieza'),
|
||||
('PZA', 'Cabeza'),
|
||||
('LT', 'Litro'),
|
||||
('PAR', 'Par'),
|
||||
("1", "Kilo"),
|
||||
("2", "Gramo"),
|
||||
("3", "Metro Lineal"),
|
||||
("4", "Metro Cuadrado"),
|
||||
("5", "Metro Cubico"),
|
||||
("6", "Pieza"),
|
||||
("7", "Cabeza"),
|
||||
("8", "Litro"),
|
||||
("9", "Par"),
|
||||
("10", "Kilowatt"),
|
||||
("11", "Millar"),
|
||||
("12", "Juego"),
|
||||
("13", "Kilowatt/Hora"),
|
||||
("14", "Tonelada"),
|
||||
("15", "Barril"),
|
||||
("16", "Gramo Neto"),
|
||||
("17", "Decenas"),
|
||||
("18", "Cientos"),
|
||||
("19", "Decenas"),
|
||||
("20", "Caja"),
|
||||
("21", "Botella"),
|
||||
("22", "Carat"),
|
||||
]
|
||||
@@ -1,44 +0,0 @@
|
||||
seed = [
|
||||
# (code, desc_es, desc_en, customs, american, ace, oma)
|
||||
('BARR', 'BARRIL', 'BARIEL', '', 'BBL', 'BLL', ''),
|
||||
('BD FT', 'PIE TABLA', 'BD FEET', '', 'FT', 'BFT', ''),
|
||||
('BOLS', 'BOLSA', 'BAG', '', 'PCS', 'BG', ''),
|
||||
('BTL', 'BOTELLA', 'BOTTLE', '', 'PCS', 'BO', ''),
|
||||
('BULT', 'BULTO', 'BULK', '', 'PCS', 'VQ', ''),
|
||||
('CAJA', 'CAJA', 'BOX', '', '', 'BX', ''),
|
||||
('CARAT', 'CARAT', 'CARAT', '', '', 'HE', ''),
|
||||
('CBZA', 'CABEZA', 'HEAD', '', 'PCS', 'Z4', ''),
|
||||
('CIEN', 'CIENTO', 'CIEN', '', '', 'CEN', ''),
|
||||
('CM', 'CENTIMETRO', 'CM', 'CM', 'CM', 'CMT', ''),
|
||||
('CM2', 'CENTIMETRO CUADRADO', 'CM2', 'CM2', 'CM2', 'CMK', ''),
|
||||
('DEC', 'DECENA', '', '', '', 'DC', ''),
|
||||
('DM', 'DECIMETRO', 'DM', '', '', 'DMT', ''),
|
||||
('DM2', 'DECIMETRO CUADRADO', 'SQ DM', '', '', 'DMK', ''),
|
||||
('DOCE', 'DOCENA', 'DOZ', '', 'DOZ', 'DZN', 'DZ'),
|
||||
('FOZ', 'ONZA LIQUIDA', 'FOZ', 'FOZ', 'FOZ', 'OZA', ''),
|
||||
('FT', 'PIES', 'FT', 'FT', 'FT', 'LF', ''),
|
||||
('FT2', 'PIE CUADRADO', 'FT2', '', 'SFT', 'FTK', ''),
|
||||
('GAL', 'GALON', 'GAL', 'GAL', 'GAL', 'GLL', ''),
|
||||
('GR', 'GRAMO', 'GRAM', '', '', 'GRM', ''),
|
||||
('IN', 'PULGADA', 'IN', '', '', 'LI', ''),
|
||||
('IN2', 'PULGADA CUADRADA', 'IN2', '', '', 'INK', ''),
|
||||
('JGO', 'JUEGO', 'SET', '', '', 'SET', ''),
|
||||
('KGS', 'KILOGRAMOS', 'KGS', '', 'KG2', 'KGM', ''),
|
||||
('LB', 'LIBRAS', 'LB', '', '', 'LBR', ''),
|
||||
('LT', 'LITRO', 'LT', 'LT', 'L', 'LTR', ''),
|
||||
('M2', 'METRO CUADRADO', 'M2', 'M2', 'M2', 'MTK', ''),
|
||||
('M3', 'METRO CUBICO', 'M3', 'M3', 'M3', 'MTQ', ''),
|
||||
('MI', 'MILLA', 'MILE', '', 'KM', 'SMI', ''),
|
||||
('MILLR', 'MILLAR', 'MILLR', '', '', 'MIL', ''),
|
||||
('MT', 'METROS', 'MT', 'MT', 'M', 'MTR', ''),
|
||||
('OZ', 'ONZA', 'OZ', 'FOZ', 'FOZ', 'OZ', ''),
|
||||
('PAR', 'PAR', 'PAIR', '', '', 'PB', ''),
|
||||
('PQ', 'PAQUETE', 'PACKAGE', '', 'PCS', 'PK_1', ''),
|
||||
('PZA', 'PIEZA', 'PCS', 'PCS', 'PCS', 'C62_1', ''),
|
||||
('QGL', 'CUARTO DE GALON', 'QGL', '', '', 'QT', ''),
|
||||
('ROLL', 'ROLLO', 'ROLL', '', '', 'RO', ''),
|
||||
('TON', 'TONELADA', 'TON', 'TON', 'TON', 'TNE_1', ''),
|
||||
('TOZ', 'ONZA TROY', 'TOZ', '', 'TOZ', 'APZ', ''),
|
||||
('YD', 'YARDA', 'YD', 'YD', 'YD', 'YRD', ''),
|
||||
('YD2', 'YARDA CUADRADA', 'YD2', '', 'SYD', 'YDK', ''),
|
||||
]
|
||||
Reference in New Issue
Block a user