Merge pull request 'feature/catalogo-pedimento' (#219) from feature/catalogo-pedimento into development

Reviewed-on: ADUANASOFT/anexo76#219
This commit is contained in:
2026-03-18 03:53:00 +00:00
16 changed files with 355 additions and 70 deletions

View File

@@ -49,6 +49,9 @@ from api.v1.modules.public.reference_data.states.seed import seed as states_seed
from api.v1.modules.public.reference_data.transport_modes.seed import (
seed as transport_modes_seed,
)
from api.v1.modules.public.reference_data.pedimento_transport_catalog.seed import (
seed as pedimento_transport_catalog_seed,
)
from api.v1.modules.public.reference_data.transport_types.seed import (
seed as transport_types_seed,
)
@@ -98,6 +101,28 @@ def upgrade() -> None:
return "NULL"
return f"'{str(val).replace(chr(39), chr(39)*2)}'"
op.execute(
"""
CREATE TABLE IF NOT EXISTS public.pedimento_transport_catalog (
code VARCHAR(3) NOT NULL,
transport_en VARCHAR(80) NOT NULL,
transport_es VARCHAR(120) NOT NULL,
payment_date_code VARCHAR(1) NOT NULL,
CONSTRAINT pedimento_transport_catalog_pkey PRIMARY KEY (code),
CONSTRAINT pedimento_transport_catalog_payment_date_code_chk
CHECK (payment_date_code IN ('E','P'))
);
"""
)
op.execute(
"""
ALTER TABLE IF EXISTS a76.pedimento_transport_means
ALTER COLUMN entry_exit TYPE VARCHAR(3),
ALTER COLUMN arrival TYPE VARCHAR(3),
ALTER COLUMN departure TYPE VARCHAR(3);
"""
)
# --- SEEDS PUBLIC (Tablas base) ---
# Seeds
values_pc = ", ".join(
@@ -285,6 +310,20 @@ def upgrade() -> None:
"""
)
values_ptc = ", ".join(
[
f"('{code}', '{en.replace(chr(39), chr(39)*2)}', '{es.replace(chr(39), chr(39)*2)}', '{pdc}')"
for code, en, es, pdc in pedimento_transport_catalog_seed
]
)
op.execute(
f"""
INSERT INTO public.pedimento_transport_catalog (code, transport_en, transport_es, payment_date_code) VALUES
{values_ptc}
ON CONFLICT (code) DO NOTHING;
"""
)
values_tt = ", ".join(
[
f"('{code}', '{desc.replace(chr(39), chr(39)*2)}')"
@@ -475,6 +514,16 @@ def upgrade() -> None:
def downgrade() -> None:
"""Downgrade schema."""
op.execute(
"""
ALTER TABLE IF EXISTS a76.pedimento_transport_means
ALTER COLUMN entry_exit TYPE VARCHAR(2),
ALTER COLUMN arrival TYPE VARCHAR(2),
ALTER COLUMN departure TYPE VARCHAR(2);
"""
)
op.drop_table("pedimento_transport_catalog", schema="public")
op.drop_table("us_tariff_fractions", schema="a76")
op.drop_table("historical_tariff_fractions", schema="a76")
op.drop_table("canadian_tariff_fractions", schema="a76")