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 }); + } +}; +