From 57b7e6dcbf43c9d65a365808022f49ab8b2a9f73 Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Wed, 31 Dec 2025 13:51:17 -0600 Subject: [PATCH 01/37] feat: add country fetching API endpoint and implement dashboard contributions management - Implemented a new API endpoint for fetching countries with pagination support. - Added a new Svelte component for managing contributions in the dashboard, including CRUD operations for contributions and general contributions. - Introduced dynamic tab navigation for different contribution types (DTA, PREV, ECI, MULT, REC). - Enhanced user interface with dialogs for adding and editing contributions and general contributions. --- .../public/reference_data/countries/routes.py | 2 +- .../edit/contributions-tab-form.svelte | 263 ++++-- .../package-transportation-tab-form.svelte | 851 +++++++++++++++++- .../dashboard/pedimentos/edit/temp.svelte | 771 ++++++++++++++++ .../routes/api-sveltekit/countries/+server.ts | 55 ++ 5 files changed, 1795 insertions(+), 147 deletions(-) create mode 100644 frontend/src/lib/components/dashboard/pedimentos/edit/temp.svelte create mode 100644 frontend/src/routes/api-sveltekit/countries/+server.ts diff --git a/backend/api/v1/modules/public/reference_data/countries/routes.py b/backend/api/v1/modules/public/reference_data/countries/routes.py index 626028b9..4bd30d05 100644 --- a/backend/api/v1/modules/public/reference_data/countries/routes.py +++ b/backend/api/v1/modules/public/reference_data/countries/routes.py @@ -16,8 +16,8 @@ async def list_countries( page: int = Query(1, ge=1, description="Número de página"), page_size: int = Query(50, ge=1, le=100, description="Tamaño de página"), db: Session = Depends(get_core_db), - current_user: dict = Depends(get_current_user), ): + """Endpoint público para obtener lista de países - no requiere autenticación""" skip = (page - 1) * page_size query = db.query(Country) items = query.offset(skip).limit(page_size).all() diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte index 8cbce24e..90143061 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte @@ -51,6 +51,14 @@ abreviacion: string; forma_pago_2: string; importe_2: number; + contribuciones_generales?: Array<{ + pedimento_sys_id: string; + clave_contribucion: string; + clave_tasa: string; + tasa_contribucion: number; + clave_forma_pago: string; + importe_contribucion: number; + }>; } interface ContribucionGeneral { @@ -132,6 +140,16 @@ // Estados para contribuciones generales (dentro del diálogo) let isContribGenDialogOpen = $state(false); let editingContribGenIndex = $state(null); + + // Estado temporal para contribución general dentro del diálogo de contribución + let tempContribGen = $state({ + pedimento_sys_id: '', + clave_contribucion: '', + clave_tasa: '', + tasa_contribucion: 0, + clave_forma_pago: '', + importe_contribucion: 0 + }); let currentContribucion = $state({ contribucion: '', @@ -142,7 +160,8 @@ gravamen: '', abreviacion: '', forma_pago_2: '', - importe_2: 0 + importe_2: 0, + contribuciones_generales: [] }); let currentContribGen = $state({ @@ -165,7 +184,8 @@ gravamen: '', abreviacion: '', forma_pago_2: '', - importe_2: 0 + importe_2: 0, + contribuciones_generales: [] }; isDialogOpen = true; } @@ -194,6 +214,34 @@ } } + // Funciones para Contribuciones Generales (Registro 510) dentro del diálogo de contribución + function openNewContribGenInDialog() { + tempContribGen = { + pedimento_sys_id: '', + clave_contribucion: '', + clave_tasa: '', + tasa_contribucion: 0, + clave_forma_pago: '', + importe_contribucion: 0 + }; + isContribGenDialogOpen = true; + } + + function saveContribGenInDialog() { + if (!currentContribucion.contribuciones_generales) { + currentContribucion.contribuciones_generales = []; + } + currentContribucion.contribuciones_generales.push({ + pedimento_sys_id: tempContribGen.pedimento_sys_id, + clave_contribucion: tempContribGen.clave_contribucion, + clave_tasa: tempContribGen.clave_tasa, + tasa_contribucion: tempContribGen.tasa_contribucion, + clave_forma_pago: tempContribGen.clave_forma_pago, + importe_contribucion: tempContribGen.importe_contribucion + }); + isContribGenDialogOpen = false; + } + // Funciones para Contribuciones Generales (Registro 510) function openNewContribGen() { editingContribGenIndex = null; @@ -527,24 +575,27 @@ - + {editingIndex !== null ? 'Editar Contribución' : 'Nueva Contribución'} -
-
+
+ +
+

Tasas Pedimento - Registro 509

+
- + v && (currentContribucion.contribucion = v)} > - {currentContribucion.contribucion || 'Seleccionar contribución'} + {currentContribucion.contribucion || 'Seleccionar'} {#each opcionesContribuciones as opcion} @@ -553,150 +604,169 @@
+
- - + +
+ v && (currentContribucion.tipo_tasa = v)} + > + + {currentContribucion.tipo_tasa || 'Seleccionar'} + + + Porcentual + Específico + Cuota minima (DTA) + Cuota fija (DTA) + Tasa de descuento sobre ad valorem + Factor de aplicación sobre tigie. + Al millar (DTA) + Tasa de descuento sobre el arancel específico + Tasa especifica sobre precios de referencia + Tasa especifica sobre precios de referencia con UM + + +
-
-
- - -
-
- - -
-
- - -
-
+
+ + +
+
-
-
- - -
-
- - -
-
+ +
+

Contribuciones Generales - Registro 510

-
-
- - +
+ + + + Clave Contribución + Forma de Pago + Importe + + + + {#if !currentContribucion.contribuciones_generales || currentContribucion.contribuciones_generales.length === 0} + + + Sin registros + + + {:else} + {#each currentContribucion.contribuciones_generales as contribGen, index} + + {contribGen.clave_contribucion} + {contribGen.clave_forma_pago} + + {contribGen.importe_contribucion.toLocaleString('es-MX', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + })} + + + {/each} + {/if} + +
-
- - + +
+ + +
- +
- + - - {editingContribGenIndex !== null ? 'Editar Contribución General' : 'Nueva Contribución General'} - + Insertando
- +
- +
- +
- +
- +
- +
@@ -704,12 +774,7 @@ - +
diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte index 87a72b7c..053c3f74 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte @@ -27,6 +27,7 @@ Copy, Upload } from 'lucide-svelte'; + import { onMount } from 'svelte'; interface Transporte { id?: number; @@ -115,12 +116,276 @@ }; }); + // Cargar países al montar el componente + onMount(async () => { + try { + console.log('🌍 Cargando todos los países desde la base de datos...'); + const response = await fetch('/api-sveltekit/countries'); + + if (!response.ok) { + console.error('❌ Error al cargar países:', response.status); + return; + } + + const data = await response.json(); + countries = data; + console.log('✅ Países cargados:', countries.length); + } catch (error) { + console.error('❌ Error al cargar países:', error); + } + }); + // Estados para diálogos let isTransporteDialogOpen = $state(false); let isPrecintoDialogOpen = $state(false); let isContenedorDialogOpen = $state(false); let isTransportesPrecintosDialogOpen = $state(false); let isGuiasDialogOpen = $state(false); + let isTransportistasDialogOpen = $state(false); + let isTransportistaFormDialogOpen = $state(false); + let isGafeteDialogOpen = $state(false); + let editingGafeteIndex = $state(null); + + // Estado para gafete actual + let currentGafete = $state({ + claveTransportista: '', + linea: '', + numeroGafeteUnico: '', + nombreTransportista: '' + }); + + // Catálogo de transportistas (datos del catálogo del sistema) + let transportistasCatalog = $state([ + { + id: 1, + clave: '159A', + nombre: 'MANUEL ALEJANDRO VENGA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: 'MEX', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 2, + clave: '159T', + nombre: 'TRANSPORTES HERMA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 3, + clave: '159V', + nombre: 'Concepción Peña Grijalva', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 4, + clave: '158A', + nombre: 'PERALTA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 5, + clave: '15C1', + nombre: 'MOLSA MOVIMIENTO LOGISTI', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 6, + clave: '15CG', + nombre: 'UNION DE FLETEROS DE TAN', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 7, + clave: '15D5', + nombre: 'Carlos Alejandro Baeta Sánchez', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 8, + clave: '15E6', + nombre: 'JUAN SEBASTIAN MERA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 9, + clave: '15FB', + nombre: 'FLORENTIN N HERNANDEZ', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 10, + clave: '15G0', + nombre: 'JOSE GABRIEL ZEPEDA DIAZ', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 11, + clave: '15G2', + nombre: 'PERALTA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 12, + clave: '15I9', + nombre: 'Blanca Fabiola Figueroa Mende', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: 'MEX', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 13, + clave: '15JD', + nombre: 'José García Cruz', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + }, + { + id: 14, + clave: '15JF', + nombre: 'TRANSPORTES ESPAÑA', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '', + telefono: '', + caat_code: '', + gafetes: [] + } + ]); + let searchTransportista = $state(''); + let currentCatalogoTransportista = $state(null); + let editingTransportistaIndex = $state(null); + + // Filtrar transportistas según búsqueda + let filteredTransportistas = $derived( + transportistasCatalog.filter((t) => { + if (!searchTransportista) return true; + const search = searchTransportista.toLowerCase(); + return ( + t.clave?.toLowerCase().includes(search) || + t.nombre?.toLowerCase().includes(search) || + t.rfc?.toLowerCase().includes(search) + ); + }) + ); + + // Lista de países desde el backend + let countries = $state>([]); + let searchCountry = $state(''); + let showCountryDropdown = $state(false); + + // Filtrar países según búsqueda + let filteredCountries = $derived( + countries.filter((c) => { + if (!searchCountry) return true; + const search = searchCountry.toLowerCase(); + return ( + c.description_es?.toLowerCase().includes(search) || + c.m3_key?.toLowerCase().includes(search) + ); + }) + ); // Estados para diálogo de Transportes y Precintos separados por comas let transportesPrecintosData = $state({ @@ -181,38 +446,38 @@ ]; const estadosMexico = [ - 'Aguascalientes', - 'Baja California', - 'Baja California Sur', - 'Campeche', - 'Chiapas', - 'Chihuahua', - 'Ciudad de México', - 'Coahuila', - 'Colima', - 'Durango', - 'Guanajuato', - 'Guerrero', - 'Hidalgo', - 'Jalisco', - 'México', - 'Michoacán', - 'Morelos', - 'Nayarit', - 'Nuevo León', - 'Oaxaca', - 'Puebla', - 'Querétaro', - 'Quintana Roo', - 'San Luis Potosí', - 'Sinaloa', - 'Sonora', - 'Tabasco', - 'Tamaulipas', - 'Tlaxcala', - 'Veracruz', - 'Yucatán', - 'Zacatecas' + { clave: 'AGS', nombre: 'Aguascalientes' }, + { clave: 'BC', nombre: 'Baja California' }, + { clave: 'BCS', nombre: 'Baja California Sur' }, + { clave: 'CAM', nombre: 'Campeche' }, + { clave: 'CHS', nombre: 'Chiapas' }, + { clave: 'CHI', nombre: 'Chihuahua' }, + { clave: 'CDMX', nombre: 'Ciudad de México' }, + { clave: 'COA', nombre: 'Coahuila' }, + { clave: 'COL', nombre: 'Colima' }, + { clave: 'DGO', nombre: 'Durango' }, + { clave: 'GTO', nombre: 'Guanajuato' }, + { clave: 'GRO', nombre: 'Guerrero' }, + { clave: 'HGO', nombre: 'Hidalgo' }, + { clave: 'JAL', nombre: 'Jalisco' }, + { clave: 'MEX', nombre: 'México' }, + { clave: 'MIC', nombre: 'Michoacán' }, + { clave: 'MOR', nombre: 'Morelos' }, + { clave: 'NAY', nombre: 'Nayarit' }, + { clave: 'NL', nombre: 'Nuevo León' }, + { clave: 'OAX', nombre: 'Oaxaca' }, + { clave: 'PUE', nombre: 'Puebla' }, + { clave: 'QRO', nombre: 'Querétaro' }, + { clave: 'QR', nombre: 'Quintana Roo' }, + { clave: 'SLP', nombre: 'San Luis Potosí' }, + { clave: 'SIN', nombre: 'Sinaloa' }, + { clave: 'SON', nombre: 'Sonora' }, + { clave: 'TAB', nombre: 'Tabasco' }, + { clave: 'TAM', nombre: 'Tamaulipas' }, + { clave: 'TLX', nombre: 'Tlaxcala' }, + { clave: 'VER', nombre: 'Veracruz' }, + { clave: 'YUC', nombre: 'Yucatán' }, + { clave: 'ZAC', nombre: 'Zacatecas' } ]; const tiposContenedor = [ @@ -328,7 +593,13 @@ } function saveGuia() { - if (!formData?.guias) return; + if (!formData) return; + + // Asegurar que existe el array de guías + if (!formData.guias) { + formData.guias = []; + } + if (editingGuiaIndex !== null) { formData.guias[editingGuiaIndex] = { ...currentGuia }; } else { @@ -402,6 +673,119 @@ } } + // Funciones para gestionar catálogo de transportistas + function openNewTransportistaForm() { + currentCatalogoTransportista = { + clave: '', + nombre: '', + rfc: '', + curp: '', + domicilio: '', + ciudad: '', + estado: '', + pais: '' + }; + editingTransportistaIndex = null; + isTransportistaFormDialogOpen = true; + } + + function editCatalogoTransportista(index: number) { + currentCatalogoTransportista = { ...transportistasCatalog[index] }; + editingTransportistaIndex = index; + isTransportistaFormDialogOpen = true; + } + + function saveCatalogoTransportista() { + if (editingTransportistaIndex !== null) { + transportistasCatalog[editingTransportistaIndex] = { ...currentCatalogoTransportista }; + } else { + transportistasCatalog.push({ ...currentCatalogoTransportista, id: Date.now() }); + } + isTransportistaFormDialogOpen = false; + currentCatalogoTransportista = null; + editingTransportistaIndex = null; + } + + function deleteCatalogoTransportista(index: number) { + if (confirm('¿Está seguro de eliminar este transportista?')) { + transportistasCatalog.splice(index, 1); + } + } + + function selectTransportista(transportista: any) { + currentTransporte.transportista = transportista.nombre; + currentTransporte.rfc = transportista.rfc; + currentTransporte.curp = transportista.curp || ''; + isTransportistasDialogOpen = false; + } + + // Funciones para gafetes + function openNewGafeteDialog() { + editingGafeteIndex = null; + currentGafete = { + claveTransportista: currentCatalogoTransportista?.clave || '', + linea: '0', + numeroGafeteUnico: '', + nombreTransportista: currentCatalogoTransportista?.nombre || '' + }; + isGafeteDialogOpen = true; + } + + function editGafete(index: number) { + if (!currentCatalogoTransportista?.gafetes) return; + editingGafeteIndex = index; + const gafete = currentCatalogoTransportista.gafetes[index]; + currentGafete = { + claveTransportista: currentCatalogoTransportista.clave || '', + linea: gafete.linea.toString(), + numeroGafeteUnico: gafete.numeroGafeteUnico, + nombreTransportista: gafete.nombreTransportista + }; + isGafeteDialogOpen = true; + } + + function deleteGafete(index: number) { + if (!currentCatalogoTransportista?.gafetes) return; + + if (!confirm('¿Está seguro de que desea borrar este gafete?')) { + return; + } + + currentCatalogoTransportista.gafetes.splice(index, 1); + // Reordenar las líneas + currentCatalogoTransportista.gafetes.forEach((gafete: any, i: number) => { + gafete.linea = i + 1; + }); + } + + function saveGafete() { + if (!currentCatalogoTransportista) return; + + // Asegurar que existe el array de gafetes + if (!currentCatalogoTransportista.gafetes) { + currentCatalogoTransportista.gafetes = []; + } + + if (editingGafeteIndex !== null) { + // Editar gafete existente + currentCatalogoTransportista.gafetes[editingGafeteIndex] = { + linea: currentCatalogoTransportista.gafetes[editingGafeteIndex].linea, + numeroGafeteUnico: currentGafete.numeroGafeteUnico, + nombreTransportista: currentGafete.nombreTransportista + }; + } else { + // Agregar nuevo gafete + currentCatalogoTransportista.gafetes.push({ + linea: currentCatalogoTransportista.gafetes.length + 1, + numeroGafeteUnico: currentGafete.numeroGafeteUnico, + nombreTransportista: currentGafete.nombreTransportista + }); + } + + editingGafeteIndex = null; + isGafeteDialogOpen = false; + } + // Funciones para Contenedores function openNewContenedor() { editingContenedorIndex = null; @@ -539,7 +923,7 @@ {:else} {#each formData.transportes as transporte, index} - {transporte.identificacion} + {transporte.identificacion_fiscal} {transporte.pais}
@@ -844,11 +1228,17 @@
- +
+ + +
@@ -889,24 +1279,52 @@ onValueChange={(v: string | undefined) => v && (currentTransporte.estado = v)} > - {currentTransporte.estado || 'Seleccionar estado'} + {currentTransporte.estado ? estadosMexico.find(e => e.clave === currentTransporte.estado)?.nombre || currentTransporte.estado : 'Seleccionar estado'} {#each estadosMexico as estado} - {estado} + {estado.clave} - {estado.nombre} {/each}
-
+
-
- - +
+ (searchCountry = (e.target as HTMLInputElement).value)} + onfocus={() => (showCountryDropdown = true)} + onblur={() => setTimeout(() => (showCountryDropdown = false), 200)} + class="w-full" + /> + {#if currentTransporte.pais && !searchCountry} +
+ {countries.find(c => c.m3_key === currentTransporte.pais)?.description_es || currentTransporte.pais} +
+ {/if} + {#if showCountryDropdown && filteredCountries.length > 0} +
+ {#each filteredCountries as country} + + {/each} +
+ {/if}
@@ -1098,6 +1516,291 @@ + + (isTransportistasDialogOpen = open)}> + + + Catálogo de Transportistas + +
+
+
+ + +
+
+ +
+
+
+ + + + Clave + Nombre + RFC + Acciones + + + + {#if filteredTransportistas.length === 0} + + + {searchTransportista ? 'No se encontraron transportistas con ese criterio.' : 'No hay transportistas en el catálogo. Haz clic en "Nuevo" para agregar.'} + + + {:else} + {#each filteredTransportistas as transportista, index} + + {transportista.clave} + {transportista.nombre} + {transportista.rfc} + +
+ + + +
+
+
+ {/each} + {/if} +
+
+
+
+ + + +
+
+ + + (isTransportistaFormDialogOpen = open)}> + + + {editingTransportistaIndex !== null ? 'Editar' : 'Nuevo'} Transportista + + {#if currentCatalogoTransportista} +
+ +
+ + +
+
+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ + +
+
+ + v && (currentCatalogoTransportista.pais = v)} + > + + {currentCatalogoTransportista.pais ? countries.find(c => c.m3_key === currentCatalogoTransportista.pais)?.description_es || currentCatalogoTransportista.pais : 'Seleccionar país'} + + + {#if countries.length === 0} + Cargando países... + {:else} + {#each countries as country} + {country.description_es} + {/each} + {/if} + + +
+
+ + v && (currentCatalogoTransportista.estado = v)} + > + + {currentCatalogoTransportista.estado ? estadosMexico.find(e => e.clave === currentCatalogoTransportista.estado)?.nombre || currentCatalogoTransportista.estado : 'Seleccionar estado'} + + + {#each estadosMexico as estado} + {estado.clave} - {estado.nombre} + {/each} + + +
+
+ + +
+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+

# DE GAFETES

+
+ +
+
+ +
+ + + + Línea + Número Gafete Único + Nombre + Acciones + + + + {#if currentCatalogoTransportista.gafetes && currentCatalogoTransportista.gafetes.length > 0} + {#each currentCatalogoTransportista.gafetes as gafete, index} + + {gafete.linea} + {gafete.numeroGafeteUnico} + {gafete.nombreTransportista} + +
+ + +
+
+
+ {/each} + {:else} + + + Sin gafetes registrados + + + {/if} +
+
+
+ +
+ + +
+
+
+ {/if} + + + + +
+
+ (isGuiasDialogOpen = open)}> @@ -1137,3 +1840,57 @@ + + + (isGafeteDialogOpen = open)}> + + + GAFETES UNICOS + +
+
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+
diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/temp.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/temp.svelte new file mode 100644 index 00000000..a540a118 --- /dev/null +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/temp.svelte @@ -0,0 +1,771 @@ + + + + + +
+ + + + + +
+ + +
+ {#if activeTab === 'DTA'} +
+
+ + +
+
+ + +

(dejar en cero para calcular automático)

+
+
+ + +

(dejar en cero para calcular automático)

+
+
+ {:else if activeTab === 'PREV'} +
+
+ + +
+
+ {:else if activeTab === 'ECI'} +
+
+ + +
+
+ + +

+ (dejar en cero para que el sistema calcule el importe) +

+
+
+ {:else if activeTab === 'MULT'} +
+
+ + +
+
+ + +
+
+ {:else if activeTab === 'REC'} +
+
+ + +
+
+ + +
+
+ {/if} +
+ + +
+ + + + Contribución + T.T. + Tasa + F.P. + Importe + Gravamen + Abreviación + F.P. + Importe + Acciones + + + + {#if !formData?.contribuciones || formData.contribuciones.length === 0} + + + No hay contribuciones registradas + + + {:else} + {#each formData.contribuciones as contribucion, index} + + {contribucion.contribucion} + {contribucion.tipo_tasa} + {contribucion.tasa.toLocaleString('es-MX', { + minimumFractionDigits: 2, + maximumFractionDigits: 5 + })} + {contribucion.forma_pago} + {contribucion.importe.toLocaleString('es-MX', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + })} + {contribucion.gravamen} + {contribucion.abreviacion} + {contribucion.forma_pago_2} + {contribucion.importe_2.toLocaleString('es-MX', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + })} + +
+ + +
+
+
+ {/each} + {/if} +
+
+
+ + +
+
+
+ + formData && (formData.calculo_manual = checked === true)} + /> + +
+ +
+ + formData && (formData.operaciones_regla_31_40 = checked === true)} + /> + +
+
+ +
+ + + +
+
+
+
+ + + + + + + {editingIndex !== null ? 'Editar Contribución' : 'Nueva Contribución'} + + + +
+ +
+

Tasas Pedimento - Registro 509

+ +
+ + v && (currentContribucion.contribucion = v)} + > + + {currentContribucion.contribucion || 'Seleccionar'} + + + {#each opcionesContribuciones as opcion} + {opcion} + {/each} + + +
+ +
+ +
+ v && (currentContribucion.tipo_tasa = v)} + > + + {currentContribucion.tipo_tasa || 'Seleccionar'} + + + Porcentual + Específico + Cuota minima (DTA) + Cuota fija (DTA) + Tasa de descuento sobre ad valorem + Factor de aplicación sobre tigie. + Al millar (DTA) + Tasa de descuento sobre el arancel específico + Tasa especifica sobre precios de referencia + Tasa especifica sobre precios de referencia con UM + + + +
+
+ +
+ + +
+
+ + +
+

Contribuciones Generales - Registro 510

+ + + {#if currentContribucion.contribuciones_generales && currentContribucion.contribuciones_generales.length > 0} + + + + Clave Contribución + Forma de Pago + Importe + + + + {#each currentContribucion.contribuciones_generales as contribGen, i} + + {contribGen.clave_contribucion} + {contribGen.clave_forma_pago} + ${contribGen.importe_contribucion.toFixed(2)} + + {/each} + +
+ {:else} +

No hay contribuciones generales registradas

+ {/if} + +
+ + + +
+
+
+ + + + + +
+
+ + + + + + Insertando + + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+
diff --git a/frontend/src/routes/api-sveltekit/countries/+server.ts b/frontend/src/routes/api-sveltekit/countries/+server.ts new file mode 100644 index 00000000..0b6855c6 --- /dev/null +++ b/frontend/src/routes/api-sveltekit/countries/+server.ts @@ -0,0 +1,55 @@ +import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ fetch }) => { + // Configurar la URL de la API usando las variables de entorno + let apiUrl = process.env.INTERNAL_API_URL; + if (!apiUrl) { + apiUrl = process.env.VITE_API_URL; + // Reemplazar 'localhost' con 'backend' para llamadas desde el servidor (SSR) + apiUrl = apiUrl?.replace('localhost', 'backend').replace('127.0.0.1', 'backend'); + } + + // Normalizar la URL + const baseUrl = apiUrl?.endsWith('/') ? apiUrl : `${apiUrl}/`; + + try { + // Endpoint público de países - no requiere autenticación + // Nota: La barra final "/" es importante para evitar redirects 307 + // El backend limita page_size a 100, así que necesitamos hacer múltiples llamadas + const allCountries: any[] = []; + let page = 1; + let hasMore = true; + + while (hasMore) { + const response = await fetch( + `${baseUrl}v1/public/refrence_data/countries/?page=${page}&page_size=100`, + { + headers: { + 'Content-Type': 'application/json' + } + } + ); + + if (!response.ok) { + console.error('Error fetching countries:', response.status, response.statusText); + const errorText = await response.text(); + console.error('Error response:', errorText); + return json({ error: 'Failed to fetch countries' }, { status: response.status }); + } + + const data = await response.json(); + allCountries.push(...(data.items || [])); + + // Si hay menos items que el page_size, es la última página + hasMore = data.items && data.items.length === 100; + page++; + } + + return json(allCountries); + } catch (error) { + console.error('Error fetching countries:', error); + return json({ error: 'Internal server error' }, { status: 500 }); + } +}; + From 0b4c385aeb46a9a274f0d0ebd7e7361edbe5ecc9 Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Fri, 2 Jan 2026 14:16:09 -0600 Subject: [PATCH 02/37] feat: Implement Document Types for Digitization module - Added backend API for managing document types related to digitization, including CRUD operations. - Created DTOs and models for DocumentTypeDigitization with validation using Pydantic. - Updated frontend API service to interact with the new document types API. - Refactored existing forms in the frontend to load and manage document types effectively. - Enhanced data loading and state management in various components related to pedimentos. --- .../v1/modules/a76/doc_types_dig/__init__.py | 1 + .../api/v1/modules/a76/doc_types_dig/dto.py | 32 ++ .../v1/modules/a76/doc_types_dig/models.py | 25 ++ .../v1/modules/a76/doc_types_dig/routes.py | 170 +++++++ .../models/pedimento_config_additional.py | 15 +- backend/api/v1/modules/a76/router.py | 2 + .../document_types_digitization.ts | 70 +++ .../accounts-compensation-tab-form.svelte | 7 +- .../edit/contributions-tab-form.svelte | 2 +- .../edit/digitization-tab-form.svelte | 418 +++++++++++++++--- .../edit/other-data-tab-form.svelte | 99 +---- .../package-transportation-tab-form.svelte | 76 +++- .../pedimentos/edit/[id]/+page.svelte | 201 +++++++-- 13 files changed, 890 insertions(+), 228 deletions(-) create mode 100644 backend/api/v1/modules/a76/doc_types_dig/__init__.py create mode 100644 backend/api/v1/modules/a76/doc_types_dig/dto.py create mode 100644 backend/api/v1/modules/a76/doc_types_dig/models.py create mode 100644 backend/api/v1/modules/a76/doc_types_dig/routes.py create mode 100644 frontend/src/lib/api/dashboard/refrence_data/document_types_digitization.ts diff --git a/backend/api/v1/modules/a76/doc_types_dig/__init__.py b/backend/api/v1/modules/a76/doc_types_dig/__init__.py new file mode 100644 index 00000000..e65cae83 --- /dev/null +++ b/backend/api/v1/modules/a76/doc_types_dig/__init__.py @@ -0,0 +1 @@ +# Document Types for Digitization module diff --git a/backend/api/v1/modules/a76/doc_types_dig/dto.py b/backend/api/v1/modules/a76/doc_types_dig/dto.py new file mode 100644 index 00000000..21ee57e2 --- /dev/null +++ b/backend/api/v1/modules/a76/doc_types_dig/dto.py @@ -0,0 +1,32 @@ +from pydantic import BaseModel, Field + + +class DocumentTypeDigitizationBase(BaseModel): + """Base schema for Document Type Digitization""" + + code: str = Field(..., max_length=10, description="Código del tipo de documento") + description: str = Field(..., description="Descripción del tipo de documento") + active: bool = Field(default=True, description="Indica si el tipo está activo") + + +class DocumentTypeDigitizationCreate(DocumentTypeDigitizationBase): + """Schema for creating a Document Type Digitization""" + + pass + + +class DocumentTypeDigitizationUpdate(BaseModel): + """Schema for updating a Document Type Digitization""" + + code: str | None = Field(None, max_length=10) + description: str | None = None + active: bool | None = None + + +class DocumentTypeDigitizationResponse(DocumentTypeDigitizationBase): + """Schema for Document Type Digitization response""" + + id: int + + class Config: + from_attributes = True diff --git a/backend/api/v1/modules/a76/doc_types_dig/models.py b/backend/api/v1/modules/a76/doc_types_dig/models.py new file mode 100644 index 00000000..db7636ce --- /dev/null +++ b/backend/api/v1/modules/a76/doc_types_dig/models.py @@ -0,0 +1,25 @@ +from api.v1.common.base_models import TenantScopedMixin, TimestampMixin +from core.database import Base +from sqlalchemy import Boolean, Integer, PrimaryKeyConstraint, String, Text, UniqueConstraint +from sqlalchemy.orm import Mapped, mapped_column + + +class DocumentTypeDigitization(Base, TenantScopedMixin, TimestampMixin): + """Tipos de documentos para digitalización de pedimentos""" + + __tablename__ = "document_types_digitization" + __table_args__ = ( + PrimaryKeyConstraint("id", name="document_types_digitization_pkey"), + UniqueConstraint( + "tenant_id", + "company_id", + "code", + name="document_types_digitization_code_key", + ), + {"schema": "a76"}, + ) + + id: Mapped[int] = mapped_column(Integer) + code: Mapped[str] = mapped_column(String(10), nullable=False, index=True) + description: Mapped[str] = mapped_column(Text, nullable=False) + active: Mapped[bool] = mapped_column(Boolean, default=True) diff --git a/backend/api/v1/modules/a76/doc_types_dig/routes.py b/backend/api/v1/modules/a76/doc_types_dig/routes.py new file mode 100644 index 00000000..a3ee51a7 --- /dev/null +++ b/backend/api/v1/modules/a76/doc_types_dig/routes.py @@ -0,0 +1,170 @@ +from typing import List + +from api.v1.modules.a76.doc_types_dig.dto import ( + DocumentTypeDigitizationCreate, + DocumentTypeDigitizationResponse, + DocumentTypeDigitizationUpdate, +) +from api.v1.modules.a76.doc_types_dig.models import DocumentTypeDigitization +from core.database import get_core_db +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy import select +from sqlalchemy.orm import Session + +router = APIRouter(prefix="/document-types-digitization", tags=["Document Types Digitization"]) + + +@router.get("", response_model=List[DocumentTypeDigitizationResponse]) +def get_all_document_types( + active_only: bool = True, + db: Session = Depends(get_core_db), +): + """ + Obtener todos los tipos de documentos para digitalización + + Args: + active_only: Si es True, solo devuelve los tipos activos + """ + query = select(DocumentTypeDigitization) + + if active_only: + query = query.where(DocumentTypeDigitization.active == True) + + query = query.order_by(DocumentTypeDigitization.code) + + result = db.execute(query) + document_types = result.scalars().all() + + return document_types + + +@router.get("/{document_type_id}", response_model=DocumentTypeDigitizationResponse) +def get_document_type( + document_type_id: int, + db: Session = Depends(get_core_db), +): + """Obtener un tipo de documento por ID""" + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.id == document_type_id) + ) + document_type = result.scalar_one_or_none() + + if not document_type: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=f"Tipo de documento con ID {document_type_id} no encontrado" + ) + + return document_type + + +@router.get("/by-code/{code}", response_model=DocumentTypeDigitizationResponse) +def get_document_type_by_code( + code: str, + db: Session = Depends(get_core_db), +): + """Obtener un tipo de documento por código""" + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.code == code) + ) + document_type = result.scalar_one_or_none() + + if not document_type: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=f"Tipo de documento con código {code} no encontrado" + ) + + return document_type + + +@router.post("", response_model=DocumentTypeDigitizationResponse, status_code=status.HTTP_201_CREATED) +def create_document_type( + document_type_data: DocumentTypeDigitizationCreate, + db: Session = Depends(get_core_db), +): + """Crear un nuevo tipo de documento""" + # Verificar si el código ya existe + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.code == document_type_data.code) + ) + existing = result.scalar_one_or_none() + + if existing: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=f"Ya existe un tipo de documento con el código {document_type_data.code}" + ) + + new_document_type = DocumentTypeDigitization(**document_type_data.model_dump()) + db.add(new_document_type) + db.commit() + db.refresh(new_document_type) + + return new_document_type + + +@router.put("/{document_type_id}", response_model=DocumentTypeDigitizationResponse) +def update_document_type( + document_type_id: int, + document_type_data: DocumentTypeDigitizationUpdate, + db: Session = Depends(get_core_db), +): + """Actualizar un tipo de documento existente""" + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.id == document_type_id) + ) + document_type = result.scalar_one_or_none() + + if not document_type: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=f"Tipo de documento con ID {document_type_id} no encontrado" + ) + + # Actualizar solo los campos proporcionados + update_data = document_type_data.model_dump(exclude_unset=True) + + # Verificar si el nuevo código ya existe (si se está actualizando) + if "code" in update_data and update_data["code"] != document_type.code: + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.code == update_data["code"]) + ) + existing = result.scalar_one_or_none() + if existing: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=f"Ya existe un tipo de documento con el código {update_data['code']}" + ) + + for field, value in update_data.items(): + setattr(document_type, field, value) + + db.commit() + db.refresh(document_type) + + return document_type + + +@router.delete("/{document_type_id}", status_code=status.HTTP_204_NO_CONTENT) +def delete_document_type( + document_type_id: int, + db: Session = Depends(get_core_db), +): + """Eliminar un tipo de documento (soft delete, marca como inactivo)""" + result = db.execute( + select(DocumentTypeDigitization).where(DocumentTypeDigitization.id == document_type_id) + ) + document_type = result.scalar_one_or_none() + + if not document_type: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=f"Tipo de documento con ID {document_type_id} no encontrado" + ) + + # Soft delete - solo marcar como inactivo + document_type.active = False + db.commit() + + return None diff --git a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py index 22735ad6..28fff3a1 100644 --- a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py +++ b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py @@ -3,11 +3,10 @@ from typing import TYPE_CHECKING from api.v1.common.base_models import TenantScopedMixin, TimestampMixin from core.database import Base from sqlalchemy import ( + Boolean, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, - SmallInteger, - String, UniqueConstraint, ) from sqlalchemy.orm import Mapped, mapped_column, relationship @@ -38,12 +37,12 @@ class PedimentoConfigAdditional(Base, TenantScopedMixin, TimestampMixin): id: Mapped[int] = mapped_column(Integer) pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False) - add_po_identifier: Mapped[int] = mapped_column(SmallInteger) - do_not_exempt_norms_complement_x: Mapped[int] = mapped_column(SmallInteger) - manual_pedimento_year: Mapped[str] = mapped_column(String(2)) - enable_import_invoice_recipient: Mapped[int] = mapped_column(SmallInteger) - send_502_validation_file_for_consolidated: Mapped[int] = mapped_column(SmallInteger) - add_remove_norms: Mapped[int] = mapped_column(SmallInteger) + add_po_identifier: Mapped[bool] = mapped_column(Boolean, default=False) + do_not_exempt_norms_complement_x: Mapped[bool] = mapped_column(Boolean, default=False) + manual_pedimento_year: Mapped[int] = mapped_column(Integer, nullable=True) + enable_import_invoice_recipient: Mapped[bool] = mapped_column(Boolean, default=False) + send_502_validation_file_for_consolidated: Mapped[bool] = mapped_column(Boolean, default=False) + add_remove_norms: Mapped[bool] = mapped_column(Boolean, default=False) pedimento: Mapped["Pedimentos"] = relationship( "Pedimentos", back_populates="pedimento_config_additional" diff --git a/backend/api/v1/modules/a76/router.py b/backend/api/v1/modules/a76/router.py index 8bfee681..a08d04d6 100644 --- a/backend/api/v1/modules/a76/router.py +++ b/backend/api/v1/modules/a76/router.py @@ -14,6 +14,7 @@ from .clients_and_providers import router as client_and_provider_router from .general_catalogs.company import router as company_router from .country_rule_oct.routes import router as country_rule_oct_router from .transportation.drivers.routes import router as drivers_router +from .doc_types_dig.routes import router as doc_types_dig_router from .general_catalogs.exchange_rate.routes import router as exchange_rate_router from .general_catalogs.identifiers.routes import router as identifiers_router from .fraction_rule_octave.routes import router as fraction_rule_octave_router @@ -73,6 +74,7 @@ router.include_router(trailers_router, prefix="/a76", tags=["a76 / trailers"]) router.include_router( customs_broker_router, prefix="/a76", tags=["a76 / customs_broker"] ) +router.include_router(doc_types_dig_router, prefix="/a76", tags=["a76 / document_types_digitization"]) router.include_router(drivers_router, prefix="/a76", tags=["a76 / drivers"]) router.include_router(transporters_router, prefix="/a76", tags=["a76 / transporters"]) diff --git a/frontend/src/lib/api/dashboard/refrence_data/document_types_digitization.ts b/frontend/src/lib/api/dashboard/refrence_data/document_types_digitization.ts new file mode 100644 index 00000000..4ddb1bc7 --- /dev/null +++ b/frontend/src/lib/api/dashboard/refrence_data/document_types_digitization.ts @@ -0,0 +1,70 @@ +import { api } from '$lib/api'; + +export interface DocumentTypeDigitization { + id: number; + code: string; + description: string; + active: boolean; +} + +export interface DocumentTypeDigitizationCreate { + code: string; + description: string; + active?: boolean; +} + +export interface DocumentTypeDigitizationUpdate { + code?: string; + description?: string; + active?: boolean; +} + +const BASE_URL = '/v1/a76/document-types-digitization'; + +/** + * API para Tipos de Documentos de Digitalización + */ +export const documentTypesDigitizationApi = { + /** + * Obtener todos los tipos de documentos para digitalización + */ + getAll: (activeOnly: boolean = true) => { + const url = `${BASE_URL}?active_only=${activeOnly}`; + return api.get(url); + }, + + /** + * Obtener un tipo de documento por ID + */ + getById: (id: number) => { + return api.get(`${BASE_URL}/${id}`); + }, + + /** + * Obtener un tipo de documento por código + */ + getByCode: (code: string) => { + return api.get(`${BASE_URL}/by-code/${code}`); + }, + + /** + * Crear un nuevo tipo de documento + */ + create: (data: DocumentTypeDigitizationCreate) => { + return api.post(BASE_URL, data); + }, + + /** + * Actualizar un tipo de documento existente + */ + update: (id: number, data: DocumentTypeDigitizationUpdate) => { + return api.put(`${BASE_URL}/${id}`, data); + }, + + /** + * Eliminar (soft delete) un tipo de documento + */ + delete: (id: number) => { + return api.delete(`${BASE_URL}/${id}`); + } +}; diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/accounts-compensation-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/accounts-compensation-tab-form.svelte index 7008c275..f0b432e5 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/accounts-compensation-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/accounts-compensation-tab-form.svelte @@ -544,7 +544,12 @@ - Cuentas Aduaneras a nivel Pedimento + + {editingCuentaIndex !== null ? 'Cuentas Aduaneras a nivel Pedimento' : 'Insertando'} + + {#if editingCuentaIndex === null} +

Cuentas Aduaneras a nivel Pedimento

+ {/if}
diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte index 90143061..41ebc60c 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte @@ -578,7 +578,7 @@ - {editingIndex !== null ? 'Editar Contribución' : 'Nueva Contribución'} + {editingIndex !== null ? 'Editar Contribución' : 'Insertando'} diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/digitization-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/digitization-tab-form.svelte index 689ee413..992a7278 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/digitization-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/digitization-tab-form.svelte @@ -33,15 +33,16 @@ ChevronRight, ChevronsRight } from 'lucide-svelte'; + import { documentTypesDigitizationApi, type DocumentTypeDigitization } from '$lib/api/dashboard/refrence_data/document_types_digitization'; interface Digitalizacion { id?: number; linea: number; - clave: string; - documento: string; - e_document: string; - operacion: string; + tipo_documento: string; + ruta_archivo_pdf: string; observaciones: string; + e_document: string; + numero_operacion_vu: string; } let { @@ -57,6 +58,51 @@ // Estados para diálogo let isDialogOpen = $state(false); let editingIndex = $state(null); + let isTipoDocumentoDialogOpen = $state(false); + let isNuevoTipoDocumentoDialogOpen = $state(false); + + // Tipos de documentos disponibles (cargados desde el backend) + let tiposDocumentos = $state([]); + let isLoadingTiposDocumentos = $state(false); + let errorLoadingTiposDocumentos = $state(null); + + // Formulario para nuevo tipo de documento + let nuevoTipoDocumento = $state({ + code: '', + description: '', + active: true + }); + + // Cargar tipos de documentos desde el backend + async function cargarTiposDocumentos() { + try { + isLoadingTiposDocumentos = true; + errorLoadingTiposDocumentos = null; + const response = await documentTypesDigitizationApi.getAll(true); + tiposDocumentos = response.data || []; + } catch (error) { + console.error('Error al cargar tipos de documentos:', error); + errorLoadingTiposDocumentos = 'Error al cargar los tipos de documentos'; + // Si falla, usar array vacío para que el componente siga funcionando + tiposDocumentos = []; + } finally { + isLoadingTiposDocumentos = false; + } + } + + // Filtro de búsqueda para tipos de documentos + let tipoDocumentoBusqueda = $state(''); + + // Tipos de documentos filtrados + const tiposDocumentosFiltrados = $derived( + tipoDocumentoBusqueda.trim() === '' + ? tiposDocumentos + : tiposDocumentos.filter( + (td) => + td.code.toLowerCase().includes(tipoDocumentoBusqueda.toLowerCase()) || + td.description.toLowerCase().includes(tipoDocumentoBusqueda.toLowerCase()) + ) + ); // Paginación let currentPage = $state(0); @@ -64,13 +110,16 @@ let currentDigitalizacion = $state({ linea: 0, - clave: '', - documento: '', + tipo_documento: '', + ruta_archivo_pdf: '', + observaciones: '', e_document: '', - operacion: '', - observaciones: '' + numero_operacion_vu: '' }); + // Referencias para los inputs de archivo + let fileInputRef: HTMLInputElement; + const totalPages = $derived( Math.ceil((formData?.digitalizaciones?.length ?? 0) / pageSize) ); @@ -83,19 +132,23 @@ ); function openNewDigitalizacion() { + console.log('🟢 INICIO openNewDigitalizacion - isDialogOpen:', isDialogOpen); editingIndex = null; const nextLinea = formData?.digitalizaciones?.length ? Math.max(...formData.digitalizaciones.map((d) => d.linea)) + 1 : 1; currentDigitalizacion = { linea: nextLinea, - clave: '', - documento: '', + tipo_documento: '', + ruta_archivo_pdf: '', + observaciones: '', e_document: '', - operacion: '', - observaciones: '' + numero_operacion_vu: '' }; + console.log('🔵 Abriendo dialog de digitalización, isDialogOpen antes:', isDialogOpen); isDialogOpen = true; + console.log('🔵 isDialogOpen después:', isDialogOpen); + console.log('🟢 FIN openNewDigitalizacion'); } function openEditDigitalizacion(index: number) { @@ -157,6 +210,45 @@ alert('Cargar E-Document no implementado aún'); } + async function seleccionarRutaArchivo() { + try { + // Usar la File System Access API si está disponible + if ('showSaveFilePicker' in window) { + // @ts-ignore - API moderna del navegador + const handle = await window.showSaveFilePicker({ + suggestedName: 'documento.pdf', + types: [ + { + description: 'PDF Files', + accept: { 'application/pdf': ['.pdf'] } + } + ] + }); + + // Obtener la ruta (nombre del archivo seleccionado) + currentDigitalizacion.ruta_archivo_pdf = handle.name; + } else { + // Fallback para navegadores que no soportan la API + const input = document.createElement('input'); + input.type = 'file'; + input.accept = '.pdf'; + + input.onchange = (e: Event) => { + const target = e.target as HTMLInputElement; + if (target.files && target.files.length > 0) { + const file = target.files[0]; + currentDigitalizacion.ruta_archivo_pdf = file.name; + } + }; + + input.click(); + } + } catch (error) { + // Usuario canceló la selección + console.log('Selección de archivo cancelada'); + } + } + function goToFirstPage() { currentPage = 0; } @@ -172,6 +264,48 @@ function goToLastPage() { currentPage = totalPages - 1; } + + function abrirTiposDocumentos() { + tipoDocumentoBusqueda = ''; + // Cargar los tipos de documentos si aún no se han cargado + if (tiposDocumentos.length === 0 && !isLoadingTiposDocumentos) { + cargarTiposDocumentos(); + } + isTipoDocumentoDialogOpen = true; + } + + function seleccionarTipoDocumento(code: string) { + currentDigitalizacion.tipo_documento = code; + isTipoDocumentoDialogOpen = false; + } + + function abrirNuevoTipoDocumento() { + nuevoTipoDocumento = { + code: '', + description: '', + active: true + }; + isNuevoTipoDocumentoDialogOpen = true; + } + + async function guardarNuevoTipoDocumento() { + try { + const response = await documentTypesDigitizationApi.create(nuevoTipoDocumento); + if (response.data) { + // Agregar el nuevo tipo a la lista + tiposDocumentos = [...tiposDocumentos, response.data]; + // Seleccionar el nuevo tipo + currentDigitalizacion.tipo_documento = response.data.code; + // Cerrar ambos dialogs + isNuevoTipoDocumentoDialogOpen = false; + isTipoDocumentoDialogOpen = false; + } + } catch (error) { + console.error('Error al crear tipo de documento:', error); + alert('Error al crear el tipo de documento'); + } + } + @@ -182,11 +316,11 @@ Línea - Clave - Documento - E-Document - Operación - Observaciones + Tipo Documento + Ruta Archivo PDF + E-Document + Núm. Operación V.U + Observaciones Acciones @@ -207,10 +341,10 @@ {#each paginatedDigitalizaciones as digitalizacion, index} {digitalizacion.linea} - {digitalizacion.clave} - {digitalizacion.documento} + {digitalizacion.tipo_documento} + {digitalizacion.ruta_archivo_pdf} {digitalizacion.e_document} - {digitalizacion.operacion} + {digitalizacion.numero_operacion_vu} {digitalizacion.observaciones} @@ -338,76 +472,224 @@ - + - - {editingIndex !== null ? 'Editar Digitalización' : 'Nueva Digitalización'} - + Digitalización {currentDigitalizacion.linea}
-
-
- +
+ + +
+ +
+ +
-
-
- - +
- - + +
+ + +
- - -
- -
- - -
- -
- + +
+
+ + + + + + + + + + + + Confirmar Eliminación + +
+

¿Está seguro que desea eliminar la fracción {fractionToDelete?.code}?

+

Esta acción no se puede deshacer.

+
+ + + + +
+
+ + + + + + CATALOGO DE TASAS DE DEPRECIACIÓN + +
+ +
+ + +
+ + +
+ + + + + + + + + + {#each depreciationCatalog as item (item.id)} + selectDepreciation(item)} + > + + + + + {:else} + + + + {/each} + {#if hasMoreDepreciation && depreciationCatalog.length > 0} + + + + {/if} + +
FracciónDescripciónTasa %
{item.fraction}{item.description}{item.depreciation_rate}%
+ {#if isLoadingDepreciation} + Cargando catálogo... + {:else if searchDepreciation} + No se encontraron registros que coincidan con "{searchDepreciation}" + {:else} + No hay registros disponibles + {/if} +
+ {#if isLoadingDepreciation} + Cargando más registros... + {:else} + + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE CODIGOS DE F.D.A. + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + + + + {#each fdaCatalog as item (item.id)} + selectFDA(item)} + > + + + + + + + + + + + {:else} + + + + {/each} + {#if hasMoreFDA && fdaCatalog.length > 0} + + + + {/if} + +
ClaveDescripciónCódigo FDARequerimientosNo. de FabriPaís de ProducciónEstatusAlmacenaCodAlm1CallAtrl
{item.fda_key || ''}{item.description || ''}{item.fda_code || ''}{item.requirements || ''}{item.manufacturer_number || ''}{item.country_of_production || ''}{item.storage_status || ''}{item.warehouse_code || ''}{item.call_atl || ''}
+ {#if isLoadingFDA} + Cargando catálogo... + {:else if searchFDA} + No se encontraron registros que coincidan con "{searchFDA}" + {:else} + No hay registros disponibles + {/if} +
+ {#if isLoadingFDA} + Cargando más registros... + {:else} + + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE CARTA PORTE + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + {#each cartaPorteCatalog as item (item.id)} + { + formData.carta_porte_code = item.clave_id; + showCartaPorteDialog = false; + }} + > + + + + + + + + {:else} + + + + {/each} + +
Clave IDDescripciónPalabras SimilaresMaterial PeligrosoFecha Inicio VigenciaFecha Fin Vigencia
{item.clave_id || ''}{item.descripcion || ''}{item.palabras_similares || ''}{item.material_peligroso || ''}{item.fecha_inicio_vigencia || ''}{item.fecha_fin_vigencia || ''}
+ {#if searchCartaPorte} + No se encontraron registros que coincidan con "{searchCartaPorte}" + {:else} + No hay registros disponibles + {/if} +
+
+
+ + + +
+
From 02d6d2bac73c09ecea1ad270a1afc4e271668bc0 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Wed, 7 Jan 2026 10:26:34 -0600 Subject: [PATCH 19/37] Se corrigio una ruta de puertos, ademas de agregar tipos de materiales a partes --- ...2f4f3ca0_add_material_type_key_to_parts.py | 2658 +++++++++++++++++ .../v1/modules/a24/inv/inv_classes/models.py | 2 +- backend/api/v1/modules/a76/parts/dto.py | 2 + backend/api/v1/modules/a76/parts/models.py | 1 + 4 files changed, 2662 insertions(+), 1 deletion(-) create mode 100644 backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py diff --git a/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py b/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py new file mode 100644 index 00000000..7e6c7705 --- /dev/null +++ b/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py @@ -0,0 +1,2658 @@ +"""add material_type_key to parts + +Revision ID: 57472f4f3ca0 +Revises: 7937209f9718 +Create Date: 2026-01-07 15:27:22.443152 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '57472f4f3ca0' +down_revision: Union[str, Sequence[str], None] = '7937209f9718' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Upgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('tenants', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.Column('slug', sa.String(length=100), nullable=False), + sa.Column('type', sa.Enum('SHARED', 'DEDICATED', name='tenanttype'), nullable=False), + sa.Column('keycloak_realm', sa.String(length=255), nullable=False), + sa.Column('db_config', sa.Text(), nullable=True), + sa.Column('contact_name', sa.String(length=255), nullable=True), + sa.Column('contact_email', sa.String(length=255), nullable=True), + sa.Column('contact_phone', sa.String(length=50), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id'), + schema='core' + ) + op.create_index(op.f('ix_core_tenants_id'), 'tenants', ['id'], unique=False, schema='core') + op.create_index(op.f('ix_core_tenants_name'), 'tenants', ['name'], unique=False, schema='core') + op.create_index(op.f('ix_core_tenants_slug'), 'tenants', ['slug'], unique=True, schema='core') + op.create_table('company', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=True), + sa.Column('rfc', sa.String(length=30), nullable=True), + sa.Column('main_activity', sa.String(length=255), nullable=True), + sa.Column('program', sa.String(length=10), nullable=True), + sa.Column('program_number', sa.String(length=40), nullable=True), + sa.Column('prosec', sa.SmallInteger(), nullable=True), + sa.Column('prosec_authorization', sa.String(length=20), nullable=True), + sa.Column('manufacturer_id', sa.String(length=25), nullable=True), + sa.Column('broker_company', sa.String(length=10), nullable=True), + sa.Column('responsible', sa.String(length=80), nullable=True), + sa.Column('responsible_name', sa.String(length=20), nullable=True), + sa.Column('responsible_last_name', sa.String(length=20), nullable=True), + sa.Column('responsible_mother_last_name', sa.String(length=20), nullable=True), + sa.Column('responsible_rfc', sa.String(length=30), nullable=True), + sa.Column('position', sa.String(length=30), nullable=True), + sa.Column('logo', sa.String(length=255), nullable=True), + sa.Column('has_express_line', sa.Boolean(), nullable=True), + sa.Column('order_format_type', sa.String(length=19), nullable=True), + sa.Column('previous_code', sa.SmallInteger(), nullable=True), + sa.Column('is_service_company', sa.Boolean(), nullable=True), + sa.Column('client_name', sa.String(length=300), nullable=True), + sa.Column('subassembly_mode', sa.String(length=7), nullable=True), + sa.Column('curp', sa.String(length=19), nullable=True), + sa.Column('inter_db_name', sa.String(length=100), nullable=True), + sa.Column('ctpat_svi', sa.String(length=100), nullable=True), + sa.Column('trusted_exporter_number', sa.String(length=50), nullable=True), + sa.Column('prevalidator_key', sa.String(length=20), nullable=True), + sa.Column('seventh_amendment', sa.Boolean(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='company_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_company_tenant_id'), 'company', ['tenant_id'], unique=False, schema='a76') + op.create_table('customs_broker_concepts', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('broker_key', sa.String(length=5), nullable=False), + sa.Column('concept', sa.String(length=15), nullable=False), + sa.Column('amount', sa.Numeric(precision=11, scale=2), nullable=True), + sa.Column('priority', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('broker_key', 'concept', 'company_id', name='uq_broker_concept'), + schema='a76' + ) + op.create_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), 'customs_broker_concepts', ['tenant_id'], unique=False, schema='a76') + op.create_table('license_usage', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('period_start', sa.DateTime(timezone=True), nullable=False), + sa.Column('period_end', sa.DateTime(timezone=True), nullable=False), + sa.Column('active_users', sa.Integer(), nullable=True), + sa.Column('storage_used_gb', sa.Integer(), nullable=True), + sa.Column('operations_count', sa.Integer(), nullable=True), + sa.Column('api_calls_count', sa.Integer(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='core' + ) + op.create_index(op.f('ix_core_license_usage_id'), 'license_usage', ['id'], unique=False, schema='core') + op.create_index(op.f('ix_core_license_usage_tenant_id'), 'license_usage', ['tenant_id'], unique=False, schema='core') + op.create_table('licenses', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('plan', sa.Enum('FREE', 'BASIC', 'PROFESSIONAL', 'ENTERPRISE', name='licenseplan'), nullable=False), + sa.Column('status', sa.Enum('ACTIVE', 'EXPIRED', 'SUSPENDED', 'PENDING', 'CANCELLED', name='licensestatus'), nullable=False), + sa.Column('max_users', sa.Integer(), nullable=False), + sa.Column('max_storage_gb', sa.Integer(), nullable=False), + sa.Column('max_monthly_operations', sa.Integer(), nullable=False), + sa.Column('feature_api_access', sa.Boolean(), nullable=True), + sa.Column('feature_advanced_reports', sa.Boolean(), nullable=True), + sa.Column('feature_integrations', sa.Boolean(), nullable=True), + sa.Column('feature_dedicated_support', sa.Boolean(), nullable=True), + sa.Column('starts_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='core' + ) + op.create_index(op.f('ix_core_licenses_id'), 'licenses', ['id'], unique=False, schema='core') + op.create_index(op.f('ix_core_licenses_tenant_id'), 'licenses', ['tenant_id'], unique=True, schema='core') + op.create_table('location', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=5), nullable=False), + sa.Column('description', sa.String(length=200), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='location_pkey'), + sa.UniqueConstraint('code'), + sa.UniqueConstraint('code', name='location_code_unique'), + schema='a24' + ) + op.create_index(op.f('ix_a24_location_company_id'), 'location', ['company_id'], unique=False, schema='a24') + op.create_index(op.f('ix_a24_location_tenant_id'), 'location', ['tenant_id'], unique=False, schema='a24') + op.create_table('classification_concepts', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('classification', sa.String(length=30), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('classification', name='uq_classification_concept'), + schema='a76' + ) + op.create_index(op.f('ix_a76_classification_concepts_company_id'), 'classification_concepts', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_classification_concepts_tenant_id'), 'classification_concepts', ['tenant_id'], unique=False, schema='a76') + op.create_table('clients_and_providers', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('type_nat_foreign', sa.String(length=1), nullable=True), + sa.Column('name', sa.String(length=256), nullable=True), + sa.Column('short_name', sa.String(length=10), nullable=True), + sa.Column('rfc', sa.String(length=30), nullable=True), + sa.Column('curp', sa.String(length=19), nullable=True), + sa.Column('client_or_provider', sa.Enum('CLIENT', 'PROVIDER', 'BOTH', name='entity_client_or_provider'), nullable=False), + sa.Column('linking', sa.String(length=1), nullable=True), + sa.Column('transform_subassembly', sa.String(length=1), nullable=True), + sa.Column('extra_information', sa.String(length=399), nullable=True), + sa.Column('web_key', sa.String(length=40), nullable=True), + sa.Column('responsible', sa.String(length=80), nullable=True), + sa.Column('position', sa.String(length=30), nullable=True), + sa.Column('incoterm', sa.String(length=19), nullable=True), + sa.Column('is_national_provider', sa.Boolean(), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='clients_and_providers_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_clients_and_providers_company_id'), 'clients_and_providers', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_clients_and_providers_tenant_id'), 'clients_and_providers', ['tenant_id'], unique=False, schema='a76') + op.create_table('customs_brokers', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('type', sa.String(length=9), nullable=True), + sa.Column('broker_key', sa.String(length=5), nullable=False), + sa.Column('name', sa.String(length=80), nullable=True), + sa.Column('address', sa.String(length=1500), nullable=True), + sa.Column('postal_code', sa.String(length=15), nullable=True), + sa.Column('city', sa.String(length=30), nullable=True), + sa.Column('state', sa.String(length=30), nullable=True), + sa.Column('phone', sa.String(length=30), nullable=True), + sa.Column('fax', sa.String(length=30), nullable=True), + sa.Column('email', sa.String(length=100), nullable=True), + sa.Column('country', sa.String(length=3), nullable=True), + sa.Column('tax_id', sa.String(length=30), nullable=True), + sa.Column('personal_id', sa.String(length=20), nullable=True), + sa.Column('position', sa.String(length=30), nullable=True), + sa.Column('license', sa.String(length=4), nullable=True), + sa.Column('company', sa.String(length=200), nullable=True), + sa.Column('contact', sa.String(length=80), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='customs_brokers_pkey'), + sa.UniqueConstraint('broker_key', 'tenant_id', 'company_id', name='uq_broker_key_tenant_company'), + schema='a76' + ) + op.create_index(op.f('ix_a76_customs_brokers_company_id'), 'customs_brokers', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_customs_brokers_tenant_id'), 'customs_brokers', ['tenant_id'], unique=False, schema='a76') + op.create_table('doda', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('integration_number', sa.String(length=30), nullable=True), + sa.Column('doda_date', sa.Integer(), nullable=True), + sa.Column('doda_time', sa.Integer(), nullable=True), + sa.Column('dispatch_customs', sa.String(length=3), nullable=True), + sa.Column('customs_sections', sa.String(length=3), nullable=True), + sa.Column('patent', sa.String(length=4), nullable=True), + sa.Column('pedimentos', sa.String(length=80), nullable=True), + sa.Column('caat', sa.String(length=10), nullable=True), + sa.Column('transport_identification', sa.String(length=20), nullable=True), + sa.Column('fast_id', sa.String(length=20), nullable=True), + sa.Column('operation_type', sa.String(length=1), nullable=True), + sa.Column('selected', sa.Boolean(), nullable=True), + sa.Column('user_selected', sa.String(length=30), nullable=True), + sa.Column('last_user', sa.String(length=30), nullable=True), + sa.Column('responsible', sa.String(length=14), nullable=True), + sa.Column('carrier', sa.String(length=8), nullable=True), + sa.Column('shipments', sa.String(length=80), nullable=True), + sa.Column('pedimento_type', sa.String(length=30), nullable=True), + sa.Column('original_chain', sa.String(length=5000), nullable=True), + sa.Column('serial_number', sa.String(length=21), nullable=True), + sa.Column('electronic_signature', sa.String(length=2000), nullable=True), + sa.Column('transaction_number', sa.String(length=30), nullable=True), + sa.Column('status', sa.String(length=30), nullable=True), + sa.Column('linq_sat_qr', sa.String(length=1000), nullable=True), + sa.Column('sat_certificate', sa.String(length=2001), nullable=True), + sa.Column('sat_digital_seal', sa.Text(), nullable=True), + sa.Column('xml_doda_sent_path', sa.String(length=1000), nullable=True), + sa.Column('xml_doda_response_path', sa.String(length=1000), nullable=True), + sa.Column('sat_original_chain', sa.Text(), nullable=True), + sa.Column('customs_clearance', sa.Integer(), nullable=True), + sa.Column('unique_badge_number', sa.String(length=250), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='doda_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_doda_company_id'), 'doda', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_doda_tenant_id'), 'doda', ['tenant_id'], unique=False, schema='a76') + op.create_table('electronic_notices', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('notice_number', sa.String(length=500), nullable=True), + sa.Column('year', sa.String(length=20), nullable=True), + sa.Column('patent', sa.String(length=4), nullable=True), + sa.Column('pedimento', sa.String(length=15), nullable=True), + sa.Column('file_sent', sa.String(length=1000), nullable=True), + sa.Column('file_response', sa.String(length=1000), nullable=True), + sa.Column('status', sa.String(length=100), nullable=True), + sa.Column('invoice', sa.String(length=50), nullable=True), + sa.Column('validation_acknowledgment', sa.String(length=20), nullable=True), + sa.Column('fea', sa.String(length=1000), nullable=True), + sa.Column('certificate_number', sa.String(length=50), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='electronic_notices_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_electronic_notices_company_id'), 'electronic_notices', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_electronic_notices_tenant_id'), 'electronic_notices', ['tenant_id'], unique=False, schema='a76') + op.create_table('equivalencies', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('identifier', sa.String(length=10), nullable=False), + sa.Column('description', sa.String(length=200), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('identifier', 'tenant_id', 'company_id', name='uq_equivalency_identifier'), + schema='a76' + ) + op.create_index(op.f('ix_a76_equivalencies_company_id'), 'equivalencies', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_equivalencies_tenant_id'), 'equivalencies', ['tenant_id'], unique=False, schema='a76') + op.create_table('error_classifications', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=100), nullable=False), + sa.Column('level', sa.String(length=3), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='error_classifications_pkey'), + sa.UniqueConstraint('code'), + sa.UniqueConstraint('code', name='error_classifications_code_unique'), + schema='a76' + ) + op.create_index(op.f('ix_a76_error_classifications_company_id'), 'error_classifications', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_error_classifications_tenant_id'), 'error_classifications', ['tenant_id'], unique=False, schema='a76') + op.create_table('exchange_rate', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('date', sa.DateTime(), nullable=False), + sa.Column('value', sa.DECIMAL(precision=13, scale=6), nullable=True), + sa.Column('local_currency', sa.String(length=7), nullable=True), + sa.Column('foreign_currency', sa.String(length=7), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='exchange_rate_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'date', name='uq_exchange_rate_date_tenant'), + schema='a76' + ) + op.create_index(op.f('ix_a76_exchange_rate_company_id'), 'exchange_rate', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_exchange_rate_tenant_id'), 'exchange_rate', ['tenant_id'], unique=False, schema='a76') + op.create_table('fraction_rule_octave', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('permission', sa.String(length=20), nullable=False), + sa.Column('line', sa.Integer(), nullable=False), + sa.Column('fraction', sa.String(length=10), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='fraction_rule_octave_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', name='uq_fraction_rule_octave_permission_line_fraction'), + schema='a76' + ) + op.create_index(op.f('ix_a76_fraction_rule_octave_company_id'), 'fraction_rule_octave', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), 'fraction_rule_octave', ['tenant_id'], unique=False, schema='a76') + op.create_table('identifiers', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=2), nullable=False), + sa.Column('description', sa.String(length=1000), nullable=True), + sa.Column('level', sa.String(length=1), nullable=True), + sa.Column('complement', sa.String(length=5000), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', name='uq_identifier_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_identifiers_company_id'), 'identifiers', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_identifiers_tenant_id'), 'identifiers', ['tenant_id'], unique=False, schema='a76') + op.create_table('inpc', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('year', sa.String(length=4), nullable=False), + sa.Column('month', sa.String(length=2), nullable=False), + sa.Column('value', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('year', 'month', 'tenant_id', 'company_id', name='uq_inpc_year_month'), + schema='a76' + ) + op.create_index(op.f('ix_a76_inpc_company_id'), 'inpc', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_inpc_tenant_id'), 'inpc', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_header', + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column('system', sa.String(length=12), nullable=True), + sa.Column('operation_type', sa.String(length=10), nullable=False), + sa.Column('invoice_type', sa.String(length=5), nullable=True), + sa.Column('invoice_number', sa.String(length=20), nullable=True), + sa.Column('project_number', sa.String(length=14), nullable=True), + sa.Column('purchase_order', sa.String(length=50), nullable=True), + sa.Column('related_doc_id', sa.Integer(), nullable=True), + sa.Column('alternate_invoice', sa.String(length=99), nullable=True), + sa.Column('invoice_ref', sa.String(length=19), nullable=True), + sa.Column('proforma_number', sa.String(length=20), nullable=True), + sa.Column('invoice_date', sa.Date(), nullable=True), + sa.Column('capture_date', sa.TIMESTAMP(), nullable=False), + sa.Column('emission_date', sa.Date(), nullable=True), + sa.Column('is_updated', sa.Boolean(), nullable=True), + sa.Column('updated_date', sa.TIMESTAMP(), nullable=True), + sa.Column('who_updated', sa.String(length=20), nullable=True), + sa.Column('capture_user', sa.String(length=20), nullable=True), + sa.Column('traffic_light_status', sa.String(length=50), nullable=True), + sa.Column('process_log', sa.String(length=300), nullable=True), + sa.Column('status_rec', sa.Integer(), nullable=True), + sa.Column('status_rep', sa.String(length=2), nullable=True), + sa.Column('observation_es', sa.Text(), nullable=True), + sa.Column('observation_en', sa.Text(), nullable=True), + sa.Column('comments_status', sa.Text(), nullable=True), + sa.Column('vu_observations', sa.String(length=500), nullable=True), + sa.Column('cfdi_uuid', sa.String(length=100), nullable=True), + sa.Column('path_pdf', sa.String(length=500), nullable=True), + sa.Column('path_xml', sa.String(length=500), nullable=True), + sa.Column('subcompany', sa.String(length=5), nullable=True), + sa.Column('party_count', sa.Integer(), nullable=True), + sa.Column('generate_id', sa.String(length=1), nullable=True), + sa.Column('generate_desc_parties', sa.String(length=12), nullable=True), + sa.Column('apply_manual_discount', sa.String(length=1), nullable=True), + sa.Column('is_bulk', sa.Boolean(), nullable=True), + sa.Column('download_substance', sa.Boolean(), nullable=True), + sa.Column('download_class', sa.Boolean(), nullable=True), + sa.Column('download_def', sa.Boolean(), nullable=True), + sa.Column('payment_terms', sa.String(length=200), nullable=True), + sa.Column('handling_fees', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('option_iv18', sa.String(length=50), nullable=True), + sa.Column('enajenation_goods', sa.Boolean(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['invoice_type'], ['public.invoice_types.key'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_header_company_id'), 'invoice_header', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_header_tenant_id'), 'invoice_header', ['tenant_id'], unique=False, schema='a76') + op.create_table('legends', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.Integer(), nullable=False), + sa.Column('description', sa.String(length=2000), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_legend_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_legends_company_id'), 'legends', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_legends_tenant_id'), 'legends', ['tenant_id'], unique=False, schema='a76') + op.create_table('multi_currency_types', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('currency_type_code', sa.String(length=3), nullable=False), + sa.Column('country_key', sa.String(length=3), nullable=True), + sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), + sa.Column('publication_date', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['country_key'], ['public.countries.m3_key'], ), + sa.ForeignKeyConstraint(['currency_type_code'], ['public.currency_types.code'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('currency_type_code', 'publication_date', 'tenant_id', 'company_id', name='uq_multi_currency_type_code_date'), + schema='a76' + ) + op.create_index(op.f('ix_a76_multi_currency_types_company_id'), 'multi_currency_types', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_multi_currency_types_tenant_id'), 'multi_currency_types', ['tenant_id'], unique=False, schema='a76') + op.create_table('packages', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('key', sa.String(length=5), nullable=False), + sa.Column('description_es', sa.String(length=40), nullable=True), + sa.Column('description_en', sa.String(length=40), nullable=True), + sa.Column('weight_unit', sa.DECIMAL(precision=19, scale=8), nullable=True), + sa.Column('plurals', sa.String(length=4), nullable=True), + sa.Column('plural_in', sa.String(length=4), nullable=True), + sa.Column('code_ace', sa.String(length=4), nullable=True), + sa.Column('code_aamex', sa.String(length=9), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='packages_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'key', name='packages_key_ukey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_packages_company_id'), 'packages', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_packages_tenant_id'), 'packages', ['tenant_id'], unique=False, schema='a76') + op.create_table('packing_lists', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('packing_list_number', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_packing_lists_company_id'), 'packing_lists', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_packing_lists_tenant_id'), 'packing_lists', ['tenant_id'], unique=False, schema='a76') + op.create_table('permission_rule_oct', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('permission', sa.String(length=20), nullable=False), + sa.Column('start_date', sa.Integer(), nullable=True), + sa.Column('end_date', sa.Integer(), nullable=True), + sa.Column('sector', sa.String(length=8), nullable=True), + sa.Column('system', sa.String(length=5), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='permission_rule_oct_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'permission', name='permission_rule_oct_permission_tenant_ukey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_permission_rule_oct_company_id'), 'permission_rule_oct', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_permission_rule_oct_tenant_id'), 'permission_rule_oct', ['tenant_id'], unique=False, schema='a76') + op.create_table('ports', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('port_code', sa.String(length=6), nullable=False), + sa.Column('description', sa.String(length=20), nullable=True), + sa.Column('location_code', sa.String(length=4), nullable=False), + sa.Column('location_description', sa.String(length=20), nullable=True), + sa.Column('port_type', sa.String(length=15), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('port_code', 'location_code', 'tenant_id', 'company_id', name='uq_port_location'), + schema='a76' + ) + op.create_index(op.f('ix_a76_ports_company_id'), 'ports', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_ports_tenant_id'), 'ports', ['tenant_id'], unique=False, schema='a76') + op.create_table('prevalidators', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('code', sa.String(length=20), nullable=False), + sa.Column('customs_prevalidator', sa.String(length=20), nullable=True), + sa.Column('patent_prevalidator', sa.String(length=20), nullable=True), + sa.Column('description', sa.String(length=50), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='prevalidators_pkey'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='prevalidators_code_unique'), + schema='a76' + ) + op.create_index(op.f('ix_a76_prevalidators_company_id'), 'prevalidators', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_prevalidators_tenant_id'), 'prevalidators', ['tenant_id'], unique=False, schema='a76') + op.create_table('seal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('seal', sa.String(length=15), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='seal_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'seal', name='seal_ukey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_seal_company_id'), 'seal', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_seal_tenant_id'), 'seal', ['tenant_id'], unique=False, schema='a76') + op.create_table('signatures', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=10), nullable=False), + sa.Column('signature', sa.String(length=1000), nullable=True), + sa.Column('photo_path', sa.String(length=1000), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='signatures_pkey'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='signatures_code_unique'), + schema='a76' + ) + op.create_index(op.f('ix_a76_signatures_company_id'), 'signatures', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_signatures_tenant_id'), 'signatures', ['tenant_id'], unique=False, schema='a76') + op.create_table('subassembly_entries', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('remission_line', sa.Integer(), nullable=False), + sa.Column('exit_invoice', sa.String(length=15), nullable=True), + sa.Column('exit_line', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_subassembly_entries_company_id'), 'subassembly_entries', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_subassembly_entries_tenant_id'), 'subassembly_entries', ['tenant_id'], unique=False, schema='a76') + op.create_table('trailer_type', + sa.Column('trailer_type_key', sa.String(length=2), nullable=False), + sa.Column('description', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('trailer_type_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_trailer_type_company_id'), 'trailer_type', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_trailer_type_tenant_id'), 'trailer_type', ['tenant_id'], unique=False, schema='a76') + op.create_table('transporter', + sa.Column('transporter_key', sa.String(length=5), nullable=False), + sa.Column('name', sa.String(length=256), nullable=True), + sa.Column('short_name', sa.String(length=10), nullable=True), + sa.Column('responsible', sa.String(length=100), nullable=True), + sa.Column('rfc', sa.String(length=30), nullable=True), + sa.Column('streets', sa.String(length=100), nullable=True), + sa.Column('postal_code', sa.String(length=15), nullable=True), + sa.Column('city', sa.String(length=30), nullable=True), + sa.Column('state', sa.String(length=30), nullable=True), + sa.Column('country', sa.String(length=3), nullable=True), + sa.Column('loader_code', sa.String(length=9), nullable=True), + sa.Column('caat_code', sa.String(length=49), nullable=True), + sa.Column('transport_code', sa.String(length=8), nullable=True), + sa.Column('transport_interface_type', sa.String(length=20), nullable=True), + sa.Column('ftp_server', sa.String(length=200), nullable=True), + sa.Column('ftp_user', sa.String(length=200), nullable=True), + sa.Column('ftp_password', sa.String(length=100), nullable=True), + sa.Column('ftp_directory', sa.String(length=1000), nullable=True), + sa.Column('filler_code', sa.String(length=4), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('transporter_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_transporter_company_id'), 'transporter', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_transporter_tenant_id'), 'transporter', ['tenant_id'], unique=False, schema='a76') + op.create_table('unit_of_measure_ace', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=4), nullable=False), + sa.Column('description', sa.String(length=49), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_ace_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_ace_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_unit_of_measure_ace_company_id'), 'unit_of_measure_ace', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_unit_of_measure_ace_tenant_id'), 'unit_of_measure_ace', ['tenant_id'], unique=False, schema='a76') + op.create_table('unit_of_measure_american', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=3), nullable=False), + sa.Column('description', sa.String(length=40), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_american_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_american_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_unit_of_measure_american_company_id'), 'unit_of_measure_american', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_unit_of_measure_american_tenant_id'), 'unit_of_measure_american', ['tenant_id'], unique=False, schema='a76') + op.create_table('unit_of_measure_customs', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=2), nullable=False), + sa.Column('description', sa.String(length=20), nullable=True), + sa.Column('scaii_unit_code', sa.String(length=5), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_customs_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_customs_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_unit_of_measure_customs_company_id'), 'unit_of_measure_customs', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_unit_of_measure_customs_tenant_id'), 'unit_of_measure_customs', ['tenant_id'], unique=False, schema='a76') + op.create_table('unit_of_measure_oma', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=10), nullable=False), + sa.Column('description', sa.String(length=200), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_oma_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_oma_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_unit_of_measure_oma_company_id'), 'unit_of_measure_oma', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_unit_of_measure_oma_tenant_id'), 'unit_of_measure_oma', ['tenant_id'], unique=False, schema='a76') + op.create_table('units_of_measure', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=5), nullable=False), + sa.Column('description', sa.String(length=100), nullable=True), + sa.Column('description_en', sa.String(length=100), nullable=True), + sa.Column('customs_code', sa.String(length=2), nullable=True), + sa.Column('american_code', sa.String(length=3), nullable=True), + sa.Column('ace_code', sa.String(length=4), nullable=True), + sa.Column('oma_code', sa.String(length=10), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['ace_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_ace.code', 'a76.unit_of_measure_ace.tenant_id', 'a76.unit_of_measure_ace.company_id'], name='fk_uom_ace', use_alter=True), + sa.ForeignKeyConstraint(['american_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_american.code', 'a76.unit_of_measure_american.tenant_id', 'a76.unit_of_measure_american.company_id'], name='fk_uom_american', use_alter=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['customs_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_customs.code', 'a76.unit_of_measure_customs.tenant_id', 'a76.unit_of_measure_customs.company_id'], name='fk_uom_customs', use_alter=True), + sa.ForeignKeyConstraint(['oma_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_oma.code', 'a76.unit_of_measure_oma.tenant_id', 'a76.unit_of_measure_oma.company_id'], name='fk_uom_oma', use_alter=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_units_of_measure_company_id'), 'units_of_measure', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_units_of_measure_tenant_id'), 'units_of_measure', ['tenant_id'], unique=False, schema='a76') + op.create_table('units_of_measure_general', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=5), nullable=False), + sa.Column('description', sa.String(length=100), nullable=True), + sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), + sa.Column('mexico_unit', sa.String(length=5), nullable=True), + sa.Column('american_unit_code', sa.String(length=5), nullable=True), + sa.Column('customs_code', sa.String(length=2), nullable=True), + sa.Column('ace_code', sa.String(length=4), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['ace_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_ace.code', 'a76.unit_of_measure_ace.tenant_id', 'a76.unit_of_measure_ace.company_id'], name='fk_uom_general_ace', use_alter=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['customs_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_customs.code', 'a76.unit_of_measure_customs.tenant_id', 'a76.unit_of_measure_customs.company_id'], name='fk_uom_general_customs', use_alter=True), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_general_code'), + sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_general_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_units_of_measure_general_company_id'), 'units_of_measure_general', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_units_of_measure_general_tenant_id'), 'units_of_measure_general', ['tenant_id'], unique=False, schema='a76') + op.create_table('vehicle', + sa.Column('vehicle_key', sa.String(length=14), nullable=False), + sa.Column('ace_vehicle_key', sa.String(length=10), nullable=True), + sa.Column('transporter_key', sa.String(length=23), nullable=True), + sa.Column('transport_identifier', sa.String(length=30), nullable=True), + sa.Column('transport_type', sa.String(length=2), nullable=True), + sa.Column('entity_code', sa.String(length=1), nullable=True), + sa.Column('transponder_number', sa.String(length=16), nullable=True), + sa.Column('dot_number', sa.String(length=8), nullable=True), + sa.Column('plate_number', sa.String(length=17), nullable=True), + sa.Column('city', sa.String(length=30), nullable=True), + sa.Column('state', sa.String(length=30), nullable=True), + sa.Column('country', sa.String(length=3), nullable=True), + sa.Column('seal', sa.String(length=49), nullable=True), + sa.Column('insurance_company_name', sa.String(length=30), nullable=True), + sa.Column('insurance_number', sa.String(length=20), nullable=True), + sa.Column('insurance_amount', sa.DECIMAL(precision=13, scale=2), nullable=True), + sa.Column('insurance_date', sa.Integer(), nullable=True), + sa.Column('box_number', sa.String(length=300), nullable=True), + sa.Column('brand', sa.String(length=20), nullable=True), + sa.Column('year', sa.String(length=4), nullable=True), + sa.Column('series', sa.String(length=30), nullable=True), + sa.Column('description', sa.String(length=100), nullable=True), + sa.Column('engine_number', sa.String(length=50), nullable=True), + sa.Column('sct_permission', sa.String(length=40), nullable=True), + sa.Column('color', sa.String(length=20), nullable=True), + sa.Column('container_key', sa.String(length=3), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('vehicle_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_vehicle_company_id'), 'vehicle', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_vehicle_tenant_id'), 'vehicle', ['tenant_id'], unique=False, schema='a76') + op.create_table('user_tenants', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('keycloak_user_id', sa.String(length=255), nullable=False), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('role', sa.String(length=50), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('keycloak_user_id', 'tenant_id', 'company_id', name='uq_user_tenant'), + schema='core' + ) + op.create_index(op.f('ix_core_user_tenants_company_id'), 'user_tenants', ['company_id'], unique=False, schema='core') + op.create_index(op.f('ix_core_user_tenants_id'), 'user_tenants', ['id'], unique=False, schema='core') + op.create_index(op.f('ix_core_user_tenants_keycloak_user_id'), 'user_tenants', ['keycloak_user_id'], unique=False, schema='core') + op.create_index(op.f('ix_core_user_tenants_tenant_id'), 'user_tenants', ['tenant_id'], unique=False, schema='core') + op.create_table('classes', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('client_id', sa.Integer(), nullable=False), + sa.Column('class_code', sa.String(length=8), nullable=False), + sa.Column('description_es', sa.String(length=500), nullable=True), + sa.Column('description_en', sa.String(length=500), nullable=True), + sa.Column('material_key', sa.String(length=10), nullable=True), + sa.Column('unit_of_measure', sa.String(length=5), nullable=True), + sa.Column('fraction', sa.String(length=10), nullable=True), + sa.Column('us_fraction', sa.String(length=16), nullable=True), + sa.Column('sub_key', sa.String(length=5), nullable=True), + sa.Column('physical_review', sa.SmallInteger(), nullable=True), + sa.Column('iva_exempt_fraction', sa.String(length=4), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_classes_client'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['material_key'], ['public.material_types.key'], name='fk_classes_material_type'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), + sa.PrimaryKeyConstraint('id', name='classes_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'client_id', 'class_code', name='ufa_classes_client_id_class_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_classes_company_id'), 'classes', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_classes_tenant_id'), 'classes', ['tenant_id'], unique=False, schema='a76') + op.create_table('clients_and_providers_address', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('client_id', sa.Integer(), nullable=False), + sa.Column('municipality', sa.String(length=150), nullable=True), + sa.Column('streets', sa.String(length=100), nullable=True), + sa.Column('neighborhood', sa.String(length=40), nullable=True), + sa.Column('interior_number', sa.String(length=20), nullable=True), + sa.Column('exterior_number', sa.String(length=20), nullable=True), + sa.Column('postal_code', sa.String(length=15), nullable=True), + sa.Column('city', sa.String(length=30), nullable=True), + sa.Column('state', sa.String(length=30), nullable=True), + sa.Column('country', sa.String(length=3), nullable=True), + sa.Column('phone', sa.String(length=30), nullable=True), + sa.Column('fax_number', sa.String(length=30), nullable=True), + sa.Column('email', sa.String(length=100), nullable=True), + sa.Column('contact', sa.String(length=50), nullable=True), + sa.Column('reference', sa.String(length=250), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_address_client', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='clients_and_providers_address_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_clients_and_providers_address_company_id'), 'clients_and_providers_address', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), 'clients_and_providers_address', ['tenant_id'], unique=False, schema='a76') + op.create_table('clients_and_providers_programs', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('client_id', sa.Integer(), nullable=False), + sa.Column('program', sa.String(length=7), nullable=True), + sa.Column('program_number', sa.String(length=40), nullable=True), + sa.Column('prosec', sa.SmallInteger(), nullable=True), + sa.Column('prosec_authorization', sa.String(length=20), nullable=True), + sa.Column('secon_auth_date', sa.Integer(), nullable=True), + sa.Column('manufacturer_id', sa.String(length=25), nullable=True), + sa.Column('tax_id', sa.String(length=30), nullable=True), + sa.Column('broker', sa.String(length=6), nullable=True), + sa.Column('import_broker', sa.String(length=6), nullable=True), + sa.Column('transfer_key', sa.String(length=8), nullable=True), + sa.Column('secon_authorization', sa.String(length=20), nullable=True), + sa.Column('applied_proportion', sa.Numeric(precision=7, scale=2), nullable=True), + sa.Column('is_certified_company', sa.String(length=1), nullable=True), + sa.Column('certified_company_registry', sa.String(length=40), nullable=True), + sa.Column('donation_auth_number', sa.String(length=50), nullable=True), + sa.Column('ctpat_svi', sa.String(length=100), nullable=True), + sa.Column('tax_registry_number', sa.String(length=40), nullable=True), + sa.Column('subassembly_service', sa.SmallInteger(), nullable=True), + sa.Column('autse_dates', sa.Integer(), nullable=True), + sa.Column('autse_number', sa.String(length=300), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_programs_client', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='clients_and_providers_programs_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_clients_and_providers_programs_company_id'), 'clients_and_providers_programs', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), 'clients_and_providers_programs', ['tenant_id'], unique=False, schema='a76') + op.create_table('concepts', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('code', sa.String(length=15), nullable=False), + sa.Column('description', sa.String(length=120), nullable=True), + sa.Column('description_en', sa.String(length=120), nullable=True), + sa.Column('detailed_description', sa.String(length=1000), nullable=True), + sa.Column('priority', sa.Integer(), nullable=True), + sa.Column('priority_ame', sa.Integer(), nullable=True), + sa.Column('first_total', sa.Boolean(), nullable=True), + sa.Column('type', sa.String(length=9), nullable=True), + sa.Column('is_printed', sa.Boolean(), nullable=True), + sa.Column('section', sa.Integer(), nullable=True), + sa.Column('classification', sa.String(length=30), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['classification'], ['a76.classification_concepts.classification'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code', name='uq_concept_code'), + schema='a76' + ) + op.create_index(op.f('ix_a76_concepts_tenant_id'), 'concepts', ['tenant_id'], unique=False, schema='a76') + op.create_table('country_rule_oct', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('permission', sa.String(length=20), nullable=False), + sa.Column('line', sa.Integer(), nullable=False), + sa.Column('fraction', sa.String(length=10), nullable=False), + sa.Column('country_code', sa.String(length=3), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id', 'company_id', 'permission', 'line', 'fraction'], ['a76.fraction_rule_octave.tenant_id', 'a76.fraction_rule_octave.company_id', 'a76.fraction_rule_octave.permission', 'a76.fraction_rule_octave.line', 'a76.fraction_rule_octave.fraction'], name='fk_country_rule_oct_frac_octava', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='country_rule_oct_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', 'country_code', name='uq_country_rule_oct_permission_line_fraction_country'), + schema='a76' + ) + op.create_index(op.f('ix_a76_country_rule_oct_company_id'), 'country_rule_oct', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_country_rule_oct_tenant_id'), 'country_rule_oct', ['tenant_id'], unique=False, schema='a76') + op.create_table('customs_brokers_personnel', + sa.Column('customs_broker_id', sa.Integer(), nullable=False), + sa.Column('line', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=80), nullable=True), + sa.Column('tax_id', sa.String(length=30), nullable=True), + sa.Column('personal_id', sa.String(length=20), nullable=True), + sa.Column('position', sa.String(length=30), nullable=True), + sa.Column('license', sa.String(length=4), nullable=True), + sa.Column('first_name', sa.String(length=80), nullable=True), + sa.Column('last_name', sa.String(length=80), nullable=True), + sa.Column('middle_name', sa.String(length=80), nullable=True), + sa.Column('email', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('customs_broker_id', 'line'), + schema='a76' + ) + op.create_index(op.f('ix_a76_customs_brokers_personnel_company_id'), 'customs_brokers_personnel', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), 'customs_brokers_personnel', ['tenant_id'], unique=False, schema='a76') + op.create_table('customs_brokers_vu', + sa.Column('customs_broker_id', sa.Integer(), nullable=False), + sa.Column('certificate_path', sa.String(length=1499), nullable=True), + sa.Column('key_path', sa.String(length=1499), nullable=True), + sa.Column('access_key', sa.String(length=50), nullable=True), + sa.Column('fiel_format', sa.String(length=19), nullable=True), + sa.Column('signature_read_path', sa.String(length=1499), nullable=True), + sa.Column('archive_path', sa.String(length=1499), nullable=True), + sa.Column('fiel_access_key', sa.String(length=50), nullable=True), + sa.Column('web_service_user', sa.String(length=100), nullable=True), + sa.Column('web_service_access_key', sa.String(length=100), nullable=True), + sa.Column('vu_email', sa.String(length=800), nullable=True), + sa.Column('vu_figure_type', sa.String(length=29), nullable=True), + sa.Column('xml_files_path', sa.String(length=1499), nullable=True), + sa.Column('query_tax_id', sa.String(length=30), nullable=True), + sa.Column('doda_certificate_path', sa.String(length=1499), nullable=True), + sa.Column('doda_key_path', sa.String(length=1499), nullable=True), + sa.Column('doda_web_service_user', sa.String(length=100), nullable=True), + sa.Column('doda_web_service_access_key', sa.String(length=100), nullable=True), + sa.Column('doda_fiel_access_key', sa.String(length=50), nullable=True), + sa.Column('doda_xml_files_path', sa.String(length=1499), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('customs_broker_id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_customs_brokers_vu_company_id'), 'customs_brokers_vu', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), 'customs_brokers_vu', ['tenant_id'], unique=False, schema='a76') + op.create_table('doda_american_pedimentos', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('doda_id', sa.Integer(), nullable=False), + sa.Column('american_pedimento_line', sa.Integer(), nullable=False), + sa.Column('american_pedimento_type', sa.String(length=2), nullable=True), + sa.Column('american_pedimento_value', sa.String(length=20), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_american_pedimentos_doda'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='doda_american_pedimentos_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_doda_american_pedimentos_company_id'), 'doda_american_pedimentos', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), 'doda_american_pedimentos', ['tenant_id'], unique=False, schema='a76') + op.create_table('doda_containers', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('doda_id', sa.Integer(), nullable=False), + sa.Column('container_line', sa.Integer(), nullable=False), + sa.Column('container_value', sa.String(length=20), nullable=True), + sa.Column('seals', sa.String(length=254), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_containers_doda'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='doda_containers_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_doda_containers_company_id'), 'doda_containers', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_doda_containers_tenant_id'), 'doda_containers', ['tenant_id'], unique=False, schema='a76') + op.create_table('doda_pedimentos', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('doda_id', sa.Integer(), nullable=False), + sa.Column('pedimento_line', sa.Integer(), nullable=False), + sa.Column('authorization_patent', sa.String(length=10), nullable=True), + sa.Column('document', sa.String(length=50), nullable=True), + sa.Column('shipment', sa.String(length=11), nullable=True), + sa.Column('cove', sa.String(length=50), nullable=True), + sa.Column('umc', sa.String(length=20), nullable=True), + sa.Column('effective_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True), + sa.Column('difference_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True), + sa.Column('dta_niu', sa.String(length=20), nullable=True), + sa.Column('article_7', sa.Boolean(), nullable=True), + sa.Column('pedimento_id', sa.Integer(), nullable=True), + sa.Column('invoice_line', sa.Integer(), nullable=True), + sa.Column('part_ii_line', sa.Integer(), nullable=True), + sa.Column('pedimento_type', sa.String(length=20), nullable=True), + sa.Column('zero_packaging_validation', sa.Boolean(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_pedimentos_doda'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='doda_pedimentos_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_doda_pedimentos_company_id'), 'doda_pedimentos', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_doda_pedimentos_tenant_id'), 'doda_pedimentos', ['tenant_id'], unique=False, schema='a76') + op.create_table('driver', + sa.Column('transporter_key', sa.String(length=5), nullable=False), + sa.Column('line', sa.Integer(), nullable=False), + sa.Column('driver_name', sa.String(length=80), nullable=True), + sa.Column('license_number', sa.String(length=29), nullable=True), + sa.Column('express_line_id', sa.String(length=17), nullable=True), + sa.Column('ace_id', sa.String(length=20), nullable=True), + sa.Column('birth_date', sa.Integer(), nullable=True), + sa.Column('gender', sa.String(length=1), nullable=True), + sa.Column('birth_country', sa.String(length=3), nullable=True), + sa.Column('hazardous_material_auth', sa.String(length=2), nullable=True), + sa.Column('hazardous_material_state', sa.String(length=30), nullable=True), + sa.Column('first_name', sa.String(length=20), nullable=True), + sa.Column('last_name', sa.String(length=20), nullable=True), + sa.Column('id_key1', sa.String(length=40), nullable=True), + sa.Column('id_number1', sa.String(length=20), nullable=True), + sa.Column('id_state1', sa.String(length=30), nullable=True), + sa.Column('id_country1', sa.String(length=3), nullable=True), + sa.Column('id_key2', sa.String(length=40), nullable=True), + sa.Column('id_number2', sa.String(length=20), nullable=True), + sa.Column('id_state2', sa.String(length=30), nullable=True), + sa.Column('id_country2', sa.String(length=3), nullable=True), + sa.Column('badge_number', sa.String(length=20), nullable=True), + sa.Column('class_type', sa.String(length=1), nullable=True), + sa.Column('unique_badge_number', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['transporter_key'], ['a76.transporter.transporter_key'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('transporter_key', 'line'), + schema='a76' + ) + op.create_index(op.f('ix_a76_driver_company_id'), 'driver', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_driver_tenant_id'), 'driver', ['tenant_id'], unique=False, schema='a76') + op.create_table('equivalency_items', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('equivalency_id', sa.Integer(), nullable=False), + sa.Column('original_field', sa.String(length=100), nullable=False), + sa.Column('external_field', sa.String(length=100), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['equivalency_id'], ['a76.equivalencies.id'], ), + sa.ForeignKeyConstraint(['original_field', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('equivalency_id', 'original_field', 'external_field', 'tenant_id', 'company_id', name='uq_equivalency_item_fields'), + schema='a76' + ) + op.create_index(op.f('ix_a76_equivalency_items_company_id'), 'equivalency_items', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_equivalency_items_tenant_id'), 'equivalency_items', ['tenant_id'], unique=False, schema='a76') + op.create_table('error_catalogs', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('code', sa.String(length=15), nullable=False), + sa.Column('description', sa.String(length=255), nullable=True), + sa.Column('classification_id', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['classification_id'], ['a76.error_classifications.id'], name='fk_error_catalogs_classification'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='error_catalogs_pkey'), + sa.UniqueConstraint('code'), + sa.UniqueConstraint('code', name='error_catalogs_code_unique'), + schema='a76' + ) + op.create_index(op.f('ix_a76_error_catalogs_company_id'), 'error_catalogs', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_error_catalogs_tenant_id'), 'error_catalogs', ['tenant_id'], unique=False, schema='a76') + op.create_table('identifier_details', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('invoice_consecutive', sa.Integer(), nullable=True), + sa.Column('part_line', sa.Integer(), nullable=True), + sa.Column('identifier_code', sa.String(length=2), nullable=True), + sa.Column('module', sa.String(length=20), nullable=True), + sa.Column('complement1', sa.String(length=50), nullable=True), + sa.Column('complement2', sa.String(length=51), nullable=True), + sa.Column('complement3', sa.String(length=50), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['identifier_code'], ['a76.identifiers.code'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_identifier_details_company_id'), 'identifier_details', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_identifier_details_tenant_id'), 'identifier_details', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_collections', + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('line_number', sa.Integer(), nullable=False), + sa.Column('invoice_number', sa.String(length=15), nullable=True), + sa.Column('concept', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_collections_company_id'), 'invoice_collections', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_collections_tenant_id'), 'invoice_collections', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_compliance_mx', + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('pedimento', sa.String(length=19), nullable=True), + sa.Column('pedimento_code', sa.String(length=5), nullable=True), + sa.Column('pedimento_k1', sa.String(length=15), nullable=True), + sa.Column('remesa', sa.Integer(), nullable=True), + sa.Column('aduana', sa.String(length=3), nullable=True), + sa.Column('port_of_entry', sa.String(length=6), nullable=True), + sa.Column('destination', sa.String(length=3), nullable=True), + sa.Column('manifest_number', sa.String(length=15), nullable=True), + sa.Column('provider_header', sa.String(length=20), nullable=True), + sa.Column('provider_id', sa.Integer(), nullable=True), + sa.Column('sold_to_header', sa.String(length=20), nullable=True), + sa.Column('sold_to_id', sa.Integer(), nullable=True), + sa.Column('shipped_to_header', sa.String(length=20), nullable=True), + sa.Column('shipped_to_id', sa.Integer(), nullable=True), + sa.Column('shipped_by_header', sa.String(length=20), nullable=True), + sa.Column('shipped_by_id', sa.Integer(), nullable=True), + sa.Column('customs_broker_id', sa.Integer(), nullable=True), + sa.Column('customs_broker_us_id', sa.Integer(), nullable=True), + sa.Column('broker_invoice_num', sa.String(length=20), nullable=True), + sa.Column('broker_invoice_date', sa.Date(), nullable=True), + sa.Column('is_mixed', sa.Boolean(), nullable=True), + sa.Column('waste_type', sa.String(length=1), nullable=True), + sa.Column('scrap_type', sa.String(length=1), nullable=True), + sa.Column('appendix_17', sa.Integer(), nullable=True), + sa.Column('is_regime_change', sa.String(length=1), nullable=True), + sa.Column('which_exchange_rate', sa.String(length=5), nullable=True), + sa.Column('value_method', sa.String(length=2), nullable=True), + sa.Column('act_value', sa.String(length=5), nullable=True), + sa.Column('is_pedimento_pending', sa.Boolean(), nullable=True), + sa.Column('is_owner_of_goods', sa.String(length=2), nullable=True), + sa.Column('generate_balances', sa.String(length=2), nullable=True), + sa.Column('was_reviewed_by_company', sa.Boolean(), nullable=True), + sa.Column('edocument', sa.String(length=50), nullable=True), + sa.Column('electronic_signature', sa.String(length=999), nullable=True), + sa.Column('certificate_number', sa.String(length=99), nullable=True), + sa.Column('niu_number', sa.String(length=19), nullable=True), + sa.Column('bill_of_lading_count', sa.String(length=12), nullable=True), + sa.Column('addendum_vu', sa.String(length=204), nullable=True), + sa.Column('origin_destination_cove', sa.String(length=19), nullable=True), + sa.Column('vucem_operation_num', sa.String(length=19), nullable=True), + sa.Column('customs_person_line', sa.Integer(), nullable=True), + sa.Column('contingency_mode', sa.Boolean(), nullable=True), + sa.Column('enclosure', sa.String(length=4), nullable=True), + sa.Column('guide_type_to_identify', sa.String(length=1), nullable=True), + sa.Column('location', sa.String(length=200), nullable=True), + sa.Column('dot_code', sa.String(length=20), nullable=True), + sa.Column('subdivision', sa.String(length=20), nullable=True), + sa.Column('acts_as', sa.String(length=20), nullable=True), + sa.Column('movement_type', sa.String(length=31), nullable=True), + sa.Column('office_document', sa.String(length=30), nullable=True), + sa.Column('reason_export', sa.String(length=1), nullable=True), + sa.Column('signature_key', sa.String(length=10), nullable=True), + sa.Column('sem_id', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['aduana'], ['public.customs_sections.customs_code'], ), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ), + sa.ForeignKeyConstraint(['customs_broker_us_id'], ['a76.customs_brokers.id'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['provider_id'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['shipped_by_id'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['shipped_to_id'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['sold_to_id'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('invoice_id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_compliance_mx_company_id'), 'invoice_compliance_mx', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), 'invoice_compliance_mx', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_financials', + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('currency', sa.String(length=3), nullable=True), + sa.Column('currency_type', sa.String(length=3), nullable=True), + sa.Column('exchange_rate', sa.Numeric(precision=13, scale=6), nullable=True), + sa.Column('exchange_rate_mm', sa.Numeric(precision=13, scale=6), nullable=True), + sa.Column('value_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('customs_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('customs_value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('raw_material_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('raw_material_value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('aggregate_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('aggregate_value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('aggregate_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('mexican_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('mexican_value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('mexican_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('national_packaging_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('national_packaging_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('national_packaging_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('freight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('insurance', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('insurance_value', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('packaging', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('other_increments', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('total_increments_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('total_increments_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('iva_mn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('iva_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('iva_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('iva_factor', sa.String(length=10), nullable=True), + sa.Column('tax_value_me', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('seal_value_2500', sa.Boolean(), nullable=True), + sa.Column('total_quantity', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('bundle_count', sa.Integer(), nullable=True), + sa.Column('weight_factor', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['currency_type'], ['public.currency_types.code'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_financials_company_id'), 'invoice_financials', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_financials_tenant_id'), 'invoice_financials', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_logistics', + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('carrier_id', sa.String(length=10), nullable=True), + sa.Column('transport_id', sa.String(length=10), nullable=True), + sa.Column('transport_us_id', sa.String(length=10), nullable=True), + sa.Column('transport_type', sa.String(length=15), nullable=False), + sa.Column('transport_num', sa.String(length=20), nullable=True), + sa.Column('transport_mode', sa.String(length=15), nullable=True), + sa.Column('driver_name', sa.String(length=80), nullable=True), + sa.Column('is_rail', sa.String(length=2), nullable=True), + sa.Column('rail_id', sa.String(length=31), nullable=True), + sa.Column('vehicle_num', sa.String(length=20), nullable=True), + sa.Column('license_plate', sa.String(length=20), nullable=True), + sa.Column('license_plate_complete', sa.String(length=40), nullable=True), + sa.Column('trailer_num', sa.String(length=20), nullable=True), + sa.Column('seal_number', sa.String(length=15), nullable=True), + sa.Column('guide_number', sa.String(length=20), nullable=True), + sa.Column('bill_number', sa.String(length=15), nullable=True), + sa.Column('reference_number', sa.String(length=14), nullable=True), + sa.Column('shipment_number', sa.String(length=19), nullable=True), + sa.Column('incoterm', sa.String(length=5), nullable=True), + sa.Column('identifier_1', sa.String(length=2), nullable=True), + sa.Column('complement_1', sa.String(length=30), nullable=True), + sa.Column('identifier_2', sa.String(length=2), nullable=True), + sa.Column('complement_2', sa.String(length=30), nullable=True), + sa.Column('weight_type', sa.String(length=6), nullable=True), + sa.Column('container_types', sa.String(length=500), nullable=True), + sa.Column('vehicle_data', sa.String(length=500), nullable=True), + sa.Column('origin_location', sa.String(length=200), nullable=True), + sa.Column('destination_location', sa.String(length=200), nullable=True), + sa.Column('transport_itinerary', sa.String(length=1000), nullable=True), + sa.Column('destination_goods', sa.String(length=50), nullable=True), + sa.Column('entry_exit_date', sa.Date(), nullable=True), + sa.Column('delivery_date', sa.Date(), nullable=True), + sa.Column('delivered_status', sa.String(length=2), nullable=True), + sa.Column('received_by', sa.String(length=50), nullable=True), + sa.Column('payment_date', sa.Date(), nullable=True), + sa.Column('payment_receipt_num', sa.String(length=20), nullable=True), + sa.Column('is_ctm_process', sa.String(length=2), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_logistics_company_id'), 'invoice_logistics', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_logistics_tenant_id'), 'invoice_logistics', ['tenant_id'], unique=False, schema='a76') + op.create_table('invoice_sales_details', + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('line_number', sa.Integer(), nullable=False), + sa.Column('sales_order', sa.String(length=20), nullable=True), + sa.Column('colors_description', sa.String(length=49), nullable=True), + sa.Column('square_color_code', sa.String(length=1), nullable=True), + sa.Column('line_bundles', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_invoice_sales_details_company_id'), 'invoice_sales_details', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_invoice_sales_details_tenant_id'), 'invoice_sales_details', ['tenant_id'], unique=False, schema='a76') + op.create_table('items', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('invoice_id', sa.BigInteger(), nullable=False), + sa.Column('reference_number', sa.String(length=20), nullable=True), + sa.Column('order', sa.String(length=50), nullable=True), + sa.Column('guide_number', sa.String(length=50), nullable=True), + sa.Column('depreciation_date', sa.Integer(), nullable=True), + sa.Column('rectification', sa.Boolean(), nullable=True), + sa.Column('warehouse', sa.String(length=30), nullable=True), + sa.Column('location', sa.String(length=200), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_items_company_id'), 'items', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_items_tenant_id'), 'items', ['tenant_id'], unique=False, schema='a76') + op.create_table('parts', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('client_id', sa.Integer(), nullable=False), + sa.Column('part_number', sa.String(length=50), nullable=False), + sa.Column('fraction', sa.String(length=10), nullable=True), + sa.Column('description_spanish', sa.String(length=500), nullable=True), + sa.Column('description_english', sa.String(length=500), nullable=True), + sa.Column('part_class', sa.String(length=8), nullable=True), + sa.Column('material_type', sa.String(length=10), nullable=True), + sa.Column('unit_of_measure', sa.String(length=5), nullable=True), + sa.Column('commercial_part_number', sa.String(length=70), nullable=True), + sa.Column('country_of_origin', sa.String(length=3), nullable=True), + sa.Column('unit_cost', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('currency_type', sa.String(length=2), nullable=True), + sa.Column('currency_key', sa.String(length=3), nullable=True), + sa.Column('unit_weight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('weight_type', sa.String(length=6), nullable=True), + sa.Column('us_fraction', sa.String(length=16), nullable=True), + sa.Column('fda_key', sa.String(length=20), nullable=True), + sa.Column('fcc_key', sa.String(length=30), nullable=True), + sa.Column('license_code', sa.String(length=3), nullable=True), + sa.Column('eccn', sa.String(length=20), nullable=True), + sa.Column('export_code', sa.String(length=2), nullable=True), + sa.Column('exclusion_symbol', sa.String(length=19), nullable=True), + sa.Column('supplier', sa.String(length=14), nullable=True), + sa.Column('alternate_unit_measure', sa.String(length=14), nullable=True), + sa.Column('added_value', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=True), + sa.Column('creation_date', sa.Integer(), nullable=True), + sa.Column('modification_date', sa.Integer(), nullable=True), + sa.Column('modification_date_iso', sa.DateTime(), nullable=True), + sa.Column('part_photo', sa.String(length=255), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['country_of_origin'], ['public.countries.m3_key'], name='fk_parts_country'), + sa.ForeignKeyConstraint(['currency_key'], ['public.currency_types.code'], name='fk_parts_currency'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), + sa.PrimaryKeyConstraint('id', name='parts_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'part_number', name='client_part_ukey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_parts_company_id'), 'parts', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_parts_tenant_id'), 'parts', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimentos', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('year', sa.String(length=2), nullable=False), + sa.Column('customs_office', sa.String(length=3), nullable=False), + sa.Column('license', sa.String(length=4), nullable=False), + sa.Column('pedimento_number', sa.String(length=7), nullable=False), + sa.Column('client_id', sa.Integer(), nullable=False), + sa.Column('operation_type', sa.Integer(), nullable=False), + sa.Column('pedimento_type', sa.String(length=20), nullable=False), + sa.Column('pedimento_code', sa.String(length=2), nullable=False), + sa.Column('regime', sa.String(length=3), nullable=False), + sa.Column('status', sa.String(length=30), nullable=True), + sa.Column('usd_value', sa.Numeric(precision=17, scale=6), nullable=True), + sa.Column('paid_price', sa.Numeric(precision=17, scale=6), nullable=True), + sa.Column('gross_weight', sa.Numeric(precision=19, scale=3), nullable=True), + sa.Column('exchange_rate', sa.Numeric(precision=9, scale=5), nullable=True), + sa.Column('observations', sa.Text(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_pedimentos_client'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_pedimentos_code'), + sa.ForeignKeyConstraint(['regime'], ['public.pedimento_regimens.code'], name='fk_pedimentos_regime'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimentos_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'year', 'customs_office', 'license', 'pedimento_number', name='pedimentos_unique_key'), + schema='a76' + ) + op.create_index('idx_pedimentos_client_id', 'pedimentos', ['client_id'], unique=False, schema='a76') + op.create_index('idx_pedimentos_created_at', 'pedimentos', ['created_at'], unique=False, schema='a76') + op.create_index('idx_pedimentos_status', 'pedimentos', ['status'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimentos_company_id'), 'pedimentos', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimentos_tenant_id'), 'pedimentos', ['tenant_id'], unique=False, schema='a76') + op.create_table('trailer', + sa.Column('trailer_number', sa.String(length=20), nullable=False), + sa.Column('ace_trailer_number', sa.String(length=10), nullable=True), + sa.Column('trailer_type_key', sa.String(length=2), nullable=True), + sa.Column('seal', sa.String(length=15), nullable=True), + sa.Column('entity_code', sa.String(length=1), nullable=True), + sa.Column('plate_number', sa.String(length=17), nullable=True), + sa.Column('state', sa.String(length=30), nullable=True), + sa.Column('country', sa.String(length=3), nullable=True), + sa.Column('container_key', sa.String(length=3), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['trailer_type_key'], ['a76.trailer_type.trailer_type_key'], ), + sa.PrimaryKeyConstraint('trailer_number'), + schema='a76' + ) + op.create_index(op.f('ix_a76_trailer_company_id'), 'trailer', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_trailer_tenant_id'), 'trailer', ['tenant_id'], unique=False, schema='a76') + op.create_table('unit_conversions', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('from_unit_code', sa.String(length=5), nullable=False), + sa.Column('to_unit_code', sa.String(length=5), nullable=False), + sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['from_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['to_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('from_unit_code', 'to_unit_code', 'tenant_id', 'company_id', name='uq_unit_conversion_pair'), + schema='a76' + ) + op.create_index(op.f('ix_a76_unit_conversions_company_id'), 'unit_conversions', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_unit_conversions_tenant_id'), 'unit_conversions', ['tenant_id'], unique=False, schema='a76') + op.create_table('fa_classes', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('class_id', sa.Integer(), nullable=False), + sa.Column('import_tariff_code', sa.String(length=10), nullable=False), + sa.Column('import_tariff_type', sa.String(length=6), nullable=False), + sa.Column('export_tariff_code', sa.String(length=10), nullable=False), + sa.Column('export_tariff_type', sa.String(length=6), nullable=False), + sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=False), + sa.Column('fda_code', sa.String(length=20), nullable=False), + sa.Column('eccn_code', sa.String(length=20), nullable=False), + sa.Column('class_enabled', sa.Boolean(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_qclasses_classes'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='qclases_pk'), + schema='a24' + ) + op.create_index(op.f('ix_a24_fa_classes_company_id'), 'fa_classes', ['company_id'], unique=False, schema='a24') + op.create_index(op.f('ix_a24_fa_classes_tenant_id'), 'fa_classes', ['tenant_id'], unique=False, schema='a24') + op.create_table('inv_classes', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('class_id', sa.Integer(), nullable=False), + sa.Column('stock_um', sa.String(length=5), nullable=False), + sa.Column('us_tariff_code', sa.String(length=19), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_sclasses_classes'), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='sclases_pk'), + schema='a24' + ) + op.create_index(op.f('ix_a24_inv_classes_company_id'), 'inv_classes', ['company_id'], unique=False, schema='a24') + op.create_index(op.f('ix_a24_inv_classes_tenant_id'), 'inv_classes', ['tenant_id'], unique=False, schema='a24') + op.create_table('line_items', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_id', sa.Integer(), nullable=False), + sa.Column('asset_number', sa.String(length=25), nullable=True), + sa.Column('asset_photo', sa.String(length=255), nullable=True), + sa.Column('equipment_message', sa.String(length=40), nullable=True), + sa.Column('invoice_type_asset', sa.String(length=6), nullable=True), + sa.Column('return_import_invoice', sa.String(length=15), nullable=True), + sa.Column('return_import_date', sa.Integer(), nullable=True), + sa.Column('movement_type_import', sa.String(length=3), nullable=True), + sa.Column('search_invoice', sa.String(length=15), nullable=True), + sa.Column('search_line', sa.Integer(), nullable=True), + sa.Column('search_type', sa.String(length=10), nullable=True), + sa.Column('download', sa.Boolean(), nullable=True), + sa.Column('own_equipment', sa.Boolean(), nullable=True), + sa.Column('omit_annex31', sa.Boolean(), nullable=True), + sa.ForeignKeyConstraint(['item_id'], ['a76.items.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a24' + ) + op.create_table('doda_container_seals', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('container_id', sa.Integer(), nullable=False), + sa.Column('doda_id', sa.Integer(), nullable=False), + sa.Column('seal_line', sa.Integer(), nullable=False), + sa.Column('seal_value', sa.String(length=21), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['container_id'], ['a76.doda_containers.id'], name='fk_doda_container_seals_container'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='doda_container_seals_pkey'), + schema='a76' + ) + op.create_index(op.f('ix_a76_doda_container_seals_company_id'), 'doda_container_seals', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_doda_container_seals_tenant_id'), 'doda_container_seals', ['tenant_id'], unique=False, schema='a76') + op.create_table('item_lines', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_id', sa.Integer(), nullable=False), + sa.Column('line_number', sa.Integer(), nullable=False), + sa.Column('part_number', sa.Integer(), nullable=True), + sa.Column('component_part_number', sa.Integer(), nullable=True), + sa.Column('class_code', sa.Integer(), nullable=True), + sa.Column('unit_of_measure', sa.Integer(), nullable=True), + sa.Column('alternate_unit', sa.Integer(), nullable=True), + sa.Column('uma_key', sa.String(length=2), nullable=True), + sa.Column('auxiliary_unit', sa.String(length=5), nullable=True), + sa.Column('permit_number', sa.String(length=20), nullable=True), + sa.Column('page_line', sa.String(length=10), nullable=True), + sa.Column('has_certificate', sa.Boolean(), nullable=True), + sa.Column('certificate_number', sa.String(length=10), nullable=True), + sa.Column('octave_permit', sa.String(length=20), nullable=True), + sa.Column('permits_ped', sa.String(length=500), nullable=True), + sa.Column('has_fda_code', sa.Boolean(), nullable=True), + sa.Column('fda_key', sa.String(length=10), nullable=True), + sa.Column('is_subitem', sa.Boolean(), nullable=True), + sa.Column('contains_subitems', sa.Boolean(), nullable=True), + sa.Column('includes_subitems', sa.Boolean(), nullable=True), + sa.Column('subitem_number', sa.Boolean(), nullable=True), + sa.Column('is_military_mcia', sa.Boolean(), nullable=True), + sa.Column('iv32_type_key', sa.String(length=5), nullable=True), + sa.Column('iv32_number', sa.String(length=35), nullable=True), + sa.Column('scrap_invoice', sa.String(length=15), nullable=True), + sa.Column('consecutive_destination', sa.Integer(), nullable=True), + sa.Column('ctm_section', sa.String(length=3), nullable=True), + sa.Column('tax_payment', sa.Boolean(), nullable=True), + sa.Column('payment_method', sa.String(length=9), nullable=True), + sa.Column('igi_amount', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('igi_payment_method', sa.String(length=9), nullable=True), + sa.Column('fcc_key', sa.String(length=30), nullable=True), + sa.Column('valuation_method', sa.String(length=2), nullable=True), + sa.Column('valuation_determined_value', sa.Numeric(precision=29, scale=8), nullable=True), + sa.Column('valuation_reason', sa.String(length=500), nullable=True), + sa.Column('container_rule', sa.String(length=50), nullable=True), + sa.Column('container_parts_ii', sa.String(length=50), nullable=True), + sa.Column('consecutive_aphis', sa.Integer(), nullable=True), + sa.Column('bom_version', sa.Integer(), nullable=True), + sa.Column('bill_version', sa.Integer(), nullable=True), + sa.Column('tlcan_value', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('identifier', sa.String(length=2), nullable=True), + sa.Column('validation_zero', sa.Integer(), nullable=True), + sa.Column('validation_one', sa.Integer(), nullable=True), + sa.Column('material_type', sa.String(length=50), nullable=True), + sa.Column('order_type', sa.String(length=50), nullable=True), + sa.Column('line_concept', sa.String(length=50), nullable=True), + sa.Column('review_dispatch', sa.String(length=10), nullable=True), + sa.Column('take_component_pt', sa.Integer(), nullable=True), + sa.Column('pallet2', sa.SmallInteger(), nullable=True), + sa.Column('wildcard_field', sa.String(length=100), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['alternate_unit'], ['a76.units_of_measure_general.id'], ), + sa.ForeignKeyConstraint(['class_code'], ['a76.classes.id'], ), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['component_part_number'], ['a76.parts.id'], ), + sa.ForeignKeyConstraint(['item_id'], ['a76.items.id'], ), + sa.ForeignKeyConstraint(['part_number'], ['a76.parts.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.ForeignKeyConstraint(['unit_of_measure'], ['a76.units_of_measure_general.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_item_lines_company_id'), 'item_lines', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_item_lines_tenant_id'), 'item_lines', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_additional', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('add_po_identifier', sa.SmallInteger(), nullable=False), + sa.Column('do_not_exempt_norms_complement_x', sa.SmallInteger(), nullable=False), + sa.Column('manual_pedimento_year', sa.String(length=2), nullable=False), + sa.Column('enable_import_invoice_recipient', sa.SmallInteger(), nullable=False), + sa.Column('send_502_validation_file_for_consolidated', sa.SmallInteger(), nullable=False), + sa.Column('add_remove_norms', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_additional', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_additional_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_additional_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_additional_company_id'), 'pedimento_config_additional', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), 'pedimento_config_additional', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_calculations', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('dta_type', sa.String(length=1), nullable=True), + sa.Column('dta_operation', sa.Boolean(), server_default='false', nullable=False), + sa.Column('dta_vehicle_count', sa.SmallInteger(), server_default='0', nullable=False), + sa.Column('dta_mixed_rate_8permil', sa.Boolean(), server_default='false', nullable=False), + sa.Column('pays_vat', sa.Boolean(), server_default='false', nullable=False), + sa.Column('pays_prevalidation', sa.Boolean(), server_default='false', nullable=False), + sa.Column('include_sagar_certificate_fee', sa.Boolean(), server_default='false', nullable=False), + sa.Column('fixed_vehicle_dta_fee', sa.Boolean(), server_default='false', nullable=False), + sa.Column('additional_fixed_fee', sa.SmallInteger(), server_default='0', nullable=False), + sa.Column('additional_fixed_fee_payment_method', sa.SmallInteger(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_calculations', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_calculations_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_calculations_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_calculations_company_id'), 'pedimento_config_calculations', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), 'pedimento_config_calculations', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_parameters', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('is_embassy', sa.Boolean(), server_default='false', nullable=False), + sa.Column('embassy_dta', sa.Numeric(precision=11, scale=2), server_default='0.00', nullable=False), + sa.Column('rule_3121_section_ii', sa.Boolean(), server_default='false', nullable=False), + sa.Column('use_previous_tariff', sa.Boolean(), server_default='false', nullable=False), + sa.Column('use_payment_date_fi', sa.Boolean(), server_default='false', nullable=False), + sa.Column('add_state_supplier_record_505', sa.Boolean(), server_default='false', nullable=False), + sa.Column('customs_value_calculation', sa.Boolean(), server_default='false', nullable=False), + sa.Column('two_decimals_unit_value', sa.Boolean(), server_default='false', nullable=False), + sa.Column('customs_value_per_item', sa.Boolean(), server_default='false', nullable=False), + sa.Column('is_national_supplier', sa.Boolean(), server_default='false', nullable=False), + sa.Column('is_consolidated', sa.Boolean(), server_default='false', nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_parameters', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_parameters_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_parameters_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_parameters_company_id'), 'pedimento_config_parameters', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), 'pedimento_config_parameters', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_surcharges', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('surcharge_igi', sa.SmallInteger(), nullable=False), + sa.Column('surcharge_dta', sa.SmallInteger(), nullable=False), + sa.Column('surcharge_vat', sa.SmallInteger(), nullable=False), + sa.Column('surcharge_isan', sa.SmallInteger(), nullable=False), + sa.Column('surcharge_ieps', sa.SmallInteger(), nullable=False), + sa.Column('surcharge_cc', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_surcharges', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_surcharges_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_surcharges_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), 'pedimento_config_surcharges', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), 'pedimento_config_surcharges', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_update_rectification', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False), + sa.Column('calculate_surcharge', sa.Boolean(), server_default='false', nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_update_rectification', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_update_rectification_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_update_rectification_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), 'pedimento_config_update_rectification', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), 'pedimento_config_update_rectification', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_config_updates', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False), + sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_updates', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_config_updates_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_updates_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_config_updates_company_id'), 'pedimento_config_updates', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), 'pedimento_config_updates', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_customs_offices', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('dispatch_customs', sa.String(length=3), nullable=False), + sa.Column('entry_exit_customs', sa.String(length=3), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_customs_offices', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_customs_offices_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_customs_offices_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_customs_offices_company_id'), 'pedimento_customs_offices', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), 'pedimento_customs_offices', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_dates', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('entry_date', sa.DateTime(), nullable=True), + sa.Column('pedimento_date', sa.DateTime(), nullable=True), + sa.Column('payment_date', sa.DateTime(), nullable=False), + sa.Column('rectification_payment_date', sa.DateTime(), nullable=True), + sa.Column('extraction_date', sa.DateTime(), nullable=True), + sa.Column('submission_date', sa.DateTime(), nullable=True), + sa.Column('eucan_date', sa.DateTime(), nullable=True), + sa.Column('original_date', sa.DateTime(), nullable=True), + sa.Column('start_date', sa.DateTime(), nullable=True), + sa.Column('end_date', sa.DateTime(), nullable=True), + sa.Column('capture_time', sa.Time(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_dates', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_dates_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_dates_pedimento_id_key'), + schema='a76' + ) + op.create_index('idx_pedimento_dates_pedimento_id', 'pedimento_dates', ['pedimento_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_dates_company_id'), 'pedimento_dates', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_dates_tenant_id'), 'pedimento_dates', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_decrementables', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('loading', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('unloading', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('others', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('currency', sa.String(length=3), nullable=False), + sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=False), + sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=False), + sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_decrementables', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_decrementables_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_decrementables_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_decrementables_company_id'), 'pedimento_decrementables', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), 'pedimento_decrementables', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_incrementables', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('insured_value', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('packaging', sa.Numeric(precision=13, scale=2), nullable=False), + sa.Column('others', sa.Numeric(precision=13, scale=3), nullable=False), + sa.Column('deductibles', sa.Numeric(precision=13, scale=3), nullable=False), + sa.Column('currency', sa.String(length=3), nullable=False), + sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=False), + sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=False), + sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_incrementables', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_incrementables_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_incrementables_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_incrementables_company_id'), 'pedimento_incrementables', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), 'pedimento_incrementables', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_indexes', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('update_factor_type', sa.SmallInteger(), nullable=False), + sa.Column('update_factor', sa.Numeric(precision=7, scale=4), nullable=False), + sa.Column('manual_update_factor', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_indexes', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_indexes_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_indexes_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_indexes_company_id'), 'pedimento_indexes', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_indexes_tenant_id'), 'pedimento_indexes', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_payments', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('acknowledgment', sa.String(length=20), nullable=False), + sa.Column('operation_number', sa.String(length=14), nullable=False), + sa.Column('bank_code', sa.Integer(), nullable=False), + sa.Column('cashier', sa.String(length=2), nullable=False), + sa.Column('date', sa.Date(), nullable=False), + sa.Column('time', sa.Time(), nullable=False), + sa.Column('shift', sa.String(length=1), nullable=False), + sa.Column('total_cash_paid', sa.Integer(), nullable=False), + sa.Column('total_contributions', sa.Integer(), nullable=False), + sa.Column('counter_payment', sa.SmallInteger(), nullable=False), + sa.Column('pece_code', sa.String(length=5), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_payments', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_payments_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_payments_pedimento_id_key'), + schema='a76' + ) + op.create_index('idx_pedimento_payments_pedimento_id', 'pedimento_payments', ['pedimento_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_payments_company_id'), 'pedimento_payments', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_payments_tenant_id'), 'pedimento_payments', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_rectification_destination', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('destination_pedimento_year', sa.String(length=2), nullable=False), + sa.Column('destination_customs_office', sa.String(length=3), nullable=False), + sa.Column('destination_license', sa.String(length=4), nullable=False), + sa.Column('destination_pedimento_number', sa.String(length=7), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_destination', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_rectification_destination_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_destination_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), 'pedimento_rectification_destination', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), 'pedimento_rectification_destination', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_rectification_origin', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('original_pedimento_year', sa.String(length=2), nullable=False), + sa.Column('original_customs_office', sa.String(length=3), nullable=False), + sa.Column('original_license', sa.String(length=4), nullable=False), + sa.Column('original_pedimento_number', sa.String(length=7), nullable=False), + sa.Column('original_pedimento_code', sa.String(length=2), nullable=False), + sa.Column('original_payment_date', sa.DateTime(), nullable=False), + sa.Column('total_cash', sa.Integer(), nullable=False), + sa.Column('total_others', sa.Integer(), nullable=False), + sa.Column('reason', sa.String(length=255), nullable=False), + sa.Column('charge_to_client', sa.SmallInteger(), nullable=False), + sa.Column('use_original_payment_date_for_interest_calc', sa.SmallInteger(), nullable=False), + sa.Column('manual_calculation', sa.SmallInteger(), nullable=False), + sa.Column('original_pedimento_norms', sa.SmallInteger(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_origin', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_rectification_origin_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_origin_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), 'pedimento_rectification_origin', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), 'pedimento_rectification_origin', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_transport_means', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('destination', sa.SmallInteger(), nullable=False), + sa.Column('entry_exit', sa.String(length=2), nullable=False), + sa.Column('arrival', sa.String(length=2), nullable=False), + sa.Column('departure', sa.String(length=2), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_transport_means', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_transport_means_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_transport_means_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_transport_means_company_id'), 'pedimento_transport_means', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), 'pedimento_transport_means', ['tenant_id'], unique=False, schema='a76') + op.create_table('pedimento_validation', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('pedimento_id', sa.Integer(), nullable=False), + sa.Column('validator', sa.String(length=3), nullable=False), + sa.Column('validation_ack', sa.String(length=8), nullable=False), + sa.Column('pre_ack', sa.String(length=8), nullable=False), + sa.Column('line_signature', sa.String(length=50), nullable=False), + sa.Column('electronic_signature', sa.String(length=999), nullable=False), + sa.Column('certificate_number', sa.String(length=99), nullable=False), + sa.Column('validator_id', sa.Integer(), nullable=False), + sa.Column('responsible_id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_validation', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id', name='pedimento_validation_pkey'), + sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_validation_pedimento_id_key'), + schema='a76' + ) + op.create_index(op.f('ix_a76_pedimento_validation_company_id'), 'pedimento_validation', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_pedimento_validation_tenant_id'), 'pedimento_validation', ['tenant_id'], unique=False, schema='a76') + op.create_table('ctm_receipts', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('receipt_line', sa.Integer(), nullable=False), + sa.Column('option', sa.String(length=3), nullable=True), + sa.Column('exit_invoice', sa.String(length=19), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['receipt_line'], ['a76.item_lines.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_ctm_receipts_company_id'), 'ctm_receipts', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_ctm_receipts_tenant_id'), 'ctm_receipts', ['tenant_id'], unique=False, schema='a76') + op.create_table('item_line_series', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('line_item_id', sa.Integer(), nullable=False), + sa.Column('row', sa.Integer(), nullable=False), + sa.Column('serial_numbers', sa.String(length=50), nullable=True), + sa.Column('model', sa.String(length=50), nullable=True), + sa.Column('sub_model', sa.String(length=50), nullable=True), + sa.Column('brand', sa.String(length=50), nullable=True), + sa.Column('expo_brad', sa.String(length=50), nullable=True), + sa.Column('number_id', sa.String(length=25), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('deleted_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), + sa.ForeignKeyConstraint(['line_item_id'], ['a76.item_lines.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_index(op.f('ix_a76_item_line_series_company_id'), 'item_line_series', ['company_id'], unique=False, schema='a76') + op.create_index(op.f('ix_a76_item_line_series_tenant_id'), 'item_line_series', ['tenant_id'], unique=False, schema='a76') + op.create_table('line_customs', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('fraction', sa.String(length=10), nullable=True), + sa.Column('fraction_type', sa.String(length=7), nullable=True), + sa.Column('american_fraction', sa.String(length=16), nullable=True), + sa.Column('alternate_fraction', sa.String(length=10), nullable=True), + sa.Column('reference_fraction', sa.String(length=10), nullable=True), + sa.Column('octave_fraction', sa.String(length=10), nullable=True), + sa.Column('tlcan_fraction', sa.String(length=13), nullable=True), + sa.Column('extra_american_fraction', sa.String(length=16), nullable=True), + sa.Column('garment_fraction', sa.String(length=19), nullable=True), + sa.Column('advalorem', sa.String(length=10), nullable=True), + sa.Column('advalorem_numeric', sa.Numeric(precision=7, scale=2), nullable=True), + sa.Column('advalorem_american', sa.Numeric(precision=5, scale=2), nullable=True), + sa.Column('advalorem_tlcan', sa.Numeric(precision=5, scale=2), nullable=True), + sa.Column('rate', sa.String(length=10), nullable=True), + sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=True), + sa.Column('origin_country', sa.String(length=3), nullable=True), + sa.Column('destination_country', sa.String(length=3), nullable=True), + sa.Column('optional_country', sa.String(length=3), nullable=True), + sa.Column('origin_procedure', sa.String(length=3), nullable=True), + sa.Column('scrap_procedure', sa.String(length=3), nullable=True), + sa.Column('sector', sa.String(length=8), nullable=True), + sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_table('line_descriptions', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('description_spanish', sa.String(length=4999), nullable=True), + sa.Column('description_english', sa.String(length=4999), nullable=True), + sa.Column('extra_description', sa.Text(), nullable=True), + sa.Column('part_description', sa.String(length=500), nullable=True), + sa.Column('class_description', sa.String(length=500), nullable=True), + sa.Column('brand', sa.String(length=50), nullable=True), + sa.Column('model', sa.String(length=50), nullable=True), + sa.Column('has_serial', sa.Boolean(), nullable=True), + sa.Column('additional_info_spanish', sa.String(length=1000), nullable=True), + sa.Column('additional_info_english', sa.String(length=1000), nullable=True), + sa.Column('lot', sa.String(length=254), nullable=True), + sa.Column('entry_number', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_table('line_financials', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('unit_cost_capture', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_current_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('sales_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('commercial_unit_cost', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_current_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('sales_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('unit_cost_mc', sa.Numeric(precision=29, scale=8), nullable=True), + sa.Column('value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_updated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('sub_import_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_returned_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('customs_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_total_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_temp_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_def_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_added_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_national_packing_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('vat_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('vat_used_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('advalorem_line_mxn', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_usd', sa.Numeric(precision=29, scale=8), nullable=True), + sa.Column('value_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_updated_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('sub_import_value_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_returned_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('customs_value_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_total_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_temp_material_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_def_material_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_added_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_national_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_us_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('vat_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('vat_used_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_non_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('igi_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('exempt_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('total_commercial_value', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('advalorem_line_usd', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_mc', sa.Numeric(precision=29, scale=8), nullable=True), + sa.Column('sub_import_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('vat_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_added_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_national_packing_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_total_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_temp_material_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.Column('value_def_material_mc', sa.Numeric(precision=23, scale=8), nullable=True), + sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_table('line_quantities', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('alternate_quantity', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('quantity_uma', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('auxiliary_quantity', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('quantity_temp_export', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('quantity_existence', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('quantity_returned', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('quantity_returned_temp', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('serial_count', sa.Integer(), nullable=True), + sa.Column('weight_unit', sa.String(length=3), nullable=True), + sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True), + sa.Column('package_key', sa.String(length=5), nullable=True), + sa.Column('package_quantity', sa.Integer(), nullable=True), + sa.Column('package_description', sa.String(length=40), nullable=True), + sa.Column('container_quantity', sa.SmallInteger(), nullable=True), + sa.Column('container_description', sa.String(length=40), nullable=True), + sa.Column('box_count', sa.String(length=30), nullable=True), + sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.create_table('line_references', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_line_id', sa.Integer(), nullable=False), + sa.Column('serie_id', sa.Integer(), nullable=True), + sa.Column('customer_invoice', sa.Integer(), nullable=True), + sa.Column('assigned_client', sa.Integer(), nullable=True), + sa.Column('supplier', sa.Integer(), nullable=True), + sa.Column('requisitioner', sa.Integer(), nullable=True), + sa.Column('sent_to', sa.Integer(), nullable=True), + sa.Column('ped_line', sa.Integer(), nullable=True), + sa.Column('ro_line', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['assigned_client'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['customer_invoice'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), + sa.ForeignKeyConstraint(['requisitioner'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['sent_to'], ['a76.clients_and_providers.id'], ), + sa.ForeignKeyConstraint(['serie_id'], ['a76.item_line_series.id'], ), + sa.ForeignKeyConstraint(['supplier'], ['a76.clients_and_providers.id'], ), + sa.PrimaryKeyConstraint('id'), + schema='a76' + ) + op.drop_constraint(op.f('fk_codeped'), 'code_pedimento_regimens', type_='foreignkey') + op.drop_constraint(op.f('fk_regimenped'), 'code_pedimento_regimens', type_='foreignkey') + op.create_foreign_key('fk_codeped', 'code_pedimento_regimens', 'pedimento_codes', ['pedimento_code'], ['code'], source_schema='public', referent_schema='public') + op.create_foreign_key('fk_regimenped', 'code_pedimento_regimens', 'pedimento_regimens', ['regimen_code'], ['code'], source_schema='public', referent_schema='public') + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('fk_regimenped', 'code_pedimento_regimens', schema='public', type_='foreignkey') + op.drop_constraint('fk_codeped', 'code_pedimento_regimens', schema='public', type_='foreignkey') + op.create_foreign_key(op.f('fk_regimenped'), 'code_pedimento_regimens', 'pedimento_regimens', ['regimen_code'], ['code']) + op.create_foreign_key(op.f('fk_codeped'), 'code_pedimento_regimens', 'pedimento_codes', ['pedimento_code'], ['code']) + op.drop_table('line_references', schema='a76') + op.drop_table('line_quantities', schema='a76') + op.drop_table('line_financials', schema='a76') + op.drop_table('line_descriptions', schema='a76') + op.drop_table('line_customs', schema='a76') + op.drop_index(op.f('ix_a76_item_line_series_tenant_id'), table_name='item_line_series', schema='a76') + op.drop_index(op.f('ix_a76_item_line_series_company_id'), table_name='item_line_series', schema='a76') + op.drop_table('item_line_series', schema='a76') + op.drop_index(op.f('ix_a76_ctm_receipts_tenant_id'), table_name='ctm_receipts', schema='a76') + op.drop_index(op.f('ix_a76_ctm_receipts_company_id'), table_name='ctm_receipts', schema='a76') + op.drop_table('ctm_receipts', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_validation_tenant_id'), table_name='pedimento_validation', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_validation_company_id'), table_name='pedimento_validation', schema='a76') + op.drop_table('pedimento_validation', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), table_name='pedimento_transport_means', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_transport_means_company_id'), table_name='pedimento_transport_means', schema='a76') + op.drop_table('pedimento_transport_means', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), table_name='pedimento_rectification_origin', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), table_name='pedimento_rectification_origin', schema='a76') + op.drop_table('pedimento_rectification_origin', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), table_name='pedimento_rectification_destination', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), table_name='pedimento_rectification_destination', schema='a76') + op.drop_table('pedimento_rectification_destination', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_payments_tenant_id'), table_name='pedimento_payments', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_payments_company_id'), table_name='pedimento_payments', schema='a76') + op.drop_index('idx_pedimento_payments_pedimento_id', table_name='pedimento_payments', schema='a76') + op.drop_table('pedimento_payments', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_indexes_tenant_id'), table_name='pedimento_indexes', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_indexes_company_id'), table_name='pedimento_indexes', schema='a76') + op.drop_table('pedimento_indexes', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), table_name='pedimento_incrementables', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_incrementables_company_id'), table_name='pedimento_incrementables', schema='a76') + op.drop_table('pedimento_incrementables', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), table_name='pedimento_decrementables', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_decrementables_company_id'), table_name='pedimento_decrementables', schema='a76') + op.drop_table('pedimento_decrementables', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_dates_tenant_id'), table_name='pedimento_dates', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_dates_company_id'), table_name='pedimento_dates', schema='a76') + op.drop_index('idx_pedimento_dates_pedimento_id', table_name='pedimento_dates', schema='a76') + op.drop_table('pedimento_dates', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), table_name='pedimento_customs_offices', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_customs_offices_company_id'), table_name='pedimento_customs_offices', schema='a76') + op.drop_table('pedimento_customs_offices', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), table_name='pedimento_config_updates', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_updates_company_id'), table_name='pedimento_config_updates', schema='a76') + op.drop_table('pedimento_config_updates', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), table_name='pedimento_config_update_rectification', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), table_name='pedimento_config_update_rectification', schema='a76') + op.drop_table('pedimento_config_update_rectification', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), table_name='pedimento_config_surcharges', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), table_name='pedimento_config_surcharges', schema='a76') + op.drop_table('pedimento_config_surcharges', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), table_name='pedimento_config_parameters', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_parameters_company_id'), table_name='pedimento_config_parameters', schema='a76') + op.drop_table('pedimento_config_parameters', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), table_name='pedimento_config_calculations', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_calculations_company_id'), table_name='pedimento_config_calculations', schema='a76') + op.drop_table('pedimento_config_calculations', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), table_name='pedimento_config_additional', schema='a76') + op.drop_index(op.f('ix_a76_pedimento_config_additional_company_id'), table_name='pedimento_config_additional', schema='a76') + op.drop_table('pedimento_config_additional', schema='a76') + op.drop_index(op.f('ix_a76_item_lines_tenant_id'), table_name='item_lines', schema='a76') + op.drop_index(op.f('ix_a76_item_lines_company_id'), table_name='item_lines', schema='a76') + op.drop_table('item_lines', schema='a76') + op.drop_index(op.f('ix_a76_doda_container_seals_tenant_id'), table_name='doda_container_seals', schema='a76') + op.drop_index(op.f('ix_a76_doda_container_seals_company_id'), table_name='doda_container_seals', schema='a76') + op.drop_table('doda_container_seals', schema='a76') + op.drop_table('line_items', schema='a24') + op.drop_index(op.f('ix_a24_inv_classes_tenant_id'), table_name='inv_classes', schema='a24') + op.drop_index(op.f('ix_a24_inv_classes_company_id'), table_name='inv_classes', schema='a24') + op.drop_table('inv_classes', schema='a24') + op.drop_index(op.f('ix_a24_fa_classes_tenant_id'), table_name='fa_classes', schema='a24') + op.drop_index(op.f('ix_a24_fa_classes_company_id'), table_name='fa_classes', schema='a24') + op.drop_table('fa_classes', schema='a24') + op.drop_index(op.f('ix_a76_unit_conversions_tenant_id'), table_name='unit_conversions', schema='a76') + op.drop_index(op.f('ix_a76_unit_conversions_company_id'), table_name='unit_conversions', schema='a76') + op.drop_table('unit_conversions', schema='a76') + op.drop_index(op.f('ix_a76_trailer_tenant_id'), table_name='trailer', schema='a76') + op.drop_index(op.f('ix_a76_trailer_company_id'), table_name='trailer', schema='a76') + op.drop_table('trailer', schema='a76') + op.drop_index(op.f('ix_a76_pedimentos_tenant_id'), table_name='pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_pedimentos_company_id'), table_name='pedimentos', schema='a76') + op.drop_index('idx_pedimentos_status', table_name='pedimentos', schema='a76') + op.drop_index('idx_pedimentos_created_at', table_name='pedimentos', schema='a76') + op.drop_index('idx_pedimentos_client_id', table_name='pedimentos', schema='a76') + op.drop_table('pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_parts_tenant_id'), table_name='parts', schema='a76') + op.drop_index(op.f('ix_a76_parts_company_id'), table_name='parts', schema='a76') + op.drop_table('parts', schema='a76') + op.drop_index(op.f('ix_a76_items_tenant_id'), table_name='items', schema='a76') + op.drop_index(op.f('ix_a76_items_company_id'), table_name='items', schema='a76') + op.drop_table('items', schema='a76') + op.drop_index(op.f('ix_a76_invoice_sales_details_tenant_id'), table_name='invoice_sales_details', schema='a76') + op.drop_index(op.f('ix_a76_invoice_sales_details_company_id'), table_name='invoice_sales_details', schema='a76') + op.drop_table('invoice_sales_details', schema='a76') + op.drop_index(op.f('ix_a76_invoice_logistics_tenant_id'), table_name='invoice_logistics', schema='a76') + op.drop_index(op.f('ix_a76_invoice_logistics_company_id'), table_name='invoice_logistics', schema='a76') + op.drop_table('invoice_logistics', schema='a76') + op.drop_index(op.f('ix_a76_invoice_financials_tenant_id'), table_name='invoice_financials', schema='a76') + op.drop_index(op.f('ix_a76_invoice_financials_company_id'), table_name='invoice_financials', schema='a76') + op.drop_table('invoice_financials', schema='a76') + op.drop_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), table_name='invoice_compliance_mx', schema='a76') + op.drop_index(op.f('ix_a76_invoice_compliance_mx_company_id'), table_name='invoice_compliance_mx', schema='a76') + op.drop_table('invoice_compliance_mx', schema='a76') + op.drop_index(op.f('ix_a76_invoice_collections_tenant_id'), table_name='invoice_collections', schema='a76') + op.drop_index(op.f('ix_a76_invoice_collections_company_id'), table_name='invoice_collections', schema='a76') + op.drop_table('invoice_collections', schema='a76') + op.drop_index(op.f('ix_a76_identifier_details_tenant_id'), table_name='identifier_details', schema='a76') + op.drop_index(op.f('ix_a76_identifier_details_company_id'), table_name='identifier_details', schema='a76') + op.drop_table('identifier_details', schema='a76') + op.drop_index(op.f('ix_a76_error_catalogs_tenant_id'), table_name='error_catalogs', schema='a76') + op.drop_index(op.f('ix_a76_error_catalogs_company_id'), table_name='error_catalogs', schema='a76') + op.drop_table('error_catalogs', schema='a76') + op.drop_index(op.f('ix_a76_equivalency_items_tenant_id'), table_name='equivalency_items', schema='a76') + op.drop_index(op.f('ix_a76_equivalency_items_company_id'), table_name='equivalency_items', schema='a76') + op.drop_table('equivalency_items', schema='a76') + op.drop_index(op.f('ix_a76_driver_tenant_id'), table_name='driver', schema='a76') + op.drop_index(op.f('ix_a76_driver_company_id'), table_name='driver', schema='a76') + op.drop_table('driver', schema='a76') + op.drop_index(op.f('ix_a76_doda_pedimentos_tenant_id'), table_name='doda_pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_doda_pedimentos_company_id'), table_name='doda_pedimentos', schema='a76') + op.drop_table('doda_pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_doda_containers_tenant_id'), table_name='doda_containers', schema='a76') + op.drop_index(op.f('ix_a76_doda_containers_company_id'), table_name='doda_containers', schema='a76') + op.drop_table('doda_containers', schema='a76') + op.drop_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), table_name='doda_american_pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_doda_american_pedimentos_company_id'), table_name='doda_american_pedimentos', schema='a76') + op.drop_table('doda_american_pedimentos', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), table_name='customs_brokers_vu', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_vu_company_id'), table_name='customs_brokers_vu', schema='a76') + op.drop_table('customs_brokers_vu', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), table_name='customs_brokers_personnel', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_personnel_company_id'), table_name='customs_brokers_personnel', schema='a76') + op.drop_table('customs_brokers_personnel', schema='a76') + op.drop_index(op.f('ix_a76_country_rule_oct_tenant_id'), table_name='country_rule_oct', schema='a76') + op.drop_index(op.f('ix_a76_country_rule_oct_company_id'), table_name='country_rule_oct', schema='a76') + op.drop_table('country_rule_oct', schema='a76') + op.drop_index(op.f('ix_a76_concepts_tenant_id'), table_name='concepts', schema='a76') + op.drop_table('concepts', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), table_name='clients_and_providers_programs', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_programs_company_id'), table_name='clients_and_providers_programs', schema='a76') + op.drop_table('clients_and_providers_programs', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), table_name='clients_and_providers_address', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_address_company_id'), table_name='clients_and_providers_address', schema='a76') + op.drop_table('clients_and_providers_address', schema='a76') + op.drop_index(op.f('ix_a76_classes_tenant_id'), table_name='classes', schema='a76') + op.drop_index(op.f('ix_a76_classes_company_id'), table_name='classes', schema='a76') + op.drop_table('classes', schema='a76') + op.drop_index(op.f('ix_core_user_tenants_tenant_id'), table_name='user_tenants', schema='core') + op.drop_index(op.f('ix_core_user_tenants_keycloak_user_id'), table_name='user_tenants', schema='core') + op.drop_index(op.f('ix_core_user_tenants_id'), table_name='user_tenants', schema='core') + op.drop_index(op.f('ix_core_user_tenants_company_id'), table_name='user_tenants', schema='core') + op.drop_table('user_tenants', schema='core') + op.drop_index(op.f('ix_a76_vehicle_tenant_id'), table_name='vehicle', schema='a76') + op.drop_index(op.f('ix_a76_vehicle_company_id'), table_name='vehicle', schema='a76') + op.drop_table('vehicle', schema='a76') + op.drop_index(op.f('ix_a76_units_of_measure_general_tenant_id'), table_name='units_of_measure_general', schema='a76') + op.drop_index(op.f('ix_a76_units_of_measure_general_company_id'), table_name='units_of_measure_general', schema='a76') + op.drop_table('units_of_measure_general', schema='a76') + op.drop_index(op.f('ix_a76_units_of_measure_tenant_id'), table_name='units_of_measure', schema='a76') + op.drop_index(op.f('ix_a76_units_of_measure_company_id'), table_name='units_of_measure', schema='a76') + op.drop_table('units_of_measure', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_oma_tenant_id'), table_name='unit_of_measure_oma', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_oma_company_id'), table_name='unit_of_measure_oma', schema='a76') + op.drop_table('unit_of_measure_oma', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_customs_tenant_id'), table_name='unit_of_measure_customs', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_customs_company_id'), table_name='unit_of_measure_customs', schema='a76') + op.drop_table('unit_of_measure_customs', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_american_tenant_id'), table_name='unit_of_measure_american', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_american_company_id'), table_name='unit_of_measure_american', schema='a76') + op.drop_table('unit_of_measure_american', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_ace_tenant_id'), table_name='unit_of_measure_ace', schema='a76') + op.drop_index(op.f('ix_a76_unit_of_measure_ace_company_id'), table_name='unit_of_measure_ace', schema='a76') + op.drop_table('unit_of_measure_ace', schema='a76') + op.drop_index(op.f('ix_a76_transporter_tenant_id'), table_name='transporter', schema='a76') + op.drop_index(op.f('ix_a76_transporter_company_id'), table_name='transporter', schema='a76') + op.drop_table('transporter', schema='a76') + op.drop_index(op.f('ix_a76_trailer_type_tenant_id'), table_name='trailer_type', schema='a76') + op.drop_index(op.f('ix_a76_trailer_type_company_id'), table_name='trailer_type', schema='a76') + op.drop_table('trailer_type', schema='a76') + op.drop_index(op.f('ix_a76_subassembly_entries_tenant_id'), table_name='subassembly_entries', schema='a76') + op.drop_index(op.f('ix_a76_subassembly_entries_company_id'), table_name='subassembly_entries', schema='a76') + op.drop_table('subassembly_entries', schema='a76') + op.drop_index(op.f('ix_a76_signatures_tenant_id'), table_name='signatures', schema='a76') + op.drop_index(op.f('ix_a76_signatures_company_id'), table_name='signatures', schema='a76') + op.drop_table('signatures', schema='a76') + op.drop_index(op.f('ix_a76_seal_tenant_id'), table_name='seal', schema='a76') + op.drop_index(op.f('ix_a76_seal_company_id'), table_name='seal', schema='a76') + op.drop_table('seal', schema='a76') + op.drop_index(op.f('ix_a76_prevalidators_tenant_id'), table_name='prevalidators', schema='a76') + op.drop_index(op.f('ix_a76_prevalidators_company_id'), table_name='prevalidators', schema='a76') + op.drop_table('prevalidators', schema='a76') + op.drop_index(op.f('ix_a76_ports_tenant_id'), table_name='ports', schema='a76') + op.drop_index(op.f('ix_a76_ports_company_id'), table_name='ports', schema='a76') + op.drop_table('ports', schema='a76') + op.drop_index(op.f('ix_a76_permission_rule_oct_tenant_id'), table_name='permission_rule_oct', schema='a76') + op.drop_index(op.f('ix_a76_permission_rule_oct_company_id'), table_name='permission_rule_oct', schema='a76') + op.drop_table('permission_rule_oct', schema='a76') + op.drop_index(op.f('ix_a76_packing_lists_tenant_id'), table_name='packing_lists', schema='a76') + op.drop_index(op.f('ix_a76_packing_lists_company_id'), table_name='packing_lists', schema='a76') + op.drop_table('packing_lists', schema='a76') + op.drop_index(op.f('ix_a76_packages_tenant_id'), table_name='packages', schema='a76') + op.drop_index(op.f('ix_a76_packages_company_id'), table_name='packages', schema='a76') + op.drop_table('packages', schema='a76') + op.drop_index(op.f('ix_a76_multi_currency_types_tenant_id'), table_name='multi_currency_types', schema='a76') + op.drop_index(op.f('ix_a76_multi_currency_types_company_id'), table_name='multi_currency_types', schema='a76') + op.drop_table('multi_currency_types', schema='a76') + op.drop_index(op.f('ix_a76_legends_tenant_id'), table_name='legends', schema='a76') + op.drop_index(op.f('ix_a76_legends_company_id'), table_name='legends', schema='a76') + op.drop_table('legends', schema='a76') + op.drop_index(op.f('ix_a76_invoice_header_tenant_id'), table_name='invoice_header', schema='a76') + op.drop_index(op.f('ix_a76_invoice_header_company_id'), table_name='invoice_header', schema='a76') + op.drop_table('invoice_header', schema='a76') + op.drop_index(op.f('ix_a76_inpc_tenant_id'), table_name='inpc', schema='a76') + op.drop_index(op.f('ix_a76_inpc_company_id'), table_name='inpc', schema='a76') + op.drop_table('inpc', schema='a76') + op.drop_index(op.f('ix_a76_identifiers_tenant_id'), table_name='identifiers', schema='a76') + op.drop_index(op.f('ix_a76_identifiers_company_id'), table_name='identifiers', schema='a76') + op.drop_table('identifiers', schema='a76') + op.drop_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), table_name='fraction_rule_octave', schema='a76') + op.drop_index(op.f('ix_a76_fraction_rule_octave_company_id'), table_name='fraction_rule_octave', schema='a76') + op.drop_table('fraction_rule_octave', schema='a76') + op.drop_index(op.f('ix_a76_exchange_rate_tenant_id'), table_name='exchange_rate', schema='a76') + op.drop_index(op.f('ix_a76_exchange_rate_company_id'), table_name='exchange_rate', schema='a76') + op.drop_table('exchange_rate', schema='a76') + op.drop_index(op.f('ix_a76_error_classifications_tenant_id'), table_name='error_classifications', schema='a76') + op.drop_index(op.f('ix_a76_error_classifications_company_id'), table_name='error_classifications', schema='a76') + op.drop_table('error_classifications', schema='a76') + op.drop_index(op.f('ix_a76_equivalencies_tenant_id'), table_name='equivalencies', schema='a76') + op.drop_index(op.f('ix_a76_equivalencies_company_id'), table_name='equivalencies', schema='a76') + op.drop_table('equivalencies', schema='a76') + op.drop_index(op.f('ix_a76_electronic_notices_tenant_id'), table_name='electronic_notices', schema='a76') + op.drop_index(op.f('ix_a76_electronic_notices_company_id'), table_name='electronic_notices', schema='a76') + op.drop_table('electronic_notices', schema='a76') + op.drop_index(op.f('ix_a76_doda_tenant_id'), table_name='doda', schema='a76') + op.drop_index(op.f('ix_a76_doda_company_id'), table_name='doda', schema='a76') + op.drop_table('doda', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_tenant_id'), table_name='customs_brokers', schema='a76') + op.drop_index(op.f('ix_a76_customs_brokers_company_id'), table_name='customs_brokers', schema='a76') + op.drop_table('customs_brokers', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_tenant_id'), table_name='clients_and_providers', schema='a76') + op.drop_index(op.f('ix_a76_clients_and_providers_company_id'), table_name='clients_and_providers', schema='a76') + op.drop_table('clients_and_providers', schema='a76') + op.drop_index(op.f('ix_a76_classification_concepts_tenant_id'), table_name='classification_concepts', schema='a76') + op.drop_index(op.f('ix_a76_classification_concepts_company_id'), table_name='classification_concepts', schema='a76') + op.drop_table('classification_concepts', schema='a76') + op.drop_index(op.f('ix_a24_location_tenant_id'), table_name='location', schema='a24') + op.drop_index(op.f('ix_a24_location_company_id'), table_name='location', schema='a24') + op.drop_table('location', schema='a24') + op.drop_index(op.f('ix_core_licenses_tenant_id'), table_name='licenses', schema='core') + op.drop_index(op.f('ix_core_licenses_id'), table_name='licenses', schema='core') + op.drop_table('licenses', schema='core') + op.drop_index(op.f('ix_core_license_usage_tenant_id'), table_name='license_usage', schema='core') + op.drop_index(op.f('ix_core_license_usage_id'), table_name='license_usage', schema='core') + op.drop_table('license_usage', schema='core') + op.drop_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), table_name='customs_broker_concepts', schema='a76') + op.drop_table('customs_broker_concepts', schema='a76') + op.drop_index(op.f('ix_a76_company_tenant_id'), table_name='company', schema='a76') + op.drop_table('company', schema='a76') + op.drop_index(op.f('ix_core_tenants_slug'), table_name='tenants', schema='core') + op.drop_index(op.f('ix_core_tenants_name'), table_name='tenants', schema='core') + op.drop_index(op.f('ix_core_tenants_id'), table_name='tenants', schema='core') + op.drop_table('tenants', schema='core') + # ### end Alembic commands ### diff --git a/backend/api/v1/modules/a24/inv/inv_classes/models.py b/backend/api/v1/modules/a24/inv/inv_classes/models.py index 229e5502..47fc679f 100644 --- a/backend/api/v1/modules/a24/inv/inv_classes/models.py +++ b/backend/api/v1/modules/a24/inv/inv_classes/models.py @@ -8,7 +8,7 @@ class SClasses(Base, TenantScopedMixin, TimestampMixin): __tablename__ = "inv_classes" # SClases __table_args__ = ( ForeignKeyConstraint( - ["class_id"], ["a76.clases.class_id"], name="fk_sclasses_classes" + ["class_id"], ["a76.classes.id"], name="fk_sclasses_classes" ), PrimaryKeyConstraint("id", name="sclases_pk"), {"schema": "a24"}, diff --git a/backend/api/v1/modules/a76/parts/dto.py b/backend/api/v1/modules/a76/parts/dto.py index dfcbca5b..e91d6156 100644 --- a/backend/api/v1/modules/a76/parts/dto.py +++ b/backend/api/v1/modules/a76/parts/dto.py @@ -12,6 +12,7 @@ class PartCreateDTO(BaseModel): description_spanish: Optional[str] = None description_english: Optional[str] = None part_class: Optional[str] = None + material_type: Optional[str] = None unit_of_measure: Optional[str] = "PZ" commercial_part_number: Optional[str] = None country_of_origin: Optional[str] = "MEX" @@ -46,6 +47,7 @@ class PartUpdateDTO(BaseModel): description_spanish: Optional[str] = None description_english: Optional[str] = None part_class: Optional[str] = None + material_type: Optional[str] = None unit_of_measure: Optional[str] = None commercial_part_number: Optional[str] = None country_of_origin: Optional[str] = None diff --git a/backend/api/v1/modules/a76/parts/models.py b/backend/api/v1/modules/a76/parts/models.py index 12750dca..aad7e6b9 100644 --- a/backend/api/v1/modules/a76/parts/models.py +++ b/backend/api/v1/modules/a76/parts/models.py @@ -62,6 +62,7 @@ class Part(Base, TenantScopedMixin, TimestampMixin): description_spanish: Mapped[Optional[str]] = mapped_column(String(500)) description_english: Mapped[Optional[str]] = mapped_column(String(500)) part_class: Mapped[Optional[str]] = mapped_column(String(8)) + material_type: Mapped[Optional[str]] = mapped_column(String(10)) unit_of_measure: Mapped[Optional[str]] = mapped_column( String(5) ) From 7249607fd78abdf22999bed6ecffbde7b8531138 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Wed, 7 Jan 2026 10:32:24 -0600 Subject: [PATCH 20/37] Un comit de guardado de seguridad --- frontend/src/lib/api/dashboard/a76/parts.ts | 2 + .../src/routes/dashboard/classes/+page.svelte | 346 ------------------ .../general_catalogs/ports/+page.svelte | 2 +- .../goods/parts/edit/[[id]]/+page.svelte | 115 ++++-- 4 files changed, 87 insertions(+), 378 deletions(-) delete mode 100644 frontend/src/routes/dashboard/classes/+page.svelte diff --git a/frontend/src/lib/api/dashboard/a76/parts.ts b/frontend/src/lib/api/dashboard/a76/parts.ts index 108934b2..3ae0b2a9 100644 --- a/frontend/src/lib/api/dashboard/a76/parts.ts +++ b/frontend/src/lib/api/dashboard/a76/parts.ts @@ -12,6 +12,7 @@ export interface Part { part_number: string; commercial_part_number: string | null; part_class: string | null; + material_type?: string | null; // Descripciones description_spanish: string | null; @@ -59,6 +60,7 @@ export interface PartCreate { description_english?: string | null; commercial_part_number?: string | null; part_class?: string | null; + material_type?: string | null; unit_of_measure: string; alternate_unit_measure?: string | null; diff --git a/frontend/src/routes/dashboard/classes/+page.svelte b/frontend/src/routes/dashboard/classes/+page.svelte deleted file mode 100644 index 247de471..00000000 --- a/frontend/src/routes/dashboard/classes/+page.svelte +++ /dev/null @@ -1,346 +0,0 @@ - - -
- -
-
-

Clases A76

-

- Gestiona las clases de materiales del sistema -

-
- -
- - - - - - - Filtros - Filtra las clases por diferentes criterios - - -
{ e.preventDefault(); applyFilters(); }} class="grid grid-cols-1 md:grid-cols-4 gap-4"> -
- - -
- -
- - -
- -
- - -
-
-
-
- - - {#if error} - - - Error - {error} - - - {/if} - - - - -
-
- Listado de Clases - - Mostrando {allItems.length} de {totalItems} registros - -
- -
-
- - - - -
-
- - - diff --git a/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte b/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte index e14df2cc..c870f080 100644 --- a/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte +++ b/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte @@ -4,7 +4,7 @@ import { browser } from '$app/environment'; import { createColumns } from '$lib/components/dashboard/ports/columns'; import CreateEditDialog from '$lib/components/dashboard/ports/create-edit-dialog.svelte'; - import DataTable from '$lib/components/dashboard/units_of_measure/ace/data-table.svelte'; + import DataTable from '$lib/components/dashboard/general_catalogs/units_of_measure/ace/data-table.svelte'; import { Button } from '$lib/components/ui/button'; import { Input } from '$lib/components/ui/input'; import { Plus } from 'lucide-svelte'; diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte index 13637b32..f78c1d18 100644 --- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte @@ -17,7 +17,7 @@ import { ArrowLeft, LoaderCircle, Save, Package, DollarSign, FileText, Settings, Image as ImageIcon, Search, - UserCheck, CheckCircle2, XCircle, Tag, Layers + UserCheck, CheckCircle2, XCircle, Tag, Layers, Scale } from 'lucide-svelte'; // Stores & APIs @@ -25,18 +25,19 @@ import { partsApi, type PartCreate } from '$lib/api/dashboard/a76/parts'; import { clientsProvidersApi } from '$lib/api/dashboard/a76/clients-providers'; import { classesApi } from '$lib/api/dashboard/a76/classes'; - import { materialTypesApi } from '$lib/api/dashboard/a76/material-types'; - + import { materialTypesApi } from '$lib/api/dashboard/a76/material-types'; + // Modales import ClientSelectorDialog from '$lib/components/dashboard/parts/client-selector-dialog.svelte'; import ClassSelectorDialog from '$lib/components/dashboard/parts/class-selector-dialog.svelte'; import MaterialTypeSelectorDialog from '$lib/components/dashboard/parts/material-type-selector-dialog.svelte'; - + // --- 1. IDENTIFICACIÓN --- let id = $derived($page.params.id === 'new' ? null : Number($page.params.id)); let isEdit = $derived(!!id); let title = $derived(isEdit ? "Editar Parte" : "Nueva Parte"); + // --- 2. ESTADOS --- let loading = $state(false); let error = $state(null); @@ -59,10 +60,10 @@ // General description_spanish: '', description_english: '', - part_class: '', - material_type_key: '', + part_class: '', + material_type: '', // Corregido: coincide con backend country_of_origin: 'MEX', - unit_of_measure: 'PZ', + unit_of_measure: 'PZ', // U.M. TIGIE // Costos y Pesos unit_weight: 0, @@ -81,14 +82,17 @@ // Opcionales 2 fda_key: '', - // Otros + // Otros (Comerciales) commercial_part_number: '', + alternate_unit_measure: '', // U.M. Comercial + + // Regulatorios fraction: '', eccn: '', license_code: '', export_code: '', exclusion_symbol: '', - alternate_unit_measure: '', + is_active: true }); @@ -122,8 +126,7 @@ description_english: d.description_english || '', part_class: d.part_class || '', - // OJO: Asegúrate que tu backend devuelva este campo si existe en BD - material_type_key: (d as any).material_type_key || '', + material_type: d.material_type || '', // Corregido country_of_origin: d.country_of_origin || 'MEX', unit_of_measure: d.unit_of_measure || 'PZ', @@ -151,7 +154,7 @@ // Cargar datos visuales if (d.client_id) await fetchClientName(d.client_id, companyId); if (d.part_class) await fetchClassDesc(d.part_class, companyId); - if ((d as any).material_type_key) await fetchMaterialName((d as any).material_type_key); + if (d.material_type) await fetchMaterialName(d.material_type); } } catch (e) { error = "Error al cargar la parte"; @@ -161,6 +164,7 @@ } } + // --- HELPERS VISUALES --- async function fetchClientName(clientId: number, companyId: number) { try { const res = await clientsProvidersApi.get(clientId, companyId); @@ -194,8 +198,7 @@ } catch (e) { console.log("Error visual material", e); } } - - + // --- HANDLERS --- function handleClientSelect(client: any) { formData.client_id = client.id; selectedClientName = client.name; @@ -208,10 +211,11 @@ } function handleMaterialSelect(item: any) { - formData.material_type_key = item.key; + formData.material_type = item.key; selectedMaterialDesc = item.description; } + // --- SUBMIT --- async function handleSubmit() { error = null; const activeCompanyId = companyStore.activeCompany?.id; @@ -221,14 +225,12 @@ loading = true; try { - const commonData = { - description_spanish: formData.description_spanish || null, description_english: formData.description_english || null, - part_class: formData.part_class || null, - material_type_key: formData.material_type_key || null, + part_class: formData.part_class || null, + material_type: formData.material_type || null, // Corregido country_of_origin: formData.country_of_origin || 'MEX', unit_of_measure: formData.unit_of_measure, @@ -253,11 +255,9 @@ }; if (isEdit && id) { - const response = await partsApi.update(id, commonData, activeCompanyId); if (response.error) throw new Error(response.error); } else { - const createData: PartCreate = { ...commonData, company_id: activeCompanyId, @@ -366,7 +366,7 @@
Opcional: Clasificación adicional por tipo de material.

-
+ + +
+ + + + {formData.unit_of_measure || 'Seleccione...'} + + + + Comunes + Pieza (PZ) + Kilogramo (KG) + Litro (L) + Metro Lineal (M) + Metro Cuadrado (M2) + Juego (JGO) + Par (PAR) + + +
@@ -498,6 +519,7 @@ +
@@ -528,15 +550,45 @@
{/if}
-
- - + +
+

+ Datos Comerciales (Factura) +

+
+ +
+ + +
+ +
+ + + + {formData.alternate_unit_measure || 'Seleccione...'} + + + + Comunes + Pieza (PZ) + Kilogramo (KG) + Litro (L) + Metro Lineal (M) + Metro Cuadrado (M2) + Juego (JGO) + Par (PAR) + Set (SET) + Caja (CAJA) + Paquete (PK) + + + +
+
+
- - -
-

Datos Regulatorios

@@ -561,6 +613,7 @@
+
From c57ddada6ee061dc295586fb1942fe4046884b7e Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Wed, 7 Jan 2026 11:36:35 -0600 Subject: [PATCH 21/37] Se agrego la forma de seleccion de clase, cliente y unidades de medida --- .../a76/general_catalogs/units-of-measure.ts | 37 +++- .../parts/unit-measure-dialog.svelte | 179 ++++++++++++++++++ .../goods/parts/edit/[[id]]/+page.svelte | 100 ++++++---- 3 files changed, 275 insertions(+), 41 deletions(-) create mode 100644 frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte diff --git a/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts b/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts index 2aa553ca..f680bae3 100644 --- a/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts +++ b/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts @@ -183,7 +183,7 @@ export interface UnitOfMeasureGeneralUpdate { } export interface UnitOfMeasureGeneralListResponse { - items: UnitOfMeasureGeneral[]; + items: UnitOfMeasureGeneral[]; total: number; page: number; page_size: number; @@ -273,3 +273,38 @@ export async function updateUnitOfMeasureCustoms(id: number, data: UnitOfMeasure export async function deleteUnitOfMeasureCustoms(id: number, companyId: number): Promise> { return await api.delete(`/v1/a76/units-of-measure/customs/${id}/?company_id=${companyId}`); } + +export interface UnitOfMeasure { + id: number; + code: string; // Ej: KG, PZ + description: string | null; + description_en: string | null; + customs_code: string | null; + american_code: string | null; + created_at: string | null; + updated_at: string | null; +} + +export interface UnitOfMeasureListResponse { + items: UnitOfMeasure[]; + total: number; + page: number; + page_size: number; + pages: number; +} + +export async function getUnitsOfMeasure( + page: number = 1, + pageSize: number = 50, + companyId: number, + filters: Record = {} +): Promise> { + const queryParams = new URLSearchParams({ + page: page.toString(), + page_size: pageSize.toString(), + company_id: companyId.toString(), + ...filters + }); + // Apunta a /v1/a76/units-of-measure/ (La ruta base del router) + return await api.get(`/v1/a76/units-of-measure/?${queryParams.toString()}`); +} \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte b/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte new file mode 100644 index 00000000..0deb485c --- /dev/null +++ b/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte @@ -0,0 +1,179 @@ + + + + + + Seleccionar Unidad de Medida + + Busca y selecciona una unidad del catálogo maestro. + + + +
+
+ + +
+ +
+ {#if loading} +
+ +
+ {/if} + + + + + Código + Descripción + + + + + {#if items.length === 0 && !loading} + + + No se encontraron resultados + + + {:else} + {#each items as item} + handleSelect(item)} + > + {item.code} + +
+ {item.description || '-'} + {#if item.description_en} + {item.description_en} + {/if} +
+
+ + + +
+ {/each} + {/if} +
+
+
+ +
+ Página {page} de {totalPages} +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte index f78c1d18..dd3723c2 100644 --- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte @@ -31,6 +31,7 @@ import ClientSelectorDialog from '$lib/components/dashboard/parts/client-selector-dialog.svelte'; import ClassSelectorDialog from '$lib/components/dashboard/parts/class-selector-dialog.svelte'; import MaterialTypeSelectorDialog from '$lib/components/dashboard/parts/material-type-selector-dialog.svelte'; + import UnitMeasureSelectorDialog from '$lib/components/dashboard/parts/unit-measure-dialog.svelte'; // --- 1. IDENTIFICACIÓN --- let id = $derived($page.params.id === 'new' ? null : Number($page.params.id)); @@ -45,6 +46,8 @@ let showClientModal = $state(false); let showClassModal = $state(false); let showMaterialModal = $state(false); + let showUOMModal = $state(false); + let showAltUOMModal = $state(false); // Descripciones Visuales let selectedClientName = $state(""); @@ -61,7 +64,7 @@ description_spanish: '', description_english: '', part_class: '', - material_type: '', // Corregido: coincide con backend + material_type: '', country_of_origin: 'MEX', unit_of_measure: 'PZ', // U.M. TIGIE @@ -215,6 +218,14 @@ selectedMaterialDesc = item.description; } + function handleUOMSelect(item: any) { + formData.unit_of_measure = item.code; +} + + function handleAltUOMSelect(item: any) { + formData.alternate_unit_measure = item.code; + } + // --- SUBMIT --- async function handleSubmit() { error = null; @@ -393,24 +404,25 @@
-->
- - - - {formData.unit_of_measure || 'Seleccione...'} - - - - Comunes - Pieza (PZ) - Kilogramo (KG) - Litro (L) - Metro Lineal (M) - Metro Cuadrado (M2) - Juego (JGO) - Par (PAR) - - - + +
+
+
+ +
+ showUOMModal = true} + /> +
+ +
@@ -563,27 +575,25 @@
- - - - {formData.alternate_unit_measure || 'Seleccione...'} - - - - Comunes - Pieza (PZ) - Kilogramo (KG) - Litro (L) - Metro Lineal (M) - Metro Cuadrado (M2) - Juego (JGO) - Par (PAR) - Set (SET) - Caja (CAJA) - Paquete (PK) - - - + +
+
+
+ +
+ showAltUOMModal = true} + /> +
+ +
@@ -658,6 +668,16 @@ onSelect={handleMaterialSelect} /> + + + + \ No newline at end of file diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte index 442e7bdb..8060ceb7 100644 --- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte @@ -1,686 +1,9 @@ -
-
- -
-

{title}

-

Gestión detallada de números de parte.

-
-
- - {#if error} -
- ⚠️ {error} -
- {/if} - -
{ e.preventDefault(); handleSubmit(); }} class="space-y-6"> - - - - -
- - - -
- - -
- -
-

- Descripción -

-
-
- -
@@ -65,6 +84,7 @@
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte index ae9cdac2..194af261 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte @@ -49,7 +49,7 @@ Temporary Import Item - Order Number: {invoice?.invoice_number || 'N/A'} | Line: 1 + Order Number: {invoice?.invoice_number || 'N/A'} | Line: currentline @@ -58,11 +58,23 @@
- + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if}
- + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if}
@@ -78,29 +90,48 @@
- - + {#if editingItem.lines && editingItem.lines.length > 0} + + + {/if}
- + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if} - + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if} - + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if} - + {#if editingItem.lines && editingItem.lines.length > 0} + + {/if}
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/main-data.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/main-data.svelte index 6230db8e..891d798c 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/main-data.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/main-data.svelte @@ -1,6 +1,19 @@
@@ -11,7 +24,7 @@
- +
@@ -20,13 +33,13 @@
- +
- - +
@@ -37,14 +50,14 @@
- + USD
- +
@@ -54,20 +67,20 @@
- +
- + +
- 0.00 +
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/packages-section.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/packages-section.svelte index dfc5fd75..40183ca1 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/packages-section.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/packages-section.svelte @@ -1,6 +1,21 @@
@@ -9,11 +24,11 @@
- +
- +
@@ -25,6 +40,7 @@
+
@@ -34,11 +50,11 @@
- +
- +
@@ -50,37 +66,37 @@
- +
- +
- +
- Advalorem: 0.00 + Advalorem: {customs.advalorem_american || '0.00'}
- +
- +
- +
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/summary-section.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/summary-section.svelte index 186aedfe..3c37fa81 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/summary-section.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/summary-section.svelte @@ -1,4 +1,7 @@
@@ -7,19 +10,19 @@
RETURN QUANTITY SUB-ITEMS
-
Temporary: 0.00000000
+
Temporary: {quantities.quantity_temp_export?.toFixed(8) || '0.00000000'}
Replacement or Change: 0.00000000
-
Definitive: 0.00000000
-
Returned Values: 0.00000000
-
Returned Values: 0.00000000
+
Definitive: {quantities.quantity_returned?.toFixed(8) || '0.00000000'}
+
Returned Values: {financials.value_returned_usd?.toFixed(8) || '0.00000000'}
+
Returned Values: {financials.value_returned_mxn?.toFixed(8) || '0.00000000'}
WEIGHTS (KILOS)
WEIGHTS (Pounds)
-
Net: 0.00000000
+
Net: {quantities.net_weight?.toFixed(8) || '0.00000000'}
0.00000000
-
Whole: 0.00000000
+
Whole: {quantities.gross_weight?.toFixed(8) || '0.00000000'}
0.00000000
@@ -31,16 +34,16 @@
(Dollars)
(Pesos)
-
Cost: 0.00000000
-
0.00000000
-
Value: 0.00000000
-
0.00000000
+
Cost: {financials.unit_cost_usd?.toFixed(8) || '0.00000000'}
+
{financials.unit_cost_mxn?.toFixed(8) || '0.00000000'}
+
Value: {financials.value_usd?.toFixed(8) || '0.00000000'}
+
{financials.value_mxn?.toFixed(8) || '0.00000000'}
-
Capture Cost: 0.00000000 USD
-
Capture Value: 0.00000000 USD
-
Customs Value: 0.00000000 USD
+
Capture Cost: {financials.unit_cost_capture?.toFixed(8) || '0.00000000'} USD
+
Capture Value: {financials.value_usd?.toFixed(8) || '0.00000000'} USD
+
Customs Value: {financials.customs_value_usd?.toFixed(8) || '0.00000000'} USD
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-continuation.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-continuation.svelte index cd4ff233..b44702d5 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-continuation.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-continuation.svelte @@ -3,6 +3,23 @@ import { Input } from '$lib/components/ui/input'; import { Label } from '$lib/components/ui/label'; import { Checkbox } from '$lib/components/ui/checkbox'; + import type { LineItem } from '$lib/api/dashboard/a76/items'; + + let { + lineItem = $bindable() + }: { + lineItem: LineItem; + } = $props(); + + let taxPaidValue = $derived(lineItem.tax_payment ? 'si' : 'no'); + function setTaxPaid(val: string) { + lineItem.tax_payment = val === 'si'; + } + + let hasCertificateValue = $derived(lineItem.has_certificate ? 'si' : 'no'); + function setHasCertificate(val: string) { + lineItem.has_certificate = val === 'si'; + }
@@ -12,7 +29,10 @@
TAX PAID - +
@@ -27,7 +47,7 @@
- +
@@ -37,7 +57,8 @@
- + +
@@ -45,7 +66,10 @@
Has Certificate of Origin? - +
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-identifiers.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-identifiers.svelte index 63974265..3a3034c3 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-identifiers.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-identifiers.svelte @@ -1,6 +1,9 @@
@@ -9,7 +12,7 @@
- +
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-labeling.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-labeling.svelte index 3dd58e63..cacb0306 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-labeling.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-labeling.svelte @@ -1,6 +1,9 @@
@@ -21,6 +24,7 @@ diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte index d5f242f6..240a6c50 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte @@ -1,5 +1,8 @@
@@ -9,6 +12,7 @@ diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/items-tab-form.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/items-tab-form.svelte index e30f3a3d..3b10300c 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/items-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/items-tab-form.svelte @@ -112,23 +112,139 @@ isEditMode = false; showItemSheet = true; - // Auto-asignar valores desde la factura + // Auto-asignar valores desde la factura con estructura completa editingItem = { invoice_id: invoice.id, reference_number: '', order: invoice.purchase_order || '', warehouse: '', - location: '' + location: '', + lines: [{ + line_number: 1, + // LineItem fields + part_number: undefined, + component_part_number: undefined, + class_code: undefined, + identifier: undefined, + unit_of_measure: undefined, + alternate_unit: undefined, + permit_number: undefined, + page_line: undefined, + has_certificate: false, + certificate_number: undefined, + is_subitem: false, + includes_subitems: false, + tax_payment: false, + payment_method: undefined, + igi_amount: undefined, + // Nested relations + financial: { + unit_cost_usd: undefined, + unit_cost_mxn: undefined, + unit_cost_capture: undefined, + unit_cost_commercial_usd: undefined, + value_usd: undefined, + value_mxn: undefined, + value_returned_usd: undefined, + value_returned_mxn: undefined, + customs_value_usd: undefined, + }, + quantity: { + quantity: undefined, + unit_of_measure: undefined, + quantity_temp_export: undefined, + quantity_returned: undefined, + net_weight: undefined, + gross_weight: undefined, + package_key: undefined, + package_quantity: undefined, + package_description: undefined, + }, + customs: { + fraction: undefined, + fraction_type: 'GENERAL', + american_fraction: undefined, + origin_country: undefined, + destination_country: undefined, + advalorem: undefined, + advalorem_american: undefined, + sector: undefined, + }, + description: { + description_spanish: undefined, + description_english: undefined, + extra_description: undefined, + additional_info_spanish: undefined, + brand: undefined, + model: undefined, + has_serial: false, + }, + reference: { + serie_id: undefined, + }, + }] }; } function handleEdit(item: Item) { isEditMode = true; selectedItem = item; - editingItem = { ...item }; + // Deep clone and normalize numeric values + editingItem = normalizeItemData({ ...item }); showItemSheet = true; } + // Normalize numeric values from strings to numbers + function normalizeItemData(item: Partial): Partial { + if (item.lines && item.lines.length > 0) { + item.lines = item.lines.map(line => { + const normalizedLine = { ...line }; + + // Normalize financials + if (normalizedLine.financial) { + normalizedLine.financial = { + ...normalizedLine.financial, + unit_cost_usd: normalizedLine.financial.unit_cost_usd != null + ? Number(normalizedLine.financial.unit_cost_usd) + : undefined, + unit_cost_mxn: normalizedLine.financial.unit_cost_mxn != null + ? Number(normalizedLine.financial.unit_cost_mxn) + : undefined, + value_usd: normalizedLine.financial.value_usd != null + ? Number(normalizedLine.financial.value_usd) + : undefined, + value_mxn: normalizedLine.financial.value_mxn != null + ? Number(normalizedLine.financial.value_mxn) + : undefined, + }; + } + + // Normalize quantities + if (normalizedLine.quantity) { + normalizedLine.quantity = { + ...normalizedLine.quantity, + quantity: normalizedLine.quantity.quantity != null + ? Number(normalizedLine.quantity.quantity) + : undefined, + net_weight: normalizedLine.quantity.net_weight != null + ? Number(normalizedLine.quantity.net_weight) + : undefined, + gross_weight: normalizedLine.quantity.gross_weight != null + ? Number(normalizedLine.quantity.gross_weight) + : undefined, + package_quantity: normalizedLine.quantity.package_quantity != null + ? Number(normalizedLine.quantity.package_quantity) + : undefined, + }; + } + + return normalizedLine; + }); + } + + return item; + } + function handleDelete(item: Item) { selectedItem = item; showDeleteDialog = true; @@ -144,7 +260,8 @@ reference_number: editingItem.reference_number, order: editingItem.order, warehouse: editingItem.warehouse, - location: editingItem.location + location: editingItem.location, + lines: editingItem.lines || [] }); // Recargar items @@ -174,7 +291,8 @@ reference_number: editingItem.reference_number, order: editingItem.order, warehouse: editingItem.warehouse, - location: editingItem.location + location: editingItem.location, + lines: editingItem.lines || [] }); // Recargar items diff --git a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts index 2c4f6bdb..88f965d2 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts +++ b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts @@ -110,7 +110,7 @@ function buildInvoicePayload(formData: FormDataSet): CreateInvoiceData | UpdateI // Solo agregar sub-recursos si tienen valores reales // Compliance MX - const hasComplianceValue = InvoiceTopFieldsFormData?.pedimento || InvoiceTopFieldsFormData?.remesa || generalFormData?.aduana || + const hasComplianceValue = InvoiceTopFieldsFormData?.pedimento_id || InvoiceTopFieldsFormData?.remesa || generalFormData?.aduana || generalFormData?.provider_id || generalFormData?.sold_to_id || generalFormData?.shipped_to_id || generalFormData?.customs_broker_id || observationFormData?.movement_type || observationFormData?.enclosure || @@ -158,7 +158,7 @@ function buildInvoicePayload(formData: FormDataSet): CreateInvoiceData | UpdateI function buildComplianceMxData(InvoiceTopFieldsFormData: any, generalFormData: any, othersFormData: any, observationFormData: any) { return { // Pedimento fields - desde InvoiceTopFieldsFormData - pedimento: InvoiceTopFieldsFormData?.pedimento || null, + pedimento_id: InvoiceTopFieldsFormData?.pedimento_id ? Number(InvoiceTopFieldsFormData.pedimento_id) : null, remesa: Number(InvoiceTopFieldsFormData?.remesa || null), is_pedimento_pending: Boolean(InvoiceTopFieldsFormData?.is_pedimento_pending || false), // Fields from generalFormData From c725a6b11a350f2991e49ca33028981739f114bf Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 8 Jan 2026 16:25:28 -0600 Subject: [PATCH 31/37] feat: Refactor line item schemas and service methods for improved readability and consistency --- .../modules/a76/items/line_items/schemas.py | 196 ++++++++++++------ backend/api/v1/modules/a76/items/service.py | 48 +++-- 2 files changed, 160 insertions(+), 84 deletions(-) diff --git a/backend/api/v1/modules/a76/items/line_items/schemas.py b/backend/api/v1/modules/a76/items/line_items/schemas.py index 771196fb..4921233f 100644 --- a/backend/api/v1/modules/a76/items/line_items/schemas.py +++ b/backend/api/v1/modules/a76/items/line_items/schemas.py @@ -6,162 +6,236 @@ from pydantic import BaseModel, Field, ConfigDict, field_validator from ..line_customs.schemas import ( LineCustomCreate, LineCustomUpdate, - LineCustomResponse + LineCustomResponse, ) from ..line_descriptions.schemas import ( LineDescriptionCreate, LineDescriptionUpdate, - LineDescriptionResponse + LineDescriptionResponse, ) from ..line_quantities.schemas import ( LineQuantityCreate, LineQuantityUpdate, - LineQuantityResponse + LineQuantityResponse, ) from ..line_financials.schemas import ( LineFinancialCreate, LineFinancialUpdate, - LineFinancialResponse + LineFinancialResponse, ) from ..line_references.schemas import ( LineReferenceCreate, LineReferenceUpdate, - LineReferenceResponse + LineReferenceResponse, ) # ============================================================================ # LINE ITEM SCHEMAS # ============================================================================ + class LineItemBase(BaseModel): """Base schema for line items""" + line_number: int = Field(..., description="Line number") - + # Part identification part_number: Optional[str] = Field(None, max_length=50, description="Part number") - component_part_number: Optional[str] = Field(None, max_length=50, description="Component part number") + component_part_number: Optional[str] = Field( + None, max_length=50, description="Component part number" + ) class_code: Optional[str] = Field(None, max_length=20, description="Class code") - - @field_validator('class_code', 'part_number', 'component_part_number', 'unit_of_measure', 'alternate_unit', mode='before') + + @field_validator( + "class_code", + "part_number", + "component_part_number", + "unit_of_measure", + "alternate_unit", + mode="before", + ) @classmethod def convert_to_string(cls, v): """Convert integers to strings for FK fields""" if v is not None and not isinstance(v, str): return str(v) return v - + # Unit of measure - unit_of_measure: Optional[str] = Field(None, max_length=10, description="Unit of measure") - alternate_unit: Optional[str] = Field(None, max_length=10, description="Alternate unit") + unit_of_measure: Optional[str] = Field( + None, max_length=10, description="Unit of measure" + ) + alternate_unit: Optional[str] = Field( + None, max_length=10, description="Alternate unit" + ) uma_key: Optional[str] = Field(None, max_length=2, description="UMA key") - auxiliary_unit: Optional[str] = Field(None, max_length=5, description="Auxiliary unit") - + auxiliary_unit: Optional[str] = Field( + None, max_length=5, description="Auxiliary unit" + ) + # Permits and certificates - permit_number: Optional[str] = Field(None, max_length=20, description="Permit number") + permit_number: Optional[str] = Field( + None, max_length=20, description="Permit number" + ) page_line: Optional[str] = Field(None, max_length=10, description="Page line") has_certificate: Optional[bool] = Field(None, description="Has certificate") - certificate_number: Optional[str] = Field(None, max_length=10, description="Certificate number") - octave_permit: Optional[str] = Field(None, max_length=20, description="Octave permit") + certificate_number: Optional[str] = Field( + None, max_length=10, description="Certificate number" + ) + octave_permit: Optional[str] = Field( + None, max_length=20, description="Octave permit" + ) permits_ped: Optional[str] = Field(None, max_length=500, description="PED permits") - + # FDA has_fda_code: Optional[bool] = Field(None, description="Has FDA code") fda_key: Optional[str] = Field(None, max_length=10, description="FDA key") - + # Subitem flags is_subitem: Optional[bool] = Field(None, description="Is subitem") contains_subitems: Optional[bool] = Field(None, description="Contains subitems") includes_subitems: Optional[bool] = Field(None, description="Includes subitems") subitem_number: Optional[bool] = Field(None, description="Subitem number") - + # Special flags - is_military_mcia: Optional[bool] = Field(None, description="Is military merchandise") - + is_military_mcia: Optional[bool] = Field( + None, description="Is military merchandise" + ) + # IV32 - iv32_type_key: Optional[str] = Field(None, max_length=5, description="IV32 type key") + iv32_type_key: Optional[str] = Field( + None, max_length=5, description="IV32 type key" + ) iv32_number: Optional[str] = Field(None, max_length=35, description="IV32 number") - + # Export specific - scrap_invoice: Optional[str] = Field(None, max_length=15, description="Scrap invoice") - consecutive_destination: Optional[int] = Field(None, description="Consecutive destination") + scrap_invoice: Optional[str] = Field( + None, max_length=15, description="Scrap invoice" + ) + consecutive_destination: Optional[int] = Field( + None, description="Consecutive destination" + ) ctm_section: Optional[str] = Field(None, max_length=3, description="CTM section") - + # Tax payment tax_payment: Optional[bool] = Field(None, description="Tax payment") - payment_method: Optional[str] = Field(None, max_length=9, description="Payment method") + payment_method: Optional[str] = Field( + None, max_length=9, description="Payment method" + ) igi_amount: Optional[Decimal] = Field(None, description="IGI amount") - igi_payment_method: Optional[str] = Field(None, max_length=9, description="IGI payment method") - + igi_payment_method: Optional[str] = Field( + None, max_length=9, description="IGI payment method" + ) + # FCC fcc_key: Optional[str] = Field(None, max_length=30, description="FCC key") - + # Valuation method - valuation_method: Optional[str] = Field(None, max_length=2, description="Valuation method") - valuation_determined_value: Optional[Decimal] = Field(None, description="Valuation determined value") - valuation_reason: Optional[str] = Field(None, max_length=500, description="Valuation reason") - + valuation_method: Optional[str] = Field( + None, max_length=2, description="Valuation method" + ) + valuation_determined_value: Optional[Decimal] = Field( + None, description="Valuation determined value" + ) + valuation_reason: Optional[str] = Field( + None, max_length=500, description="Valuation reason" + ) + # Container rules - container_rule: Optional[str] = Field(None, max_length=50, description="Container rule") - container_parts_ii: Optional[str] = Field(None, max_length=50, description="Container parts II") - + container_rule: Optional[str] = Field( + None, max_length=50, description="Container rule" + ) + container_parts_ii: Optional[str] = Field( + None, max_length=50, description="Container parts II" + ) + # APHIS consecutive_aphis: Optional[int] = Field(None, description="Consecutive APHIS") - + # BOM/Commercial bom_version: Optional[int] = Field(None, description="BOM version") bill_version: Optional[int] = Field(None, description="Bill version") - + # TLCAN value tlcan_value: Optional[Decimal] = Field(None, description="TLCAN value") - + # Identifier identifier: Optional[str] = Field(None, max_length=2, description="Identifier") - + # Validation fields validation_zero: Optional[int] = Field(None, description="Validation zero") validation_one: Optional[int] = Field(None, description="Validation one") - + # Material type - material_type: Optional[str] = Field(None, max_length=50, description="Material type") - + material_type: Optional[str] = Field( + None, max_length=50, description="Material type" + ) + # Order concept order_type: Optional[str] = Field(None, max_length=50, description="Order type") line_concept: Optional[str] = Field(None, max_length=50, description="Line concept") - + # Review dispatch - review_dispatch: Optional[str] = Field(None, max_length=10, description="Review dispatch") - + review_dispatch: Optional[str] = Field( + None, max_length=10, description="Review dispatch" + ) + # Take component from PT take_component_pt: Optional[int] = Field(None, description="Take component from PT") - + # Pallet pallet2: Optional[int] = Field(None, description="Pallet 2") - + # Wildcard field - wildcard_field: Optional[str] = Field(None, max_length=100, description="Wildcard field") + wildcard_field: Optional[str] = Field( + None, max_length=100, description="Wildcard field" + ) class LineItemCreate(LineItemBase): """Schema for creating line item with all nested data""" - financial: Optional[LineFinancialCreate] = Field(None, description="Financial data for this line") - quantity: Optional[LineQuantityCreate] = Field(None, description="Quantity data for this line") - customs: Optional[LineCustomCreate] = Field(None, description="Customs data for this line") - description: Optional[LineDescriptionCreate] = Field(None, description="Description data for this line") - reference: Optional[LineReferenceCreate] = Field(None, description="Reference data for this line") + + financial: Optional[LineFinancialCreate] = Field( + None, description="Financial data for this line" + ) + quantity: Optional[LineQuantityCreate] = Field( + None, description="Quantity data for this line" + ) + customs: Optional[LineCustomCreate] = Field( + None, description="Customs data for this line" + ) + description: Optional[LineDescriptionCreate] = Field( + None, description="Description data for this line" + ) + reference: Optional[LineReferenceCreate] = Field( + None, description="Reference data for this line" + ) class LineItemUpdate(LineItemBase): """Schema for updating line item with all nested data""" + line_number: Optional[int] = Field(None, description="Line number") - financial: Optional[LineFinancialUpdate] = Field(None, description="Financial data for this line") - quantity: Optional[LineQuantityUpdate] = Field(None, description="Quantity data for this line") - customs: Optional[LineCustomUpdate] = Field(None, description="Customs data for this line") - description: Optional[LineDescriptionUpdate] = Field(None, description="Description data for this line") - reference: Optional[LineReferenceUpdate] = Field(None, description="Reference data for this line") + financial: Optional[LineFinancialUpdate] = Field( + None, description="Financial data for this line" + ) + quantity: Optional[LineQuantityUpdate] = Field( + None, description="Quantity data for this line" + ) + customs: Optional[LineCustomUpdate] = Field( + None, description="Customs data for this line" + ) + description: Optional[LineDescriptionUpdate] = Field( + None, description="Description data for this line" + ) + reference: Optional[LineReferenceUpdate] = Field( + None, description="Reference data for this line" + ) class LineItemResponse(LineItemBase): """Schema for line item response with all nested data""" + id: int item_id: int financial: Optional[LineFinancialResponse] = None diff --git a/backend/api/v1/modules/a76/items/service.py b/backend/api/v1/modules/a76/items/service.py index 4cc4c946..74ba2da1 100644 --- a/backend/api/v1/modules/a76/items/service.py +++ b/backend/api/v1/modules/a76/items/service.py @@ -36,10 +36,7 @@ class ItemService: @staticmethod def get_by_id( - db: Session, - item_id: int, - tenant_id: int, - company_id: int + db: Session, item_id: int, tenant_id: int, company_id: int ) -> Optional[Item]: """Get an item by ID with tenant/company validation""" return ( @@ -91,8 +88,7 @@ class ItemService: if filters.get("item_type"): query = query.filter(Item.item_type == filters["item_type"]) if filters.get("system_origin"): - query = query.filter(Item.system_origin == - filters["system_origin"]) + query = query.filter(Item.system_origin == filters["system_origin"]) if filters.get("search"): search_term = f"%{filters['search']}%" query = query.filter( @@ -186,8 +182,13 @@ class ItemService: print(f" Has reference: {reference_data is not None}") line_dict = line_data.model_dump( - exclude={"financial", "quantity", - "customs", "description", "reference"} + exclude={ + "financial", + "quantity", + "customs", + "description", + "reference", + } ) line_dict["item_id"] = db_item.id line_dict["tenant_id"] = tenant_id @@ -274,8 +275,7 @@ class ItemService: # Extract lines data lines_data = item_data.lines - item_dict = item_data.model_dump( - exclude={"lines"}, exclude_unset=True) + item_dict = item_data.model_dump(exclude={"lines"}, exclude_unset=True) # Update item fields for key, value in item_dict.items(): @@ -298,46 +298,48 @@ class ItemService: reference_data = line_data.reference line_dict = line_data.model_dump( - exclude={"financial", "quantity", - "customs", "description", "reference"}, - exclude_unset=True + exclude={ + "financial", + "quantity", + "customs", + "description", + "reference", + }, + exclude_unset=True, ) line_dict["item_id"] = db_item.id line_dict["tenant_id"] = tenant_id line_dict["company_id"] = company_id - + db_line = LineItem(**line_dict) db.add(db_line) db.flush() # Create nested data if provided if financial_data is not None: - financial_dict = financial_data.model_dump( - exclude_unset=True) + financial_dict = financial_data.model_dump(exclude_unset=True) financial_dict["item_line_id"] = db_line.id db.add(LineFinancial(**financial_dict)) if quantity_data is not None: - quantity_dict = quantity_data.model_dump( - exclude_unset=True) + quantity_dict = quantity_data.model_dump(exclude_unset=True) quantity_dict["item_line_id"] = db_line.id db.add(LineQuantity(**quantity_dict)) if customs_data is not None: - customs_dict = customs_data.model_dump( - exclude_unset=True) + customs_dict = customs_data.model_dump(exclude_unset=True) customs_dict["item_line_id"] = db_line.id db.add(LineCustom(**customs_dict)) if description_data is not None: description_dict = description_data.model_dump( - exclude_unset=True) + exclude_unset=True + ) description_dict["item_line_id"] = db_line.id db.add(LineDescription(**description_dict)) if reference_data is not None: - reference_dict = reference_data.model_dump( - exclude_unset=True) + reference_dict = reference_data.model_dump(exclude_unset=True) reference_dict["item_line_id"] = db_line.id db.add(LineReference(**reference_dict)) From ea0e57067828394539d84c7f23e970fc5572b96b Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Thu, 8 Jan 2026 16:33:43 -0600 Subject: [PATCH 32/37] feat: add fixed asset classes management page and embed functionality - Implemented a new page for managing fixed asset classes with full CRUD functionality. - Added filtering options for searching classes by code, description, type, and fraction. - Integrated dialogs for inserting, editing, and deleting classes with validation. - Enhanced error handling and user feedback with toast notifications. - Created an embedded iframe for the fixed asset classes page in the merchandise section. --- .../api/v1/modules/a24/fa/fa_classes/dto.py | 107 ++ .../v1/modules/a24/fa/fa_classes/models.py | 17 +- .../v1/modules/a24/fa/fa_classes/routes.py | 32 + .../v1/modules/a24/fa/fa_classes/service.py | 223 ++++ backend/api/v1/modules/a24/router.py | 14 + backend/api/v1/modules/a76/classes/dto.py | 79 +- backend/api/v1/modules/a76/classes/models.py | 2 +- backend/api/v1/modules/a76/classes/routes.py | 67 +- backend/api/v1/modules/a76/classes/service.py | 257 +++- backend/api/v1/router.py | 2 + backend/main.py | 25 +- .../src/lib/api/dashboard/a24/fa_classes.ts | 110 ++ frontend/src/lib/api/dashboard/a76/classes.ts | 7 + .../classes/forms/FixedAssetClassForm.svelte | 1177 +++++++++++++++++ .../customs_brokers/create-dialog.svelte | 4 +- .../src/lib/components/sidebar/modules.ts | 8 +- .../catalogs/fixed-asset-classes/+page.svelte | 914 +++++++++++++ .../fixed_asset_classes/embed/+page.svelte | 17 + 18 files changed, 3014 insertions(+), 48 deletions(-) create mode 100644 backend/api/v1/modules/a24/fa/fa_classes/dto.py create mode 100644 backend/api/v1/modules/a24/fa/fa_classes/routes.py create mode 100644 backend/api/v1/modules/a24/fa/fa_classes/service.py create mode 100644 backend/api/v1/modules/a24/router.py create mode 100644 frontend/src/lib/api/dashboard/a24/fa_classes.ts create mode 100644 frontend/src/lib/components/dashboard/classes/forms/FixedAssetClassForm.svelte create mode 100644 frontend/src/routes/dashboard/catalogs/fixed-asset-classes/+page.svelte create mode 100644 frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte diff --git a/backend/api/v1/modules/a24/fa/fa_classes/dto.py b/backend/api/v1/modules/a24/fa/fa_classes/dto.py new file mode 100644 index 00000000..671a010d --- /dev/null +++ b/backend/api/v1/modules/a24/fa/fa_classes/dto.py @@ -0,0 +1,107 @@ +""" +DTOs (Data Transfer Objects) para módulo de clases de activos fijos (FA) +""" + +from datetime import datetime +from decimal import Decimal +from typing import Optional + +from pydantic import BaseModel, ConfigDict, Field + + +class FAClassCreateDTO(BaseModel): + """DTO para crear una clase de activo fijo""" + + class_id: int = Field(..., description="ID de la clase base en a76.classes") + + import_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de importación" + ) + import_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de importación" + ) + export_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de exportación" + ) + export_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de exportación" + ) + depreciation_rate: Optional[Decimal] = Field( + None, description="Tasa de depreciación anual", ge=0, le=100 + ) + fda_code: Optional[str] = Field( + None, max_length=20, description="Código FDA" + ) + eccn_code: Optional[str] = Field( + None, max_length=20, description="Código ECCN (Export Control Classification Number)" + ) + class_enabled: Optional[bool] = Field( + True, description="Indica si la clase está habilitada" + ) + + class Config: + from_attributes = True + + +class FAClassUpdateDTO(BaseModel): + """DTO para actualizar una clase de activo fijo""" + + import_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de importación" + ) + import_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de importación" + ) + export_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de exportación" + ) + export_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de exportación" + ) + depreciation_rate: Optional[Decimal] = Field( + None, description="Tasa de depreciación anual", ge=0, le=100 + ) + fda_code: Optional[str] = Field( + None, max_length=20, description="Código FDA" + ) + eccn_code: Optional[str] = Field( + None, max_length=20, description="Código ECCN" + ) + class_enabled: Optional[bool] = Field( + None, description="Indica si la clase está habilitada" + ) + + class Config: + from_attributes = True + + +class FAClassResponseDTO(BaseModel): + """DTO para respuesta de clase de activo fijo""" + + id: int + tenant_id: int + company_id: int + class_id: int + import_tariff_code: Optional[str] = None + import_tariff_type: Optional[str] = None + export_tariff_code: Optional[str] = None + export_tariff_type: Optional[str] = None + depreciation_rate: Optional[Decimal] = None + fda_code: Optional[str] = None + eccn_code: Optional[str] = None + class_enabled: Optional[bool] = None + created_at: datetime + updated_at: datetime + + model_config = ConfigDict(from_attributes=True) + + +class FAClassListResponseDTO(BaseModel): + """DTO para respuesta de lista paginada de clases de activos fijos""" + + items: list[FAClassResponseDTO] + total: int + page: int + page_size: int + + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/a24/fa/fa_classes/models.py b/backend/api/v1/modules/a24/fa/fa_classes/models.py index 1f8f5fc4..90c8cb1f 100644 --- a/backend/api/v1/modules/a24/fa/fa_classes/models.py +++ b/backend/api/v1/modules/a24/fa/fa_classes/models.py @@ -1,4 +1,5 @@ from decimal import Decimal +from typing import Optional from api.v1.common.base_models import TenantScopedMixin, TimestampMixin from core.database import Base @@ -24,11 +25,11 @@ class QClasses(Base, TenantScopedMixin, TimestampMixin): id: Mapped[int] = mapped_column(Integer, primary_key=True) class_id: Mapped[int] = mapped_column(Integer, nullable=False) - import_tariff_code: Mapped[str] = mapped_column(String(10)) # FRACCIONIMPO - import_tariff_type: Mapped[str] = mapped_column(String(6)) # TIPOFRACIMPO - export_tariff_code: Mapped[str] = mapped_column(String(10)) # FRACCIONEXPO - export_tariff_type: Mapped[str] = mapped_column(String(6)) # TIPOFRACEXPO - depreciation_rate: Mapped[Decimal] = mapped_column(Numeric(5, 2)) # TASADEPRECIA - fda_code: Mapped[str] = mapped_column(String(20)) # FDA - eccn_code: Mapped[str] = mapped_column(String(20)) # ECCN - class_enabled: Mapped[bool] = mapped_column(Boolean) # HABILITADESHABILITACLASE + import_tariff_code: Mapped[Optional[str]] = mapped_column(String(10), nullable=True) # FRACCIONIMPO + import_tariff_type: Mapped[Optional[str]] = mapped_column(String(6), nullable=True) # TIPOFRACIMPO + export_tariff_code: Mapped[Optional[str]] = mapped_column(String(10), nullable=True) # FRACCIONEXPO + export_tariff_type: Mapped[Optional[str]] = mapped_column(String(6), nullable=True) # TIPOFRACEXPO + depreciation_rate: Mapped[Optional[Decimal]] = mapped_column(Numeric(5, 2), nullable=True) # TASADEPRECIA + fda_code: Mapped[Optional[str]] = mapped_column(String(20), nullable=True) # FDA + eccn_code: Mapped[Optional[str]] = mapped_column(String(20), nullable=True) # ECCN + class_enabled: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) # HABILITADESHABILITACLASE diff --git a/backend/api/v1/modules/a24/fa/fa_classes/routes.py b/backend/api/v1/modules/a24/fa/fa_classes/routes.py new file mode 100644 index 00000000..9e57a5d6 --- /dev/null +++ b/backend/api/v1/modules/a24/fa/fa_classes/routes.py @@ -0,0 +1,32 @@ +""" +Endpoints API para gestión de clases de activos fijos (FA) +""" + +from typing import Any, Dict +from fastapi import Depends, Query +from sqlalchemy.orm import Session + +from core.database import get_core_db +from core.security import get_current_user +from api.v1.common.tenant_crud_routes import TenantCRUDRoutes, validate_access_to_resource + +from .dto import FAClassCreateDTO, FAClassResponseDTO, FAClassUpdateDTO +from .service import FAClassService + +# Create router with generic CRUD routes +crud_routes = TenantCRUDRoutes( + service=FAClassService, + create_schema=FAClassCreateDTO, + update_schema=FAClassUpdateDTO, + response_schema=FAClassResponseDTO, + prefix="/fa/classes", + tags=["a24 / fa / classes"], + resource_name="Fixed Asset Class", + id_name="fa_class_id", + enable_list=True, + enable_filters=True, + default_page_size=50, + max_page_size=100, +) + +router = crud_routes.router diff --git a/backend/api/v1/modules/a24/fa/fa_classes/service.py b/backend/api/v1/modules/a24/fa/fa_classes/service.py new file mode 100644 index 00000000..4a5caacf --- /dev/null +++ b/backend/api/v1/modules/a24/fa/fa_classes/service.py @@ -0,0 +1,223 @@ +""" +Capa de servicio para lógica de negocio de clases de activos fijos (FA) +""" + +import logging +from typing import Any, Dict, List, Optional + +from fastapi import HTTPException +from sqlalchemy import and_ +from sqlalchemy.exc import IntegrityError +from sqlalchemy.orm import Session + +from .dto import FAClassCreateDTO, FAClassResponseDTO, FAClassUpdateDTO +from .models import QClasses + +logger = logging.getLogger(__name__) + + +class FAClassService: + """Servicio para gestión de clases de activos fijos""" + + @staticmethod + def get_all( + db: Session, + tenant_id: int, + company_id: int, + skip: int = 0, + limit: int = 100, + filters: Optional[Dict[str, Any]] = None, + ) -> tuple[List[QClasses], int]: + """ + Obtener todas las clases de activos fijos con paginación y filtros + """ + query = db.query(QClasses).filter( + QClasses.tenant_id == tenant_id, QClasses.company_id == company_id + ) + + if filters: + if filters.get("class_id"): + query = query.filter(QClasses.class_id == filters["class_id"]) + if filters.get("fda_code"): + query = query.filter( + QClasses.fda_code.ilike(f"%{filters['fda_code']}%") + ) + if filters.get("class_enabled") is not None: + query = query.filter( + QClasses.class_enabled == filters["class_enabled"] + ) + + total = query.count() + items = query.offset(skip).limit(limit).all() + + return items, total + + @staticmethod + def get_by_id( + db: Session, fa_class_id: int, tenant_id: int, company_id: int + ) -> Optional[QClasses]: + """Obtener una clase de activo fijo por ID""" + return ( + db.query(QClasses) + .filter( + QClasses.id == fa_class_id, + QClasses.tenant_id == tenant_id, + QClasses.company_id == company_id, + ) + .first() + ) + + @staticmethod + def get_by_class_id( + db: Session, class_id: int, tenant_id: int, company_id: int + ) -> Optional[QClasses]: + """Obtener una clase de activo fijo por class_id de a76""" + return ( + db.query(QClasses) + .filter( + QClasses.class_id == class_id, + QClasses.tenant_id == tenant_id, + QClasses.company_id == company_id, + ) + .first() + ) + + @staticmethod + def create( + db: Session, fa_class_data: FAClassCreateDTO, tenant_id: int, company_id: int + ) -> QClasses: + """Crear una nueva clase de activo fijo""" + try: + # Verificar que la clase base existe en a76.classes + from api.v1.modules.a76.classes.models import Class + + base_class = ( + db.query(Class) + .filter( + Class.id == fa_class_data.class_id, + Class.tenant_id == tenant_id, + Class.company_id == company_id, + ) + .first() + ) + + if not base_class: + raise HTTPException( + status_code=404, + detail=f"Base class with id {fa_class_data.class_id} not found" + ) + + # Verificar que no exista ya una clase de activo fijo para esta clase base + existing = FAClassService.get_by_class_id( + db, fa_class_data.class_id, tenant_id, company_id + ) + if existing: + raise HTTPException( + status_code=400, + detail=f"Fixed asset class already exists for class_id {fa_class_data.class_id}" + ) + + data_dict = fa_class_data.model_dump() + + new_fa_class = QClasses( + **data_dict, + tenant_id=tenant_id, + company_id=company_id, + ) + + db.add(new_fa_class) + db.commit() + db.refresh(new_fa_class) + + logger.info( + f"Created fixed asset class {new_fa_class.id} for class_id {new_fa_class.class_id}" + ) + + return new_fa_class + + except IntegrityError as e: + db.rollback() + logger.error(f"IntegrityError creating fixed asset class: {str(e)}") + raise HTTPException( + status_code=400, + detail=f"Database constraint violation: {str(e.orig)}" + ) + except HTTPException: + raise + except Exception as e: + db.rollback() + logger.error(f"Error creating fixed asset class: {str(e)}") + raise HTTPException(status_code=500, detail=str(e)) + + @staticmethod + def update( + db: Session, + fa_class_id: int, + tenant_id: int, + fa_class_data: FAClassUpdateDTO, + company_id: int, + ) -> QClasses: + """Actualizar una clase de activo fijo""" + fa_class = FAClassService.get_by_id(db, fa_class_id, tenant_id, company_id) + + if not fa_class: + raise HTTPException( + status_code=404, + detail=f"Fixed asset class {fa_class_id} not found" + ) + + try: + update_data = fa_class_data.model_dump(exclude_unset=True) + + for key, value in update_data.items(): + setattr(fa_class, key, value) + + db.commit() + db.refresh(fa_class) + + logger.info(f"Updated fixed asset class {fa_class_id}") + + return fa_class + + except IntegrityError as e: + db.rollback() + logger.error(f"IntegrityError updating fixed asset class: {str(e)}") + raise HTTPException( + status_code=400, + detail=f"Database constraint violation: {str(e.orig)}" + ) + except Exception as e: + db.rollback() + logger.error(f"Error updating fixed asset class: {str(e)}") + raise HTTPException(status_code=500, detail=str(e)) + + @staticmethod + def delete( + db: Session, fa_class_id: int, tenant_id: int, company_id: int + ) -> None: + """Eliminar una clase de activo fijo""" + fa_class = FAClassService.get_by_id(db, fa_class_id, tenant_id, company_id) + + if not fa_class: + raise HTTPException( + status_code=404, + detail=f"Fixed asset class {fa_class_id} not found" + ) + + try: + db.delete(fa_class) + db.commit() + + logger.info(f"Deleted fixed asset class {fa_class_id}") + + except IntegrityError as e: + db.rollback() + logger.error(f"IntegrityError deleting fixed asset class: {str(e)}") + raise HTTPException( + status_code=400, + detail="Cannot delete: Fixed asset class is referenced by other records" + ) + except Exception as e: + db.rollback() + logger.error(f"Error deleting fixed asset class: {str(e)}") + raise HTTPException(status_code=500, detail=str(e)) diff --git a/backend/api/v1/modules/a24/router.py b/backend/api/v1/modules/a24/router.py new file mode 100644 index 00000000..237f172e --- /dev/null +++ b/backend/api/v1/modules/a24/router.py @@ -0,0 +1,14 @@ +""" +Router principal del módulo A24 (SCAF - Sistema de Control de Activo Fijo) +""" + +from fastapi import APIRouter + +# Importar routers de submódulos +from .fa.fa_classes.routes import router as fa_classes_router + +# Router principal de A24 +router = APIRouter() + +# Registrar routers de FA (Fixed Assets) +router.include_router(fa_classes_router, prefix="/a24", tags=["a24 / fa / classes"]) diff --git a/backend/api/v1/modules/a76/classes/dto.py b/backend/api/v1/modules/a76/classes/dto.py index a59dac9c..9b5a92a8 100644 --- a/backend/api/v1/modules/a76/classes/dto.py +++ b/backend/api/v1/modules/a76/classes/dto.py @@ -4,6 +4,7 @@ Reemplaza schemas.py siguiendo enfoque DDD y estilo NestJS """ from datetime import datetime +from decimal import Decimal from typing import Optional from pydantic import BaseModel, ConfigDict, Field @@ -14,22 +15,22 @@ class ClassCreateDTO(BaseModel): client_id: int = Field(..., description="Client key") class_code: str = Field(..., max_length=8, description="Class code") - description_es: Optional[str] = Field( - None, max_length=500, description="Description in Spanish" + description_es: str = Field( + ..., max_length=500, description="Description in Spanish (required)" ) description_en: Optional[str] = Field( None, max_length=500, description="Description in English" ) - material_key: Optional[str] = Field( - None, + material_key: str = Field( + ..., max_length=10, - description="Material key (homologated TIPOMAT/TIPOMATEQUIPO)", + description="Material key - Fixed Asset Type (required)", ) - unit_of_measure: Optional[str] = Field( - None, max_length=5, description="Unit of measure (homologated UNIMEDIDA)" + unit_of_measure: str = Field( + ..., max_length=5, description="Unit of measure - U.M. comercial (required)" ) - fraction: Optional[str] = Field( - None, max_length=10, description="Mexican tariff fraction" + fraction: str = Field( + ..., max_length=20, description="Mexican tariff fraction (required)" ) us_fraction: Optional[str] = Field( None, max_length=16, description="US tariff fraction" @@ -48,9 +49,45 @@ class ClassCreateDTO(BaseModel): from_attributes = True +class ClassCreateDTOFA(ClassCreateDTO): + """DTO para crear una clase de activo fijo (clase base + extensión FA)""" + + # Campos específicos de activos fijos (a24.fa_classes) + import_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de importación" + ) + import_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de importación" + ) + export_tariff_code: Optional[str] = Field( + None, max_length=10, description="Código de fracción de exportación" + ) + export_tariff_type: Optional[str] = Field( + None, max_length=6, description="Tipo de fracción de exportación" + ) + depreciation_rate: Optional[Decimal] = Field( + None, ge=0, le=100, description="Tasa de depreciación anual (%)" + ) + fda_code: Optional[str] = Field( + None, max_length=20, description="Código FDA" + ) + eccn_code: Optional[str] = Field( + None, max_length=20, description="Código ECCN" + ) + class_enabled: Optional[bool] = Field( + True, description="Indica si la clase está habilitada" + ) + + class Config: + from_attributes = True + + class ClassUpdateDTO(BaseModel): """DTO para actualizar una clase""" + class_code: Optional[str] = Field( + None, max_length=8, description="Class code" + ) description_es: Optional[str] = Field( None, max_length=500, description="Description in Spanish" ) @@ -66,7 +103,7 @@ class ClassUpdateDTO(BaseModel): None, max_length=5, description="Unit of measure (homologated UNIMEDIDA)" ) fraction: Optional[str] = Field( - None, max_length=10, description="Mexican tariff fraction" + None, max_length=20, description="Mexican tariff fraction" ) us_fraction: Optional[str] = Field( None, max_length=16, description="US tariff fraction" @@ -81,8 +118,7 @@ class ClassUpdateDTO(BaseModel): None, max_length=4, description="IVA exempt fraction" ) - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True, extra='forbid') # Explicitly forbid extra fields class ClassResponseDTO(BaseModel): @@ -108,6 +144,23 @@ class ClassResponseDTO(BaseModel): model_config = ConfigDict(from_attributes=True) +class ClassResponseDTOFA(ClassResponseDTO): + """DTO para respuesta de clase de activo fijo (incluye campos FA)""" + + # Campos de a24.fa_classes + fa_id: Optional[int] = None + import_tariff_code: Optional[str] = None + import_tariff_type: Optional[str] = None + export_tariff_code: Optional[str] = None + export_tariff_type: Optional[str] = None + depreciation_rate: Optional[Decimal] = None + fda_code: Optional[str] = None + eccn_code: Optional[str] = None + class_enabled: Optional[bool] = None + + model_config = ConfigDict(from_attributes=True) + + class ClassBasicDTO(BaseModel): """DTO para información básica de clase""" @@ -147,4 +200,4 @@ class ClassSearchDTO(BaseModel): ) class Config: - from_attributes = True + from_attributes = True \ No newline at end of file diff --git a/backend/api/v1/modules/a76/classes/models.py b/backend/api/v1/modules/a76/classes/models.py index e12374f7..a5d1c851 100644 --- a/backend/api/v1/modules/a76/classes/models.py +++ b/backend/api/v1/modules/a76/classes/models.py @@ -75,7 +75,7 @@ class Class(Base, TenantScopedMixin, TimestampMixin): ) # UNIMED - homologated from UNIMEDIDA # Tariff fractions - fraction: Mapped[Optional[str]] = mapped_column(String(10)) # FRACCION + fraction: Mapped[Optional[str]] = mapped_column(String(20)) # FRACCION us_fraction: Mapped[Optional[str]] = mapped_column( String(16) ) # FRACCIONAME - US tariff fraction diff --git a/backend/api/v1/modules/a76/classes/routes.py b/backend/api/v1/modules/a76/classes/routes.py index 14860e93..df1779ed 100644 --- a/backend/api/v1/modules/a76/classes/routes.py +++ b/backend/api/v1/modules/a76/classes/routes.py @@ -2,13 +2,19 @@ Endpoints API para gestión de clases SCAII y SCAF """ -from api.v1.common.tenant_crud_routes import TenantCRUDRoutes +from typing import Dict, Any +from fastapi import Depends, Query +from sqlalchemy.orm import Session -from .dto import ClassCreateDTO, ClassResponseDTO, ClassUpdateDTO +from core.database import get_core_db +from core.security import get_current_user +from api.v1.common.tenant_crud_routes import TenantCRUDRoutes, validate_access_to_resource + +from .dto import ClassCreateDTO, ClassCreateDTOFA, ClassResponseDTO, ClassResponseDTOFA, ClassUpdateDTO from .service import ClassService # Create router with generic CRUD routes -router = TenantCRUDRoutes( +crud_routes = TenantCRUDRoutes( service=ClassService, create_schema=ClassCreateDTO, update_schema=ClassUpdateDTO, @@ -16,9 +22,58 @@ router = TenantCRUDRoutes( prefix="/classes", tags=["a76 / classes"], resource_name="Class", - id_name="class_id", + id_name="id", enable_list=True, enable_filters=True, default_page_size=50, - max_page_size=100, -).router + max_page_size=1000, +) + +router = crud_routes.router + + +@router.post( + "/seed", + summary="Seed Fixed Asset Classes", + description="Initialize fixed asset class catalog with default data", +) +async def seed_classes( + company_id: int = Query(..., description="Company ID"), + client_id: int = Query(..., description="Client ID"), + db: Session = Depends(get_core_db), + current_user: Dict[str, Any] = Depends(get_current_user), +): + """Seed initial data for fixed asset classes""" + tenant_id = validate_access_to_resource(db, company_id, current_user) + + count = ClassService.seed_initial_data(db, tenant_id, company_id, client_id) + + return { + "message": f"Successfully created {count} fixed asset classes", + "count": count, + } + + +@router.post( + "/fa", + response_model=ClassResponseDTOFA, + status_code=201, + summary="Create Fixed Asset Class", + description="Create a class with FA extension in a single transaction", +) +async def create_fa_class( + class_data: ClassCreateDTOFA, + company_id: int = Query(..., description="Company ID"), + db: Session = Depends(get_core_db), + current_user: Dict[str, Any] = Depends(get_current_user), +): + """Create a fixed asset class (both base class and FA extension)""" + import logging + logger = logging.getLogger(__name__) + logger.info(f"create_fa_class endpoint called with: {class_data.model_dump()}") + + tenant_id = validate_access_to_resource(db, company_id, current_user) + + result = ClassService.create_fa_class(db, class_data, tenant_id, company_id) + + return result \ No newline at end of file diff --git a/backend/api/v1/modules/a76/classes/service.py b/backend/api/v1/modules/a76/classes/service.py index ff7e2a93..9f124632 100644 --- a/backend/api/v1/modules/a76/classes/service.py +++ b/backend/api/v1/modules/a76/classes/service.py @@ -13,8 +13,10 @@ from sqlalchemy.orm import Session from .dto import ( ClassBasicDTO, ClassCreateDTO, + ClassCreateDTOFA, ClassListDTO, ClassResponseDTO, + ClassResponseDTOFA, ClassSearchDTO, ClassUpdateDTO, ) @@ -38,6 +40,7 @@ class ClassService: """ Get all classes for a tenant with pagination and filters """ + logger.info(f"get_all called with tenant_id={tenant_id}, company_id={company_id}, skip={skip}, limit={limit}") query = db.query(Class).filter( Class.tenant_id == tenant_id, Class.company_id == company_id ) @@ -70,7 +73,8 @@ class ClassService: total = query.count() items = query.offset(skip).limit(limit).all() - + + logger.info(f"get_all returning {len(items)} items out of {total} total") return items, total @staticmethod @@ -109,18 +113,19 @@ class ClassService: if existing: raise HTTPException( status_code=400, - detail=f"Class with code '{data_dict['class_code']}' already exists for this tenant and company" + detail=f" El código de clase '{data_dict['class_code']}' ya existe. Por favor use un código diferente." ) - # Validate material_key exists if provided - if data_dict.get("material_key"): - from api.v1.modules.public.reference_data.material_types.models import MaterialType - material_exists = db.query(MaterialType).filter( - MaterialType.key == data_dict["material_key"] - ).first() - if not material_exists: - # Set to None if material_key doesn't exist - data_dict["material_key"] = None + # Validate material_key exists (now required) + from api.v1.modules.public.reference_data.material_types.models import MaterialType + material_exists = db.query(MaterialType).filter( + MaterialType.key == data_dict["material_key"] + ).first() + if not material_exists: + raise HTTPException( + status_code=400, + detail=f"Material type '{data_dict['material_key']}' does not exist" + ) class_obj = Class(**data_dict) class_obj.tenant_id = tenant_id @@ -147,11 +152,16 @@ class ClassService: company_id: int, ) -> Optional[Class]: """Update a class""" + logger.info(f"Update called for class_id={class_id}, tenant_id={tenant_id}, company_id={company_id}") + logger.info(f"Update data received: {class_data.model_dump(exclude_unset=True)}") + class_obj = ClassService.get_by_id(db, class_id, tenant_id, company_id) if not class_obj: + logger.warning(f"Class {class_id} not found for tenant {tenant_id}, company {company_id}") return None update_data = class_data.model_dump(exclude_unset=True) + logger.info(f"Update data after model_dump: {update_data}") # Validate material_key exists if provided if "material_key" in update_data and update_data["material_key"]: @@ -163,24 +173,241 @@ class ClassService: # Set to None if material_key doesn't exist update_data["material_key"] = None + # Validate class_code is unique if being changed + if "class_code" in update_data and update_data["class_code"]: + new_code = update_data["class_code"] + # Check if another class with this code exists (excluding current class) + # The unique constraint is on (tenant_id, company_id, client_id, class_code) + existing_class = db.query(Class).filter( + Class.class_code == new_code, + Class.tenant_id == tenant_id, + Class.company_id == company_id, + Class.client_id == class_obj.client_id, # Same client + Class.id != class_id # Exclude current class + ).first() + + logger.info(f"Checking for duplicate class_code '{new_code}' for client {class_obj.client_id}") + if existing_class: + logger.warning(f"Duplicate class_code found: {existing_class.id}") + raise HTTPException( + status_code=400, + detail=f"El código '{new_code}' ya está en uso para este cliente. Por favor ingrese un código diferente." + ) + for field, value in update_data.items(): setattr(class_obj, field, value) - db.commit() - db.refresh(class_obj) - return class_obj + try: + logger.info(f"Attempting to commit changes for class {class_id}") + db.commit() + db.refresh(class_obj) + logger.info(f"Successfully updated class {class_id}") + return class_obj + except IntegrityError as e: + db.rollback() + error_msg = str(e.orig) + logger.error(f"IntegrityError updating class {class_id}: {error_msg}") + + # Check if it's a duplicate class_code error + if "already exists" in error_msg.lower() or "duplicate" in error_msg.lower(): + # Extract the code from update_data if it was changed + code = update_data.get("class_code", class_obj.class_code) + raise HTTPException( + status_code=400, + detail=f"El código '{code}' ya está en uso. Por favor ingrese un código diferente." + ) + + raise HTTPException( + status_code=400, + detail=f"Error al actualizar la clase: {error_msg}" + ) + except Exception as e: + db.rollback() + logger.error(f"Unexpected error updating class {class_id}: {type(e).__name__}: {str(e)}") + raise @staticmethod def delete(db: Session, class_id: int, tenant_id: int, company_id: int) -> bool: - """Delete a class""" + """Delete a class (and its FA extension if exists)""" + from api.v1.modules.a24.fa.fa_classes.models import QClasses + class_obj = ClassService.get_by_id(db, class_id, tenant_id, company_id) if not class_obj: return False + # Delete FA extension first (if exists) to avoid FK constraint violation + fa_extension = db.query(QClasses).filter( + QClasses.class_id == class_id, + QClasses.tenant_id == tenant_id + ).first() + + if fa_extension: + db.delete(fa_extension) + + # Now delete the base class db.delete(class_obj) db.commit() return True + @staticmethod + def create_fa_class( + db: Session, class_data: ClassCreateDTOFA, tenant_id: int, company_id: int + ) -> Dict[str, Any]: + """ + Create a fixed asset class (both a76.classes and a24.fa_classes) + Returns a dict with both records combined + """ + import logging + logger = logging.getLogger(__name__) + logger.info(f"create_fa_class called with data: {class_data.model_dump()}") + + from api.v1.modules.a24.fa.fa_classes.models import QClasses + + # Extract base class fields + base_fields = { + "client_id", "class_code", "description_es", "description_en", + "material_key", "unit_of_measure", "fraction", "us_fraction", + "sub_key", "physical_review", "iva_exempt_fraction" + } + base_data = {k: v for k, v in class_data.model_dump().items() if k in base_fields} + + # Extract FA-specific fields + fa_fields = { + "import_tariff_code", "import_tariff_type", "export_tariff_code", + "export_tariff_type", "depreciation_rate", "fda_code", "eccn_code", + "class_enabled" + } + fa_data = {k: v for k, v in class_data.model_dump().items() if k in fa_fields} + + try: + # 1. Create base class + base_dto = ClassCreateDTO(**base_data) + base_class = ClassService.create(db, base_dto, tenant_id, company_id) + + # 2. Create FA extension + fa_obj = QClasses(**fa_data) + fa_obj.class_id = base_class.id + fa_obj.tenant_id = tenant_id + fa_obj.company_id = company_id + + db.add(fa_obj) + db.commit() + db.refresh(fa_obj) + + # 3. Combine response - build dict manually to avoid SQLAlchemy internals + combined_response = { + # Base class fields + "id": base_class.id, + "tenant_id": base_class.tenant_id, + "company_id": base_class.company_id, + "client_id": base_class.client_id, + "class_code": base_class.class_code, + "description_es": base_class.description_es, + "description_en": base_class.description_en, + "material_key": base_class.material_key, + "unit_of_measure": base_class.unit_of_measure, + "fraction": base_class.fraction, + "us_fraction": base_class.us_fraction, + "sub_key": base_class.sub_key, + "physical_review": base_class.physical_review, + "iva_exempt_fraction": base_class.iva_exempt_fraction, + "created_at": base_class.created_at, + "updated_at": base_class.updated_at, + # FA extension fields + "fa_id": fa_obj.id, + "import_tariff_code": fa_obj.import_tariff_code, + "import_tariff_type": fa_obj.import_tariff_type, + "export_tariff_code": fa_obj.export_tariff_code, + "export_tariff_type": fa_obj.export_tariff_type, + "depreciation_rate": fa_obj.depreciation_rate, + "fda_code": fa_obj.fda_code, + "eccn_code": fa_obj.eccn_code, + "class_enabled": fa_obj.class_enabled, + } + + return combined_response + + except Exception as e: + db.rollback() + # If FA creation fails, rollback base class too + if 'base_class' in locals(): + try: + db.delete(base_class) + db.commit() + except: + pass + + # Extract and improve error message + error_msg = str(e) + if "already exists" in error_msg.lower() or "duplicad" in error_msg.lower(): + # Extract code from error if possible + code = class_data.class_code + raise HTTPException( + status_code=400, + detail=f"El código '{code}' ya está en uso. Por favor ingrese un código diferente." + ) + + raise HTTPException( + status_code=400, + detail=f"Error al crear clase de activo fijo: {error_msg}" + ) + + @staticmethod + def seed_initial_data( + db: Session, tenant_id: int, company_id: int, client_id: int + ) -> int: + """ + Seed initial fixed asset class data + Returns: number of records created + """ + from .seed import seed + + created_count = 0 + for record in seed: + ( + class_code, + description_es, + description_en, + material_key, + unit_of_measure, + fraction, + us_fraction, + bom, + ) = record + + # Check if already exists + existing = ( + db.query(Class) + .filter( + Class.tenant_id == tenant_id, + Class.company_id == company_id, + Class.client_id == client_id, + Class.class_code == class_code, + ) + .first() + ) + + if not existing: + class_obj = Class( + tenant_id=tenant_id, + company_id=company_id, + client_id=client_id, + class_code=class_code, + description_es=description_es, + description_en=description_en, + material_key=material_key if material_key else None, + unit_of_measure=unit_of_measure if unit_of_measure else None, + fraction=fraction if fraction else None, + us_fraction=us_fraction if us_fraction else None, + ) + db.add(class_obj) + created_count += 1 + + if created_count > 0: + db.commit() + + return created_count + def __init__(self, db: Session): self.db = db diff --git a/backend/api/v1/router.py b/backend/api/v1/router.py index 9fd2618e..b8d7f073 100644 --- a/backend/api/v1/router.py +++ b/backend/api/v1/router.py @@ -8,6 +8,7 @@ from fastapi import APIRouter # Importar routers de módulos from .modules.core.router import router as core_router from .modules.a76.router import router as a76_router +from .modules.a24.router import router as a24_router from .modules.public.router import router as public_router # Router principal @@ -16,6 +17,7 @@ router = APIRouter() # Registrar módulos router.include_router(core_router) router.include_router(a76_router) +router.include_router(a24_router) router.include_router(public_router) diff --git a/backend/main.py b/backend/main.py index 0959a83d..f0fee380 100644 --- a/backend/main.py +++ b/backend/main.py @@ -13,8 +13,10 @@ from core.middleware import ( RequestLoggingMiddleware, TenantMiddleware, ) -from fastapi import FastAPI +from fastapi import FastAPI, Request, status, HTTPException from fastapi.middleware.cors import CORSMiddleware +from fastapi.exceptions import RequestValidationError +from fastapi.responses import JSONResponse from api.v1.modules.a76.items.models import Item # Importar rutas para registrar con el router from api.v1.modules.a76.items.series.models import Serie # Importar modelos para registrar con SQLAlchemy @@ -38,6 +40,27 @@ app = FastAPI( ) +# Add validation error handler +@app.exception_handler(RequestValidationError) +async def validation_exception_handler(request: Request, exc: RequestValidationError): + logger.error(f"Validation error for {request.method} {request.url.path}: {exc.errors()}") + logger.error(f"Request body: {await request.body()}") + return JSONResponse( + status_code=status.HTTP_400_BAD_REQUEST, + content={"detail": exc.errors(), "body": exc.body}, + ) + + +# Add HTTP exception handler +@app.exception_handler(HTTPException) +async def http_exception_handler(request: Request, exc: HTTPException): + logger.error(f"HTTP {exc.status_code} for {request.method} {request.url.path}: {exc.detail}") + return JSONResponse( + status_code=exc.status_code, + content={"detail": exc.detail}, + ) + + # Inicializar la base de datos @app.on_event("startup") async def on_startup(): diff --git a/frontend/src/lib/api/dashboard/a24/fa_classes.ts b/frontend/src/lib/api/dashboard/a24/fa_classes.ts new file mode 100644 index 00000000..91359f52 --- /dev/null +++ b/frontend/src/lib/api/dashboard/a24/fa_classes.ts @@ -0,0 +1,110 @@ +/** + * API para gestión de Fixed Asset Classes (Clases de Activos Fijos A24) + */ +import { api } from '$lib/api'; +import type { ApiResponse } from '$lib/api'; + +export interface FAClass { + id: number; + tenant_id: number; + company_id: number; + class_id: number; + import_tariff_code: string | null; + import_tariff_type: string | null; + export_tariff_code: string | null; + export_tariff_type: string | null; + depreciation_rate: number | null; + fda_code: string | null; + eccn_code: string | null; + class_enabled: boolean | null; + created_at: string; + updated_at: string; +} + +export interface FAClassCreate { + class_id: number; + import_tariff_code?: string | null; + import_tariff_type?: string | null; + export_tariff_code?: string | null; + export_tariff_type?: string | null; + depreciation_rate?: number | null; + fda_code?: string | null; + eccn_code?: string | null; + class_enabled?: boolean; +} + +export interface FAClassUpdate { + import_tariff_code?: string | null; + import_tariff_type?: string | null; + export_tariff_code?: string | null; + export_tariff_type?: string | null; + depreciation_rate?: number | null; + fda_code?: string | null; + eccn_code?: string | null; + class_enabled?: boolean; +} + +export interface FAClassListResponse { + items: FAClass[]; + total: number; + page: number; + page_size: number; +} + +export interface FAClassListParams { + company_id: number; + page?: number; + page_size?: number; + class_id?: number; + fda_code?: string; + class_enabled?: boolean; +} + +/** + * API de Fixed Asset Classes + */ +export const faClassesApi = { + /** + * Obtener lista de clases de activos fijos con paginación + */ + list: (params: FAClassListParams): Promise> => { + const { company_id, page = 1, page_size = 50, ...filters } = params; + const queryParams = new URLSearchParams({ + company_id: company_id.toString(), + page: page.toString(), + page_size: page_size.toString(), + ...Object.fromEntries( + Object.entries(filters).filter(([_, v]) => v !== undefined).map(([k, v]) => [k, String(v)]) + ) + }); + return api.get(`/v1/a24/fa/classes/?${queryParams}`); + }, + + /** + * Obtener una clase de activo fijo por ID + */ + get: (id: number, company_id: number): Promise> => { + return api.get(`/v1/a24/fa/classes/${id}?company_id=${company_id}`); + }, + + /** + * Crear una nueva clase de activo fijo + */ + create: (data: FAClassCreate, company_id: number): Promise> => { + return api.post(`/v1/a24/fa/classes/?company_id=${company_id}`, data); + }, + + /** + * Actualizar una clase de activo fijo existente + */ + update: (id: number, data: FAClassUpdate, company_id: number): Promise> => { + return api.put(`/v1/a24/fa/classes/${id}?company_id=${company_id}`, data); + }, + + /** + * Eliminar una clase de activo fijo + */ + delete: (id: number, company_id: number): Promise> => { + return api.delete(`/v1/a24/fa/classes/${id}?company_id=${company_id}`); + } +}; diff --git a/frontend/src/lib/api/dashboard/a76/classes.ts b/frontend/src/lib/api/dashboard/a76/classes.ts index a08c2832..cd1e6c1b 100644 --- a/frontend/src/lib/api/dashboard/a76/classes.ts +++ b/frontend/src/lib/api/dashboard/a76/classes.ts @@ -103,5 +103,12 @@ export const classesApi = { */ delete: (id: number, company_id: number): Promise> => { return api.delete(`/v1/a76/classes/${id}?company_id=${company_id}`); + }, + + /** + * Inicializar datos semilla de clases de activo fijo + */ + seed: (company_id: number, client_id: number): Promise> => { + return api.post(`/v1/a76/classes/seed?company_id=${company_id}&client_id=${client_id}`, {}); } }; diff --git a/frontend/src/lib/components/dashboard/classes/forms/FixedAssetClassForm.svelte b/frontend/src/lib/components/dashboard/classes/forms/FixedAssetClassForm.svelte new file mode 100644 index 00000000..16632751 --- /dev/null +++ b/frontend/src/lib/components/dashboard/classes/forms/FixedAssetClassForm.svelte @@ -0,0 +1,1177 @@ + + +
+ +
+
+ + { + // Limpiar error local si existe + if (validationErrors.class_code) { + const errors = { ...validationErrors }; + delete errors.class_code; + validationErrors = errors; + } + }} + onblur={() => validateField('class_code')} + /> + {#if validationErrors.class_code} +

{validationErrors.class_code}

+ {/if} +
+
+ + +
+
+ + +
+ + validateField('description_es')} + /> + {#if validationErrors.description_es} +

{validationErrors.description_es}

+ {/if} +
+ + +
+ + +
+ + +
+ +
+ validateField('material_key')} + /> + + + {formData.material_description || ''} + +
+ {#if validationErrors.material_key} +

{validationErrors.material_key}

+ {/if} +
+ + +
+ +
+ validateField('unit_of_measure')} + /> + + + {formData.unit_of_measure_description || ''} + + + Clave U.M.A: {formData.unit_measure_key || ''} + +
+ {#if validationErrors.unit_of_measure} +

{validationErrors.unit_of_measure}

+ {/if} +
+ + +
+ +
+ validateField('fraction')} + /> + + + U.M.T: {formData.fraction_umt || ''} + + + Clave U.M.A: {formData.fraction_uma_key || ''} + +
+ {#if validationErrors.fraction} +

{validationErrors.fraction}

+ {/if} +
+ + +
+ +
+ + + + Ad/valorem: {formData.us_fraction_ad_valorem || '0.00'} + + + Tasa Fija: {formData.us_fraction_fixed_rate || '0.00000000'} + +
+
+ + +
+ +
+ + % + +
+ + +
+
+
+ + +
+ +
+ + +
+
+ + +
+ +
+
+ (formData.iva_exempt_fraction = true)} + class="h-4 w-4" + /> + +
+
+ (formData.iva_exempt_fraction = false)} + class="h-4 w-4" + /> + +
+
+
+ + +
+ +
+ + +
+
+
+ + + + + + + CATALOGO DE ACTIVO FIJO + +
+
+ + +
+
+ + + + + + + + + {#each filteredMaterialTypes as material (material.key)} + selectMaterial(material)} + > + + + + {/each} + +
ClaveDescripción
{material.key}{material.description}
+
+
+ + + +
+
+ + + + + + UNIDADES DE MEDIDA + +
+
+ + +
+
+ + + + + + + + + + + {#each filteredUnits as unit (unit.code)} + selectUnit(unit)} + > + + + + + + {/each} + +
CódigoDescripciónDescription (English)Clave Mexicana
{unit.code}{unit.description}{unit.descriptionEnglish}{unit.claveMexicana}
+
+
+ + + +
+
+ + + + + + CATALOGO DE FRACCIONES SITAR - SCAII + +
+
+ + +
+
+ + + + + + + + + + + {#each tariffFractions as fraction (fraction.code)} + selectFraction(fraction)} + > + + + + + + {:else} + + + + {/each} + +
FracciónNICODescripciónU.M.T
{fraction.fraction}{fraction.nico}{fraction.description}{fraction.umt}
+ {#if isLoadingFractions} + Cargando fracciones... + {:else} + No hay fracciones disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE FRACCIONES AMERICANAS + +
+
+ + +
+
+ + + + + + + + + + + + {#each usTariffFractions as fraction (fraction.id)} + selectUSFraction(fraction)} + > + + + + + + + {:else} + + + + {/each} + +
CódigoPrefijoAd valoremCosto FijoDescripción
{fraction.code}{fraction.prefix || ''}{fraction.ad_valorem || '0.00'}{fraction.fixed_cost || '0.00'}{fraction.description || ''}
+ {#if isLoadingUSFractions} + Cargando fracciones... + {:else} + No hay fracciones disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE DEPRECIACION + +
+
+ + +
+
+ + + + + + + + + + {#each depreciationCatalog as item (item.id)} + selectDepreciation(item)} + > + + + + + {:else} + + + + {/each} + +
FracciónDescripción% Depreciación
{item.fraction}{item.description}{item.depreciation_rate}%
+ {#if isLoadingDepreciation} + Cargando... + {:else} + No hay registros disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO FDA + +
+
+ + +
+
+ + + + + + + + + {#each fdaCatalog as item (item.id)} + selectFDA(item)} + > + + + + {:else} + + + + {/each} + +
Clave FDADescripción
{item.fda_key}{item.description}
+ {#if isLoadingFDA} + Cargando... + {:else} + No hay registros disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE CARTA PORTE + +
+
+ + +
+
+ + + + + + + + + {#each cartaPorteCatalog as item (item.id)} + { + formData.carta_porte_code = item.code; + showCartaPorteDialog = false; + }} + > + + + + {:else} + + + + {/each} + +
CódigoDescripción
{item.code}{item.description}
+ No hay registros disponibles +
+
+
+ + + +
+
diff --git a/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte b/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte index fd76c8cf..0b4393ff 100644 --- a/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte +++ b/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte @@ -205,10 +205,10 @@
- - +
+
+ + +
+ + + + + + + + + + + + + + {#if isLoading} + + + + {:else if filteredClasses.length === 0} + + + + {:else} + {#each filteredClasses as cls (cls.id)} + selectClass(cls)} + > + + + + + + + + + {/each} + {/if} + +
+ + ClaseDescripción EspañolDescripción InglésTipoU.MFracción U.M.T. Fracción US
Cargando...
+ No hay clases de activo fijo registradas +
+ + + + {cls.class_code} + + {cls.description_es || ''}{cls.description_en || ''} + + {cls.material_key || ''} + + {cls.unit_of_measure || ''}{cls.fraction || ''} - {cls.us_fraction || '-'}
+
+
+
+ + +
+
+

Código de Clase

+

+ {formData.class_code || '---'} +

+
+ +
+
+
+ +

{formData.description_es || 'Sin descripción'}

+
+
+ +

{formData.description_en || 'No translation available'}

+
+
+ +
+
+ +
+ + {formData.material_key || '-'} +
+
+
+ + {formData.unit_of_measure || '-'} +
+
+ +
+ +

+ {formData.fraction || '0000.00.00'} +

+
+
+
+
+
+ + +
+
+ +
+ + + +
+
+
+ + + + + + {selectedClass ? 'Editar' : 'Nueva'} Clase de Activo Fijo + + + + {#if validationError} +
+
+
+ ! +
+
+

Error de Validación

+

{validationError}

+
+ +
+
+ {/if} + +
+ validationError = ''} + onSave={async (data: Partial) => { + // Evitar múltiples clics + if (isSaving) { + console.log('⚠️ Ya está guardando, ignorando clic'); + return; + } + isSaving = true; + validationError = ''; + + console.log('========================================'); + console.log('=== INICIO ONSAVE ==='); + console.log('Datos recibidos:', data); + console.log('selectedClass:', selectedClass); + console.log('========================================'); + + try { + const cleanData = $state.snapshot(data); + const companyId = companyStore.activeCompany?.id; + const token = await getToken(); + + if (!companyId) { + throw new Error('No hay empresa seleccionada'); + } + + if (!token) { + throw new Error('No estás autenticado'); + } + + let response; + + if (selectedClass?.id) { + // === ACTUALIZACIÓN === + console.log('🔄 MODO: ACTUALIZACIÓN'); + console.log('ID de clase:', selectedClass.id); + + response = await classesApi.update(selectedClass.id, { + class_code: cleanData.class_code?.trim() || '', + description_es: cleanData.description_es?.trim() || '', + description_en: cleanData.description_en?.trim() || '', + material_key: cleanData.material_key?.trim() || '', + unit_of_measure: cleanData.unit_of_measure?.trim() || '', + fraction: cleanData.fraction?.trim() || '', + us_fraction: cleanData.us_fraction || '', + physical_review: cleanData.physical_review ? 1 : 0, + iva_exempt_fraction: cleanData.iva_exempt_fraction || '' + }, companyId); + + // ¡IMPORTANTE! fetchApi NO lanza excepciones, retorna { error, status } + if (response.error) { + console.error('❌ Error en respuesta de actualización:', response); + throw new Error(response.error); + } + + console.log('✅ Actualización exitosa'); + } else { + // === CREACIÓN === + console.log('➕ MODO: CREACIÓN'); + + const payload = { + client_id: 2, + class_code: cleanData.class_code?.trim() || '', + description_es: cleanData.description_es?.trim() || '', + description_en: cleanData.description_en?.trim() || '', + material_key: cleanData.material_key?.trim() || '', + unit_of_measure: cleanData.unit_of_measure?.trim() || '', + fraction: cleanData.fraction?.trim() || '', + us_fraction: cleanData.us_fraction?.trim() || '', + sub_key: cleanData.sub_key || '', + physical_review: cleanData.physical_review ? 1 : 0, + iva_exempt_fraction: cleanData.iva_exempt_fraction || '', + depreciation_rate: cleanData.depreciation_rate || null, + fda_code: cleanData.fda_code || null, + class_enabled: true + }; + + console.log('Payload:', payload); + + const fetchResponse = await fetch(`http://localhost:8000/api/v1/a76/classes/fa?company_id=${companyId}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify(payload) + }); + + if (!fetchResponse.ok) { + const errorData = await fetchResponse.json(); + console.error('❌ Error del servidor:', errorData); + throw errorData; + } + + response = await fetchResponse.json(); + console.log('✅ Creación exitosa'); + } + + // === ÉXITO TOTAL === + console.log('✅ GUARDADO EXITOSO - Cerrando diálogo'); + const wasUpdate = !!selectedClass?.id; + await loadClasses(); + showInsertDialog = false; + selectedClass = null; + validationError = ''; + toast.success(wasUpdate ? 'Clase actualizada correctamente' : 'Clase creada correctamente'); + + } catch (error: any) { + // === ERROR === + console.error('========================================'); + console.error('❌ ERROR CAPTURADO'); + console.error('Error:', error); + console.error('Error.response:', error?.response); + console.error('Error.response.data:', error?.response?.data); + console.error('Error.detail:', error?.detail); + console.error('========================================'); + + let errorMsg = 'Error al guardar'; + + // Primero intentar con error.detail (fetch directo) + if (error?.detail) { + if (typeof error.detail === 'string') { + errorMsg = error.detail; + } else if (Array.isArray(error.detail)) { + errorMsg = error.detail.map((e: any) => e.msg || e).join(', '); + } + } + // Luego con error.response.data.detail (axios) + else if (error?.response?.data?.detail) { + if (typeof error.response.data.detail === 'string') { + errorMsg = error.response.data.detail; + } else if (Array.isArray(error.response.data.detail)) { + errorMsg = error.response.data.detail.map((e: any) => e.msg || e).join(', '); + } + } + // Por último el mensaje genérico + else if (error?.message) { + errorMsg = error.message; + } + + console.error('📝 Mensaje de error extraído:', errorMsg); + + validationError = errorMsg; + console.error('🔴 validationError asignado:', validationError); + console.error('🔴 showInsertDialog permanece:', showInsertDialog); + console.error('========================================'); + + // NO cerramos el diálogo, permanece abierto + } finally { + isSaving = false; + console.log('✅ isSaving = false'); + } + }} + onCancel={() => { + showInsertDialog = false; + selectedClass = null; + }} + /> +
+ + + + +
+
+ + + + + + ¿Confirmar eliminación? + +
+

+ ¿Estás seguro que deseas eliminar la clase {selectedClass?.class_code}? +

+

+ {selectedClass?.description_es} +

+

+ Esta acción no se puede deshacer. +

+
+ + + + +
+
diff --git a/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte b/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte new file mode 100644 index 00000000..928dc6fd --- /dev/null +++ b/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte @@ -0,0 +1,17 @@ + + +
+ +
From 9d007b6af33ad3fc37702ad2dc0d1314ef38c5a6 Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Thu, 8 Jan 2026 17:01:16 -0600 Subject: [PATCH 33/37] feat: implement create/edit dialog for class management with form validation and data loading --- .../classes/create-edit-dialog.svelte | 520 ++++++++++++++++++ 1 file changed, 520 insertions(+) create mode 100644 frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte new file mode 100644 index 00000000..6f9572cd --- /dev/null +++ b/frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte @@ -0,0 +1,520 @@ + + + + + + {title} + + {isEdit ? 'Modifica los datos de la clase' : 'Completa los datos para crear una nueva clase'} + + + + + + {#if error} +
+ {error} +
+ {/if} + + + {#if companyStore.activeCompany} +
+
+ + + + +
+

+ {companyStore.activeCompany.name} +

+

+ ID: {companyStore.activeCompany.id} +

+
+
+
+ {/if} + + +
+ + {#if loadingClients} +
+
+ Cargando clientes... +
+ {:else if clients.length > 0} + + {:else} +
+ No hay clientes disponibles +
+ {/if} +
+ + +
+ + +
+ + +
+
+ + -
-
- - - - -
-
- - - - - - Confirmar Eliminación - -
-

¿Está seguro que desea eliminar la fracción {fractionToDelete?.code}?

-

Esta acción no se puede deshacer.

-
- - - - -
-
- - - - - - CATALOGO DE TASAS DE DEPRECIACIÓN - -
- -
- - -
- - -
- - - - - - - - - - {#each depreciationCatalog as item (item.id)} - selectDepreciation(item)} - > - - - - - {:else} - - - - {/each} - {#if hasMoreDepreciation && depreciationCatalog.length > 0} - - - - {/if} - -
FracciónDescripciónTasa %
{item.fraction}{item.description}{item.depreciation_rate}%
- {#if isLoadingDepreciation} - Cargando catálogo... - {:else if searchDepreciation} - No se encontraron registros que coincidan con "{searchDepreciation}" - {:else} - No hay registros disponibles - {/if} -
- {#if isLoadingDepreciation} - Cargando más registros... - {:else} - - {/if} -
-
-
- - - -
-
- - - - - - CATALOGO DE CODIGOS DE F.D.A. - -
- -
- - -
- - -
- - - - - - - - - - - - - - - - {#each fdaCatalog as item (item.id)} - selectFDA(item)} - > - - - - - - - - - - - {:else} - - - - {/each} - {#if hasMoreFDA && fdaCatalog.length > 0} - - - - {/if} - -
ClaveDescripciónCódigo FDARequerimientosNo. de FabriPaís de ProducciónEstatusAlmacenaCodAlm1CallAtrl
{item.fda_key || ''}{item.description || ''}{item.fda_code || ''}{item.requirements || ''}{item.manufacturer_number || ''}{item.country_of_production || ''}{item.storage_status || ''}{item.warehouse_code || ''}{item.call_atl || ''}
- {#if isLoadingFDA} - Cargando catálogo... - {:else if searchFDA} - No se encontraron registros que coincidan con "{searchFDA}" - {:else} - No hay registros disponibles - {/if} -
- {#if isLoadingFDA} - Cargando más registros... - {:else} - - {/if} -
-
-
- - - -
-
- - - - - - CATALOGO DE CARTA PORTE - -
- -
- - -
- - -
- - - - - - - - - - - - - {#each cartaPorteCatalog as item (item.id)} - { - formData.carta_porte_code = item.clave_id; - showCartaPorteDialog = false; - }} - > - - - - - - - - {:else} - - - - {/each} - -
Clave IDDescripciónPalabras SimilaresMaterial PeligrosoFecha Inicio VigenciaFecha Fin Vigencia
{item.clave_id || ''}{item.descripcion || ''}{item.palabras_similares || ''}{item.material_peligroso || ''}{item.fecha_inicio_vigencia || ''}{item.fecha_fin_vigencia || ''}
- {#if searchCartaPorte} - No se encontraron registros que coincidan con "{searchCartaPorte}" - {:else} - No hay registros disponibles - {/if} -
-
-
- - - -
-
diff --git a/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte b/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte deleted file mode 100644 index 928dc6fd..00000000 --- a/frontend/src/routes/dashboard/merchandise/fixed_asset_classes/embed/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - -
- -
From 08416d6cadccb9e5434a2ec37c9b38b24c43a89d Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 8 Jan 2026 21:12:31 -0600 Subject: [PATCH 35/37] Refactor Part model and related components - Updated the Part model in models.py to improve readability and maintainability by organizing imports and formatting. - Enhanced relationships in the Part model for better clarity. - Modified main.py to streamline imports for parts and related models. - Adjusted partForm.svelte to correctly reference properties from inv_data and fa_data. - Updated +page.svelte to fix the import path for DataTable and refine data handling. - Changed edit/[[id]]/+page.svelte to enforce type safety for the 'type' variable. --- ...2f4f3ca0_add_material_type_key_to_parts.py | 2658 ----------------- backend/api/v1/modules/a76/parts/models.py | 60 +- backend/main.py | 20 +- .../dashboard/goods/parts/partForm.svelte | 12 +- .../routes/dashboard/goods/parts/+page.svelte | 14 +- .../goods/parts/edit/[[id]]/+page.svelte | 2 +- 6 files changed, 69 insertions(+), 2697 deletions(-) delete mode 100644 backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py diff --git a/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py b/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py deleted file mode 100644 index 7e6c7705..00000000 --- a/backend/alembic/versions/57472f4f3ca0_add_material_type_key_to_parts.py +++ /dev/null @@ -1,2658 +0,0 @@ -"""add material_type_key to parts - -Revision ID: 57472f4f3ca0 -Revises: 7937209f9718 -Create Date: 2026-01-07 15:27:22.443152 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '57472f4f3ca0' -down_revision: Union[str, Sequence[str], None] = '7937209f9718' -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - """Upgrade schema.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('tenants', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('slug', sa.String(length=100), nullable=False), - sa.Column('type', sa.Enum('SHARED', 'DEDICATED', name='tenanttype'), nullable=False), - sa.Column('keycloak_realm', sa.String(length=255), nullable=False), - sa.Column('db_config', sa.Text(), nullable=True), - sa.Column('contact_name', sa.String(length=255), nullable=True), - sa.Column('contact_email', sa.String(length=255), nullable=True), - sa.Column('contact_phone', sa.String(length=50), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id'), - schema='core' - ) - op.create_index(op.f('ix_core_tenants_id'), 'tenants', ['id'], unique=False, schema='core') - op.create_index(op.f('ix_core_tenants_name'), 'tenants', ['name'], unique=False, schema='core') - op.create_index(op.f('ix_core_tenants_slug'), 'tenants', ['slug'], unique=True, schema='core') - op.create_table('company', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=True), - sa.Column('rfc', sa.String(length=30), nullable=True), - sa.Column('main_activity', sa.String(length=255), nullable=True), - sa.Column('program', sa.String(length=10), nullable=True), - sa.Column('program_number', sa.String(length=40), nullable=True), - sa.Column('prosec', sa.SmallInteger(), nullable=True), - sa.Column('prosec_authorization', sa.String(length=20), nullable=True), - sa.Column('manufacturer_id', sa.String(length=25), nullable=True), - sa.Column('broker_company', sa.String(length=10), nullable=True), - sa.Column('responsible', sa.String(length=80), nullable=True), - sa.Column('responsible_name', sa.String(length=20), nullable=True), - sa.Column('responsible_last_name', sa.String(length=20), nullable=True), - sa.Column('responsible_mother_last_name', sa.String(length=20), nullable=True), - sa.Column('responsible_rfc', sa.String(length=30), nullable=True), - sa.Column('position', sa.String(length=30), nullable=True), - sa.Column('logo', sa.String(length=255), nullable=True), - sa.Column('has_express_line', sa.Boolean(), nullable=True), - sa.Column('order_format_type', sa.String(length=19), nullable=True), - sa.Column('previous_code', sa.SmallInteger(), nullable=True), - sa.Column('is_service_company', sa.Boolean(), nullable=True), - sa.Column('client_name', sa.String(length=300), nullable=True), - sa.Column('subassembly_mode', sa.String(length=7), nullable=True), - sa.Column('curp', sa.String(length=19), nullable=True), - sa.Column('inter_db_name', sa.String(length=100), nullable=True), - sa.Column('ctpat_svi', sa.String(length=100), nullable=True), - sa.Column('trusted_exporter_number', sa.String(length=50), nullable=True), - sa.Column('prevalidator_key', sa.String(length=20), nullable=True), - sa.Column('seventh_amendment', sa.Boolean(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='company_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_company_tenant_id'), 'company', ['tenant_id'], unique=False, schema='a76') - op.create_table('customs_broker_concepts', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('broker_key', sa.String(length=5), nullable=False), - sa.Column('concept', sa.String(length=15), nullable=False), - sa.Column('amount', sa.Numeric(precision=11, scale=2), nullable=True), - sa.Column('priority', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('broker_key', 'concept', 'company_id', name='uq_broker_concept'), - schema='a76' - ) - op.create_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), 'customs_broker_concepts', ['tenant_id'], unique=False, schema='a76') - op.create_table('license_usage', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('period_start', sa.DateTime(timezone=True), nullable=False), - sa.Column('period_end', sa.DateTime(timezone=True), nullable=False), - sa.Column('active_users', sa.Integer(), nullable=True), - sa.Column('storage_used_gb', sa.Integer(), nullable=True), - sa.Column('operations_count', sa.Integer(), nullable=True), - sa.Column('api_calls_count', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='core' - ) - op.create_index(op.f('ix_core_license_usage_id'), 'license_usage', ['id'], unique=False, schema='core') - op.create_index(op.f('ix_core_license_usage_tenant_id'), 'license_usage', ['tenant_id'], unique=False, schema='core') - op.create_table('licenses', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('plan', sa.Enum('FREE', 'BASIC', 'PROFESSIONAL', 'ENTERPRISE', name='licenseplan'), nullable=False), - sa.Column('status', sa.Enum('ACTIVE', 'EXPIRED', 'SUSPENDED', 'PENDING', 'CANCELLED', name='licensestatus'), nullable=False), - sa.Column('max_users', sa.Integer(), nullable=False), - sa.Column('max_storage_gb', sa.Integer(), nullable=False), - sa.Column('max_monthly_operations', sa.Integer(), nullable=False), - sa.Column('feature_api_access', sa.Boolean(), nullable=True), - sa.Column('feature_advanced_reports', sa.Boolean(), nullable=True), - sa.Column('feature_integrations', sa.Boolean(), nullable=True), - sa.Column('feature_dedicated_support', sa.Boolean(), nullable=True), - sa.Column('starts_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='core' - ) - op.create_index(op.f('ix_core_licenses_id'), 'licenses', ['id'], unique=False, schema='core') - op.create_index(op.f('ix_core_licenses_tenant_id'), 'licenses', ['tenant_id'], unique=True, schema='core') - op.create_table('location', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=5), nullable=False), - sa.Column('description', sa.String(length=200), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='location_pkey'), - sa.UniqueConstraint('code'), - sa.UniqueConstraint('code', name='location_code_unique'), - schema='a24' - ) - op.create_index(op.f('ix_a24_location_company_id'), 'location', ['company_id'], unique=False, schema='a24') - op.create_index(op.f('ix_a24_location_tenant_id'), 'location', ['tenant_id'], unique=False, schema='a24') - op.create_table('classification_concepts', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('classification', sa.String(length=30), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('classification', name='uq_classification_concept'), - schema='a76' - ) - op.create_index(op.f('ix_a76_classification_concepts_company_id'), 'classification_concepts', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_classification_concepts_tenant_id'), 'classification_concepts', ['tenant_id'], unique=False, schema='a76') - op.create_table('clients_and_providers', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('type_nat_foreign', sa.String(length=1), nullable=True), - sa.Column('name', sa.String(length=256), nullable=True), - sa.Column('short_name', sa.String(length=10), nullable=True), - sa.Column('rfc', sa.String(length=30), nullable=True), - sa.Column('curp', sa.String(length=19), nullable=True), - sa.Column('client_or_provider', sa.Enum('CLIENT', 'PROVIDER', 'BOTH', name='entity_client_or_provider'), nullable=False), - sa.Column('linking', sa.String(length=1), nullable=True), - sa.Column('transform_subassembly', sa.String(length=1), nullable=True), - sa.Column('extra_information', sa.String(length=399), nullable=True), - sa.Column('web_key', sa.String(length=40), nullable=True), - sa.Column('responsible', sa.String(length=80), nullable=True), - sa.Column('position', sa.String(length=30), nullable=True), - sa.Column('incoterm', sa.String(length=19), nullable=True), - sa.Column('is_national_provider', sa.Boolean(), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='clients_and_providers_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_clients_and_providers_company_id'), 'clients_and_providers', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_clients_and_providers_tenant_id'), 'clients_and_providers', ['tenant_id'], unique=False, schema='a76') - op.create_table('customs_brokers', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('type', sa.String(length=9), nullable=True), - sa.Column('broker_key', sa.String(length=5), nullable=False), - sa.Column('name', sa.String(length=80), nullable=True), - sa.Column('address', sa.String(length=1500), nullable=True), - sa.Column('postal_code', sa.String(length=15), nullable=True), - sa.Column('city', sa.String(length=30), nullable=True), - sa.Column('state', sa.String(length=30), nullable=True), - sa.Column('phone', sa.String(length=30), nullable=True), - sa.Column('fax', sa.String(length=30), nullable=True), - sa.Column('email', sa.String(length=100), nullable=True), - sa.Column('country', sa.String(length=3), nullable=True), - sa.Column('tax_id', sa.String(length=30), nullable=True), - sa.Column('personal_id', sa.String(length=20), nullable=True), - sa.Column('position', sa.String(length=30), nullable=True), - sa.Column('license', sa.String(length=4), nullable=True), - sa.Column('company', sa.String(length=200), nullable=True), - sa.Column('contact', sa.String(length=80), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='customs_brokers_pkey'), - sa.UniqueConstraint('broker_key', 'tenant_id', 'company_id', name='uq_broker_key_tenant_company'), - schema='a76' - ) - op.create_index(op.f('ix_a76_customs_brokers_company_id'), 'customs_brokers', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_customs_brokers_tenant_id'), 'customs_brokers', ['tenant_id'], unique=False, schema='a76') - op.create_table('doda', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('integration_number', sa.String(length=30), nullable=True), - sa.Column('doda_date', sa.Integer(), nullable=True), - sa.Column('doda_time', sa.Integer(), nullable=True), - sa.Column('dispatch_customs', sa.String(length=3), nullable=True), - sa.Column('customs_sections', sa.String(length=3), nullable=True), - sa.Column('patent', sa.String(length=4), nullable=True), - sa.Column('pedimentos', sa.String(length=80), nullable=True), - sa.Column('caat', sa.String(length=10), nullable=True), - sa.Column('transport_identification', sa.String(length=20), nullable=True), - sa.Column('fast_id', sa.String(length=20), nullable=True), - sa.Column('operation_type', sa.String(length=1), nullable=True), - sa.Column('selected', sa.Boolean(), nullable=True), - sa.Column('user_selected', sa.String(length=30), nullable=True), - sa.Column('last_user', sa.String(length=30), nullable=True), - sa.Column('responsible', sa.String(length=14), nullable=True), - sa.Column('carrier', sa.String(length=8), nullable=True), - sa.Column('shipments', sa.String(length=80), nullable=True), - sa.Column('pedimento_type', sa.String(length=30), nullable=True), - sa.Column('original_chain', sa.String(length=5000), nullable=True), - sa.Column('serial_number', sa.String(length=21), nullable=True), - sa.Column('electronic_signature', sa.String(length=2000), nullable=True), - sa.Column('transaction_number', sa.String(length=30), nullable=True), - sa.Column('status', sa.String(length=30), nullable=True), - sa.Column('linq_sat_qr', sa.String(length=1000), nullable=True), - sa.Column('sat_certificate', sa.String(length=2001), nullable=True), - sa.Column('sat_digital_seal', sa.Text(), nullable=True), - sa.Column('xml_doda_sent_path', sa.String(length=1000), nullable=True), - sa.Column('xml_doda_response_path', sa.String(length=1000), nullable=True), - sa.Column('sat_original_chain', sa.Text(), nullable=True), - sa.Column('customs_clearance', sa.Integer(), nullable=True), - sa.Column('unique_badge_number', sa.String(length=250), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='doda_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_doda_company_id'), 'doda', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_doda_tenant_id'), 'doda', ['tenant_id'], unique=False, schema='a76') - op.create_table('electronic_notices', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('notice_number', sa.String(length=500), nullable=True), - sa.Column('year', sa.String(length=20), nullable=True), - sa.Column('patent', sa.String(length=4), nullable=True), - sa.Column('pedimento', sa.String(length=15), nullable=True), - sa.Column('file_sent', sa.String(length=1000), nullable=True), - sa.Column('file_response', sa.String(length=1000), nullable=True), - sa.Column('status', sa.String(length=100), nullable=True), - sa.Column('invoice', sa.String(length=50), nullable=True), - sa.Column('validation_acknowledgment', sa.String(length=20), nullable=True), - sa.Column('fea', sa.String(length=1000), nullable=True), - sa.Column('certificate_number', sa.String(length=50), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='electronic_notices_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_electronic_notices_company_id'), 'electronic_notices', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_electronic_notices_tenant_id'), 'electronic_notices', ['tenant_id'], unique=False, schema='a76') - op.create_table('equivalencies', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('identifier', sa.String(length=10), nullable=False), - sa.Column('description', sa.String(length=200), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('identifier', 'tenant_id', 'company_id', name='uq_equivalency_identifier'), - schema='a76' - ) - op.create_index(op.f('ix_a76_equivalencies_company_id'), 'equivalencies', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_equivalencies_tenant_id'), 'equivalencies', ['tenant_id'], unique=False, schema='a76') - op.create_table('error_classifications', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=100), nullable=False), - sa.Column('level', sa.String(length=3), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='error_classifications_pkey'), - sa.UniqueConstraint('code'), - sa.UniqueConstraint('code', name='error_classifications_code_unique'), - schema='a76' - ) - op.create_index(op.f('ix_a76_error_classifications_company_id'), 'error_classifications', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_error_classifications_tenant_id'), 'error_classifications', ['tenant_id'], unique=False, schema='a76') - op.create_table('exchange_rate', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('date', sa.DateTime(), nullable=False), - sa.Column('value', sa.DECIMAL(precision=13, scale=6), nullable=True), - sa.Column('local_currency', sa.String(length=7), nullable=True), - sa.Column('foreign_currency', sa.String(length=7), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='exchange_rate_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'date', name='uq_exchange_rate_date_tenant'), - schema='a76' - ) - op.create_index(op.f('ix_a76_exchange_rate_company_id'), 'exchange_rate', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_exchange_rate_tenant_id'), 'exchange_rate', ['tenant_id'], unique=False, schema='a76') - op.create_table('fraction_rule_octave', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('permission', sa.String(length=20), nullable=False), - sa.Column('line', sa.Integer(), nullable=False), - sa.Column('fraction', sa.String(length=10), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='fraction_rule_octave_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', name='uq_fraction_rule_octave_permission_line_fraction'), - schema='a76' - ) - op.create_index(op.f('ix_a76_fraction_rule_octave_company_id'), 'fraction_rule_octave', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), 'fraction_rule_octave', ['tenant_id'], unique=False, schema='a76') - op.create_table('identifiers', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=2), nullable=False), - sa.Column('description', sa.String(length=1000), nullable=True), - sa.Column('level', sa.String(length=1), nullable=True), - sa.Column('complement', sa.String(length=5000), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', name='uq_identifier_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_identifiers_company_id'), 'identifiers', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_identifiers_tenant_id'), 'identifiers', ['tenant_id'], unique=False, schema='a76') - op.create_table('inpc', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('year', sa.String(length=4), nullable=False), - sa.Column('month', sa.String(length=2), nullable=False), - sa.Column('value', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('year', 'month', 'tenant_id', 'company_id', name='uq_inpc_year_month'), - schema='a76' - ) - op.create_index(op.f('ix_a76_inpc_company_id'), 'inpc', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_inpc_tenant_id'), 'inpc', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_header', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('system', sa.String(length=12), nullable=True), - sa.Column('operation_type', sa.String(length=10), nullable=False), - sa.Column('invoice_type', sa.String(length=5), nullable=True), - sa.Column('invoice_number', sa.String(length=20), nullable=True), - sa.Column('project_number', sa.String(length=14), nullable=True), - sa.Column('purchase_order', sa.String(length=50), nullable=True), - sa.Column('related_doc_id', sa.Integer(), nullable=True), - sa.Column('alternate_invoice', sa.String(length=99), nullable=True), - sa.Column('invoice_ref', sa.String(length=19), nullable=True), - sa.Column('proforma_number', sa.String(length=20), nullable=True), - sa.Column('invoice_date', sa.Date(), nullable=True), - sa.Column('capture_date', sa.TIMESTAMP(), nullable=False), - sa.Column('emission_date', sa.Date(), nullable=True), - sa.Column('is_updated', sa.Boolean(), nullable=True), - sa.Column('updated_date', sa.TIMESTAMP(), nullable=True), - sa.Column('who_updated', sa.String(length=20), nullable=True), - sa.Column('capture_user', sa.String(length=20), nullable=True), - sa.Column('traffic_light_status', sa.String(length=50), nullable=True), - sa.Column('process_log', sa.String(length=300), nullable=True), - sa.Column('status_rec', sa.Integer(), nullable=True), - sa.Column('status_rep', sa.String(length=2), nullable=True), - sa.Column('observation_es', sa.Text(), nullable=True), - sa.Column('observation_en', sa.Text(), nullable=True), - sa.Column('comments_status', sa.Text(), nullable=True), - sa.Column('vu_observations', sa.String(length=500), nullable=True), - sa.Column('cfdi_uuid', sa.String(length=100), nullable=True), - sa.Column('path_pdf', sa.String(length=500), nullable=True), - sa.Column('path_xml', sa.String(length=500), nullable=True), - sa.Column('subcompany', sa.String(length=5), nullable=True), - sa.Column('party_count', sa.Integer(), nullable=True), - sa.Column('generate_id', sa.String(length=1), nullable=True), - sa.Column('generate_desc_parties', sa.String(length=12), nullable=True), - sa.Column('apply_manual_discount', sa.String(length=1), nullable=True), - sa.Column('is_bulk', sa.Boolean(), nullable=True), - sa.Column('download_substance', sa.Boolean(), nullable=True), - sa.Column('download_class', sa.Boolean(), nullable=True), - sa.Column('download_def', sa.Boolean(), nullable=True), - sa.Column('payment_terms', sa.String(length=200), nullable=True), - sa.Column('handling_fees', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('option_iv18', sa.String(length=50), nullable=True), - sa.Column('enajenation_goods', sa.Boolean(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['invoice_type'], ['public.invoice_types.key'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_header_company_id'), 'invoice_header', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_header_tenant_id'), 'invoice_header', ['tenant_id'], unique=False, schema='a76') - op.create_table('legends', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.Integer(), nullable=False), - sa.Column('description', sa.String(length=2000), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_legend_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_legends_company_id'), 'legends', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_legends_tenant_id'), 'legends', ['tenant_id'], unique=False, schema='a76') - op.create_table('multi_currency_types', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('currency_type_code', sa.String(length=3), nullable=False), - sa.Column('country_key', sa.String(length=3), nullable=True), - sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), - sa.Column('publication_date', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['country_key'], ['public.countries.m3_key'], ), - sa.ForeignKeyConstraint(['currency_type_code'], ['public.currency_types.code'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('currency_type_code', 'publication_date', 'tenant_id', 'company_id', name='uq_multi_currency_type_code_date'), - schema='a76' - ) - op.create_index(op.f('ix_a76_multi_currency_types_company_id'), 'multi_currency_types', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_multi_currency_types_tenant_id'), 'multi_currency_types', ['tenant_id'], unique=False, schema='a76') - op.create_table('packages', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('key', sa.String(length=5), nullable=False), - sa.Column('description_es', sa.String(length=40), nullable=True), - sa.Column('description_en', sa.String(length=40), nullable=True), - sa.Column('weight_unit', sa.DECIMAL(precision=19, scale=8), nullable=True), - sa.Column('plurals', sa.String(length=4), nullable=True), - sa.Column('plural_in', sa.String(length=4), nullable=True), - sa.Column('code_ace', sa.String(length=4), nullable=True), - sa.Column('code_aamex', sa.String(length=9), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='packages_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'key', name='packages_key_ukey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_packages_company_id'), 'packages', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_packages_tenant_id'), 'packages', ['tenant_id'], unique=False, schema='a76') - op.create_table('packing_lists', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('packing_list_number', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_packing_lists_company_id'), 'packing_lists', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_packing_lists_tenant_id'), 'packing_lists', ['tenant_id'], unique=False, schema='a76') - op.create_table('permission_rule_oct', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('permission', sa.String(length=20), nullable=False), - sa.Column('start_date', sa.Integer(), nullable=True), - sa.Column('end_date', sa.Integer(), nullable=True), - sa.Column('sector', sa.String(length=8), nullable=True), - sa.Column('system', sa.String(length=5), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='permission_rule_oct_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'permission', name='permission_rule_oct_permission_tenant_ukey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_permission_rule_oct_company_id'), 'permission_rule_oct', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_permission_rule_oct_tenant_id'), 'permission_rule_oct', ['tenant_id'], unique=False, schema='a76') - op.create_table('ports', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('port_code', sa.String(length=6), nullable=False), - sa.Column('description', sa.String(length=20), nullable=True), - sa.Column('location_code', sa.String(length=4), nullable=False), - sa.Column('location_description', sa.String(length=20), nullable=True), - sa.Column('port_type', sa.String(length=15), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('port_code', 'location_code', 'tenant_id', 'company_id', name='uq_port_location'), - schema='a76' - ) - op.create_index(op.f('ix_a76_ports_company_id'), 'ports', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_ports_tenant_id'), 'ports', ['tenant_id'], unique=False, schema='a76') - op.create_table('prevalidators', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('code', sa.String(length=20), nullable=False), - sa.Column('customs_prevalidator', sa.String(length=20), nullable=True), - sa.Column('patent_prevalidator', sa.String(length=20), nullable=True), - sa.Column('description', sa.String(length=50), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='prevalidators_pkey'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='prevalidators_code_unique'), - schema='a76' - ) - op.create_index(op.f('ix_a76_prevalidators_company_id'), 'prevalidators', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_prevalidators_tenant_id'), 'prevalidators', ['tenant_id'], unique=False, schema='a76') - op.create_table('seal', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('seal', sa.String(length=15), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='seal_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'seal', name='seal_ukey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_seal_company_id'), 'seal', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_seal_tenant_id'), 'seal', ['tenant_id'], unique=False, schema='a76') - op.create_table('signatures', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=10), nullable=False), - sa.Column('signature', sa.String(length=1000), nullable=True), - sa.Column('photo_path', sa.String(length=1000), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='signatures_pkey'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='signatures_code_unique'), - schema='a76' - ) - op.create_index(op.f('ix_a76_signatures_company_id'), 'signatures', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_signatures_tenant_id'), 'signatures', ['tenant_id'], unique=False, schema='a76') - op.create_table('subassembly_entries', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('remission_line', sa.Integer(), nullable=False), - sa.Column('exit_invoice', sa.String(length=15), nullable=True), - sa.Column('exit_line', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_subassembly_entries_company_id'), 'subassembly_entries', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_subassembly_entries_tenant_id'), 'subassembly_entries', ['tenant_id'], unique=False, schema='a76') - op.create_table('trailer_type', - sa.Column('trailer_type_key', sa.String(length=2), nullable=False), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('trailer_type_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_trailer_type_company_id'), 'trailer_type', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_trailer_type_tenant_id'), 'trailer_type', ['tenant_id'], unique=False, schema='a76') - op.create_table('transporter', - sa.Column('transporter_key', sa.String(length=5), nullable=False), - sa.Column('name', sa.String(length=256), nullable=True), - sa.Column('short_name', sa.String(length=10), nullable=True), - sa.Column('responsible', sa.String(length=100), nullable=True), - sa.Column('rfc', sa.String(length=30), nullable=True), - sa.Column('streets', sa.String(length=100), nullable=True), - sa.Column('postal_code', sa.String(length=15), nullable=True), - sa.Column('city', sa.String(length=30), nullable=True), - sa.Column('state', sa.String(length=30), nullable=True), - sa.Column('country', sa.String(length=3), nullable=True), - sa.Column('loader_code', sa.String(length=9), nullable=True), - sa.Column('caat_code', sa.String(length=49), nullable=True), - sa.Column('transport_code', sa.String(length=8), nullable=True), - sa.Column('transport_interface_type', sa.String(length=20), nullable=True), - sa.Column('ftp_server', sa.String(length=200), nullable=True), - sa.Column('ftp_user', sa.String(length=200), nullable=True), - sa.Column('ftp_password', sa.String(length=100), nullable=True), - sa.Column('ftp_directory', sa.String(length=1000), nullable=True), - sa.Column('filler_code', sa.String(length=4), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('transporter_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_transporter_company_id'), 'transporter', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_transporter_tenant_id'), 'transporter', ['tenant_id'], unique=False, schema='a76') - op.create_table('unit_of_measure_ace', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=4), nullable=False), - sa.Column('description', sa.String(length=49), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_ace_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_ace_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_unit_of_measure_ace_company_id'), 'unit_of_measure_ace', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_unit_of_measure_ace_tenant_id'), 'unit_of_measure_ace', ['tenant_id'], unique=False, schema='a76') - op.create_table('unit_of_measure_american', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=3), nullable=False), - sa.Column('description', sa.String(length=40), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_american_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_american_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_unit_of_measure_american_company_id'), 'unit_of_measure_american', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_unit_of_measure_american_tenant_id'), 'unit_of_measure_american', ['tenant_id'], unique=False, schema='a76') - op.create_table('unit_of_measure_customs', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=2), nullable=False), - sa.Column('description', sa.String(length=20), nullable=True), - sa.Column('scaii_unit_code', sa.String(length=5), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_customs_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_customs_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_unit_of_measure_customs_company_id'), 'unit_of_measure_customs', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_unit_of_measure_customs_tenant_id'), 'unit_of_measure_customs', ['tenant_id'], unique=False, schema='a76') - op.create_table('unit_of_measure_oma', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=10), nullable=False), - sa.Column('description', sa.String(length=200), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_oma_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_oma_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_unit_of_measure_oma_company_id'), 'unit_of_measure_oma', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_unit_of_measure_oma_tenant_id'), 'unit_of_measure_oma', ['tenant_id'], unique=False, schema='a76') - op.create_table('units_of_measure', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=5), nullable=False), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('description_en', sa.String(length=100), nullable=True), - sa.Column('customs_code', sa.String(length=2), nullable=True), - sa.Column('american_code', sa.String(length=3), nullable=True), - sa.Column('ace_code', sa.String(length=4), nullable=True), - sa.Column('oma_code', sa.String(length=10), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['ace_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_ace.code', 'a76.unit_of_measure_ace.tenant_id', 'a76.unit_of_measure_ace.company_id'], name='fk_uom_ace', use_alter=True), - sa.ForeignKeyConstraint(['american_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_american.code', 'a76.unit_of_measure_american.tenant_id', 'a76.unit_of_measure_american.company_id'], name='fk_uom_american', use_alter=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['customs_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_customs.code', 'a76.unit_of_measure_customs.tenant_id', 'a76.unit_of_measure_customs.company_id'], name='fk_uom_customs', use_alter=True), - sa.ForeignKeyConstraint(['oma_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_oma.code', 'a76.unit_of_measure_oma.tenant_id', 'a76.unit_of_measure_oma.company_id'], name='fk_uom_oma', use_alter=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_units_of_measure_company_id'), 'units_of_measure', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_units_of_measure_tenant_id'), 'units_of_measure', ['tenant_id'], unique=False, schema='a76') - op.create_table('units_of_measure_general', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=5), nullable=False), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), - sa.Column('mexico_unit', sa.String(length=5), nullable=True), - sa.Column('american_unit_code', sa.String(length=5), nullable=True), - sa.Column('customs_code', sa.String(length=2), nullable=True), - sa.Column('ace_code', sa.String(length=4), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['ace_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_ace.code', 'a76.unit_of_measure_ace.tenant_id', 'a76.unit_of_measure_ace.company_id'], name='fk_uom_general_ace', use_alter=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['customs_code', 'tenant_id', 'company_id'], ['a76.unit_of_measure_customs.code', 'a76.unit_of_measure_customs.tenant_id', 'a76.unit_of_measure_customs.company_id'], name='fk_uom_general_customs', use_alter=True), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_general_code'), - sa.UniqueConstraint('code', 'tenant_id', 'company_id', name='uq_uom_general_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_units_of_measure_general_company_id'), 'units_of_measure_general', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_units_of_measure_general_tenant_id'), 'units_of_measure_general', ['tenant_id'], unique=False, schema='a76') - op.create_table('vehicle', - sa.Column('vehicle_key', sa.String(length=14), nullable=False), - sa.Column('ace_vehicle_key', sa.String(length=10), nullable=True), - sa.Column('transporter_key', sa.String(length=23), nullable=True), - sa.Column('transport_identifier', sa.String(length=30), nullable=True), - sa.Column('transport_type', sa.String(length=2), nullable=True), - sa.Column('entity_code', sa.String(length=1), nullable=True), - sa.Column('transponder_number', sa.String(length=16), nullable=True), - sa.Column('dot_number', sa.String(length=8), nullable=True), - sa.Column('plate_number', sa.String(length=17), nullable=True), - sa.Column('city', sa.String(length=30), nullable=True), - sa.Column('state', sa.String(length=30), nullable=True), - sa.Column('country', sa.String(length=3), nullable=True), - sa.Column('seal', sa.String(length=49), nullable=True), - sa.Column('insurance_company_name', sa.String(length=30), nullable=True), - sa.Column('insurance_number', sa.String(length=20), nullable=True), - sa.Column('insurance_amount', sa.DECIMAL(precision=13, scale=2), nullable=True), - sa.Column('insurance_date', sa.Integer(), nullable=True), - sa.Column('box_number', sa.String(length=300), nullable=True), - sa.Column('brand', sa.String(length=20), nullable=True), - sa.Column('year', sa.String(length=4), nullable=True), - sa.Column('series', sa.String(length=30), nullable=True), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('engine_number', sa.String(length=50), nullable=True), - sa.Column('sct_permission', sa.String(length=40), nullable=True), - sa.Column('color', sa.String(length=20), nullable=True), - sa.Column('container_key', sa.String(length=3), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('vehicle_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_vehicle_company_id'), 'vehicle', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_vehicle_tenant_id'), 'vehicle', ['tenant_id'], unique=False, schema='a76') - op.create_table('user_tenants', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('keycloak_user_id', sa.String(length=255), nullable=False), - sa.Column('is_active', sa.Boolean(), nullable=False), - sa.Column('role', sa.String(length=50), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('keycloak_user_id', 'tenant_id', 'company_id', name='uq_user_tenant'), - schema='core' - ) - op.create_index(op.f('ix_core_user_tenants_company_id'), 'user_tenants', ['company_id'], unique=False, schema='core') - op.create_index(op.f('ix_core_user_tenants_id'), 'user_tenants', ['id'], unique=False, schema='core') - op.create_index(op.f('ix_core_user_tenants_keycloak_user_id'), 'user_tenants', ['keycloak_user_id'], unique=False, schema='core') - op.create_index(op.f('ix_core_user_tenants_tenant_id'), 'user_tenants', ['tenant_id'], unique=False, schema='core') - op.create_table('classes', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('client_id', sa.Integer(), nullable=False), - sa.Column('class_code', sa.String(length=8), nullable=False), - sa.Column('description_es', sa.String(length=500), nullable=True), - sa.Column('description_en', sa.String(length=500), nullable=True), - sa.Column('material_key', sa.String(length=10), nullable=True), - sa.Column('unit_of_measure', sa.String(length=5), nullable=True), - sa.Column('fraction', sa.String(length=10), nullable=True), - sa.Column('us_fraction', sa.String(length=16), nullable=True), - sa.Column('sub_key', sa.String(length=5), nullable=True), - sa.Column('physical_review', sa.SmallInteger(), nullable=True), - sa.Column('iva_exempt_fraction', sa.String(length=4), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_classes_client'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['material_key'], ['public.material_types.key'], name='fk_classes_material_type'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), - sa.PrimaryKeyConstraint('id', name='classes_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'client_id', 'class_code', name='ufa_classes_client_id_class_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_classes_company_id'), 'classes', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_classes_tenant_id'), 'classes', ['tenant_id'], unique=False, schema='a76') - op.create_table('clients_and_providers_address', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('client_id', sa.Integer(), nullable=False), - sa.Column('municipality', sa.String(length=150), nullable=True), - sa.Column('streets', sa.String(length=100), nullable=True), - sa.Column('neighborhood', sa.String(length=40), nullable=True), - sa.Column('interior_number', sa.String(length=20), nullable=True), - sa.Column('exterior_number', sa.String(length=20), nullable=True), - sa.Column('postal_code', sa.String(length=15), nullable=True), - sa.Column('city', sa.String(length=30), nullable=True), - sa.Column('state', sa.String(length=30), nullable=True), - sa.Column('country', sa.String(length=3), nullable=True), - sa.Column('phone', sa.String(length=30), nullable=True), - sa.Column('fax_number', sa.String(length=30), nullable=True), - sa.Column('email', sa.String(length=100), nullable=True), - sa.Column('contact', sa.String(length=50), nullable=True), - sa.Column('reference', sa.String(length=250), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_address_client', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='clients_and_providers_address_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_clients_and_providers_address_company_id'), 'clients_and_providers_address', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), 'clients_and_providers_address', ['tenant_id'], unique=False, schema='a76') - op.create_table('clients_and_providers_programs', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('client_id', sa.Integer(), nullable=False), - sa.Column('program', sa.String(length=7), nullable=True), - sa.Column('program_number', sa.String(length=40), nullable=True), - sa.Column('prosec', sa.SmallInteger(), nullable=True), - sa.Column('prosec_authorization', sa.String(length=20), nullable=True), - sa.Column('secon_auth_date', sa.Integer(), nullable=True), - sa.Column('manufacturer_id', sa.String(length=25), nullable=True), - sa.Column('tax_id', sa.String(length=30), nullable=True), - sa.Column('broker', sa.String(length=6), nullable=True), - sa.Column('import_broker', sa.String(length=6), nullable=True), - sa.Column('transfer_key', sa.String(length=8), nullable=True), - sa.Column('secon_authorization', sa.String(length=20), nullable=True), - sa.Column('applied_proportion', sa.Numeric(precision=7, scale=2), nullable=True), - sa.Column('is_certified_company', sa.String(length=1), nullable=True), - sa.Column('certified_company_registry', sa.String(length=40), nullable=True), - sa.Column('donation_auth_number', sa.String(length=50), nullable=True), - sa.Column('ctpat_svi', sa.String(length=100), nullable=True), - sa.Column('tax_registry_number', sa.String(length=40), nullable=True), - sa.Column('subassembly_service', sa.SmallInteger(), nullable=True), - sa.Column('autse_dates', sa.Integer(), nullable=True), - sa.Column('autse_number', sa.String(length=300), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_clients_and_providers_programs_client', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='clients_and_providers_programs_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_clients_and_providers_programs_company_id'), 'clients_and_providers_programs', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), 'clients_and_providers_programs', ['tenant_id'], unique=False, schema='a76') - op.create_table('concepts', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('code', sa.String(length=15), nullable=False), - sa.Column('description', sa.String(length=120), nullable=True), - sa.Column('description_en', sa.String(length=120), nullable=True), - sa.Column('detailed_description', sa.String(length=1000), nullable=True), - sa.Column('priority', sa.Integer(), nullable=True), - sa.Column('priority_ame', sa.Integer(), nullable=True), - sa.Column('first_total', sa.Boolean(), nullable=True), - sa.Column('type', sa.String(length=9), nullable=True), - sa.Column('is_printed', sa.Boolean(), nullable=True), - sa.Column('section', sa.Integer(), nullable=True), - sa.Column('classification', sa.String(length=30), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['classification'], ['a76.classification_concepts.classification'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('code', name='uq_concept_code'), - schema='a76' - ) - op.create_index(op.f('ix_a76_concepts_tenant_id'), 'concepts', ['tenant_id'], unique=False, schema='a76') - op.create_table('country_rule_oct', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('permission', sa.String(length=20), nullable=False), - sa.Column('line', sa.Integer(), nullable=False), - sa.Column('fraction', sa.String(length=10), nullable=False), - sa.Column('country_code', sa.String(length=3), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id', 'company_id', 'permission', 'line', 'fraction'], ['a76.fraction_rule_octave.tenant_id', 'a76.fraction_rule_octave.company_id', 'a76.fraction_rule_octave.permission', 'a76.fraction_rule_octave.line', 'a76.fraction_rule_octave.fraction'], name='fk_country_rule_oct_frac_octava', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='country_rule_oct_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'permission', 'line', 'fraction', 'country_code', name='uq_country_rule_oct_permission_line_fraction_country'), - schema='a76' - ) - op.create_index(op.f('ix_a76_country_rule_oct_company_id'), 'country_rule_oct', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_country_rule_oct_tenant_id'), 'country_rule_oct', ['tenant_id'], unique=False, schema='a76') - op.create_table('customs_brokers_personnel', - sa.Column('customs_broker_id', sa.Integer(), nullable=False), - sa.Column('line', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=80), nullable=True), - sa.Column('tax_id', sa.String(length=30), nullable=True), - sa.Column('personal_id', sa.String(length=20), nullable=True), - sa.Column('position', sa.String(length=30), nullable=True), - sa.Column('license', sa.String(length=4), nullable=True), - sa.Column('first_name', sa.String(length=80), nullable=True), - sa.Column('last_name', sa.String(length=80), nullable=True), - sa.Column('middle_name', sa.String(length=80), nullable=True), - sa.Column('email', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('customs_broker_id', 'line'), - schema='a76' - ) - op.create_index(op.f('ix_a76_customs_brokers_personnel_company_id'), 'customs_brokers_personnel', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), 'customs_brokers_personnel', ['tenant_id'], unique=False, schema='a76') - op.create_table('customs_brokers_vu', - sa.Column('customs_broker_id', sa.Integer(), nullable=False), - sa.Column('certificate_path', sa.String(length=1499), nullable=True), - sa.Column('key_path', sa.String(length=1499), nullable=True), - sa.Column('access_key', sa.String(length=50), nullable=True), - sa.Column('fiel_format', sa.String(length=19), nullable=True), - sa.Column('signature_read_path', sa.String(length=1499), nullable=True), - sa.Column('archive_path', sa.String(length=1499), nullable=True), - sa.Column('fiel_access_key', sa.String(length=50), nullable=True), - sa.Column('web_service_user', sa.String(length=100), nullable=True), - sa.Column('web_service_access_key', sa.String(length=100), nullable=True), - sa.Column('vu_email', sa.String(length=800), nullable=True), - sa.Column('vu_figure_type', sa.String(length=29), nullable=True), - sa.Column('xml_files_path', sa.String(length=1499), nullable=True), - sa.Column('query_tax_id', sa.String(length=30), nullable=True), - sa.Column('doda_certificate_path', sa.String(length=1499), nullable=True), - sa.Column('doda_key_path', sa.String(length=1499), nullable=True), - sa.Column('doda_web_service_user', sa.String(length=100), nullable=True), - sa.Column('doda_web_service_access_key', sa.String(length=100), nullable=True), - sa.Column('doda_fiel_access_key', sa.String(length=50), nullable=True), - sa.Column('doda_xml_files_path', sa.String(length=1499), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('customs_broker_id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_customs_brokers_vu_company_id'), 'customs_brokers_vu', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), 'customs_brokers_vu', ['tenant_id'], unique=False, schema='a76') - op.create_table('doda_american_pedimentos', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('doda_id', sa.Integer(), nullable=False), - sa.Column('american_pedimento_line', sa.Integer(), nullable=False), - sa.Column('american_pedimento_type', sa.String(length=2), nullable=True), - sa.Column('american_pedimento_value', sa.String(length=20), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_american_pedimentos_doda'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='doda_american_pedimentos_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_doda_american_pedimentos_company_id'), 'doda_american_pedimentos', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), 'doda_american_pedimentos', ['tenant_id'], unique=False, schema='a76') - op.create_table('doda_containers', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('doda_id', sa.Integer(), nullable=False), - sa.Column('container_line', sa.Integer(), nullable=False), - sa.Column('container_value', sa.String(length=20), nullable=True), - sa.Column('seals', sa.String(length=254), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_containers_doda'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='doda_containers_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_doda_containers_company_id'), 'doda_containers', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_doda_containers_tenant_id'), 'doda_containers', ['tenant_id'], unique=False, schema='a76') - op.create_table('doda_pedimentos', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('doda_id', sa.Integer(), nullable=False), - sa.Column('pedimento_line', sa.Integer(), nullable=False), - sa.Column('authorization_patent', sa.String(length=10), nullable=True), - sa.Column('document', sa.String(length=50), nullable=True), - sa.Column('shipment', sa.String(length=11), nullable=True), - sa.Column('cove', sa.String(length=50), nullable=True), - sa.Column('umc', sa.String(length=20), nullable=True), - sa.Column('effective_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True), - sa.Column('difference_amount_usd', sa.Numeric(precision=15, scale=2), nullable=True), - sa.Column('dta_niu', sa.String(length=20), nullable=True), - sa.Column('article_7', sa.Boolean(), nullable=True), - sa.Column('pedimento_id', sa.Integer(), nullable=True), - sa.Column('invoice_line', sa.Integer(), nullable=True), - sa.Column('part_ii_line', sa.Integer(), nullable=True), - sa.Column('pedimento_type', sa.String(length=20), nullable=True), - sa.Column('zero_packaging_validation', sa.Boolean(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['doda_id'], ['a76.doda.id'], name='fk_doda_pedimentos_doda'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='doda_pedimentos_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_doda_pedimentos_company_id'), 'doda_pedimentos', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_doda_pedimentos_tenant_id'), 'doda_pedimentos', ['tenant_id'], unique=False, schema='a76') - op.create_table('driver', - sa.Column('transporter_key', sa.String(length=5), nullable=False), - sa.Column('line', sa.Integer(), nullable=False), - sa.Column('driver_name', sa.String(length=80), nullable=True), - sa.Column('license_number', sa.String(length=29), nullable=True), - sa.Column('express_line_id', sa.String(length=17), nullable=True), - sa.Column('ace_id', sa.String(length=20), nullable=True), - sa.Column('birth_date', sa.Integer(), nullable=True), - sa.Column('gender', sa.String(length=1), nullable=True), - sa.Column('birth_country', sa.String(length=3), nullable=True), - sa.Column('hazardous_material_auth', sa.String(length=2), nullable=True), - sa.Column('hazardous_material_state', sa.String(length=30), nullable=True), - sa.Column('first_name', sa.String(length=20), nullable=True), - sa.Column('last_name', sa.String(length=20), nullable=True), - sa.Column('id_key1', sa.String(length=40), nullable=True), - sa.Column('id_number1', sa.String(length=20), nullable=True), - sa.Column('id_state1', sa.String(length=30), nullable=True), - sa.Column('id_country1', sa.String(length=3), nullable=True), - sa.Column('id_key2', sa.String(length=40), nullable=True), - sa.Column('id_number2', sa.String(length=20), nullable=True), - sa.Column('id_state2', sa.String(length=30), nullable=True), - sa.Column('id_country2', sa.String(length=3), nullable=True), - sa.Column('badge_number', sa.String(length=20), nullable=True), - sa.Column('class_type', sa.String(length=1), nullable=True), - sa.Column('unique_badge_number', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['transporter_key'], ['a76.transporter.transporter_key'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('transporter_key', 'line'), - schema='a76' - ) - op.create_index(op.f('ix_a76_driver_company_id'), 'driver', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_driver_tenant_id'), 'driver', ['tenant_id'], unique=False, schema='a76') - op.create_table('equivalency_items', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('equivalency_id', sa.Integer(), nullable=False), - sa.Column('original_field', sa.String(length=100), nullable=False), - sa.Column('external_field', sa.String(length=100), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['equivalency_id'], ['a76.equivalencies.id'], ), - sa.ForeignKeyConstraint(['original_field', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('equivalency_id', 'original_field', 'external_field', 'tenant_id', 'company_id', name='uq_equivalency_item_fields'), - schema='a76' - ) - op.create_index(op.f('ix_a76_equivalency_items_company_id'), 'equivalency_items', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_equivalency_items_tenant_id'), 'equivalency_items', ['tenant_id'], unique=False, schema='a76') - op.create_table('error_catalogs', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('code', sa.String(length=15), nullable=False), - sa.Column('description', sa.String(length=255), nullable=True), - sa.Column('classification_id', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['classification_id'], ['a76.error_classifications.id'], name='fk_error_catalogs_classification'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='error_catalogs_pkey'), - sa.UniqueConstraint('code'), - sa.UniqueConstraint('code', name='error_catalogs_code_unique'), - schema='a76' - ) - op.create_index(op.f('ix_a76_error_catalogs_company_id'), 'error_catalogs', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_error_catalogs_tenant_id'), 'error_catalogs', ['tenant_id'], unique=False, schema='a76') - op.create_table('identifier_details', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('invoice_consecutive', sa.Integer(), nullable=True), - sa.Column('part_line', sa.Integer(), nullable=True), - sa.Column('identifier_code', sa.String(length=2), nullable=True), - sa.Column('module', sa.String(length=20), nullable=True), - sa.Column('complement1', sa.String(length=50), nullable=True), - sa.Column('complement2', sa.String(length=51), nullable=True), - sa.Column('complement3', sa.String(length=50), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['identifier_code'], ['a76.identifiers.code'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_identifier_details_company_id'), 'identifier_details', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_identifier_details_tenant_id'), 'identifier_details', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_collections', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('line_number', sa.Integer(), nullable=False), - sa.Column('invoice_number', sa.String(length=15), nullable=True), - sa.Column('concept', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_collections_company_id'), 'invoice_collections', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_collections_tenant_id'), 'invoice_collections', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_compliance_mx', - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('pedimento', sa.String(length=19), nullable=True), - sa.Column('pedimento_code', sa.String(length=5), nullable=True), - sa.Column('pedimento_k1', sa.String(length=15), nullable=True), - sa.Column('remesa', sa.Integer(), nullable=True), - sa.Column('aduana', sa.String(length=3), nullable=True), - sa.Column('port_of_entry', sa.String(length=6), nullable=True), - sa.Column('destination', sa.String(length=3), nullable=True), - sa.Column('manifest_number', sa.String(length=15), nullable=True), - sa.Column('provider_header', sa.String(length=20), nullable=True), - sa.Column('provider_id', sa.Integer(), nullable=True), - sa.Column('sold_to_header', sa.String(length=20), nullable=True), - sa.Column('sold_to_id', sa.Integer(), nullable=True), - sa.Column('shipped_to_header', sa.String(length=20), nullable=True), - sa.Column('shipped_to_id', sa.Integer(), nullable=True), - sa.Column('shipped_by_header', sa.String(length=20), nullable=True), - sa.Column('shipped_by_id', sa.Integer(), nullable=True), - sa.Column('customs_broker_id', sa.Integer(), nullable=True), - sa.Column('customs_broker_us_id', sa.Integer(), nullable=True), - sa.Column('broker_invoice_num', sa.String(length=20), nullable=True), - sa.Column('broker_invoice_date', sa.Date(), nullable=True), - sa.Column('is_mixed', sa.Boolean(), nullable=True), - sa.Column('waste_type', sa.String(length=1), nullable=True), - sa.Column('scrap_type', sa.String(length=1), nullable=True), - sa.Column('appendix_17', sa.Integer(), nullable=True), - sa.Column('is_regime_change', sa.String(length=1), nullable=True), - sa.Column('which_exchange_rate', sa.String(length=5), nullable=True), - sa.Column('value_method', sa.String(length=2), nullable=True), - sa.Column('act_value', sa.String(length=5), nullable=True), - sa.Column('is_pedimento_pending', sa.Boolean(), nullable=True), - sa.Column('is_owner_of_goods', sa.String(length=2), nullable=True), - sa.Column('generate_balances', sa.String(length=2), nullable=True), - sa.Column('was_reviewed_by_company', sa.Boolean(), nullable=True), - sa.Column('edocument', sa.String(length=50), nullable=True), - sa.Column('electronic_signature', sa.String(length=999), nullable=True), - sa.Column('certificate_number', sa.String(length=99), nullable=True), - sa.Column('niu_number', sa.String(length=19), nullable=True), - sa.Column('bill_of_lading_count', sa.String(length=12), nullable=True), - sa.Column('addendum_vu', sa.String(length=204), nullable=True), - sa.Column('origin_destination_cove', sa.String(length=19), nullable=True), - sa.Column('vucem_operation_num', sa.String(length=19), nullable=True), - sa.Column('customs_person_line', sa.Integer(), nullable=True), - sa.Column('contingency_mode', sa.Boolean(), nullable=True), - sa.Column('enclosure', sa.String(length=4), nullable=True), - sa.Column('guide_type_to_identify', sa.String(length=1), nullable=True), - sa.Column('location', sa.String(length=200), nullable=True), - sa.Column('dot_code', sa.String(length=20), nullable=True), - sa.Column('subdivision', sa.String(length=20), nullable=True), - sa.Column('acts_as', sa.String(length=20), nullable=True), - sa.Column('movement_type', sa.String(length=31), nullable=True), - sa.Column('office_document', sa.String(length=30), nullable=True), - sa.Column('reason_export', sa.String(length=1), nullable=True), - sa.Column('signature_key', sa.String(length=10), nullable=True), - sa.Column('sem_id', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['aduana'], ['public.customs_sections.customs_code'], ), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['customs_broker_id'], ['a76.customs_brokers.id'], ), - sa.ForeignKeyConstraint(['customs_broker_us_id'], ['a76.customs_brokers.id'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['provider_id'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['shipped_by_id'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['shipped_to_id'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['sold_to_id'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('invoice_id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_compliance_mx_company_id'), 'invoice_compliance_mx', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), 'invoice_compliance_mx', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_financials', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('currency', sa.String(length=3), nullable=True), - sa.Column('currency_type', sa.String(length=3), nullable=True), - sa.Column('exchange_rate', sa.Numeric(precision=13, scale=6), nullable=True), - sa.Column('exchange_rate_mm', sa.Numeric(precision=13, scale=6), nullable=True), - sa.Column('value_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('customs_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('customs_value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('raw_material_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('raw_material_value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('aggregate_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('aggregate_value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('aggregate_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('mexican_value_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('mexican_value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('mexican_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('national_packaging_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('national_packaging_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('national_packaging_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('freight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('insurance', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('insurance_value', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('packaging', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('other_increments', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('total_increments_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('total_increments_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('iva_mn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('iva_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('iva_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('iva_factor', sa.String(length=10), nullable=True), - sa.Column('tax_value_me', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('seal_value_2500', sa.Boolean(), nullable=True), - sa.Column('total_quantity', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('bundle_count', sa.Integer(), nullable=True), - sa.Column('weight_factor', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['currency_type'], ['public.currency_types.code'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_financials_company_id'), 'invoice_financials', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_financials_tenant_id'), 'invoice_financials', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_logistics', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('carrier_id', sa.String(length=10), nullable=True), - sa.Column('transport_id', sa.String(length=10), nullable=True), - sa.Column('transport_us_id', sa.String(length=10), nullable=True), - sa.Column('transport_type', sa.String(length=15), nullable=False), - sa.Column('transport_num', sa.String(length=20), nullable=True), - sa.Column('transport_mode', sa.String(length=15), nullable=True), - sa.Column('driver_name', sa.String(length=80), nullable=True), - sa.Column('is_rail', sa.String(length=2), nullable=True), - sa.Column('rail_id', sa.String(length=31), nullable=True), - sa.Column('vehicle_num', sa.String(length=20), nullable=True), - sa.Column('license_plate', sa.String(length=20), nullable=True), - sa.Column('license_plate_complete', sa.String(length=40), nullable=True), - sa.Column('trailer_num', sa.String(length=20), nullable=True), - sa.Column('seal_number', sa.String(length=15), nullable=True), - sa.Column('guide_number', sa.String(length=20), nullable=True), - sa.Column('bill_number', sa.String(length=15), nullable=True), - sa.Column('reference_number', sa.String(length=14), nullable=True), - sa.Column('shipment_number', sa.String(length=19), nullable=True), - sa.Column('incoterm', sa.String(length=5), nullable=True), - sa.Column('identifier_1', sa.String(length=2), nullable=True), - sa.Column('complement_1', sa.String(length=30), nullable=True), - sa.Column('identifier_2', sa.String(length=2), nullable=True), - sa.Column('complement_2', sa.String(length=30), nullable=True), - sa.Column('weight_type', sa.String(length=6), nullable=True), - sa.Column('container_types', sa.String(length=500), nullable=True), - sa.Column('vehicle_data', sa.String(length=500), nullable=True), - sa.Column('origin_location', sa.String(length=200), nullable=True), - sa.Column('destination_location', sa.String(length=200), nullable=True), - sa.Column('transport_itinerary', sa.String(length=1000), nullable=True), - sa.Column('destination_goods', sa.String(length=50), nullable=True), - sa.Column('entry_exit_date', sa.Date(), nullable=True), - sa.Column('delivery_date', sa.Date(), nullable=True), - sa.Column('delivered_status', sa.String(length=2), nullable=True), - sa.Column('received_by', sa.String(length=50), nullable=True), - sa.Column('payment_date', sa.Date(), nullable=True), - sa.Column('payment_receipt_num', sa.String(length=20), nullable=True), - sa.Column('is_ctm_process', sa.String(length=2), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_logistics_company_id'), 'invoice_logistics', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_logistics_tenant_id'), 'invoice_logistics', ['tenant_id'], unique=False, schema='a76') - op.create_table('invoice_sales_details', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('line_number', sa.Integer(), nullable=False), - sa.Column('sales_order', sa.String(length=20), nullable=True), - sa.Column('colors_description', sa.String(length=49), nullable=True), - sa.Column('square_color_code', sa.String(length=1), nullable=True), - sa.Column('line_bundles', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_invoice_sales_details_company_id'), 'invoice_sales_details', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_invoice_sales_details_tenant_id'), 'invoice_sales_details', ['tenant_id'], unique=False, schema='a76') - op.create_table('items', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('invoice_id', sa.BigInteger(), nullable=False), - sa.Column('reference_number', sa.String(length=20), nullable=True), - sa.Column('order', sa.String(length=50), nullable=True), - sa.Column('guide_number', sa.String(length=50), nullable=True), - sa.Column('depreciation_date', sa.Integer(), nullable=True), - sa.Column('rectification', sa.Boolean(), nullable=True), - sa.Column('warehouse', sa.String(length=30), nullable=True), - sa.Column('location', sa.String(length=200), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['invoice_id'], ['a76.invoice_header.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_items_company_id'), 'items', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_items_tenant_id'), 'items', ['tenant_id'], unique=False, schema='a76') - op.create_table('parts', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('client_id', sa.Integer(), nullable=False), - sa.Column('part_number', sa.String(length=50), nullable=False), - sa.Column('fraction', sa.String(length=10), nullable=True), - sa.Column('description_spanish', sa.String(length=500), nullable=True), - sa.Column('description_english', sa.String(length=500), nullable=True), - sa.Column('part_class', sa.String(length=8), nullable=True), - sa.Column('material_type', sa.String(length=10), nullable=True), - sa.Column('unit_of_measure', sa.String(length=5), nullable=True), - sa.Column('commercial_part_number', sa.String(length=70), nullable=True), - sa.Column('country_of_origin', sa.String(length=3), nullable=True), - sa.Column('unit_cost', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('currency_type', sa.String(length=2), nullable=True), - sa.Column('currency_key', sa.String(length=3), nullable=True), - sa.Column('unit_weight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('weight_type', sa.String(length=6), nullable=True), - sa.Column('us_fraction', sa.String(length=16), nullable=True), - sa.Column('fda_key', sa.String(length=20), nullable=True), - sa.Column('fcc_key', sa.String(length=30), nullable=True), - sa.Column('license_code', sa.String(length=3), nullable=True), - sa.Column('eccn', sa.String(length=20), nullable=True), - sa.Column('export_code', sa.String(length=2), nullable=True), - sa.Column('exclusion_symbol', sa.String(length=19), nullable=True), - sa.Column('supplier', sa.String(length=14), nullable=True), - sa.Column('alternate_unit_measure', sa.String(length=14), nullable=True), - sa.Column('added_value', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=True), - sa.Column('creation_date', sa.Integer(), nullable=True), - sa.Column('modification_date', sa.Integer(), nullable=True), - sa.Column('modification_date_iso', sa.DateTime(), nullable=True), - sa.Column('part_photo', sa.String(length=255), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['country_of_origin'], ['public.countries.m3_key'], name='fk_parts_country'), - sa.ForeignKeyConstraint(['currency_key'], ['public.currency_types.code'], name='fk_parts_currency'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['unit_of_measure', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), - sa.PrimaryKeyConstraint('id', name='parts_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'part_number', name='client_part_ukey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_parts_company_id'), 'parts', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_parts_tenant_id'), 'parts', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimentos', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('year', sa.String(length=2), nullable=False), - sa.Column('customs_office', sa.String(length=3), nullable=False), - sa.Column('license', sa.String(length=4), nullable=False), - sa.Column('pedimento_number', sa.String(length=7), nullable=False), - sa.Column('client_id', sa.Integer(), nullable=False), - sa.Column('operation_type', sa.Integer(), nullable=False), - sa.Column('pedimento_type', sa.String(length=20), nullable=False), - sa.Column('pedimento_code', sa.String(length=2), nullable=False), - sa.Column('regime', sa.String(length=3), nullable=False), - sa.Column('status', sa.String(length=30), nullable=True), - sa.Column('usd_value', sa.Numeric(precision=17, scale=6), nullable=True), - sa.Column('paid_price', sa.Numeric(precision=17, scale=6), nullable=True), - sa.Column('gross_weight', sa.Numeric(precision=19, scale=3), nullable=True), - sa.Column('exchange_rate', sa.Numeric(precision=9, scale=5), nullable=True), - sa.Column('observations', sa.Text(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['client_id'], ['a76.clients_and_providers.id'], name='fk_pedimentos_client'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_pedimentos_code'), - sa.ForeignKeyConstraint(['regime'], ['public.pedimento_regimens.code'], name='fk_pedimentos_regime'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimentos_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'year', 'customs_office', 'license', 'pedimento_number', name='pedimentos_unique_key'), - schema='a76' - ) - op.create_index('idx_pedimentos_client_id', 'pedimentos', ['client_id'], unique=False, schema='a76') - op.create_index('idx_pedimentos_created_at', 'pedimentos', ['created_at'], unique=False, schema='a76') - op.create_index('idx_pedimentos_status', 'pedimentos', ['status'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimentos_company_id'), 'pedimentos', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimentos_tenant_id'), 'pedimentos', ['tenant_id'], unique=False, schema='a76') - op.create_table('trailer', - sa.Column('trailer_number', sa.String(length=20), nullable=False), - sa.Column('ace_trailer_number', sa.String(length=10), nullable=True), - sa.Column('trailer_type_key', sa.String(length=2), nullable=True), - sa.Column('seal', sa.String(length=15), nullable=True), - sa.Column('entity_code', sa.String(length=1), nullable=True), - sa.Column('plate_number', sa.String(length=17), nullable=True), - sa.Column('state', sa.String(length=30), nullable=True), - sa.Column('country', sa.String(length=3), nullable=True), - sa.Column('container_key', sa.String(length=3), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['trailer_type_key'], ['a76.trailer_type.trailer_type_key'], ), - sa.PrimaryKeyConstraint('trailer_number'), - schema='a76' - ) - op.create_index(op.f('ix_a76_trailer_company_id'), 'trailer', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_trailer_tenant_id'), 'trailer', ['tenant_id'], unique=False, schema='a76') - op.create_table('unit_conversions', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('from_unit_code', sa.String(length=5), nullable=False), - sa.Column('to_unit_code', sa.String(length=5), nullable=False), - sa.Column('conversion_factor', sa.Numeric(precision=13, scale=6), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['from_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['to_unit_code', 'tenant_id', 'company_id'], ['a76.units_of_measure.code', 'a76.units_of_measure.tenant_id', 'a76.units_of_measure.company_id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('from_unit_code', 'to_unit_code', 'tenant_id', 'company_id', name='uq_unit_conversion_pair'), - schema='a76' - ) - op.create_index(op.f('ix_a76_unit_conversions_company_id'), 'unit_conversions', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_unit_conversions_tenant_id'), 'unit_conversions', ['tenant_id'], unique=False, schema='a76') - op.create_table('fa_classes', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('class_id', sa.Integer(), nullable=False), - sa.Column('import_tariff_code', sa.String(length=10), nullable=False), - sa.Column('import_tariff_type', sa.String(length=6), nullable=False), - sa.Column('export_tariff_code', sa.String(length=10), nullable=False), - sa.Column('export_tariff_type', sa.String(length=6), nullable=False), - sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=False), - sa.Column('fda_code', sa.String(length=20), nullable=False), - sa.Column('eccn_code', sa.String(length=20), nullable=False), - sa.Column('class_enabled', sa.Boolean(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_qclasses_classes'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='qclases_pk'), - schema='a24' - ) - op.create_index(op.f('ix_a24_fa_classes_company_id'), 'fa_classes', ['company_id'], unique=False, schema='a24') - op.create_index(op.f('ix_a24_fa_classes_tenant_id'), 'fa_classes', ['tenant_id'], unique=False, schema='a24') - op.create_table('inv_classes', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('class_id', sa.Integer(), nullable=False), - sa.Column('stock_um', sa.String(length=5), nullable=False), - sa.Column('us_tariff_code', sa.String(length=19), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['class_id'], ['a76.classes.id'], name='fk_sclasses_classes'), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='sclases_pk'), - schema='a24' - ) - op.create_index(op.f('ix_a24_inv_classes_company_id'), 'inv_classes', ['company_id'], unique=False, schema='a24') - op.create_index(op.f('ix_a24_inv_classes_tenant_id'), 'inv_classes', ['tenant_id'], unique=False, schema='a24') - op.create_table('line_items', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_id', sa.Integer(), nullable=False), - sa.Column('asset_number', sa.String(length=25), nullable=True), - sa.Column('asset_photo', sa.String(length=255), nullable=True), - sa.Column('equipment_message', sa.String(length=40), nullable=True), - sa.Column('invoice_type_asset', sa.String(length=6), nullable=True), - sa.Column('return_import_invoice', sa.String(length=15), nullable=True), - sa.Column('return_import_date', sa.Integer(), nullable=True), - sa.Column('movement_type_import', sa.String(length=3), nullable=True), - sa.Column('search_invoice', sa.String(length=15), nullable=True), - sa.Column('search_line', sa.Integer(), nullable=True), - sa.Column('search_type', sa.String(length=10), nullable=True), - sa.Column('download', sa.Boolean(), nullable=True), - sa.Column('own_equipment', sa.Boolean(), nullable=True), - sa.Column('omit_annex31', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['item_id'], ['a76.items.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a24' - ) - op.create_table('doda_container_seals', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('container_id', sa.Integer(), nullable=False), - sa.Column('doda_id', sa.Integer(), nullable=False), - sa.Column('seal_line', sa.Integer(), nullable=False), - sa.Column('seal_value', sa.String(length=21), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['container_id'], ['a76.doda_containers.id'], name='fk_doda_container_seals_container'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='doda_container_seals_pkey'), - schema='a76' - ) - op.create_index(op.f('ix_a76_doda_container_seals_company_id'), 'doda_container_seals', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_doda_container_seals_tenant_id'), 'doda_container_seals', ['tenant_id'], unique=False, schema='a76') - op.create_table('item_lines', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_id', sa.Integer(), nullable=False), - sa.Column('line_number', sa.Integer(), nullable=False), - sa.Column('part_number', sa.Integer(), nullable=True), - sa.Column('component_part_number', sa.Integer(), nullable=True), - sa.Column('class_code', sa.Integer(), nullable=True), - sa.Column('unit_of_measure', sa.Integer(), nullable=True), - sa.Column('alternate_unit', sa.Integer(), nullable=True), - sa.Column('uma_key', sa.String(length=2), nullable=True), - sa.Column('auxiliary_unit', sa.String(length=5), nullable=True), - sa.Column('permit_number', sa.String(length=20), nullable=True), - sa.Column('page_line', sa.String(length=10), nullable=True), - sa.Column('has_certificate', sa.Boolean(), nullable=True), - sa.Column('certificate_number', sa.String(length=10), nullable=True), - sa.Column('octave_permit', sa.String(length=20), nullable=True), - sa.Column('permits_ped', sa.String(length=500), nullable=True), - sa.Column('has_fda_code', sa.Boolean(), nullable=True), - sa.Column('fda_key', sa.String(length=10), nullable=True), - sa.Column('is_subitem', sa.Boolean(), nullable=True), - sa.Column('contains_subitems', sa.Boolean(), nullable=True), - sa.Column('includes_subitems', sa.Boolean(), nullable=True), - sa.Column('subitem_number', sa.Boolean(), nullable=True), - sa.Column('is_military_mcia', sa.Boolean(), nullable=True), - sa.Column('iv32_type_key', sa.String(length=5), nullable=True), - sa.Column('iv32_number', sa.String(length=35), nullable=True), - sa.Column('scrap_invoice', sa.String(length=15), nullable=True), - sa.Column('consecutive_destination', sa.Integer(), nullable=True), - sa.Column('ctm_section', sa.String(length=3), nullable=True), - sa.Column('tax_payment', sa.Boolean(), nullable=True), - sa.Column('payment_method', sa.String(length=9), nullable=True), - sa.Column('igi_amount', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('igi_payment_method', sa.String(length=9), nullable=True), - sa.Column('fcc_key', sa.String(length=30), nullable=True), - sa.Column('valuation_method', sa.String(length=2), nullable=True), - sa.Column('valuation_determined_value', sa.Numeric(precision=29, scale=8), nullable=True), - sa.Column('valuation_reason', sa.String(length=500), nullable=True), - sa.Column('container_rule', sa.String(length=50), nullable=True), - sa.Column('container_parts_ii', sa.String(length=50), nullable=True), - sa.Column('consecutive_aphis', sa.Integer(), nullable=True), - sa.Column('bom_version', sa.Integer(), nullable=True), - sa.Column('bill_version', sa.Integer(), nullable=True), - sa.Column('tlcan_value', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('identifier', sa.String(length=2), nullable=True), - sa.Column('validation_zero', sa.Integer(), nullable=True), - sa.Column('validation_one', sa.Integer(), nullable=True), - sa.Column('material_type', sa.String(length=50), nullable=True), - sa.Column('order_type', sa.String(length=50), nullable=True), - sa.Column('line_concept', sa.String(length=50), nullable=True), - sa.Column('review_dispatch', sa.String(length=10), nullable=True), - sa.Column('take_component_pt', sa.Integer(), nullable=True), - sa.Column('pallet2', sa.SmallInteger(), nullable=True), - sa.Column('wildcard_field', sa.String(length=100), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['alternate_unit'], ['a76.units_of_measure_general.id'], ), - sa.ForeignKeyConstraint(['class_code'], ['a76.classes.id'], ), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['component_part_number'], ['a76.parts.id'], ), - sa.ForeignKeyConstraint(['item_id'], ['a76.items.id'], ), - sa.ForeignKeyConstraint(['part_number'], ['a76.parts.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.ForeignKeyConstraint(['unit_of_measure'], ['a76.units_of_measure_general.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_item_lines_company_id'), 'item_lines', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_item_lines_tenant_id'), 'item_lines', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_additional', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('add_po_identifier', sa.SmallInteger(), nullable=False), - sa.Column('do_not_exempt_norms_complement_x', sa.SmallInteger(), nullable=False), - sa.Column('manual_pedimento_year', sa.String(length=2), nullable=False), - sa.Column('enable_import_invoice_recipient', sa.SmallInteger(), nullable=False), - sa.Column('send_502_validation_file_for_consolidated', sa.SmallInteger(), nullable=False), - sa.Column('add_remove_norms', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_additional', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_additional_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_additional_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_additional_company_id'), 'pedimento_config_additional', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), 'pedimento_config_additional', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_calculations', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('dta_type', sa.String(length=1), nullable=True), - sa.Column('dta_operation', sa.Boolean(), server_default='false', nullable=False), - sa.Column('dta_vehicle_count', sa.SmallInteger(), server_default='0', nullable=False), - sa.Column('dta_mixed_rate_8permil', sa.Boolean(), server_default='false', nullable=False), - sa.Column('pays_vat', sa.Boolean(), server_default='false', nullable=False), - sa.Column('pays_prevalidation', sa.Boolean(), server_default='false', nullable=False), - sa.Column('include_sagar_certificate_fee', sa.Boolean(), server_default='false', nullable=False), - sa.Column('fixed_vehicle_dta_fee', sa.Boolean(), server_default='false', nullable=False), - sa.Column('additional_fixed_fee', sa.SmallInteger(), server_default='0', nullable=False), - sa.Column('additional_fixed_fee_payment_method', sa.SmallInteger(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_calculations', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_calculations_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_calculations_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_calculations_company_id'), 'pedimento_config_calculations', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), 'pedimento_config_calculations', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_parameters', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('is_embassy', sa.Boolean(), server_default='false', nullable=False), - sa.Column('embassy_dta', sa.Numeric(precision=11, scale=2), server_default='0.00', nullable=False), - sa.Column('rule_3121_section_ii', sa.Boolean(), server_default='false', nullable=False), - sa.Column('use_previous_tariff', sa.Boolean(), server_default='false', nullable=False), - sa.Column('use_payment_date_fi', sa.Boolean(), server_default='false', nullable=False), - sa.Column('add_state_supplier_record_505', sa.Boolean(), server_default='false', nullable=False), - sa.Column('customs_value_calculation', sa.Boolean(), server_default='false', nullable=False), - sa.Column('two_decimals_unit_value', sa.Boolean(), server_default='false', nullable=False), - sa.Column('customs_value_per_item', sa.Boolean(), server_default='false', nullable=False), - sa.Column('is_national_supplier', sa.Boolean(), server_default='false', nullable=False), - sa.Column('is_consolidated', sa.Boolean(), server_default='false', nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_parameters', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_parameters_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_parameters_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_parameters_company_id'), 'pedimento_config_parameters', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), 'pedimento_config_parameters', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_surcharges', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('surcharge_igi', sa.SmallInteger(), nullable=False), - sa.Column('surcharge_dta', sa.SmallInteger(), nullable=False), - sa.Column('surcharge_vat', sa.SmallInteger(), nullable=False), - sa.Column('surcharge_isan', sa.SmallInteger(), nullable=False), - sa.Column('surcharge_ieps', sa.SmallInteger(), nullable=False), - sa.Column('surcharge_cc', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_surcharges', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_surcharges_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_surcharges_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), 'pedimento_config_surcharges', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), 'pedimento_config_surcharges', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_update_rectification', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False), - sa.Column('calculate_surcharge', sa.Boolean(), server_default='false', nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_update_rectification', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_update_rectification_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_update_rectification_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), 'pedimento_config_update_rectification', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), 'pedimento_config_update_rectification', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_config_updates', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('update_vat', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_advalorem', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_dta', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_cc', sa.Boolean(), server_default='false', nullable=False), - sa.Column('update_ieps', sa.Boolean(), server_default='false', nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_config_updates', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_config_updates_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_updates_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_config_updates_company_id'), 'pedimento_config_updates', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), 'pedimento_config_updates', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_customs_offices', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('dispatch_customs', sa.String(length=3), nullable=False), - sa.Column('entry_exit_customs', sa.String(length=3), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_customs_offices', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_customs_offices_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_customs_offices_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_customs_offices_company_id'), 'pedimento_customs_offices', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), 'pedimento_customs_offices', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_dates', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('entry_date', sa.DateTime(), nullable=True), - sa.Column('pedimento_date', sa.DateTime(), nullable=True), - sa.Column('payment_date', sa.DateTime(), nullable=False), - sa.Column('rectification_payment_date', sa.DateTime(), nullable=True), - sa.Column('extraction_date', sa.DateTime(), nullable=True), - sa.Column('submission_date', sa.DateTime(), nullable=True), - sa.Column('eucan_date', sa.DateTime(), nullable=True), - sa.Column('original_date', sa.DateTime(), nullable=True), - sa.Column('start_date', sa.DateTime(), nullable=True), - sa.Column('end_date', sa.DateTime(), nullable=True), - sa.Column('capture_time', sa.Time(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_dates', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_dates_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_dates_pedimento_id_key'), - schema='a76' - ) - op.create_index('idx_pedimento_dates_pedimento_id', 'pedimento_dates', ['pedimento_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_dates_company_id'), 'pedimento_dates', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_dates_tenant_id'), 'pedimento_dates', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_decrementables', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('loading', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('unloading', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('others', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('currency', sa.String(length=3), nullable=False), - sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=False), - sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=False), - sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_decrementables', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_decrementables_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_decrementables_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_decrementables_company_id'), 'pedimento_decrementables', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), 'pedimento_decrementables', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_incrementables', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('insured_value', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('freight', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('insurance', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('packaging', sa.Numeric(precision=13, scale=2), nullable=False), - sa.Column('others', sa.Numeric(precision=13, scale=3), nullable=False), - sa.Column('deductibles', sa.Numeric(precision=13, scale=3), nullable=False), - sa.Column('currency', sa.String(length=3), nullable=False), - sa.Column('currency_factor', sa.Numeric(precision=15, scale=8), nullable=False), - sa.Column('not_affect_usd_value', sa.SmallInteger(), nullable=False), - sa.Column('not_affect_customs_value', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_incrementables', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_incrementables_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_incrementables_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_incrementables_company_id'), 'pedimento_incrementables', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), 'pedimento_incrementables', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_indexes', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('update_factor_type', sa.SmallInteger(), nullable=False), - sa.Column('update_factor', sa.Numeric(precision=7, scale=4), nullable=False), - sa.Column('manual_update_factor', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_indexes', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_indexes_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_indexes_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_indexes_company_id'), 'pedimento_indexes', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_indexes_tenant_id'), 'pedimento_indexes', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_payments', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('acknowledgment', sa.String(length=20), nullable=False), - sa.Column('operation_number', sa.String(length=14), nullable=False), - sa.Column('bank_code', sa.Integer(), nullable=False), - sa.Column('cashier', sa.String(length=2), nullable=False), - sa.Column('date', sa.Date(), nullable=False), - sa.Column('time', sa.Time(), nullable=False), - sa.Column('shift', sa.String(length=1), nullable=False), - sa.Column('total_cash_paid', sa.Integer(), nullable=False), - sa.Column('total_contributions', sa.Integer(), nullable=False), - sa.Column('counter_payment', sa.SmallInteger(), nullable=False), - sa.Column('pece_code', sa.String(length=5), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_payments', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_payments_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_payments_pedimento_id_key'), - schema='a76' - ) - op.create_index('idx_pedimento_payments_pedimento_id', 'pedimento_payments', ['pedimento_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_payments_company_id'), 'pedimento_payments', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_payments_tenant_id'), 'pedimento_payments', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_rectification_destination', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('destination_pedimento_year', sa.String(length=2), nullable=False), - sa.Column('destination_customs_office', sa.String(length=3), nullable=False), - sa.Column('destination_license', sa.String(length=4), nullable=False), - sa.Column('destination_pedimento_number', sa.String(length=7), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_destination', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_rectification_destination_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_destination_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), 'pedimento_rectification_destination', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), 'pedimento_rectification_destination', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_rectification_origin', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('original_pedimento_year', sa.String(length=2), nullable=False), - sa.Column('original_customs_office', sa.String(length=3), nullable=False), - sa.Column('original_license', sa.String(length=4), nullable=False), - sa.Column('original_pedimento_number', sa.String(length=7), nullable=False), - sa.Column('original_pedimento_code', sa.String(length=2), nullable=False), - sa.Column('original_payment_date', sa.DateTime(), nullable=False), - sa.Column('total_cash', sa.Integer(), nullable=False), - sa.Column('total_others', sa.Integer(), nullable=False), - sa.Column('reason', sa.String(length=255), nullable=False), - sa.Column('charge_to_client', sa.SmallInteger(), nullable=False), - sa.Column('use_original_payment_date_for_interest_calc', sa.SmallInteger(), nullable=False), - sa.Column('manual_calculation', sa.SmallInteger(), nullable=False), - sa.Column('original_pedimento_norms', sa.SmallInteger(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_rectification_origin', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_rectification_origin_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_origin_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), 'pedimento_rectification_origin', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), 'pedimento_rectification_origin', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_transport_means', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('destination', sa.SmallInteger(), nullable=False), - sa.Column('entry_exit', sa.String(length=2), nullable=False), - sa.Column('arrival', sa.String(length=2), nullable=False), - sa.Column('departure', sa.String(length=2), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_transport_means', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_transport_means_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_transport_means_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_transport_means_company_id'), 'pedimento_transport_means', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), 'pedimento_transport_means', ['tenant_id'], unique=False, schema='a76') - op.create_table('pedimento_validation', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('pedimento_id', sa.Integer(), nullable=False), - sa.Column('validator', sa.String(length=3), nullable=False), - sa.Column('validation_ack', sa.String(length=8), nullable=False), - sa.Column('pre_ack', sa.String(length=8), nullable=False), - sa.Column('line_signature', sa.String(length=50), nullable=False), - sa.Column('electronic_signature', sa.String(length=999), nullable=False), - sa.Column('certificate_number', sa.String(length=99), nullable=False), - sa.Column('validator_id', sa.Integer(), nullable=False), - sa.Column('responsible_id', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], name='fk_pedimento_validation', ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id', name='pedimento_validation_pkey'), - sa.UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_validation_pedimento_id_key'), - schema='a76' - ) - op.create_index(op.f('ix_a76_pedimento_validation_company_id'), 'pedimento_validation', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_pedimento_validation_tenant_id'), 'pedimento_validation', ['tenant_id'], unique=False, schema='a76') - op.create_table('ctm_receipts', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('receipt_line', sa.Integer(), nullable=False), - sa.Column('option', sa.String(length=3), nullable=True), - sa.Column('exit_invoice', sa.String(length=19), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['receipt_line'], ['a76.item_lines.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_ctm_receipts_company_id'), 'ctm_receipts', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_ctm_receipts_tenant_id'), 'ctm_receipts', ['tenant_id'], unique=False, schema='a76') - op.create_table('item_line_series', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('line_item_id', sa.Integer(), nullable=False), - sa.Column('row', sa.Integer(), nullable=False), - sa.Column('serial_numbers', sa.String(length=50), nullable=True), - sa.Column('model', sa.String(length=50), nullable=True), - sa.Column('sub_model', sa.String(length=50), nullable=True), - sa.Column('brand', sa.String(length=50), nullable=True), - sa.Column('expo_brad', sa.String(length=50), nullable=True), - sa.Column('number_id', sa.String(length=25), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('company_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('updated_at', sa.DateTime(), nullable=False), - sa.Column('deleted_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ), - sa.ForeignKeyConstraint(['line_item_id'], ['a76.item_lines.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_index(op.f('ix_a76_item_line_series_company_id'), 'item_line_series', ['company_id'], unique=False, schema='a76') - op.create_index(op.f('ix_a76_item_line_series_tenant_id'), 'item_line_series', ['tenant_id'], unique=False, schema='a76') - op.create_table('line_customs', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('fraction', sa.String(length=10), nullable=True), - sa.Column('fraction_type', sa.String(length=7), nullable=True), - sa.Column('american_fraction', sa.String(length=16), nullable=True), - sa.Column('alternate_fraction', sa.String(length=10), nullable=True), - sa.Column('reference_fraction', sa.String(length=10), nullable=True), - sa.Column('octave_fraction', sa.String(length=10), nullable=True), - sa.Column('tlcan_fraction', sa.String(length=13), nullable=True), - sa.Column('extra_american_fraction', sa.String(length=16), nullable=True), - sa.Column('garment_fraction', sa.String(length=19), nullable=True), - sa.Column('advalorem', sa.String(length=10), nullable=True), - sa.Column('advalorem_numeric', sa.Numeric(precision=7, scale=2), nullable=True), - sa.Column('advalorem_american', sa.Numeric(precision=5, scale=2), nullable=True), - sa.Column('advalorem_tlcan', sa.Numeric(precision=5, scale=2), nullable=True), - sa.Column('rate', sa.String(length=10), nullable=True), - sa.Column('depreciation_rate', sa.Numeric(precision=5, scale=2), nullable=True), - sa.Column('origin_country', sa.String(length=3), nullable=True), - sa.Column('destination_country', sa.String(length=3), nullable=True), - sa.Column('optional_country', sa.String(length=3), nullable=True), - sa.Column('origin_procedure', sa.String(length=3), nullable=True), - sa.Column('scrap_procedure', sa.String(length=3), nullable=True), - sa.Column('sector', sa.String(length=8), nullable=True), - sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_table('line_descriptions', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('description_spanish', sa.String(length=4999), nullable=True), - sa.Column('description_english', sa.String(length=4999), nullable=True), - sa.Column('extra_description', sa.Text(), nullable=True), - sa.Column('part_description', sa.String(length=500), nullable=True), - sa.Column('class_description', sa.String(length=500), nullable=True), - sa.Column('brand', sa.String(length=50), nullable=True), - sa.Column('model', sa.String(length=50), nullable=True), - sa.Column('has_serial', sa.Boolean(), nullable=True), - sa.Column('additional_info_spanish', sa.String(length=1000), nullable=True), - sa.Column('additional_info_english', sa.String(length=1000), nullable=True), - sa.Column('lot', sa.String(length=254), nullable=True), - sa.Column('entry_number', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_table('line_financials', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('unit_cost_capture', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_current_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('sales_cost_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('commercial_unit_cost', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_current_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('sales_cost_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('unit_cost_mc', sa.Numeric(precision=29, scale=8), nullable=True), - sa.Column('value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_commercial_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_updated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_subitem_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('sub_import_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_returned_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_depreciated_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('customs_value_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_total_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_temp_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_def_material_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_added_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_national_packing_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('vat_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('vat_used_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('advalorem_line_mxn', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_usd', sa.Numeric(precision=29, scale=8), nullable=True), - sa.Column('value_commercial_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_updated_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_subitem_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('sub_import_value_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_returned_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_depreciated_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('customs_value_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_auxiliary_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_total_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_temp_material_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_def_material_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_added_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_national_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_us_packing_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('vat_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('vat_used_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_non_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_originating_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('igi_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('exempt_amount_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('total_commercial_value', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('advalorem_line_usd', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_mc', sa.Numeric(precision=29, scale=8), nullable=True), - sa.Column('sub_import_value_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('vat_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_added_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_national_packing_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_total_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_temp_material_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.Column('value_def_material_mc', sa.Numeric(precision=23, scale=8), nullable=True), - sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_table('line_quantities', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('quantity', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('alternate_quantity', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('quantity_uma', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('auxiliary_quantity', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('quantity_temp_export', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('quantity_existence', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('quantity_returned', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('quantity_returned_temp', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('serial_count', sa.Integer(), nullable=True), - sa.Column('weight_unit', sa.String(length=3), nullable=True), - sa.Column('net_weight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('gross_weight', sa.Numeric(precision=19, scale=8), nullable=True), - sa.Column('package_key', sa.String(length=5), nullable=True), - sa.Column('package_quantity', sa.Integer(), nullable=True), - sa.Column('package_description', sa.String(length=40), nullable=True), - sa.Column('container_quantity', sa.SmallInteger(), nullable=True), - sa.Column('container_description', sa.String(length=40), nullable=True), - sa.Column('box_count', sa.String(length=30), nullable=True), - sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.create_table('line_references', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_line_id', sa.Integer(), nullable=False), - sa.Column('serie_id', sa.Integer(), nullable=True), - sa.Column('customer_invoice', sa.Integer(), nullable=True), - sa.Column('assigned_client', sa.Integer(), nullable=True), - sa.Column('supplier', sa.Integer(), nullable=True), - sa.Column('requisitioner', sa.Integer(), nullable=True), - sa.Column('sent_to', sa.Integer(), nullable=True), - sa.Column('ped_line', sa.Integer(), nullable=True), - sa.Column('ro_line', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['assigned_client'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['customer_invoice'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['item_line_id'], ['a76.item_lines.id'], ), - sa.ForeignKeyConstraint(['requisitioner'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['sent_to'], ['a76.clients_and_providers.id'], ), - sa.ForeignKeyConstraint(['serie_id'], ['a76.item_line_series.id'], ), - sa.ForeignKeyConstraint(['supplier'], ['a76.clients_and_providers.id'], ), - sa.PrimaryKeyConstraint('id'), - schema='a76' - ) - op.drop_constraint(op.f('fk_codeped'), 'code_pedimento_regimens', type_='foreignkey') - op.drop_constraint(op.f('fk_regimenped'), 'code_pedimento_regimens', type_='foreignkey') - op.create_foreign_key('fk_codeped', 'code_pedimento_regimens', 'pedimento_codes', ['pedimento_code'], ['code'], source_schema='public', referent_schema='public') - op.create_foreign_key('fk_regimenped', 'code_pedimento_regimens', 'pedimento_regimens', ['regimen_code'], ['code'], source_schema='public', referent_schema='public') - # ### end Alembic commands ### - - -def downgrade() -> None: - """Downgrade schema.""" - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('fk_regimenped', 'code_pedimento_regimens', schema='public', type_='foreignkey') - op.drop_constraint('fk_codeped', 'code_pedimento_regimens', schema='public', type_='foreignkey') - op.create_foreign_key(op.f('fk_regimenped'), 'code_pedimento_regimens', 'pedimento_regimens', ['regimen_code'], ['code']) - op.create_foreign_key(op.f('fk_codeped'), 'code_pedimento_regimens', 'pedimento_codes', ['pedimento_code'], ['code']) - op.drop_table('line_references', schema='a76') - op.drop_table('line_quantities', schema='a76') - op.drop_table('line_financials', schema='a76') - op.drop_table('line_descriptions', schema='a76') - op.drop_table('line_customs', schema='a76') - op.drop_index(op.f('ix_a76_item_line_series_tenant_id'), table_name='item_line_series', schema='a76') - op.drop_index(op.f('ix_a76_item_line_series_company_id'), table_name='item_line_series', schema='a76') - op.drop_table('item_line_series', schema='a76') - op.drop_index(op.f('ix_a76_ctm_receipts_tenant_id'), table_name='ctm_receipts', schema='a76') - op.drop_index(op.f('ix_a76_ctm_receipts_company_id'), table_name='ctm_receipts', schema='a76') - op.drop_table('ctm_receipts', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_validation_tenant_id'), table_name='pedimento_validation', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_validation_company_id'), table_name='pedimento_validation', schema='a76') - op.drop_table('pedimento_validation', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_transport_means_tenant_id'), table_name='pedimento_transport_means', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_transport_means_company_id'), table_name='pedimento_transport_means', schema='a76') - op.drop_table('pedimento_transport_means', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_rectification_origin_tenant_id'), table_name='pedimento_rectification_origin', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_rectification_origin_company_id'), table_name='pedimento_rectification_origin', schema='a76') - op.drop_table('pedimento_rectification_origin', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_rectification_destination_tenant_id'), table_name='pedimento_rectification_destination', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_rectification_destination_company_id'), table_name='pedimento_rectification_destination', schema='a76') - op.drop_table('pedimento_rectification_destination', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_payments_tenant_id'), table_name='pedimento_payments', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_payments_company_id'), table_name='pedimento_payments', schema='a76') - op.drop_index('idx_pedimento_payments_pedimento_id', table_name='pedimento_payments', schema='a76') - op.drop_table('pedimento_payments', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_indexes_tenant_id'), table_name='pedimento_indexes', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_indexes_company_id'), table_name='pedimento_indexes', schema='a76') - op.drop_table('pedimento_indexes', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_incrementables_tenant_id'), table_name='pedimento_incrementables', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_incrementables_company_id'), table_name='pedimento_incrementables', schema='a76') - op.drop_table('pedimento_incrementables', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_decrementables_tenant_id'), table_name='pedimento_decrementables', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_decrementables_company_id'), table_name='pedimento_decrementables', schema='a76') - op.drop_table('pedimento_decrementables', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_dates_tenant_id'), table_name='pedimento_dates', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_dates_company_id'), table_name='pedimento_dates', schema='a76') - op.drop_index('idx_pedimento_dates_pedimento_id', table_name='pedimento_dates', schema='a76') - op.drop_table('pedimento_dates', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_customs_offices_tenant_id'), table_name='pedimento_customs_offices', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_customs_offices_company_id'), table_name='pedimento_customs_offices', schema='a76') - op.drop_table('pedimento_customs_offices', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_updates_tenant_id'), table_name='pedimento_config_updates', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_updates_company_id'), table_name='pedimento_config_updates', schema='a76') - op.drop_table('pedimento_config_updates', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_tenant_id'), table_name='pedimento_config_update_rectification', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_update_rectification_company_id'), table_name='pedimento_config_update_rectification', schema='a76') - op.drop_table('pedimento_config_update_rectification', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_surcharges_tenant_id'), table_name='pedimento_config_surcharges', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_surcharges_company_id'), table_name='pedimento_config_surcharges', schema='a76') - op.drop_table('pedimento_config_surcharges', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_parameters_tenant_id'), table_name='pedimento_config_parameters', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_parameters_company_id'), table_name='pedimento_config_parameters', schema='a76') - op.drop_table('pedimento_config_parameters', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_calculations_tenant_id'), table_name='pedimento_config_calculations', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_calculations_company_id'), table_name='pedimento_config_calculations', schema='a76') - op.drop_table('pedimento_config_calculations', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_additional_tenant_id'), table_name='pedimento_config_additional', schema='a76') - op.drop_index(op.f('ix_a76_pedimento_config_additional_company_id'), table_name='pedimento_config_additional', schema='a76') - op.drop_table('pedimento_config_additional', schema='a76') - op.drop_index(op.f('ix_a76_item_lines_tenant_id'), table_name='item_lines', schema='a76') - op.drop_index(op.f('ix_a76_item_lines_company_id'), table_name='item_lines', schema='a76') - op.drop_table('item_lines', schema='a76') - op.drop_index(op.f('ix_a76_doda_container_seals_tenant_id'), table_name='doda_container_seals', schema='a76') - op.drop_index(op.f('ix_a76_doda_container_seals_company_id'), table_name='doda_container_seals', schema='a76') - op.drop_table('doda_container_seals', schema='a76') - op.drop_table('line_items', schema='a24') - op.drop_index(op.f('ix_a24_inv_classes_tenant_id'), table_name='inv_classes', schema='a24') - op.drop_index(op.f('ix_a24_inv_classes_company_id'), table_name='inv_classes', schema='a24') - op.drop_table('inv_classes', schema='a24') - op.drop_index(op.f('ix_a24_fa_classes_tenant_id'), table_name='fa_classes', schema='a24') - op.drop_index(op.f('ix_a24_fa_classes_company_id'), table_name='fa_classes', schema='a24') - op.drop_table('fa_classes', schema='a24') - op.drop_index(op.f('ix_a76_unit_conversions_tenant_id'), table_name='unit_conversions', schema='a76') - op.drop_index(op.f('ix_a76_unit_conversions_company_id'), table_name='unit_conversions', schema='a76') - op.drop_table('unit_conversions', schema='a76') - op.drop_index(op.f('ix_a76_trailer_tenant_id'), table_name='trailer', schema='a76') - op.drop_index(op.f('ix_a76_trailer_company_id'), table_name='trailer', schema='a76') - op.drop_table('trailer', schema='a76') - op.drop_index(op.f('ix_a76_pedimentos_tenant_id'), table_name='pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_pedimentos_company_id'), table_name='pedimentos', schema='a76') - op.drop_index('idx_pedimentos_status', table_name='pedimentos', schema='a76') - op.drop_index('idx_pedimentos_created_at', table_name='pedimentos', schema='a76') - op.drop_index('idx_pedimentos_client_id', table_name='pedimentos', schema='a76') - op.drop_table('pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_parts_tenant_id'), table_name='parts', schema='a76') - op.drop_index(op.f('ix_a76_parts_company_id'), table_name='parts', schema='a76') - op.drop_table('parts', schema='a76') - op.drop_index(op.f('ix_a76_items_tenant_id'), table_name='items', schema='a76') - op.drop_index(op.f('ix_a76_items_company_id'), table_name='items', schema='a76') - op.drop_table('items', schema='a76') - op.drop_index(op.f('ix_a76_invoice_sales_details_tenant_id'), table_name='invoice_sales_details', schema='a76') - op.drop_index(op.f('ix_a76_invoice_sales_details_company_id'), table_name='invoice_sales_details', schema='a76') - op.drop_table('invoice_sales_details', schema='a76') - op.drop_index(op.f('ix_a76_invoice_logistics_tenant_id'), table_name='invoice_logistics', schema='a76') - op.drop_index(op.f('ix_a76_invoice_logistics_company_id'), table_name='invoice_logistics', schema='a76') - op.drop_table('invoice_logistics', schema='a76') - op.drop_index(op.f('ix_a76_invoice_financials_tenant_id'), table_name='invoice_financials', schema='a76') - op.drop_index(op.f('ix_a76_invoice_financials_company_id'), table_name='invoice_financials', schema='a76') - op.drop_table('invoice_financials', schema='a76') - op.drop_index(op.f('ix_a76_invoice_compliance_mx_tenant_id'), table_name='invoice_compliance_mx', schema='a76') - op.drop_index(op.f('ix_a76_invoice_compliance_mx_company_id'), table_name='invoice_compliance_mx', schema='a76') - op.drop_table('invoice_compliance_mx', schema='a76') - op.drop_index(op.f('ix_a76_invoice_collections_tenant_id'), table_name='invoice_collections', schema='a76') - op.drop_index(op.f('ix_a76_invoice_collections_company_id'), table_name='invoice_collections', schema='a76') - op.drop_table('invoice_collections', schema='a76') - op.drop_index(op.f('ix_a76_identifier_details_tenant_id'), table_name='identifier_details', schema='a76') - op.drop_index(op.f('ix_a76_identifier_details_company_id'), table_name='identifier_details', schema='a76') - op.drop_table('identifier_details', schema='a76') - op.drop_index(op.f('ix_a76_error_catalogs_tenant_id'), table_name='error_catalogs', schema='a76') - op.drop_index(op.f('ix_a76_error_catalogs_company_id'), table_name='error_catalogs', schema='a76') - op.drop_table('error_catalogs', schema='a76') - op.drop_index(op.f('ix_a76_equivalency_items_tenant_id'), table_name='equivalency_items', schema='a76') - op.drop_index(op.f('ix_a76_equivalency_items_company_id'), table_name='equivalency_items', schema='a76') - op.drop_table('equivalency_items', schema='a76') - op.drop_index(op.f('ix_a76_driver_tenant_id'), table_name='driver', schema='a76') - op.drop_index(op.f('ix_a76_driver_company_id'), table_name='driver', schema='a76') - op.drop_table('driver', schema='a76') - op.drop_index(op.f('ix_a76_doda_pedimentos_tenant_id'), table_name='doda_pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_doda_pedimentos_company_id'), table_name='doda_pedimentos', schema='a76') - op.drop_table('doda_pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_doda_containers_tenant_id'), table_name='doda_containers', schema='a76') - op.drop_index(op.f('ix_a76_doda_containers_company_id'), table_name='doda_containers', schema='a76') - op.drop_table('doda_containers', schema='a76') - op.drop_index(op.f('ix_a76_doda_american_pedimentos_tenant_id'), table_name='doda_american_pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_doda_american_pedimentos_company_id'), table_name='doda_american_pedimentos', schema='a76') - op.drop_table('doda_american_pedimentos', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_vu_tenant_id'), table_name='customs_brokers_vu', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_vu_company_id'), table_name='customs_brokers_vu', schema='a76') - op.drop_table('customs_brokers_vu', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_personnel_tenant_id'), table_name='customs_brokers_personnel', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_personnel_company_id'), table_name='customs_brokers_personnel', schema='a76') - op.drop_table('customs_brokers_personnel', schema='a76') - op.drop_index(op.f('ix_a76_country_rule_oct_tenant_id'), table_name='country_rule_oct', schema='a76') - op.drop_index(op.f('ix_a76_country_rule_oct_company_id'), table_name='country_rule_oct', schema='a76') - op.drop_table('country_rule_oct', schema='a76') - op.drop_index(op.f('ix_a76_concepts_tenant_id'), table_name='concepts', schema='a76') - op.drop_table('concepts', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_programs_tenant_id'), table_name='clients_and_providers_programs', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_programs_company_id'), table_name='clients_and_providers_programs', schema='a76') - op.drop_table('clients_and_providers_programs', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_address_tenant_id'), table_name='clients_and_providers_address', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_address_company_id'), table_name='clients_and_providers_address', schema='a76') - op.drop_table('clients_and_providers_address', schema='a76') - op.drop_index(op.f('ix_a76_classes_tenant_id'), table_name='classes', schema='a76') - op.drop_index(op.f('ix_a76_classes_company_id'), table_name='classes', schema='a76') - op.drop_table('classes', schema='a76') - op.drop_index(op.f('ix_core_user_tenants_tenant_id'), table_name='user_tenants', schema='core') - op.drop_index(op.f('ix_core_user_tenants_keycloak_user_id'), table_name='user_tenants', schema='core') - op.drop_index(op.f('ix_core_user_tenants_id'), table_name='user_tenants', schema='core') - op.drop_index(op.f('ix_core_user_tenants_company_id'), table_name='user_tenants', schema='core') - op.drop_table('user_tenants', schema='core') - op.drop_index(op.f('ix_a76_vehicle_tenant_id'), table_name='vehicle', schema='a76') - op.drop_index(op.f('ix_a76_vehicle_company_id'), table_name='vehicle', schema='a76') - op.drop_table('vehicle', schema='a76') - op.drop_index(op.f('ix_a76_units_of_measure_general_tenant_id'), table_name='units_of_measure_general', schema='a76') - op.drop_index(op.f('ix_a76_units_of_measure_general_company_id'), table_name='units_of_measure_general', schema='a76') - op.drop_table('units_of_measure_general', schema='a76') - op.drop_index(op.f('ix_a76_units_of_measure_tenant_id'), table_name='units_of_measure', schema='a76') - op.drop_index(op.f('ix_a76_units_of_measure_company_id'), table_name='units_of_measure', schema='a76') - op.drop_table('units_of_measure', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_oma_tenant_id'), table_name='unit_of_measure_oma', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_oma_company_id'), table_name='unit_of_measure_oma', schema='a76') - op.drop_table('unit_of_measure_oma', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_customs_tenant_id'), table_name='unit_of_measure_customs', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_customs_company_id'), table_name='unit_of_measure_customs', schema='a76') - op.drop_table('unit_of_measure_customs', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_american_tenant_id'), table_name='unit_of_measure_american', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_american_company_id'), table_name='unit_of_measure_american', schema='a76') - op.drop_table('unit_of_measure_american', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_ace_tenant_id'), table_name='unit_of_measure_ace', schema='a76') - op.drop_index(op.f('ix_a76_unit_of_measure_ace_company_id'), table_name='unit_of_measure_ace', schema='a76') - op.drop_table('unit_of_measure_ace', schema='a76') - op.drop_index(op.f('ix_a76_transporter_tenant_id'), table_name='transporter', schema='a76') - op.drop_index(op.f('ix_a76_transporter_company_id'), table_name='transporter', schema='a76') - op.drop_table('transporter', schema='a76') - op.drop_index(op.f('ix_a76_trailer_type_tenant_id'), table_name='trailer_type', schema='a76') - op.drop_index(op.f('ix_a76_trailer_type_company_id'), table_name='trailer_type', schema='a76') - op.drop_table('trailer_type', schema='a76') - op.drop_index(op.f('ix_a76_subassembly_entries_tenant_id'), table_name='subassembly_entries', schema='a76') - op.drop_index(op.f('ix_a76_subassembly_entries_company_id'), table_name='subassembly_entries', schema='a76') - op.drop_table('subassembly_entries', schema='a76') - op.drop_index(op.f('ix_a76_signatures_tenant_id'), table_name='signatures', schema='a76') - op.drop_index(op.f('ix_a76_signatures_company_id'), table_name='signatures', schema='a76') - op.drop_table('signatures', schema='a76') - op.drop_index(op.f('ix_a76_seal_tenant_id'), table_name='seal', schema='a76') - op.drop_index(op.f('ix_a76_seal_company_id'), table_name='seal', schema='a76') - op.drop_table('seal', schema='a76') - op.drop_index(op.f('ix_a76_prevalidators_tenant_id'), table_name='prevalidators', schema='a76') - op.drop_index(op.f('ix_a76_prevalidators_company_id'), table_name='prevalidators', schema='a76') - op.drop_table('prevalidators', schema='a76') - op.drop_index(op.f('ix_a76_ports_tenant_id'), table_name='ports', schema='a76') - op.drop_index(op.f('ix_a76_ports_company_id'), table_name='ports', schema='a76') - op.drop_table('ports', schema='a76') - op.drop_index(op.f('ix_a76_permission_rule_oct_tenant_id'), table_name='permission_rule_oct', schema='a76') - op.drop_index(op.f('ix_a76_permission_rule_oct_company_id'), table_name='permission_rule_oct', schema='a76') - op.drop_table('permission_rule_oct', schema='a76') - op.drop_index(op.f('ix_a76_packing_lists_tenant_id'), table_name='packing_lists', schema='a76') - op.drop_index(op.f('ix_a76_packing_lists_company_id'), table_name='packing_lists', schema='a76') - op.drop_table('packing_lists', schema='a76') - op.drop_index(op.f('ix_a76_packages_tenant_id'), table_name='packages', schema='a76') - op.drop_index(op.f('ix_a76_packages_company_id'), table_name='packages', schema='a76') - op.drop_table('packages', schema='a76') - op.drop_index(op.f('ix_a76_multi_currency_types_tenant_id'), table_name='multi_currency_types', schema='a76') - op.drop_index(op.f('ix_a76_multi_currency_types_company_id'), table_name='multi_currency_types', schema='a76') - op.drop_table('multi_currency_types', schema='a76') - op.drop_index(op.f('ix_a76_legends_tenant_id'), table_name='legends', schema='a76') - op.drop_index(op.f('ix_a76_legends_company_id'), table_name='legends', schema='a76') - op.drop_table('legends', schema='a76') - op.drop_index(op.f('ix_a76_invoice_header_tenant_id'), table_name='invoice_header', schema='a76') - op.drop_index(op.f('ix_a76_invoice_header_company_id'), table_name='invoice_header', schema='a76') - op.drop_table('invoice_header', schema='a76') - op.drop_index(op.f('ix_a76_inpc_tenant_id'), table_name='inpc', schema='a76') - op.drop_index(op.f('ix_a76_inpc_company_id'), table_name='inpc', schema='a76') - op.drop_table('inpc', schema='a76') - op.drop_index(op.f('ix_a76_identifiers_tenant_id'), table_name='identifiers', schema='a76') - op.drop_index(op.f('ix_a76_identifiers_company_id'), table_name='identifiers', schema='a76') - op.drop_table('identifiers', schema='a76') - op.drop_index(op.f('ix_a76_fraction_rule_octave_tenant_id'), table_name='fraction_rule_octave', schema='a76') - op.drop_index(op.f('ix_a76_fraction_rule_octave_company_id'), table_name='fraction_rule_octave', schema='a76') - op.drop_table('fraction_rule_octave', schema='a76') - op.drop_index(op.f('ix_a76_exchange_rate_tenant_id'), table_name='exchange_rate', schema='a76') - op.drop_index(op.f('ix_a76_exchange_rate_company_id'), table_name='exchange_rate', schema='a76') - op.drop_table('exchange_rate', schema='a76') - op.drop_index(op.f('ix_a76_error_classifications_tenant_id'), table_name='error_classifications', schema='a76') - op.drop_index(op.f('ix_a76_error_classifications_company_id'), table_name='error_classifications', schema='a76') - op.drop_table('error_classifications', schema='a76') - op.drop_index(op.f('ix_a76_equivalencies_tenant_id'), table_name='equivalencies', schema='a76') - op.drop_index(op.f('ix_a76_equivalencies_company_id'), table_name='equivalencies', schema='a76') - op.drop_table('equivalencies', schema='a76') - op.drop_index(op.f('ix_a76_electronic_notices_tenant_id'), table_name='electronic_notices', schema='a76') - op.drop_index(op.f('ix_a76_electronic_notices_company_id'), table_name='electronic_notices', schema='a76') - op.drop_table('electronic_notices', schema='a76') - op.drop_index(op.f('ix_a76_doda_tenant_id'), table_name='doda', schema='a76') - op.drop_index(op.f('ix_a76_doda_company_id'), table_name='doda', schema='a76') - op.drop_table('doda', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_tenant_id'), table_name='customs_brokers', schema='a76') - op.drop_index(op.f('ix_a76_customs_brokers_company_id'), table_name='customs_brokers', schema='a76') - op.drop_table('customs_brokers', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_tenant_id'), table_name='clients_and_providers', schema='a76') - op.drop_index(op.f('ix_a76_clients_and_providers_company_id'), table_name='clients_and_providers', schema='a76') - op.drop_table('clients_and_providers', schema='a76') - op.drop_index(op.f('ix_a76_classification_concepts_tenant_id'), table_name='classification_concepts', schema='a76') - op.drop_index(op.f('ix_a76_classification_concepts_company_id'), table_name='classification_concepts', schema='a76') - op.drop_table('classification_concepts', schema='a76') - op.drop_index(op.f('ix_a24_location_tenant_id'), table_name='location', schema='a24') - op.drop_index(op.f('ix_a24_location_company_id'), table_name='location', schema='a24') - op.drop_table('location', schema='a24') - op.drop_index(op.f('ix_core_licenses_tenant_id'), table_name='licenses', schema='core') - op.drop_index(op.f('ix_core_licenses_id'), table_name='licenses', schema='core') - op.drop_table('licenses', schema='core') - op.drop_index(op.f('ix_core_license_usage_tenant_id'), table_name='license_usage', schema='core') - op.drop_index(op.f('ix_core_license_usage_id'), table_name='license_usage', schema='core') - op.drop_table('license_usage', schema='core') - op.drop_index(op.f('ix_a76_customs_broker_concepts_tenant_id'), table_name='customs_broker_concepts', schema='a76') - op.drop_table('customs_broker_concepts', schema='a76') - op.drop_index(op.f('ix_a76_company_tenant_id'), table_name='company', schema='a76') - op.drop_table('company', schema='a76') - op.drop_index(op.f('ix_core_tenants_slug'), table_name='tenants', schema='core') - op.drop_index(op.f('ix_core_tenants_name'), table_name='tenants', schema='core') - op.drop_index(op.f('ix_core_tenants_id'), table_name='tenants', schema='core') - op.drop_table('tenants', schema='core') - # ### end Alembic commands ### diff --git a/backend/api/v1/modules/a76/parts/models.py b/backend/api/v1/modules/a76/parts/models.py index a5da21c2..db56d294 100644 --- a/backend/api/v1/modules/a76/parts/models.py +++ b/backend/api/v1/modules/a76/parts/models.py @@ -1,6 +1,7 @@ """ Modelos ORM para gestión de partes/componentes - Anexo 76 (Master Data) """ + from datetime import datetime from decimal import Decimal from typing import TYPE_CHECKING, Optional @@ -8,19 +9,29 @@ from typing import TYPE_CHECKING, Optional from api.v1.common.base_models import TenantScopedMixin, TimestampMixin from core.database import Base from sqlalchemy import ( - ForeignKeyConstraint, Integer, Numeric, PrimaryKeyConstraint, - String, UniqueConstraint, Boolean, DateTime + ForeignKeyConstraint, + Integer, + Numeric, + PrimaryKeyConstraint, + String, + UniqueConstraint, + Boolean, + DateTime, ) + # Importante usar relationship y Mapped from sqlalchemy.orm import Mapped, mapped_column, relationship if TYPE_CHECKING: from api.v1.modules.a76.classes.models import Class from api.v1.modules.public.reference_data.currency_types.models import CurrencyType - from api.v1.modules.a76.general_catalogs.units_of_measure.models import UnitOfMeasure + from api.v1.modules.a76.general_catalogs.units_of_measure.models import ( + UnitOfMeasure, + ) from api.v1.modules.a24.fa.fa_parts.models import FaPart from api.v1.modules.a24.inv.inv_parts.models import InvPart + class Part(Base, TenantScopedMixin, TimestampMixin): __tablename__ = "parts" __table_args__ = ( @@ -30,14 +41,21 @@ class Part(Base, TenantScopedMixin, TimestampMixin): ), ForeignKeyConstraint( ["unit_of_measure", "tenant_id", "company_id"], - ["a76.units_of_measure.code", "a76.units_of_measure.tenant_id", - "a76.units_of_measure.company_id"], + [ + "a76.units_of_measure.code", + "a76.units_of_measure.tenant_id", + "a76.units_of_measure.company_id", + ], ), # Puente hacia la tabla de clases ForeignKeyConstraint( ["part_class", "tenant_id", "company_id"], - ["a76.classes.class_code", "a76.classes.tenant_id", "a76.classes.company_id"], - name="fk_parts_class" + [ + "a76.classes.class_code", + "a76.classes.tenant_id", + "a76.classes.company_id", + ], + name="fk_parts_class", ), UniqueConstraint( "tenant_id", "company_id", "part_number", name="client_part_ukey" @@ -54,7 +72,7 @@ class Part(Base, TenantScopedMixin, TimestampMixin): description_english: Mapped[Optional[str]] = mapped_column(String(500)) part_class: Mapped[Optional[str]] = mapped_column(String(8)) unit_of_measure: Mapped[Optional[str]] = mapped_column(String(5)) - + unit_cost: Mapped[Optional[Decimal]] = mapped_column(Numeric(23, 8)) currency_type: Mapped[Optional[str]] = mapped_column(String(2)) currency_key: Mapped[Optional[str]] = mapped_column(String(3)) @@ -73,31 +91,33 @@ class Part(Base, TenantScopedMixin, TimestampMixin): is_active: Mapped[Optional[bool]] = mapped_column(Boolean, default=True) part_photo: Mapped[Optional[str]] = mapped_column(String(255)) - + creation_date: Mapped[Optional[int]] = mapped_column() modification_date: Mapped[Optional[int]] = mapped_column() modification_date_iso: Mapped[Optional[datetime]] = mapped_column(DateTime) - # --- RELACIONES CORREGIDAS --- - currency: Mapped[Optional["CurrencyType"]] = relationship( - foreign_keys="[Part.currency_key]" - ) + # --- RELACIONES --- + currency: Mapped[Optional["CurrencyType"]] = relationship("CurrencyType") unit_of_measure_info: Mapped[Optional["UnitOfMeasure"]] = relationship( - foreign_keys="[Part.unit_of_measure, Part.tenant_id, Part.company_id]" + "UnitOfMeasure" ) part_class_info: Mapped[Optional["Class"]] = relationship( - "Class", - back_populates="parts", - foreign_keys="[Part.part_class, Part.tenant_id, Part.company_id]" + "Class", back_populates="parts", overlaps="unit_of_measure_info" ) # Extensiones Anexo 24 fa_data: Mapped[Optional["FaPart"]] = relationship( - "FaPart", back_populates="master_info", uselist=False, cascade="all, delete-orphan" + "FaPart", + back_populates="master_info", + uselist=False, + cascade="all, delete-orphan", ) inv_data: Mapped[Optional["InvPart"]] = relationship( - "InvPart", back_populates="master_info", uselist=False, cascade="all, delete-orphan" + "InvPart", + back_populates="master_info", + uselist=False, + cascade="all, delete-orphan", ) def __repr__(self) -> str: - return f"" \ No newline at end of file + return f"" diff --git a/backend/main.py b/backend/main.py index c497cc46..c567450d 100644 --- a/backend/main.py +++ b/backend/main.py @@ -19,12 +19,12 @@ from fastapi.middleware.cors import CORSMiddleware from fastapi.exceptions import RequestValidationError from fastapi.responses import JSONResponse -from api.v1.modules.a76.items.models import ( - Item, -) # Importar rutas para registrar con el router -from api.v1.modules.a76.items.series.models import ( - Serie, -) # Importar modelos para registrar con SQLAlchemy +# Importar modelos para registrar con SQLAlchemy +from api.v1.modules.a76.items.models import Item +from api.v1.modules.a76.items.series.models import Serie +from api.v1.modules.a76.parts.models import Part +from api.v1.modules.a24.fa.fa_parts.models import FaPart +from api.v1.modules.a24.inv.inv_parts.models import InvPart # Configurar logging logging.basicConfig( @@ -51,7 +51,9 @@ register_exception_handlers(app) # Add validation error handler @app.exception_handler(RequestValidationError) async def validation_exception_handler(request: Request, exc: RequestValidationError): - logger.error(f"Validation error for {request.method} {request.url.path}: {exc.errors()}") + logger.error( + f"Validation error for {request.method} {request.url.path}: {exc.errors()}" + ) logger.error(f"Request body: {await request.body()}") return JSONResponse( status_code=status.HTTP_400_BAD_REQUEST, @@ -62,7 +64,9 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE # Add HTTP exception handler @app.exception_handler(HTTPException) async def http_exception_handler(request: Request, exc: HTTPException): - logger.error(f"HTTP {exc.status_code} for {request.method} {request.url.path}: {exc.detail}") + logger.error( + f"HTTP {exc.status_code} for {request.method} {request.url.path}: {exc.detail}" + ) return JSONResponse( status_code=exc.status_code, content={"detail": exc.detail}, diff --git a/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte b/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte index bed5413b..9e5f34c8 100644 --- a/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte +++ b/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte @@ -107,14 +107,14 @@ description_spanish: d.description_spanish || '', description_english: d.description_english || '', part_class: d.part_class || '', - material_type: (d as any).material_type || '', - origin_country: d.origin_country || 'MEX', + material_type: d.inv_data?.material_type || '', + origin_country: d.fa_data?.origin_country || 'MEX', unit_of_measure: d.unit_of_measure || 'PZ', fraction: d.fraction || '', us_fraction: d.us_fraction || '', unit_weight: Number(d.unit_weight) || 0, weight_type: d.weight_type || 'KG', - supplier: d.supplier || '', + supplier: d.inv_data?.supplier_code || '', fda_key: d.fda_key || '', fcc_key: d.fcc_key || '', eccn: d.eccn || '', @@ -123,10 +123,10 @@ exclusion_symbol: d.exclusion_symbol || '', unit_cost: Number(d.unit_cost) || 0, currency_key: d.currency_key || 'USD', - added_value: Number(d.added_value) || 0, + added_value: Number(d.inv_data?.added_value) || 0, value_added_type: 'USD', commercial_part_number: d.commercial_part_number || '', - alternate_unit_measure: d.alternate_unit_measure || '', + alternate_unit_measure: d.inv_data?.alternate_uom || '', part_photo: d.part_photo || '', is_active: d.is_active ?? true, // Cargar datos FA si existen @@ -135,7 +135,7 @@ }; if (d.client_id) await fetchClientName(d.client_id, companyId); if (d.part_class) await fetchClassDesc(d.part_class, companyId); - if ((d as any).material_type) await fetchMaterialName((d as any).material_type); + if (d.inv_data?.material_type) await fetchMaterialName(d.inv_data.material_type); } } catch (e) { console.error(e); } finally { loading = false; } } diff --git a/frontend/src/routes/dashboard/goods/parts/+page.svelte b/frontend/src/routes/dashboard/goods/parts/+page.svelte index 25ea479f..dae74cc6 100644 --- a/frontend/src/routes/dashboard/goods/parts/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/+page.svelte @@ -1,7 +1,7 @@ \ No newline at end of file From 8dca19413ba31bba216124601e1b836ff26d50dc Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 8 Jan 2026 21:14:08 -0600 Subject: [PATCH 36/37] feat: add Fixed Asset Classes management page with CRUD functionality --- backend/api/v1/modules/a76/classes/dto.py | 4 - backend/api/v1/modules/a76/classes/models.py | 13 +- backend/api/v1/modules/a76/classes/routes.py | 23 - backend/api/v1/modules/a76/classes/service.py | 112 +- frontend/src/lib/api/dashboard/a76/classes.ts | 13 +- .../goods/classes/create-edit-dialog.svelte | 48 +- .../classes/forms/FixedAssetClassForm.svelte | 1177 +++++++++++++++++ .../goods/fixed-asset-classes/+page.svelte | 871 ++++++++++++ 8 files changed, 2078 insertions(+), 183 deletions(-) create mode 100644 frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte create mode 100644 frontend/src/routes/dashboard/goods/fixed-asset-classes/+page.svelte diff --git a/backend/api/v1/modules/a76/classes/dto.py b/backend/api/v1/modules/a76/classes/dto.py index 9b5a92a8..7fc3ccc0 100644 --- a/backend/api/v1/modules/a76/classes/dto.py +++ b/backend/api/v1/modules/a76/classes/dto.py @@ -13,7 +13,6 @@ from pydantic import BaseModel, ConfigDict, Field class ClassCreateDTO(BaseModel): """DTO para crear una clase""" - client_id: int = Field(..., description="Client key") class_code: str = Field(..., max_length=8, description="Class code") description_es: str = Field( ..., max_length=500, description="Description in Spanish (required)" @@ -127,7 +126,6 @@ class ClassResponseDTO(BaseModel): id: int tenant_id: int company_id: int - client_id: int class_code: str description_es: Optional[str] = None description_en: Optional[str] = None @@ -164,7 +162,6 @@ class ClassResponseDTOFA(ClassResponseDTO): class ClassBasicDTO(BaseModel): """DTO para información básica de clase""" - client_id: int class_code: str description_es: Optional[str] = None description_en: Optional[str] = None @@ -190,7 +187,6 @@ class ClassListDTO(BaseModel): class ClassSearchDTO(BaseModel): """DTO para búsqueda de clases""" - client_id: Optional[int] = Field(None, description="Filter by client key") class_code: Optional[str] = Field(None, description="Search by class code") description: Optional[str] = Field(None, description="Search in descriptions") material_key: Optional[str] = Field(None, description="Filter by material key") diff --git a/backend/api/v1/modules/a76/classes/models.py b/backend/api/v1/modules/a76/classes/models.py index a5d1c851..58459b11 100644 --- a/backend/api/v1/modules/a76/classes/models.py +++ b/backend/api/v1/modules/a76/classes/models.py @@ -31,9 +31,6 @@ class Class(Base, TenantScopedMixin, TimestampMixin): __tablename__ = "classes" __table_args__ = ( PrimaryKeyConstraint("id", name="classes_pkey"), - ForeignKeyConstraint( - ["client_id"], ["a76.clients_and_providers.id"], name="fk_classes_client" - ), ForeignKeyConstraint( ["material_key"], ["public.material_types.key"], @@ -47,15 +44,13 @@ class Class(Base, TenantScopedMixin, TimestampMixin): UniqueConstraint( "tenant_id", "company_id", - "client_id", "class_code", - name="ufa_classes_client_id_class_code", + name="uq_classes_tenant_company_code", ), {"schema": "a76"}, ) id: Mapped[int] = mapped_column(Integer, primary_key=True) - client_id: Mapped[int] = mapped_column(Integer) # Unique constraint compuesta class_code: Mapped[str] = mapped_column(String(8)) # CLASE @@ -98,11 +93,11 @@ class Class(Base, TenantScopedMixin, TimestampMixin): # Inverse relationship with GParts that have this class parts: Mapped[list["Part"]] = relationship( - primaryjoin="and_(Class.client_id == Part.client_id, Class.class_code == Part.part_class)", - foreign_keys="[Part.client_id, Part.part_class]", + primaryjoin="and_(Class.class_code == Part.part_class)", + foreign_keys="[Part.part_class]", viewonly=True, back_populates="part_class_info", ) def __repr__(self) -> str: - return f"" + return f"" diff --git a/backend/api/v1/modules/a76/classes/routes.py b/backend/api/v1/modules/a76/classes/routes.py index df1779ed..fb3d3d65 100644 --- a/backend/api/v1/modules/a76/classes/routes.py +++ b/backend/api/v1/modules/a76/classes/routes.py @@ -31,29 +31,6 @@ crud_routes = TenantCRUDRoutes( router = crud_routes.router - -@router.post( - "/seed", - summary="Seed Fixed Asset Classes", - description="Initialize fixed asset class catalog with default data", -) -async def seed_classes( - company_id: int = Query(..., description="Company ID"), - client_id: int = Query(..., description="Client ID"), - db: Session = Depends(get_core_db), - current_user: Dict[str, Any] = Depends(get_current_user), -): - """Seed initial data for fixed asset classes""" - tenant_id = validate_access_to_resource(db, company_id, current_user) - - count = ClassService.seed_initial_data(db, tenant_id, company_id, client_id) - - return { - "message": f"Successfully created {count} fixed asset classes", - "count": count, - } - - @router.post( "/fa", response_model=ClassResponseDTOFA, diff --git a/backend/api/v1/modules/a76/classes/service.py b/backend/api/v1/modules/a76/classes/service.py index 9f124632..d8ecc25f 100644 --- a/backend/api/v1/modules/a76/classes/service.py +++ b/backend/api/v1/modules/a76/classes/service.py @@ -46,8 +46,6 @@ class ClassService: ) if filters: - if filters.get("client_id"): - query = query.filter(Class.client_id == filters["client_id"]) if filters.get("class_code"): query = query.filter( Class.class_code.ilike(f"%{filters['class_code']}%") @@ -106,7 +104,6 @@ class ClassService: existing = db.query(Class).filter( Class.tenant_id == tenant_id, Class.company_id == company_id, - Class.client_id == data_dict["client_id"], Class.class_code == data_dict["class_code"] ).first() @@ -177,16 +174,15 @@ class ClassService: if "class_code" in update_data and update_data["class_code"]: new_code = update_data["class_code"] # Check if another class with this code exists (excluding current class) - # The unique constraint is on (tenant_id, company_id, client_id, class_code) + # The unique constraint is on (tenant_id, company_id, class_code) existing_class = db.query(Class).filter( Class.class_code == new_code, Class.tenant_id == tenant_id, Class.company_id == company_id, - Class.client_id == class_obj.client_id, # Same client Class.id != class_id # Exclude current class ).first() - logger.info(f"Checking for duplicate class_code '{new_code}' for client {class_obj.client_id}") + logger.info(f"Checking for duplicate class_code '{new_code}'") if existing_class: logger.warning(f"Duplicate class_code found: {existing_class.id}") raise HTTPException( @@ -265,7 +261,7 @@ class ClassService: # Extract base class fields base_fields = { - "client_id", "class_code", "description_es", "description_en", + "class_code", "description_es", "description_en", "material_key", "unit_of_measure", "fraction", "us_fraction", "sub_key", "physical_review", "iva_exempt_fraction" } @@ -300,7 +296,6 @@ class ClassService: "id": base_class.id, "tenant_id": base_class.tenant_id, "company_id": base_class.company_id, - "client_id": base_class.client_id, "class_code": base_class.class_code, "description_es": base_class.description_es, "description_en": base_class.description_en, @@ -352,62 +347,6 @@ class ClassService: detail=f"Error al crear clase de activo fijo: {error_msg}" ) - @staticmethod - def seed_initial_data( - db: Session, tenant_id: int, company_id: int, client_id: int - ) -> int: - """ - Seed initial fixed asset class data - Returns: number of records created - """ - from .seed import seed - - created_count = 0 - for record in seed: - ( - class_code, - description_es, - description_en, - material_key, - unit_of_measure, - fraction, - us_fraction, - bom, - ) = record - - # Check if already exists - existing = ( - db.query(Class) - .filter( - Class.tenant_id == tenant_id, - Class.company_id == company_id, - Class.client_id == client_id, - Class.class_code == class_code, - ) - .first() - ) - - if not existing: - class_obj = Class( - tenant_id=tenant_id, - company_id=company_id, - client_id=client_id, - class_code=class_code, - description_es=description_es, - description_en=description_en, - material_key=material_key if material_key else None, - unit_of_measure=unit_of_measure if unit_of_measure else None, - fraction=fraction if fraction else None, - us_fraction=us_fraction if us_fraction else None, - ) - db.add(class_obj) - created_count += 1 - - if created_count > 0: - db.commit() - - return created_count - def __init__(self, db: Session): self.db = db @@ -430,7 +369,6 @@ class ClassService: self.db.query(Class) .filter( and_( - Class.client_id == class_data.client_id, Class.class_code == class_data.class_code, ) ) @@ -440,12 +378,11 @@ class ClassService: if existing: raise HTTPException( status_code=400, - detail=f"Class with client_id '{class_data.client_id}' and class_code '{class_data.class_code}' already exists", + detail=f"Class with class_code '{class_data.class_code}' already exists", ) # Crear clase db_class = Class( - client_id=class_data.client_id, class_code=class_data.class_code, description_spanish=class_data.description_spanish, description_english=class_data.description_english, @@ -469,7 +406,7 @@ class ClassService: logger.error(f"IntegrityError creating class: {str(e)}") raise HTTPException( status_code=400, - detail="Class with this client_id and class_code already exists", + detail="Class with this class_code already exists", ) except HTTPException: raise @@ -478,12 +415,11 @@ class ClassService: logger.error(f"Error creating class: {str(e)}") raise HTTPException(status_code=500, detail="Error creating class") - def get_class(self, client_id: int, class_code: str) -> Optional[ClassResponseDTO]: + def get_class(self, class_code: str) -> Optional[ClassResponseDTO]: """ Obtiene una clase por clave compuesta Args: - client_id: Clave del cliente class_code: Código de clase Returns: @@ -491,7 +427,7 @@ class ClassService: """ class_obj = ( self.db.query(Class) - .filter(and_(Class.client_id == client_id, Class.class_code == class_code)) + .filter(and_(Class.class_code == class_code)) .first() ) @@ -520,9 +456,6 @@ class ClassService: # Aplicar filtros si se proporcionan if search_params: - if search_params.client_id: - query = query.filter(Class.client_id == search_params.client_id) - if search_params.class_code: query = query.filter( Class.class_code.ilike(f"%{search_params.class_code}%") @@ -569,13 +502,12 @@ class ClassService: ) def update_class( - self, client_id: int, class_code: str, class_data: ClassUpdateDTO + self, class_code: str, class_data: ClassUpdateDTO ) -> Optional[ClassResponseDTO]: """ Actualiza una clase Args: - client_id: Clave del cliente class_code: Código de clase class_data: Datos a actualizar @@ -584,7 +516,7 @@ class ClassService: """ class_obj = ( self.db.query(Class) - .filter(and_(Class.client_id == client_id, Class.class_code == class_code)) + .filter(and_(Class.class_code == class_code)) .first() ) @@ -604,15 +536,14 @@ class ClassService: except Exception as e: self.db.rollback() - logger.error(f"Error updating class {client_id}-{class_code}: {str(e)}") + logger.error(f"Error updating class {class_code}: {str(e)}") raise HTTPException(status_code=500, detail="Error updating class") - def delete_class(self, client_id: int, class_code: str) -> bool: + def delete_class(self, class_code: str) -> bool: """ Elimina una clase Args: - client_id: Clave del cliente class_code: Código de clase Returns: @@ -620,7 +551,7 @@ class ClassService: """ class_obj = ( self.db.query(Class) - .filter(and_(Class.client_id == client_id, Class.class_code == class_code)) + .filter(and_(Class.class_code == class_code)) .first() ) @@ -633,7 +564,7 @@ class ClassService: return True except Exception as e: self.db.rollback() - logger.error(f"Error deleting class {client_id}-{class_code}: {str(e)}") + logger.error(f"Error deleting class {class_code}: {str(e)}") raise HTTPException(status_code=500, detail="Error deleting class") def search_by_fraction(self, fraction: str) -> List[ClassBasicDTO]: @@ -643,19 +574,6 @@ class ClassService: ) return [ClassBasicDTO.model_validate(class_obj) for class_obj in classes] - def search_by_client( - self, client_id: int, skip: int = 0, limit: int = 100 - ) -> List[ClassBasicDTO]: - """Obtiene todas las clases de un cliente específico""" - classes = ( - self.db.query(Class) - .filter(Class.client_id == client_id) - .offset(skip) - .limit(limit) - .all() - ) - return [ClassBasicDTO.model_validate(class_obj) for class_obj in classes] - def search_by_material(self, material_key: str) -> List[ClassBasicDTO]: """Busca clases por clave de material""" classes = ( @@ -678,9 +596,6 @@ class ClassService: """Obtiene estadísticas básicas de clases""" total_classes = self.db.query(Class).count() - # Contar por clientes - clients_count = self.db.query(Class.client_id).distinct().count() - # Contar por revisión física physical_review_stats = {} for i in range(3): # Asumiendo valores 0, 1, 2 @@ -695,7 +610,6 @@ class ClassService: return { "total_classes": total_classes, - "clients_with_classes": clients_count, "classes_with_fraction": with_fraction, "classes_with_us_fraction": with_us_fraction, **physical_review_stats, diff --git a/frontend/src/lib/api/dashboard/a76/classes.ts b/frontend/src/lib/api/dashboard/a76/classes.ts index 9473979a..fc787b97 100644 --- a/frontend/src/lib/api/dashboard/a76/classes.ts +++ b/frontend/src/lib/api/dashboard/a76/classes.ts @@ -7,7 +7,6 @@ export interface A76Class { id: number; tenant_id: number; company_id: number; - client_id: number; class_code: string; description_es: string | null; description_en: string | null; @@ -26,7 +25,6 @@ export interface A76Class { // DTO para crear (match con tu formulario) export interface A76ClassCreate { company_id: number; - client_id: number; class_code: string; description_es?: string | null; description_en?: string | null; @@ -94,7 +92,14 @@ export const classesApi = { /** * Inicializar datos semilla de clases de activo fijo */ - seed: (company_id: number, client_id: number): Promise> => { - return api.post(`/v1/a76/classes/seed?company_id=${company_id}&client_id=${client_id}`, {}); + seed: (company_id: number): Promise> => { + return api.post(`/v1/a76/classes/seed?company_id=${company_id}`, {}); + }, + + /** + * Crear una clase de activo fijo (crea tanto A76Class como FAClass en una transacción) + */ + createFA: (data: any, company_id: number): Promise> => { + return api.post(`/v1/a76/classes/fa?company_id=${company_id}`, data); } }; \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte index aaaaafa4..15119178 100644 --- a/frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte +++ b/frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte @@ -7,7 +7,7 @@ import * as Select from "$lib/components/ui/select"; import { classesApi, type A76Class, type A76ClassCreate, type A76ClassUpdate } from "$lib/api/dashboard/a76/classes"; import { materialTypesApi, type MaterialType } from "$lib/api/dashboard/refrence_data/material_types"; - import { clientsProvidersApi, type ClientProviderBasic } from "$lib/api/dashboard/a76/clients-providers"; + import { clientsProvidersApi, type ClientProvider } from "$lib/api/dashboard/a76/clients-providers"; import { companyStore } from "$lib/stores/company.svelte"; import { onMount } from 'svelte'; @@ -27,7 +27,6 @@ // Estado del formulario let formData = $state({ - client_id: item?.client_id || null, class_code: item?.class_code || '', description_es: item?.description_es || '', description_en: item?.description_en || '', @@ -44,7 +43,7 @@ let error = $state(null); let materialTypes = $state([]); let loadingMaterialTypes = $state(false); - let clients = $state([]); + let clients = $state([]); let loadingClients = $state(false); // Variables para controlar los selects @@ -73,9 +72,9 @@ // Cargar clientes loadingClients = true; try { - const response = await clientsProvidersApi.listClients(companyId, 0, 500); + const response = await clientsProvidersApi.list(companyId, 1, 500); if (response.data) { - clients = response.data; + clients = response.data.items; } } catch (e) { console.error('Error loading clients:', e); @@ -88,7 +87,6 @@ $effect(() => { if (item) { formData = { - client_id: item.client_id, class_code: item.class_code, description_es: item.description_es || '', description_en: item.description_en || '', @@ -107,7 +105,6 @@ } else { // Reset para modo crear formData = { - client_id: null, class_code: '', description_es: '', description_en: '', @@ -142,12 +139,6 @@ error = 'No hay compañía seleccionada'; return; } - - // Validaciones básicas - if (!formData.client_id) { - error = 'Debes seleccionar un cliente'; - return; - } if (!formData.class_code.trim()) { error = 'El código de clase es requerido'; return; @@ -178,7 +169,6 @@ if (isEdit && item) { // Actualizar const updateData: A76ClassUpdate = { - client_id: formData.client_id!, class_code: formData.class_code, description_es: formData.description_es || null, description_en: formData.description_en || null, @@ -192,10 +182,8 @@ }; response = await classesApi.update(item.id, updateData, companyId); } else { - // Crear con el client_id seleccionado const createData: A76ClassCreate = { company_id: companyId, - client_id: formData.client_id!, class_code: formData.class_code, description_es: formData.description_es || null, description_en: formData.description_en || null, @@ -303,34 +291,6 @@
{/if} - -
- - {#if loadingClients} -
-
- Cargando clientes... -
- {:else if clients.length > 0} - - {:else} -
- No hay clientes disponibles -
- {/if} -
-
diff --git a/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte b/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte new file mode 100644 index 00000000..16632751 --- /dev/null +++ b/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte @@ -0,0 +1,1177 @@ + + +
+ +
+
+ + { + // Limpiar error local si existe + if (validationErrors.class_code) { + const errors = { ...validationErrors }; + delete errors.class_code; + validationErrors = errors; + } + }} + onblur={() => validateField('class_code')} + /> + {#if validationErrors.class_code} +

{validationErrors.class_code}

+ {/if} +
+
+ + +
+
+ + +
+ + validateField('description_es')} + /> + {#if validationErrors.description_es} +

{validationErrors.description_es}

+ {/if} +
+ + +
+ + +
+ + +
+ +
+ validateField('material_key')} + /> + + + {formData.material_description || ''} + +
+ {#if validationErrors.material_key} +

{validationErrors.material_key}

+ {/if} +
+ + +
+ +
+ validateField('unit_of_measure')} + /> + + + {formData.unit_of_measure_description || ''} + + + Clave U.M.A: {formData.unit_measure_key || ''} + +
+ {#if validationErrors.unit_of_measure} +

{validationErrors.unit_of_measure}

+ {/if} +
+ + +
+ +
+ validateField('fraction')} + /> + + + U.M.T: {formData.fraction_umt || ''} + + + Clave U.M.A: {formData.fraction_uma_key || ''} + +
+ {#if validationErrors.fraction} +

{validationErrors.fraction}

+ {/if} +
+ + +
+ +
+ + + + Ad/valorem: {formData.us_fraction_ad_valorem || '0.00'} + + + Tasa Fija: {formData.us_fraction_fixed_rate || '0.00000000'} + +
+
+ + +
+ +
+ + % + +
+ + +
+
+
+ + +
+ +
+ + +
+
+ + +
+ +
+
+ (formData.iva_exempt_fraction = true)} + class="h-4 w-4" + /> + +
+
+ (formData.iva_exempt_fraction = false)} + class="h-4 w-4" + /> + +
+
+
+ + +
+ +
+ + +
+
+
+ + + + + + + CATALOGO DE ACTIVO FIJO + +
+
+ + +
+
+ + + + + + + + + {#each filteredMaterialTypes as material (material.key)} + selectMaterial(material)} + > + + + + {/each} + +
ClaveDescripción
{material.key}{material.description}
+
+
+ + + +
+
+ + + + + + UNIDADES DE MEDIDA + +
+
+ + +
+
+ + + + + + + + + + + {#each filteredUnits as unit (unit.code)} + selectUnit(unit)} + > + + + + + + {/each} + +
CódigoDescripciónDescription (English)Clave Mexicana
{unit.code}{unit.description}{unit.descriptionEnglish}{unit.claveMexicana}
+
+
+ + + +
+
+ + + + + + CATALOGO DE FRACCIONES SITAR - SCAII + +
+
+ + +
+
+ + + + + + + + + + + {#each tariffFractions as fraction (fraction.code)} + selectFraction(fraction)} + > + + + + + + {:else} + + + + {/each} + +
FracciónNICODescripciónU.M.T
{fraction.fraction}{fraction.nico}{fraction.description}{fraction.umt}
+ {#if isLoadingFractions} + Cargando fracciones... + {:else} + No hay fracciones disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE FRACCIONES AMERICANAS + +
+
+ + +
+
+ + + + + + + + + + + + {#each usTariffFractions as fraction (fraction.id)} + selectUSFraction(fraction)} + > + + + + + + + {:else} + + + + {/each} + +
CódigoPrefijoAd valoremCosto FijoDescripción
{fraction.code}{fraction.prefix || ''}{fraction.ad_valorem || '0.00'}{fraction.fixed_cost || '0.00'}{fraction.description || ''}
+ {#if isLoadingUSFractions} + Cargando fracciones... + {:else} + No hay fracciones disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE DEPRECIACION + +
+
+ + +
+
+ + + + + + + + + + {#each depreciationCatalog as item (item.id)} + selectDepreciation(item)} + > + + + + + {:else} + + + + {/each} + +
FracciónDescripción% Depreciación
{item.fraction}{item.description}{item.depreciation_rate}%
+ {#if isLoadingDepreciation} + Cargando... + {:else} + No hay registros disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO FDA + +
+
+ + +
+
+ + + + + + + + + {#each fdaCatalog as item (item.id)} + selectFDA(item)} + > + + + + {:else} + + + + {/each} + +
Clave FDADescripción
{item.fda_key}{item.description}
+ {#if isLoadingFDA} + Cargando... + {:else} + No hay registros disponibles + {/if} +
+
+
+ + + +
+
+ + + + + + CATALOGO DE CARTA PORTE + +
+
+ + +
+
+ + + + + + + + + {#each cartaPorteCatalog as item (item.id)} + { + formData.carta_porte_code = item.code; + showCartaPorteDialog = false; + }} + > + + + + {:else} + + + + {/each} + +
CódigoDescripción
{item.code}{item.description}
+ No hay registros disponibles +
+
+
+ + + +
+
diff --git a/frontend/src/routes/dashboard/goods/fixed-asset-classes/+page.svelte b/frontend/src/routes/dashboard/goods/fixed-asset-classes/+page.svelte new file mode 100644 index 00000000..2224b5a7 --- /dev/null +++ b/frontend/src/routes/dashboard/goods/fixed-asset-classes/+page.svelte @@ -0,0 +1,871 @@ + + +
+ +
+

CATALOGO DE CLASES DE ACTIVO FIJO

+

+ Gestiona y consulta las clases de activo fijo +

+
+ + +
+ +
+ +
+
+
+

Filtros

+ + Filtra las clases por diferentes criterios (los filtros se aplican automáticamente) + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+

Listado de Clases

+
+ + Mostrando de {filteredClasses.length} registros + + +
+
+ + +
+ + + + + + + + + + + + + + {#if isLoading} + + + + {:else if filteredClasses.length === 0} + + + + {:else} + {#each filteredClasses as cls (cls.id)} + selectClass(cls)} + > + + + + + + + + + {/each} + {/if} + +
+ + ClaseDescripción EspañolDescripción InglésTipoU.MFracción U.M.T. Fracción US
Cargando...
+ No hay clases de activo fijo registradas +
+ + + + {cls.class_code} + + {cls.description_es || ''}{cls.description_en || ''} + + {cls.material_key || ''} + + {cls.unit_of_measure || ''}{cls.fraction || ''} - {cls.us_fraction || '-'}
+
+
+
+ + +
+
+

Código de Clase

+

+ {formData.class_code || '---'} +

+
+ +
+
+
+ +

{formData.description_es || 'Sin descripción'}

+
+
+ +

{formData.description_en || 'No translation available'}

+
+
+ +
+
+ +
+ + {formData.material_key || '-'} +
+
+
+ + {formData.unit_of_measure || '-'} +
+
+ +
+ +

+ {formData.fraction || '0000.00.00'} +

+
+
+
+
+
+ + +
+
+ +
+ + + +
+
+
+ + + + + + {selectedClass ? 'Editar' : 'Nueva'} Clase de Activo Fijo + + + + {#if validationError} +
+
+
+ ! +
+
+

Error de Validación

+

{validationError}

+
+ +
+
+ {/if} + +
+ validationError = ''} + onSave={async (data: Partial) => { + // Evitar múltiples clics + if (isSaving) { + console.log('⚠️ Ya está guardando, ignorando clic'); + return; + } + isSaving = true; + validationError = ''; + + console.log('========================================'); + console.log('=== INICIO ONSAVE ==='); + console.log('Datos recibidos:', data); + console.log('selectedClass:', selectedClass); + console.log('========================================'); + + try { + const cleanData = $state.snapshot(data); + const companyId = companyStore.activeCompany?.id; + + if (!companyId) { + throw new Error('No hay empresa seleccionada'); + } + + let response; + + if (selectedClass?.id) { + // === ACTUALIZACIÓN === + console.log('🔄 MODO: ACTUALIZACIÓN'); + console.log('ID de clase:', selectedClass.id); + + response = await classesApi.update(selectedClass.id, { + class_code: cleanData.class_code?.trim() || '', + description_es: cleanData.description_es?.trim() || '', + description_en: cleanData.description_en?.trim() || '', + material_key: cleanData.material_key?.trim() || '', + unit_of_measure: cleanData.unit_of_measure?.trim() || '', + fraction: cleanData.fraction?.trim() || '', + us_fraction: cleanData.us_fraction || '', + physical_review: cleanData.physical_review ? 1 : 0, + iva_exempt_fraction: cleanData.iva_exempt_fraction || '' + }, companyId); + + // ¡IMPORTANTE! fetchApi NO lanza excepciones, retorna { error, status } + if (response.error) { + console.error('❌ Error en respuesta de actualización:', response); + throw new Error(response.error); + } + + console.log('✅ Actualización exitosa'); + } else { + // === CREACIÓN === + console.log('➕ MODO: CREACIÓN'); + + const payload = { + class_code: cleanData.class_code?.trim() || '', + description_es: cleanData.description_es?.trim() || '', + description_en: cleanData.description_en?.trim() || '', + material_key: cleanData.material_key?.trim() || '', + unit_of_measure: cleanData.unit_of_measure?.trim() || '', + fraction: cleanData.fraction?.trim() || '', + us_fraction: cleanData.us_fraction?.trim() || '', + sub_key: cleanData.sub_key || '', + physical_review: cleanData.physical_review ? 1 : 0, + iva_exempt_fraction: cleanData.iva_exempt_fraction || '', + depreciation_rate: cleanData.depreciation_rate || null, + fda_code: cleanData.fda_code || null, + class_enabled: true + }; + + console.log('Payload:', payload); + + response = await classesApi.createFA(payload, companyId); + + if (response.error) { + console.error('❌ Error del servidor:', response.error); + throw new Error(response.error); + } + + console.log('✅ Creación exitosa'); + } + + // === ÉXITO TOTAL === + console.log('✅ GUARDADO EXITOSO - Cerrando diálogo'); + const wasUpdate = !!selectedClass?.id; + await loadClasses(); + showInsertDialog = false; + selectedClass = null; + validationError = ''; + toast.success(wasUpdate ? 'Clase actualizada correctamente' : 'Clase creada correctamente'); + + } catch (error: any) { + // === ERROR === + console.error('========================================'); + console.error('❌ ERROR CAPTURADO'); + console.error('Error:', error); + console.error('Error.response:', error?.response); + console.error('Error.response.data:', error?.response?.data); + console.error('Error.detail:', error?.detail); + console.error('========================================'); + + let errorMsg = 'Error al guardar'; + + // Primero intentar con error.detail (fetch directo) + if (error?.detail) { + if (typeof error.detail === 'string') { + errorMsg = error.detail; + } else if (Array.isArray(error.detail)) { + errorMsg = error.detail.map((e: any) => e.msg || e).join(', '); + } + } + // Luego con error.response.data.detail (axios) + else if (error?.response?.data?.detail) { + if (typeof error.response.data.detail === 'string') { + errorMsg = error.response.data.detail; + } else if (Array.isArray(error.response.data.detail)) { + errorMsg = error.response.data.detail.map((e: any) => e.msg || e).join(', '); + } + } + // Por último el mensaje genérico + else if (error?.message) { + errorMsg = error.message; + } + + console.error('📝 Mensaje de error extraído:', errorMsg); + + validationError = errorMsg; + console.error('🔴 validationError asignado:', validationError); + console.error('🔴 showInsertDialog permanece:', showInsertDialog); + console.error('========================================'); + + // NO cerramos el diálogo, permanece abierto + } finally { + isSaving = false; + console.log('✅ isSaving = false'); + } + }} + onCancel={() => { + showInsertDialog = false; + selectedClass = null; + }} + /> +
+ + + + +
+
+ + + + + + ¿Confirmar eliminación? + +
+

+ ¿Estás seguro que deseas eliminar la clase {selectedClass?.class_code}? +

+

+ {selectedClass?.description_es} +

+

+ Esta acción no se puede deshacer. +

+
+ + + + +
+
From 25c51120f9f8d291c20747419243d1b07f64c4dd Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 8 Jan 2026 21:14:16 -0600 Subject: [PATCH 37/37] feat: update sidebar navigation for fixed asset classes and add tariff fractions page --- .../src/lib/components/sidebar/modules.ts | 15 +- .../tariff-fractions/+page.svelte | 211 ++++++++++++++++++ 2 files changed, 213 insertions(+), 13 deletions(-) create mode 100644 frontend/src/routes/dashboard/general_catalogs/tariff-fractions/+page.svelte diff --git a/frontend/src/lib/components/sidebar/modules.ts b/frontend/src/lib/components/sidebar/modules.ts index 783dca21..6e90fd7c 100644 --- a/frontend/src/lib/components/sidebar/modules.ts +++ b/frontend/src/lib/components/sidebar/modules.ts @@ -298,7 +298,7 @@ export function getSidebarData(): SidebarData { items: [ { title: m["sidebar.goods.classes"](), - url: "/dashboard/goods/classes", + url: "/dashboard/goods/fixed-asset-classes", }, { title: m["sidebar.goods.parts"](), @@ -386,18 +386,7 @@ export function getSidebarData(): SidebarData { url: "/dashboard/customs_brokers", icon: BadgeCheck, items: [], - }, - { - title: "Mercancías", - url: "#", - icon: Package, - items: [ - { - title: "Catálogo de Clases de Activo Fijo", - url: "/dashboard/catalogs/fixed-asset-classes", - }, - ], - }, + }, { title: m["sidebar.reference_data.configuracion"](), url: "#", diff --git a/frontend/src/routes/dashboard/general_catalogs/tariff-fractions/+page.svelte b/frontend/src/routes/dashboard/general_catalogs/tariff-fractions/+page.svelte new file mode 100644 index 00000000..337aaa4d --- /dev/null +++ b/frontend/src/routes/dashboard/general_catalogs/tariff-fractions/+page.svelte @@ -0,0 +1,211 @@ + + +
+ + + + Catálogo de Fracciones SITAR - SCAII + +

+ Nomenclatura arancelaria mexicana completa +

+
+ + +
+ +
+
+ + +
+ +
+ + +
+
+ {#if isLoading} +
+ + Cargando... +
+ {:else} + Mostrando {filteredFractions.length} de {totalRecords} fracciones arancelarias + {#if searchQuery} + (filtrado) + {/if} + {/if} +
+ {#if !searchQuery && totalPages > 1} +
+ Página {currentPage} de {totalPages} +
+ {/if} +
+ + +
+ + + + Código + Fracción + Descripción + NICO + UMT + Adv. Impo + Adv. Expo + + + + {#if filteredFractions.length === 0} + + + {#if isLoading} + Cargando fracciones arancelarias... + {:else if searchQuery} + No se encontraron fracciones que coincidan con la búsqueda + {:else} + No hay fracciones arancelarias disponibles + {/if} + + + {:else} + {#each filteredFractions as fraction (fraction.id)} + + {fraction.code} + {fraction.fraction} + + {fraction.description || '-'} + + {fraction.nico || '-'} + {fraction.umt || '-'} + {fraction.adv_impo || '-'} + {fraction.adv_expo || '-'} + + {/each} + {/if} + + +
+ + + {#if !searchQuery && totalPages > 1} +
+ + + + Página {currentPage} de {totalPages} + + + +
+ {/if} +
+
+
+