diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/country-dialog.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/country-dialog.svelte index 9f890415..ddb6b92d 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/country-dialog.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/country-dialog.svelte @@ -27,6 +27,8 @@ }); if (response.ok) { const data = await response.json(); + console.log('Countries data received:', data); + console.log('First country sample:', data[0]); if (Array.isArray(data)) { countries = data; } else if (data.items && Array.isArray(data.items)) { @@ -35,7 +37,8 @@ console.error('Unexpected data format:', data); countries = []; } - filteredCountries = countries; + filteredCountries = countries; + console.log('Total countries loaded:', countries.length); } else { error = `Error: ${response.status} - ${response.statusText}`; console.error('Error response:', await response.text()); @@ -80,7 +83,7 @@ - + CATALOGO DE PAISES @@ -88,7 +91,11 @@
- +
@@ -106,7 +113,9 @@ - + @@ -125,11 +134,11 @@ class="border-b hover:bg-zinc-100 dark:hover:bg-zinc-800 cursor-pointer transition-colors" onclick={() => handleSelect(country)} > - - - - - + + + + + {/each} {#if filteredCountries.length === 0} @@ -143,9 +152,7 @@
Clave M3Clave M3 Clave Mexicana{country.m3_key || ''}{country.mex_key || ''}{country.description_es || ''}{country.ame_key || ''}{country.description_en || ''}{country.m3_key || ''}{country.mex_key || ''}{country.description_es || ''}{country.ame_key || ''}{country.description_en || ''}
-
+
- -
-
+ -
+
{#if line} @@ -152,7 +99,7 @@
- + General @@ -216,5 +163,23 @@ {/if}
-
-
\ No newline at end of file + + + + + \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/part-number-dialog.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/part-number-dialog.svelte index 90d657f5..bcb53791 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/part-number-dialog.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/part-number-dialog.svelte @@ -24,12 +24,11 @@ const filteredParts = $derived( searchQuery - ? parts.filter( - (p) => - p.part_number?.toLowerCase().includes(searchQuery.toLowerCase()) || - p.description_spanish?.toLowerCase().includes(searchQuery.toLowerCase()) || - p.description_english?.toLowerCase().includes(searchQuery.toLowerCase()) - ) + ? parts.filter(p => + p.part_number?.toLowerCase().includes(searchQuery.toLowerCase()) || + p.description_spanish?.toLowerCase().includes(searchQuery.toLowerCase()) || + p.description_english?.toLowerCase().includes(searchQuery.toLowerCase()) + ) : parts ); @@ -53,12 +52,15 @@ isSearching = true; try { - const response = await fetch(`/api-sveltekit/parts?company_id=${activeCompanyId}&limit=100`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' + const response = await fetch( + `/api-sveltekit/parts?company_id=${activeCompanyId}&limit=100`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } } - }); + ); if (!response.ok) { throw new Error('Error al buscar números de parte'); @@ -85,9 +87,8 @@ function handleScroll(e: Event) { const target = e.target as HTMLDivElement; const threshold = 100; - const scrolledToBottom = - target.scrollHeight - target.scrollTop - target.clientHeight < threshold; - + const scrolledToBottom = target.scrollHeight - target.scrollTop - target.clientHeight < threshold; + if (scrolledToBottom && displayedParts.length < filteredParts.length) { currentPage++; loadMoreParts(); @@ -103,10 +104,12 @@ - + Seleccionar Número de Parte - Busca y selecciona un número de parte para la partida + + Busca y selecciona un número de parte para la partida +
@@ -145,18 +148,15 @@ {:else} {#each displayedParts as part} - handleSelect(part)} - > + handleSelect(part)}> {part.part_number} {part.description_spanish || '-'} - {part.description_english || '-'} + {part.description_english || '-'} {part.part_class || '-'} - + {/each} diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tariff-fraction-dialog.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tariff-fraction-dialog.svelte index 89ce0247..02721e57 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tariff-fraction-dialog.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tariff-fraction-dialog.svelte @@ -17,7 +17,7 @@ let loadingMore = $state(false); let searchTerm = $state(''); let error = $state(''); - + // Pagination state let currentPage = $state(1); let totalPages = $state(1); @@ -34,7 +34,7 @@ loadingMore = true; } error = ''; - + try { const params = new URLSearchParams({ page: page.toString(), @@ -45,10 +45,11 @@ const response = await fetch(`/api-sveltekit/tariff-fractions?${params}`, { credentials: 'include' }); - + if (response.ok) { - const data = await response.json(); - + const data = await response.json(); + console.log('Tariff fractions data received:', data); + if (data.items && Array.isArray(data.items)) { if (append) { fractions = [...fractions, ...data.items]; @@ -57,7 +58,8 @@ } currentPage = data.page; totalPages = data.pages; - hasMore = currentPage < totalPages; + hasMore = currentPage < totalPages; + console.log(`Loaded page ${currentPage}/${totalPages}, total items: ${fractions.length}`); } else { console.error('Unexpected data format:', data); if (!append) fractions = []; @@ -77,10 +79,10 @@ function handleScroll(e: Event) { if (!scrollContainer || loading || loadingMore || !hasMore) return; - + const target = e.target as HTMLDivElement; const scrollBottom = target.scrollHeight - target.scrollTop - target.clientHeight; - + // Load more when within 200px of bottom if (scrollBottom < 200) { loadFractions(currentPage + 1, true); @@ -118,7 +120,7 @@ - + FRACCIONES ARANCELARIAS @@ -137,7 +139,11 @@

-
+
{#if loading}
@@ -151,12 +157,18 @@ - - + + - + @@ -192,7 +204,9 @@ {/if} {#if !hasMore && fractions.length > 0} -
Todos los resultados cargados
+
+ Todos los resultados cargados +
{/if} {/if} diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/unit-of-measure-dialog.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/unit-of-measure-dialog.svelte index f62aa919..55dab050 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/unit-of-measure-dialog.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/unit-of-measure-dialog.svelte @@ -27,7 +27,8 @@ credentials: 'include' }); if (response.ok) { - const data = await response.json(); + const data = await response.json(); + console.log('Units data received:', data); // El backend puede devolver { items: [...] } o directamente un array if (Array.isArray(data)) { units = data; @@ -83,7 +84,7 @@ - + CATALOGOS DE UNIDADES DE MEDIDA @@ -91,7 +92,11 @@
- +
@@ -109,7 +114,9 @@
CódigoFracciónCódigoFracción DescripciónNICONICO UMT
- + @@ -150,9 +157,7 @@
U.M.U.M. Descripción Español
-
+
-
+
General @@ -112,13 +116,13 @@ - + {#if !isTargetingPreset} -
+

Información de la Factura (SCAII - Inventario)

{#if !invoice?.id} -
+
⚠️ Esta factura aún no se ha guardado. Los items se asociarán cuando guardes la factura.
@@ -139,7 +143,7 @@
Sistema: - SCAII (Inventory)
@@ -207,7 +211,7 @@ - +
@@ -223,21 +227,21 @@
- {#if line} + {#if line?.description} {/if}
- {#if line} + {#if line?.description} {/if}
@@ -262,7 +266,7 @@ - +
@@ -350,7 +354,7 @@ id="packages" type="number" placeholder="0" - bind:value={line.quantity.packages} + bind:value={(line.quantity as any).packages} /> {/if}
@@ -360,7 +364,7 @@ {/if}
@@ -374,7 +378,7 @@ id="imported_quantity" type="number" placeholder="0" - bind:value={line.quantity.quantity_imported} + bind:value={(line.quantity as any).quantity_imported} /> {/if}
@@ -385,7 +389,8 @@ id="remaining_quantity" type="number" placeholder="0" - value={(line.quantity.quantity || 0) - (line.quantity.quantity_imported || 0)} + value={(line.quantity.quantity || 0) - + ((line.quantity as any).quantity_imported || 0)} disabled /> {/if} @@ -395,7 +400,7 @@
- +
@@ -435,7 +440,7 @@ {#if line?.description} @@ -445,5 +450,5 @@
- - + +