From 7d1fe2bae81f1e725536e6ccc74a3fa74100c495 Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 12:06:38 -0600 Subject: [PATCH 1/6] refactor: replace Dialog components with Sheet components and improve layout in various dialogs --- .../edit/items/fa/country-dialog.svelte | 31 +++-- .../edit/items/fa/item-sheet-fa.svelte | 113 ++++++------------ .../edit/items/fa/part-number-dialog.svelte | 48 ++++---- .../items/fa/tariff-fraction-dialog.svelte | 42 ++++--- .../items/fa/unit-of-measure-dialog.svelte | 19 +-- .../edit/items/inv/item-sheet-inv.svelte | 71 ++++++----- 6 files changed, 160 insertions(+), 164 deletions(-) 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 @@
- - + + From 13254bbcfca080d24cbd9876b18814d03b292454 Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 12:46:47 -0600 Subject: [PATCH 2/6] feat: implement server API route to set active company in cookie and update setActiveCompany method --- frontend/src/lib/stores/company.svelte.ts | 19 ++++++++++-- .../company/set-active/+server.ts | 29 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 frontend/src/routes/api-sveltekit/company/set-active/+server.ts diff --git a/frontend/src/lib/stores/company.svelte.ts b/frontend/src/lib/stores/company.svelte.ts index 9f04bcdb..788afe61 100644 --- a/frontend/src/lib/stores/company.svelte.ts +++ b/frontend/src/lib/stores/company.svelte.ts @@ -120,7 +120,7 @@ class CompanyStore { * @param company - La compañía a establecer como activa * @param silent - Si es true, no dispara el evento companyChanged (para inicialización) */ - setActiveCompany(company: Company, silent: boolean = false) { + async setActiveCompany(company: Company, silent: boolean = false) { const previousCompanyId = this._activeCompany?.id; this._activeCompany = company; @@ -130,8 +130,21 @@ class CompanyStore { } // Guardar en cookie para acceso desde el servidor (SSR) - if (typeof document !== 'undefined') { - document.cookie = `active_company_id=${company.id}; path=/; max-age=${60 * 60 * 24 * 30}; SameSite=Lax`; + // Usar el endpoint del servidor para garantizar que la cookie esté disponible en SSR + if (browser) { + try { + await fetch('/api-sveltekit/company/set-active', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ companyId: company.id }), + credentials: 'include' + }); + console.log('Cookie set via server:', `active_company_id=${company.id}`); + } catch (error) { + console.error('Error setting active company cookie:', error); + } } // Despachar evento personalizado solo si: diff --git a/frontend/src/routes/api-sveltekit/company/set-active/+server.ts b/frontend/src/routes/api-sveltekit/company/set-active/+server.ts new file mode 100644 index 00000000..3820adfa --- /dev/null +++ b/frontend/src/routes/api-sveltekit/company/set-active/+server.ts @@ -0,0 +1,29 @@ +/** + * API route para establecer la compañía activa en una cookie + */ +import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const POST: RequestHandler = async ({ cookies, request }) => { + try { + const { companyId } = await request.json(); + + if (!companyId || typeof companyId !== 'number') { + return json({ error: 'Invalid company ID' }, { status: 400 }); + } + + // Establecer la cookie desde el servidor + cookies.set('active_company_id', companyId.toString(), { + path: '/', + maxAge: 60 * 60 * 24 * 30, // 30 días + sameSite: 'lax', + httpOnly: false, // Permitir acceso desde JavaScript + secure: process.env.NODE_ENV === 'production' + }); + + return json({ success: true, companyId }); + } catch (error) { + console.error('Error setting active company:', error); + return json({ error: 'Internal server error' }, { status: 500 }); + } +}; From 794d6d178169097f31b3ecbf16713c0b58a0712e Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 15:49:54 -0600 Subject: [PATCH 3/6] refactor: streamline item validation functions and enhance number formatting in summary section --- .../a76/items/common/common_validators.py | 43 ++++++++----------- .../imports/temporary/validators/common.py | 14 +++--- .../imports/temporary/validators/create.py | 18 ++++---- .../a76/items/line_descriptions/models.py | 3 +- .../a76/items/line_descriptions/schemas.py | 1 + .../edit/items/fa/summary-section.svelte | 32 ++++++++------ 6 files changed, 57 insertions(+), 54 deletions(-) diff --git a/backend/api/v1/modules/a76/items/common/common_validators.py b/backend/api/v1/modules/a76/items/common/common_validators.py index 652e79fc..06e0b449 100644 --- a/backend/api/v1/modules/a76/items/common/common_validators.py +++ b/backend/api/v1/modules/a76/items/common/common_validators.py @@ -3,36 +3,31 @@ from core.exceptions import ErrorCollector from ..line_items import models from sqlalchemy.orm import Session -def item_exists( - db: Session, - item_line: int, - tenant_id: int, - company_id: int -): + +def item_exists(db: Session, item_line: int, tenant_id: int, company_id: int): item_exists = ( - db.query(models.LineItem.id) + db.query(models.LineItem) .filter( models.LineItem.line_number == item_line, models.LineItem.tenant_id == tenant_id, models.LineItem.company_id == company_id, ) + .first() + ) + + return item_exists + + +def count_items(db: Session, invoice_id: int, tenant_id: int, company_id: int): + count = ( + db.query(func.count()) + .select_from(models.Item) + .filter( + models.Item.invoice_id == invoice_id, + models.Item.tenant_id == tenant_id, + models.Item.company_id == company_id, + ) .scalar() ) - if item_exists: - return item_exists - return None - -def count_items( - db: Session, - invoice_id: int, - tenant_id: int, - company_id: int -): - count = db.query(func.count()).select_from(models.Item).filter( - models.Item.invoice_id == invoice_id, - models.Item.tenant_id == tenant_id, - models.Item.company_id == company_id, - ).scalar() - - return count \ No newline at end of file + return count diff --git a/backend/api/v1/modules/a76/items/imports/temporary/validators/common.py b/backend/api/v1/modules/a76/items/imports/temporary/validators/common.py index 47fd73d5..d10c95fd 100644 --- a/backend/api/v1/modules/a76/items/imports/temporary/validators/common.py +++ b/backend/api/v1/modules/a76/items/imports/temporary/validators/common.py @@ -42,9 +42,7 @@ def validate_common( invoice: InvoiceHeader = invoice_exists_by_id( db, invoice_id, tenant_id, company_id, errors ) - line_item: LineItem = item_exists( - db, line.line_number, tenant_id, company_id - ) + line_item: LineItem = item_exists(db, line.line_number, tenant_id, company_id) fecha_factura = invoice.invoice_date if invoice else None fraction = None @@ -181,13 +179,15 @@ def validate_common( fraction = line.customs.fraction if line.customs.fraction else fraction country = line.customs.origin_country - if line_item: + if line_item and line_item.customs: country = ( - line_item.customs.fraction if line_item.customs.origin_country else country + line_item.customs.origin_country + if line_item.customs.origin_country + else country ) fraction_type = line.customs.fraction_type.upper() - if line_item: + if line_item and line_item.customs: fraction_type = ( line_item.customs.fraction_type if line_item.customs.fraction_type @@ -195,7 +195,7 @@ def validate_common( ) sector = line.customs.sector - if line_item: + if line_item and line_item.customs: sector = line_item.customs.sector if line_item.customs.sector else sector country_m3 = db.query(Country.m3_key).filter(Country.m3_key == country).scalar() diff --git a/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py b/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py index 8f1a0206..146a4278 100644 --- a/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py +++ b/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py @@ -206,8 +206,8 @@ def validate_create( net_weight_input = line.quantity.net_weight or Decimal("0") # Determinar si la unidad de medida es de peso - unit_is_kgs = line.unit_of_measure and line.unit_of_measure.upper() == "KGS" - unit_is_lbs = line.unit_of_measure and line.unit_of_measure.upper() == "LB" + unit_is_kgs = line.unit_of_measure and line.unit_of_measure == "24" #KGS + unit_is_lbs = line.unit_of_measure and line.unit_of_measure == "25" #LBS # Calcular peso neto en kilogramos (estándar interno) if unit_is_kgs: @@ -237,11 +237,11 @@ def validate_create( package_weight_unit = Decimal("0") # Obtener peso unitario del bulto si existe - if line.quantity.package_key: + if line.quantity.package_id: package: Package = ( db.query(Package) .filter( - Package.key == line.quantity.package_key, + Package.id == line.quantity.package_id, Package.tenant_id == tenant_id, Package.company_id == company_id, ) @@ -278,22 +278,22 @@ def validate_create( # ========================================== # ASIGNAR DESCRIPCIÓN DE BULTOS # ========================================== - if package_quantity and package_quantity > 0 and line.quantity.package_key: + if package_quantity and package_quantity > 0 and line.quantity.package_id: package: Package = ( db.query(Package) .filter( - Package.key == line.quantity.package_key, + Package.id == line.quantity.package_id, Package.tenant_id == tenant_id, Package.company_id == company_id, ) .first() ) if package: - line.quantity.package_description = package.description_es + line.description.package_description = package.description_es else: line.quantity.package_quantity = 0 - line.quantity.package_key = None - line.quantity.package_description = None + line.quantity.package_id = None + line.description.package_description = None # ========================================== # ASIGNAR FRACCIÓN AMERICANA POR DEFECTO diff --git a/backend/api/v1/modules/a76/items/line_descriptions/models.py b/backend/api/v1/modules/a76/items/line_descriptions/models.py index 39e09560..d8c7ecbf 100644 --- a/backend/api/v1/modules/a76/items/line_descriptions/models.py +++ b/backend/api/v1/modules/a76/items/line_descriptions/models.py @@ -24,7 +24,8 @@ class LineDescription(Base): description_english: Mapped[Optional[str]] = mapped_column(String(4999)) # DESCRIPCIONI extra_description: Mapped[Optional[str]] = mapped_column(Text) # DESCRIPCIONEEXTRA part_description: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONPARTE - class_description: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONCLASE + class_description: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONCLASE + package_description: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONBULTO # Product attributes brand: Mapped[Optional[str]] = mapped_column(String(50)) # MARCA diff --git a/backend/api/v1/modules/a76/items/line_descriptions/schemas.py b/backend/api/v1/modules/a76/items/line_descriptions/schemas.py index 56965c36..8a65d68e 100644 --- a/backend/api/v1/modules/a76/items/line_descriptions/schemas.py +++ b/backend/api/v1/modules/a76/items/line_descriptions/schemas.py @@ -13,6 +13,7 @@ class LineDescriptionBase(BaseModel): extra_description: Optional[str] = Field(None, description="Extra description (DESCRIPCIONEEXTRA)") part_description: Optional[str] = Field(None, max_length=500, description="Part description (DESCRIPCIONPARTE)") class_description: Optional[str] = Field(None, max_length=500, description="Class description (DESCRIPCIONCLASE)") + package_description: Optional[str] = Field(None, max_length=500, description="Package description (DESCRIPCIONBULTO)") # Product attributes brand: Optional[str] = Field(None, max_length=50, description="Brand (MARCA)") 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 27b66319..0320095a 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 @@ -2,6 +2,12 @@ import type { LineFinancials, LineQuantities } from '$lib/api/dashboard/a76/items'; let { financials = $bindable(), quantities = $bindable() }: { financials: LineFinancials; quantities: LineQuantities } = $props(); + + // Helper function to safely format numbers + function formatNumber(value: any, decimals: number = 8): string { + const num = Number(value); + return isNaN(num) ? '0.00000000' : num.toFixed(decimals); + }
@@ -10,18 +16,18 @@
RETURN QUANTITY SUB-ITEMS
-
Temporary: {quantities.quantity_temp_export?.toFixed(8) || '0.00000000'}
+
Temporary: {formatNumber(quantities.quantity_temp_export)}
Replacement or Change: 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'}
+
Definitive: {formatNumber(quantities.quantity_returned)}
+
Returned Values: {formatNumber(financials.value_returned_usd)}
+
Returned Values: {formatNumber(financials.value_returned_mxn)}
WEIGHTS (KILOS)
WEIGHTS (Pounds)
-
Net: {quantities.net_weight?.toFixed(8) || '0.00000000'}
+
Net: {formatNumber(quantities.net_weight)}
0.00000000
-
Whole: {quantities.gross_weight?.toFixed(8) || '0.00000000'}
+
Whole: {formatNumber(quantities.gross_weight)}
0.00000000
@@ -33,13 +39,13 @@
(Dollars)
(Pesos)
-
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: {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
+
Cost: {formatNumber(financials.unit_cost_usd)}
+
{formatNumber(financials.unit_cost_mxn)}
+
Value: {formatNumber(financials.value_usd)}
+
{formatNumber(financials.value_mxn)}
+
Capture Cost: {formatNumber(financials.unit_cost_capture)} USD
+
Capture Value: {formatNumber(financials.value_usd)} USD
+
Customs Value: {formatNumber(financials.customs_value_usd)} USD
From e05e50f2b88e8e98847a2cb7275ba8af75482532 Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 16:26:06 -0600 Subject: [PATCH 4/6] refactor: enhance invoice mapping functions and integrate PedimentosResponse DTO in catalog service --- .../modules/a76/pedmientos/catalog_service.py | 6 +- .../api/v1/modules/a76/pedmientos/schemas.py | 5 +- .../edit/items/fa/item-sheet-fa.svelte | 2 + .../dashboard/invoices/edit/[id]/+page.svelte | 190 +++++++++++++++++- 4 files changed, 190 insertions(+), 13 deletions(-) diff --git a/backend/api/v1/modules/a76/pedmientos/catalog_service.py b/backend/api/v1/modules/a76/pedmientos/catalog_service.py index b78bd8b8..13b4a01e 100644 --- a/backend/api/v1/modules/a76/pedmientos/catalog_service.py +++ b/backend/api/v1/modules/a76/pedmientos/catalog_service.py @@ -17,6 +17,7 @@ from api.v1.modules.public.reference_data.customs_sections.dto import CustomsSec from api.v1.modules.public.reference_data.code_pedimento_regimens.dto import CodePedimentoRegimenDTO from api.v1.modules.a76.customs_brokers.dto import CustomsBrokerResponseDTO from api.v1.modules.a76.clients_and_providers.dto import ClientProviderResponseDTO +from .dtos.pedimentos import PedimentosResponse from .schemas import PedimentoCatalogsResponse, PedimentoCreationResponse, PedimentoEditionResponse @@ -111,10 +112,13 @@ class PedimentoCatalogService: if not pedimento: return None + + # Convert SQLAlchemy object to Pydantic DTO + pedimento_dto = PedimentosResponse.model_validate(pedimento) return PedimentoEditionResponse( **catalogs.model_dump(), is_create=False, - pedimento=pedimento, + pedimento=pedimento_dto, pedimento_id=pedimento_id ) diff --git a/backend/api/v1/modules/a76/pedmientos/schemas.py b/backend/api/v1/modules/a76/pedmientos/schemas.py index fb673d64..aeec5ee3 100644 --- a/backend/api/v1/modules/a76/pedmientos/schemas.py +++ b/backend/api/v1/modules/a76/pedmientos/schemas.py @@ -2,7 +2,7 @@ Consolidated schemas for Pedimento catalog responses """ -from typing import List, Optional, Any +from typing import List, Optional from pydantic import BaseModel # Import DTOs for catalog items @@ -11,6 +11,7 @@ from api.v1.modules.public.reference_data.customs_sections.dto import CustomsSec from api.v1.modules.public.reference_data.code_pedimento_regimens.dto import CodePedimentoRegimenDTO from api.v1.modules.a76.customs_brokers.dto import CustomsBrokerResponseDTO from api.v1.modules.a76.clients_and_providers.dto import ClientProviderResponseDTO +from .dtos.pedimentos import PedimentosResponse class PedimentoCatalogsResponse(BaseModel): @@ -33,5 +34,5 @@ class PedimentoEditionResponse(PedimentoCatalogsResponse): """Response for editing an existing pedimento (catalogs + pedimento data)""" is_create: bool = False - pedimento: Optional[Any] = None # Will be PedimentosResponse but avoiding circular import + pedimento: Optional[PedimentosResponse] = None pedimento_id: Optional[int] = None 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 5bf87a1c..ea64e1f0 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 @@ -24,6 +24,7 @@ invoice, onSave, onCancel, + isTargetingPreset = false, isSaving = false }: { open: boolean; @@ -32,6 +33,7 @@ invoice: Invoice | null; onSave: () => void; onCancel?: () => void; + isTargetingPreset?: boolean; isSaving?: boolean; } = $props(); diff --git a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte index 1e1d88b1..c76ab8f0 100644 --- a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte +++ b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte @@ -222,29 +222,199 @@ return { ...skeleton, ...filtered }; } + // Función para mapear la factura existente a los formData + function mapInvoiceToTopFields(invoice: any) { + if (!invoice) return topFieldsSkeleton; + + let operationType: string | null = null; + if (invoice.operation_type) { + operationType = invoice.operation_type; + } else if (data.filters?.operation_type !== undefined) { + operationType = data.filters.operation_type ?? null; + } + + return { + is_pedimento_pending: invoice.compliance_mx?.is_pedimento_pending || false, + pedimento_id: invoice.compliance_mx?.pedimento_id || '', + remesa: invoice.compliance_mx?.remesa || '', + invoice_number: invoice.invoice_number || '', + invoice_date: invoice.invoice_date || new Date().toISOString().split('T')[0], + emission_date: invoice.emission_date || new Date().toISOString().split('T')[0], + operation_type: operationType, + invoice_type: invoice.invoice_type || (data.filters?.invoice_type ?? ''), + fecha_pedimento_del: '', + fecha_pedimento_al: '', + clave_pedimento: '', + regimen_pedimento: '' + }; + } + + function mapInvoiceToGeneral(invoice: any) { + if (!invoice) return generalSkeleton; + + return { + provider_header: invoice.compliance_mx?.provider_header || 'proveedor', + provider_id: invoice.compliance_mx?.provider_id || null, + sold_to_header: invoice.compliance_mx?.sold_to_header || 'consignado_a', + sold_to_id: invoice.compliance_mx?.sold_to_id || null, + shipped_to_header: invoice.compliance_mx?.shipped_to_header || 'enviado_a', + shipped_to_id: invoice.compliance_mx?.shipped_to_id || null, + customs_broker_id: invoice.compliance_mx?.customs_broker_id || null, + customs_broker_us_id: invoice.compliance_mx?.customs_broker_us_id || null, + currency_type: invoice.financials?.currency_type || '', + currency: invoice.financials?.currency || 'foreign', + exchange_rate: invoice.financials?.exchange_rate || null, + weight_type: 'kgs', + iva_factor: invoice.financials?.iva_factor || null, + carrier_id: invoice.logistics?.carrier_id || null, + transport_id: invoice.logistics?.transport_id || '', + driver_name: invoice.logistics?.driver_name || '', + transport_type: invoice.logistics?.transport_type || '', + transport_num: invoice.logistics?.vehicle_num || '', + aduana: invoice.compliance_mx?.aduana || '', + document_type: invoice.document_type || '' + }; + } + + function mapInvoiceToObservations(invoice: any) { + if (!invoice) return observationSkeleton; + + return { + observation_es: invoice.observation_es || '', + observation_en: invoice.observation_en || '', + freight: invoice.financials?.freight || null, + insurance_value: invoice.financials?.insurance_value || null, + insurance: invoice.financials?.insurance || null, + packaging: invoice.financials?.packaging || null, + other_increments: invoice.financials?.other_increments || null, + total_increments_mn: invoice.financials?.total_increments_mn || null, + total_increments_me: invoice.financials?.total_increments_me || null, + incoterm: invoice.logistics?.incoterm || null, + enclosure: invoice.compliance_mx?.enclosure || null, + num_seals: null, + movement_type: invoice.compliance_mx?.movement_type || '', + alternate_invoice: invoice.alternate_invoice || '', + valuation_method: invoice.compliance_mx?.value_method || null + }; + } + + function mapInvoiceToItems(invoice: any) { + if (!invoice) return ensureItemsFormData(null); + + return { + items: invoice.items || [] + }; + } + + function mapInvoiceToOthers(invoice: any) { + if (!invoice) return othersSkeleton; + + return { + comments_status: invoice.comments_status || '', + transport_mode: invoice.logistics?.transport_mode || 'TRUCK', + is_mixed: invoice.compliance_mx?.is_mixed || false, + print_stamp: invoice.print_stamp || false, + rule_3121_parties_ii: invoice.compliance_mx?.rule_3121_parties_ii || false, + related_doc_id: invoice.related_doc_id || null, + code_signature: invoice.compliance_mx?.code_signature || '', + electronic_signature: invoice.compliance_mx?.electronic_signature || '', + mandatory_person: invoice.compliance_mx?.mandatory_person || '', + contingency_mode: invoice.compliance_mx?.contingency_mode || false, + cove: invoice.compliance_mx?.cove || '', + operation_num: invoice.compliance_mx?.operation_num || '', + adendas: invoice.compliance_mx?.adendas || '', + observations_vu: invoice.compliance_mx?.observations_vu || '', + certified_number: invoice.compliance_mx?.certified_number || '', + bill_number: invoice.logistics?.bill_number || '', + guide_number: invoice.logistics?.guide_number || '', + shipment_number: invoice.logistics?.shipment_number || '', + option_iv18: invoice.compliance_mx?.option_iv18 || '', + delivered_status: invoice.delivered_status || false, + received_by: invoice.received_by || '', + delivery_date: invoice.delivery_date || '' + }; + } + + function mapInvoiceToContinuation(invoice: any) { + if (!invoice) return continuationSkeleton; + + return { + numero_tipo_transporte: invoice.logistics?.numero_tipo_transporte || '', + es_ferrocarril: invoice.logistics?.es_ferrocarril || 'no', + numero_bl: invoice.logistics?.numero_bl || '', + cantidad_guias_embarque: invoice.logistics?.cantidad_guias_embarque || null, + destino_origen: invoice.logistics?.destino_origen || '', + puerto_entrada: invoice.logistics?.puerto_entrada || '', + vehicle_data: invoice.logistics?.vehicle_data || '', + fue_revisado_equipo: invoice.logistics?.fue_revisado_equipo || false, + sub_division: invoice.compliance_mx?.subdivision || false, + funge_como_cd: invoice.logistics?.acts_as_cd || false, + llego_pedimento: invoice.compliance_mx?.llego_pedimento || false, + errores_facturacion: invoice.errores_facturacion || [], + semaforo_verde_aduana_mexicana: invoice.compliance_mx?.semaforo_verde_aduana_mexicana || false, + semaforo_verde_aduana_americana: invoice.compliance_mx?.semaforo_verde_aduana_americana || false, + semaforo_rojo_aduana_mexicana: invoice.compliance_mx?.semaforo_rojo_aduana_mexicana || false, + semaforo_rojo_aduana_americana: invoice.compliance_mx?.semaforo_rojo_aduana_americana || false, + is_mixed: invoice.compliance_mx?.is_mixed || false, + reason_export: invoice.compliance_mx?.reason_export || '1', + purchase_order: invoice.purchase_order || '', + payment_terms: invoice.payment_terms || '', + handling_fees: invoice.financials?.handling_fees || 0, + cfdi_uuid: invoice.cfdi_uuid || '', + path_pdf: invoice.path_pdf || '', + path_xml: invoice.path_xml || '' + }; + } + // Referencias a los componentes de formulario para obtener sus datos + // Si estamos en modo edición (!data.isCreate) y tenemos una factura, usarla + // Si estamos en modo creación, usar defaultSettings let InvoiceTopFieldsFormData = $state( - mergeDefaults(topFieldsSkeleton, data.defaultSettings?.InvoiceTopFieldsFormData) + !data.isCreate && data.invoice + ? mapInvoiceToTopFields(data.invoice) + : mergeDefaults(topFieldsSkeleton, data.defaultSettings?.InvoiceTopFieldsFormData) ); let generalFormData = $state( - mergeDefaults(generalSkeleton, data.defaultSettings?.generalFormData) + !data.isCreate && data.invoice + ? mapInvoiceToGeneral(data.invoice) + : mergeDefaults(generalSkeleton, data.defaultSettings?.generalFormData) ); let observationFormData = $state( - mergeDefaults(observationSkeleton, data.defaultSettings?.observationFormData) + !data.isCreate && data.invoice + ? mapInvoiceToObservations(data.invoice) + : mergeDefaults(observationSkeleton, data.defaultSettings?.observationFormData) + ); + let itemsFormData = $state( + !data.isCreate && data.invoice + ? mapInvoiceToItems(data.invoice) + : ensureItemsFormData(data.defaultSettings?.itemsFormData) ); - let itemsFormData = $state(ensureItemsFormData(data.defaultSettings?.itemsFormData)); let othersFormData = $state( - mergeDefaults(othersSkeleton, data.defaultSettings?.othersFormData) + !data.isCreate && data.invoice + ? mapInvoiceToOthers(data.invoice) + : mergeDefaults(othersSkeleton, data.defaultSettings?.othersFormData) ); let continuationFormData = $state( - mergeDefaults(continuationSkeleton, data.defaultSettings?.continuationFormData) + !data.isCreate && data.invoice + ? mapInvoiceToContinuation(data.invoice) + : mergeDefaults(continuationSkeleton, data.defaultSettings?.continuationFormData) ); // Estados para saber si existen datos previos - let observationExists = $state(!!data.defaultSettings?.observationFormData); - let itemsExists = $state(!!data.defaultSettings?.itemsFormData?.items?.length); - let othersExists = $state(!!data.defaultSettings?.othersFormData); - let continuationExists = $state(!!data.defaultSettings?.continuationFormData); + let observationExists = $state( + !data.isCreate ? !!data.invoice : !!data.defaultSettings?.observationFormData + ); + let itemsExists = $state( + !data.isCreate + ? !!(data.invoice?.items && data.invoice.items.length > 0) + : !!data.defaultSettings?.itemsFormData?.items?.length + ); + let othersExists = $state( + !data.isCreate ? !!data.invoice : !!data.defaultSettings?.othersFormData + ); + let continuationExists = $state( + !data.isCreate ? !!data.invoice : !!data.defaultSettings?.continuationFormData + ); let calculatedExchangeRate = $state( data.invoice?.financials?.exchange_rate ?? null From 472e42a02f2f294e42d6925b749e43a039ca461f Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 16:30:18 -0600 Subject: [PATCH 5/6] refactor: remove console logs and clean up fetch URL assignments in various components --- .../dashboard/invoices/edit/items/fa/country-dialog.svelte | 7 ++----- .../invoices/edit/items/fa/tariff-fraction-dialog.svelte | 6 ++---- .../invoices/edit/items/fa/unit-of-measure-dialog.svelte | 3 +-- frontend/src/lib/stores/company.svelte.ts | 3 +-- frontend/src/routes/api-sveltekit/classes/+server.ts | 1 - frontend/src/routes/api-sveltekit/classes/[id]/+server.ts | 1 - frontend/src/routes/api-sveltekit/parts/+server.ts | 3 +-- frontend/src/routes/api-sveltekit/parts/[id]/+server.ts | 3 +-- .../src/routes/api-sveltekit/tariff-fractions/+server.ts | 4 ---- .../src/routes/api-sveltekit/units-of-measure/+server.ts | 4 ---- .../routes/api-sveltekit/units-of-measure/[id]/+server.ts | 3 +-- frontend/src/routes/dashboard/invoices/+page.svelte | 3 +-- .../src/routes/dashboard/invoices/edit/[id]/+page.svelte | 3 +-- frontend/test_bits.js | 7 ------- 14 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 frontend/test_bits.js 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 ddb6b92d..a7b032be 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 @@ -26,9 +26,7 @@ credentials: 'include' }); if (response.ok) { - const data = await response.json(); - console.log('Countries data received:', data); - console.log('First country sample:', data[0]); + const data = await response.json(); if (Array.isArray(data)) { countries = data; } else if (data.items && Array.isArray(data.items)) { @@ -37,8 +35,7 @@ console.error('Unexpected data format:', data); countries = []; } - filteredCountries = countries; - console.log('Total countries loaded:', countries.length); + filteredCountries = countries; } else { error = `Error: ${response.status} - ${response.statusText}`; console.error('Error response:', await response.text()); 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 02721e57..a298f2c4 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 @@ -47,8 +47,7 @@ }); if (response.ok) { - const data = await response.json(); - console.log('Tariff fractions data received:', data); + const data = await response.json(); if (data.items && Array.isArray(data.items)) { if (append) { @@ -58,8 +57,7 @@ } currentPage = data.page; totalPages = data.pages; - hasMore = currentPage < totalPages; - console.log(`Loaded page ${currentPage}/${totalPages}, total items: ${fractions.length}`); + hasMore = currentPage < totalPages; } else { console.error('Unexpected data format:', data); if (!append) fractions = []; 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 55dab050..1df38b06 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,8 +27,7 @@ credentials: 'include' }); if (response.ok) { - const data = await response.json(); - console.log('Units data received:', data); + const data = await response.json(); // El backend puede devolver { items: [...] } o directamente un array if (Array.isArray(data)) { units = data; diff --git a/frontend/src/lib/stores/company.svelte.ts b/frontend/src/lib/stores/company.svelte.ts index 788afe61..f2572f93 100644 --- a/frontend/src/lib/stores/company.svelte.ts +++ b/frontend/src/lib/stores/company.svelte.ts @@ -140,8 +140,7 @@ class CompanyStore { }, body: JSON.stringify({ companyId: company.id }), credentials: 'include' - }); - console.log('Cookie set via server:', `active_company_id=${company.id}`); + }); } catch (error) { console.error('Error setting active company cookie:', error); } diff --git a/frontend/src/routes/api-sveltekit/classes/+server.ts b/frontend/src/routes/api-sveltekit/classes/+server.ts index 1d44c79d..f5ea10d4 100644 --- a/frontend/src/routes/api-sveltekit/classes/+server.ts +++ b/frontend/src/routes/api-sveltekit/classes/+server.ts @@ -36,7 +36,6 @@ export const GET: RequestHandler = async ({ cookies, url }) => { try { const fetchUrl = `${baseUrl}v1/a76/classes?${queryString}`; - console.log('Fetching classes from:', fetchUrl); const response = await fetch( fetchUrl, diff --git a/frontend/src/routes/api-sveltekit/classes/[id]/+server.ts b/frontend/src/routes/api-sveltekit/classes/[id]/+server.ts index d8de375c..43180934 100644 --- a/frontend/src/routes/api-sveltekit/classes/[id]/+server.ts +++ b/frontend/src/routes/api-sveltekit/classes/[id]/+server.ts @@ -32,7 +32,6 @@ export const GET: RequestHandler = async ({ cookies, url, params }) => { try { const fetchUrl = `${baseUrl}v1/a76/classes/${id}?company_id=${companyId}`; - console.log('Fetching class from:', fetchUrl); const response = await fetch( fetchUrl, diff --git a/frontend/src/routes/api-sveltekit/parts/+server.ts b/frontend/src/routes/api-sveltekit/parts/+server.ts index 8fcc4b47..fe1b1f23 100644 --- a/frontend/src/routes/api-sveltekit/parts/+server.ts +++ b/frontend/src/routes/api-sveltekit/parts/+server.ts @@ -35,8 +35,7 @@ export const GET: RequestHandler = async ({ cookies, url }) => { const queryString = searchParams.toString(); try { - const fetchUrl = `${baseUrl}v1/a76/parts?${queryString}`; - console.log('Fetching parts from:', fetchUrl); + const fetchUrl = `${baseUrl}v1/a76/parts?${queryString}`; const response = await fetch( fetchUrl, diff --git a/frontend/src/routes/api-sveltekit/parts/[id]/+server.ts b/frontend/src/routes/api-sveltekit/parts/[id]/+server.ts index ba82f40d..ef9662f0 100644 --- a/frontend/src/routes/api-sveltekit/parts/[id]/+server.ts +++ b/frontend/src/routes/api-sveltekit/parts/[id]/+server.ts @@ -31,8 +31,7 @@ export const GET: RequestHandler = async ({ cookies, url, params }) => { const baseUrl = apiUrl?.endsWith('/') ? apiUrl : `${apiUrl}/`; try { - const fetchUrl = `${baseUrl}v1/a76/parts/${id}?company_id=${companyId}`; - console.log('Fetching part from:', fetchUrl); + const fetchUrl = `${baseUrl}v1/a76/parts/${id}?company_id=${companyId}`; const response = await fetch( fetchUrl, diff --git a/frontend/src/routes/api-sveltekit/tariff-fractions/+server.ts b/frontend/src/routes/api-sveltekit/tariff-fractions/+server.ts index 1a15e7d8..52a37f85 100644 --- a/frontend/src/routes/api-sveltekit/tariff-fractions/+server.ts +++ b/frontend/src/routes/api-sveltekit/tariff-fractions/+server.ts @@ -20,8 +20,6 @@ export const GET: RequestHandler = async ({ cookies, url }) => { try { const fetchUrl = `${baseUrl}v1/a76/tariff-fractions?${queryString}`; - console.log('Fetching tariff fractions from:', fetchUrl); - console.log('Token:', token ? 'Present' : 'Missing'); const response = await fetch( fetchUrl, @@ -35,8 +33,6 @@ export const GET: RequestHandler = async ({ cookies, url }) => { ); const data = await response.json(); - console.log('Response status:', response.status); - console.log('Response data:', JSON.stringify(data).substring(0, 200)); if (!response.ok) { return new Response(JSON.stringify(data), { diff --git a/frontend/src/routes/api-sveltekit/units-of-measure/+server.ts b/frontend/src/routes/api-sveltekit/units-of-measure/+server.ts index 35a9fc11..200120c7 100644 --- a/frontend/src/routes/api-sveltekit/units-of-measure/+server.ts +++ b/frontend/src/routes/api-sveltekit/units-of-measure/+server.ts @@ -36,8 +36,6 @@ export const GET: RequestHandler = async ({ cookies, url }) => { try { const fetchUrl = `${baseUrl}v1/a76/units-of-measure?${queryString}`; - console.log('Fetching units from:', fetchUrl); - console.log('Token:', token ? 'Present' : 'Missing'); const response = await fetch( fetchUrl, @@ -51,8 +49,6 @@ export const GET: RequestHandler = async ({ cookies, url }) => { ); const data = await response.json(); - console.log('Response status:', response.status); - console.log('Response data:', JSON.stringify(data).substring(0, 200)); if (!response.ok) { return new Response(JSON.stringify(data), { diff --git a/frontend/src/routes/api-sveltekit/units-of-measure/[id]/+server.ts b/frontend/src/routes/api-sveltekit/units-of-measure/[id]/+server.ts index 110e12c4..08813905 100644 --- a/frontend/src/routes/api-sveltekit/units-of-measure/[id]/+server.ts +++ b/frontend/src/routes/api-sveltekit/units-of-measure/[id]/+server.ts @@ -31,8 +31,7 @@ export const GET: RequestHandler = async ({ cookies, params, url }) => { const baseUrl = apiUrl?.endsWith('/') ? apiUrl : `${apiUrl}/`; try { - const fetchUrl = `${baseUrl}v1/a76/units-of-measure/${id}?company_id=${companyId}`; - console.log('Fetching unit of measure from:', fetchUrl); + const fetchUrl = `${baseUrl}v1/a76/units-of-measure/${id}?company_id=${companyId}`; const response = await fetch( fetchUrl, diff --git a/frontend/src/routes/dashboard/invoices/+page.svelte b/frontend/src/routes/dashboard/invoices/+page.svelte index 0da3bdce..f3ebcc7c 100644 --- a/frontend/src/routes/dashboard/invoices/+page.svelte +++ b/frontend/src/routes/dashboard/invoices/+page.svelte @@ -187,8 +187,7 @@ selectedInvoiceId = null; } else { selectedInvoiceId = invoice.id; - } - console.log('Selected Invoice ID:', selectedInvoiceId); + } } const selectedInvoice = $derived( diff --git a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte index c76ab8f0..506ec342 100644 --- a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte +++ b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte @@ -484,8 +484,7 @@ const actualResponse = response as any; const items = actualResponse.data?.items || []; - if (items.length === 0) { - console.log('No exchange rate found for', date); + if (items.length === 0) { if (!uiStore.isExchangeRateDialogOpen) { missingExchangeRateDate = date; showExchangeRateDialog = true; diff --git a/frontend/test_bits.js b/frontend/test_bits.js deleted file mode 100644 index 6228649d..00000000 --- a/frontend/test_bits.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Dialog } from "bits-ui"; -console.log("Dialog is:", Dialog); -try { - console.log("Dialog.Root is:", Dialog.Root); -} catch (e) { - console.log("Error accessing Dialog.Root:", e.message); -} From 50aa87b2aab46f74741901ea8542c671f6ba248d Mon Sep 17 00:00:00 2001 From: acazares Date: Fri, 13 Feb 2026 17:04:03 -0600 Subject: [PATCH 6/6] fix: correct logic for handling pedimento_id in invoice update validation --- .../modules/a76/invoices/imports/temporary/validators/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/api/v1/modules/a76/invoices/imports/temporary/validators/update.py b/backend/api/v1/modules/a76/invoices/imports/temporary/validators/update.py index 97ee1843..d30069a4 100644 --- a/backend/api/v1/modules/a76/invoices/imports/temporary/validators/update.py +++ b/backend/api/v1/modules/a76/invoices/imports/temporary/validators/update.py @@ -58,7 +58,7 @@ def validate_update( # Columna A: Pedimento (si no viene en CSV, usar el existente) if invoice_data.compliance_mx.pedimento_id: - invoice_data.compliance_mx.pedimento_id = clean_str(invoice_data.compliance_mx.pedimento_id) + invoice_data.compliance_mx.pedimento_id = invoice_data.compliance_mx.pedimento_id else: invoice_data.compliance_mx.pedimento_id = existing_invoice.compliance_mx.pedimento_id if existing_invoice.compliance_mx else None