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 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/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/backend/main.py b/backend/main.py index 3f405d59..ae673fbf 100644 --- a/backend/main.py +++ b/backend/main.py @@ -29,7 +29,9 @@ 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 from api.v1.modules.a76.manifests.manifest.models import Manifest -from api.v1.modules.a76.manifests.concept_manifestation.models import ConceptManifestation +from api.v1.modules.a76.manifests.concept_manifestation.models import ( + ConceptManifestation, +) from api.v1.modules.a76.manifests.value_manifestation.models import ValueManifestation # Configurar logging @@ -93,7 +95,6 @@ async def on_startup(): run_migrations() logger.info("Base de datos inicializada correctamente.") - # Configurar CORS app.add_middleware( CORSMiddleware, @@ -112,6 +113,7 @@ app.add_middleware(TenantMiddleware) # Middleware de Contexto de Usuario (Audit Log) from api.v1.modules.a76.audit_log.middleware import UserContextMiddleware + app.add_middleware(UserContextMiddleware) # Importar modelos para Audit Log @@ -130,100 +132,121 @@ from api.v1.modules.a76.general_catalogs.company.models import Company from api.v1.modules.public.reference_data.countries.models import Country from api.v1.modules.public.reference_data.currency_types.models import CurrencyType from api.v1.modules.public.reference_data.customs_sections.models import CustomsSection -from api.v1.modules.public.reference_data.customs_warehouses.models import CustomsWarehouse +from api.v1.modules.public.reference_data.customs_warehouses.models import ( + CustomsWarehouse, +) from api.v1.modules.public.reference_data.incoterms.models import Incoterm from api.v1.modules.public.reference_data.invoice_types.models import InvoiceType from api.v1.modules.public.reference_data.material_types.models import MaterialType from api.v1.modules.public.reference_data.payment_methods.models import PaymentMethod from api.v1.modules.public.reference_data.pedimento_codes.models import PedimentoCode -from api.v1.modules.public.reference_data.pedimento_regimens.models import RegimenPedimento +from api.v1.modules.public.reference_data.pedimento_regimens.models import ( + RegimenPedimento, +) from api.v1.modules.public.reference_data.sectors.models import Sector from api.v1.modules.public.reference_data.states.models import State from api.v1.modules.public.reference_data.transport_modes.models import TransportMode from api.v1.modules.public.reference_data.transport_types.models import TransportType -from api.v1.modules.public.reference_data.valuation_methods.models import ValuationMethod +from api.v1.modules.public.reference_data.valuation_methods.models import ( + ValuationMethod, +) from api.v1.modules.a76.general_catalogs.units_of_measure.models import UnitOfMeasure from api.v1.modules.a76.general_catalogs.exchange_rate.models import ExchangeRate from api.v1.modules.a76.general_catalogs.identifiers.models import Identifier from api.v1.modules.a76.classes.models import Class -from api.v1.modules.a76.general_catalogs.classification_concepts.models import ClassificationConcept +from api.v1.modules.a76.general_catalogs.classification_concepts.models import ( + ClassificationConcept, +) from api.v1.modules.a76.general_catalogs.concepts.models import Concept -from api.v1.modules.a76.general_catalogs.customs_broker_concepts.models import CustomsBrokerConcept -from api.v1.modules.a76.general_catalogs.depreciation_catalog.models import DepreciationCatalog +from api.v1.modules.a76.general_catalogs.customs_broker_concepts.models import ( + CustomsBrokerConcept, +) +from api.v1.modules.a76.general_catalogs.depreciation_catalog.models import ( + DepreciationCatalog, +) from api.v1.modules.a76.general_catalogs.doda.models import Doda -from api.v1.modules.a76.general_catalogs.electronic_notices.models import ElectronicNotice +from api.v1.modules.a76.general_catalogs.electronic_notices.models import ( + ElectronicNotice, +) from api.v1.modules.a76.general_catalogs.equivalencies.models import Equivalency from api.v1.modules.a76.general_catalogs.error_catalogs.models import ErrorCatalog from api.v1.modules.a76.general_catalogs.fda_catalog.models import FDACatalog from api.v1.modules.a76.general_catalogs.inpc.models import INPC from api.v1.modules.a76.general_catalogs.legends.models import Legend -from api.v1.modules.a76.general_catalogs.multi_currency_types.models import MultiCurrencyType +from api.v1.modules.a76.general_catalogs.multi_currency_types.models import ( + MultiCurrencyType, +) from api.v1.modules.a76.general_catalogs.packages.models import Package from api.v1.modules.a76.general_catalogs.ports.models import Port from api.v1.modules.a76.general_catalogs.prevalidators.models import Prevalidator from api.v1.modules.a76.general_catalogs.seal.models import Seal from api.v1.modules.a76.general_catalogs.signatures.models import Signature -from api.v1.modules.a76.general_catalogs.fractions.tariff_fractions.models import TariffFraction +from api.v1.modules.a76.general_catalogs.fractions.tariff_fractions.models import ( + TariffFraction, +) from api.v1.modules.a76.general_catalogs.unit_conversions.models import UnitConversion -from api.v1.modules.a76.general_catalogs.fractions.us_tariff_fractions.models import USTariffFraction +from api.v1.modules.a76.general_catalogs.fractions.us_tariff_fractions.models import ( + USTariffFraction, +) + # Registrar Listeners de Auditoría @app.on_event("startup") def register_audit(): - register_audit_listeners([ - # Core Transactions - Pedimentos, - InvoiceHeader, - InvoiceSalesDetails, - Item, - - # Sidebar Core Modules - ClientProvider, - CustomsBroker, - Part, - Company, - - # Reference Data - Country, - CurrencyType, - CustomsSection, - CustomsWarehouse, - Incoterm, - InvoiceType, - MaterialType, - PaymentMethod, - PedimentoCode, - RegimenPedimento, - Sector, - State, - TransportMode, - TransportType, - ValuationMethod, - UnitOfMeasure, - ExchangeRate, - Identifier, - Class, - ClassificationConcept, - Concept, - CustomsBrokerConcept, - DepreciationCatalog, - Doda, - ElectronicNotice, - Equivalency, - ErrorCatalog, - FDACatalog, - INPC, - Legend, - MultiCurrencyType, - Package, - Port, - Prevalidator, - Seal, - Signature, - TariffFraction, - UnitConversion, - USTariffFraction - ]) + register_audit_listeners( + [ + # Core Transactions + Pedimentos, + InvoiceHeader, + InvoiceSalesDetails, + Item, + # Sidebar Core Modules + ClientProvider, + CustomsBroker, + Part, + Company, + # Reference Data + Country, + CurrencyType, + CustomsSection, + CustomsWarehouse, + Incoterm, + InvoiceType, + MaterialType, + PaymentMethod, + PedimentoCode, + RegimenPedimento, + Sector, + State, + TransportMode, + TransportType, + ValuationMethod, + UnitOfMeasure, + ExchangeRate, + Identifier, + Class, + ClassificationConcept, + Concept, + CustomsBrokerConcept, + DepreciationCatalog, + Doda, + ElectronicNotice, + Equivalency, + ErrorCatalog, + FDACatalog, + INPC, + Legend, + MultiCurrencyType, + Package, + Port, + Prevalidator, + Seal, + Signature, + TariffFraction, + UnitConversion, + USTariffFraction, + ] + ) # Crear directorio de uploads si no existe y montar archivos estáticos diff --git a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edit-dialog.svelte index 930275f5..30f7a7c0 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edit-dialog.svelte +++ b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edit-dialog.svelte @@ -122,7 +122,7 @@ id="broker_key" bind:value={formData.broker_key} placeholder="Ej: 01001" - maxlength="5" + maxlength={5} disabled={isEdit} /> @@ -133,7 +133,7 @@ id="concept" bind:value={formData.concept} placeholder="Ej: 001" - maxlength="15" + maxlength={15} disabled={isEdit} /> diff --git a/frontend/src/lib/components/dashboard/general_catalogs/identifiers/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/general_catalogs/identifiers/create-edit-dialog.svelte index 6e57fd57..73dd547f 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/identifiers/create-edit-dialog.svelte +++ b/frontend/src/lib/components/dashboard/general_catalogs/identifiers/create-edit-dialog.svelte @@ -5,6 +5,11 @@ import { Label } from '$lib/components/ui/label'; import { companyStore } from '$lib/stores/company.svelte'; import { obtenerAtajosFormularioIdentificadores } from '$lib/config/shortcuts/dashboard/general_catalogs/identifiers/edit'; + import { + createIdentifier, + updateIdentifier, + type Identifier + } from '$lib/api/dashboard/a76/general_catalogs/identifiers'; let { open = $bindable(false), 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..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,7 +26,7 @@ credentials: 'include' }); if (response.ok) { - const data = await response.json(); + const data = await response.json(); if (Array.isArray(data)) { countries = data; } else if (data.items && Array.isArray(data.items)) { @@ -80,7 +80,7 @@ - + CATALOGO DE PAISES @@ -88,7 +88,11 @@
- +
@@ -106,7 +110,9 @@ - + @@ -125,11 +131,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 +149,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 +101,7 @@
- + General @@ -216,5 +165,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/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
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..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 @@ -83,7 +83,7 @@ - + CATALOGOS DE UNIDADES DE MEDIDA @@ -91,7 +91,11 @@
- +
@@ -109,7 +113,9 @@ - + @@ -150,9 +156,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 @@
- - + + diff --git a/frontend/src/lib/components/dashboard/reference_data/incoterms/data-table.svelte b/frontend/src/lib/components/dashboard/reference_data/incoterms/data-table.svelte index 4c448e3d..3d5b2a66 100644 --- a/frontend/src/lib/components/dashboard/reference_data/incoterms/data-table.svelte +++ b/frontend/src/lib/components/dashboard/reference_data/incoterms/data-table.svelte @@ -1,123 +1,106 @@ -
-
- - - {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} - - {#each headerGroup.headers as header (header.id)} - - {#if !header.isPlaceholder} - - {/if} - - {/each} - - {/each} - - - {#each table.getRowModel().rows as row (row.id)} - - {#each row.getVisibleCells() as cell (cell.id)} - +
+ + + {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} + + {#each headerGroup.headers as header (header.id)} + + {#if !header.isPlaceholder} - - {/each} - - {:else} - - - No hay resultados. + {/if} + + {/each} + + {/each} + + + {#each table.getRowModel().rows as row (row.id)} + + {#each row.getVisibleCells() as cell (cell.id)} + + - - {/each} - - - {#if hasMore} - - -
- {#if loading} -
-
- Cargando más... -
- {:else} -
- Desplázate para cargar más -
- {/if} -
-
-
- {/if} -
-
+ {/each} + + {:else} + + + No hay resultados. + + + {/each} + + +
+ +
+
+ Total: {totalItems} registros +
+
+ +
diff --git a/frontend/src/lib/stores/company.svelte.ts b/frontend/src/lib/stores/company.svelte.ts index b45a6df3..ddcbf4b9 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,20 @@ 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' + }); + } catch (error) { + console.error('Error setting active company cookie:', error); + } } // Despachar evento personalizado solo si: 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/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 }); + } +}; 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/general_catalogs/classification_concepts/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.server.ts index d5aa261b..f6619ae7 100644 --- a/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.server.ts @@ -39,7 +39,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { page_size: pageSize.toString(), ...filters }); - const response = await authenticatedFetch(`v1/a76/classification-concepts?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); + const response = await authenticatedFetch(`v1/a76/classification-concepts/?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); if (!response.ok) { return { error: 'Failed to load', classifications: { items: [], total: 0, page, page_size: pageSize, pages: 0 } }; diff --git a/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.svelte b/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.svelte index d914cb4b..ce51bb9b 100644 --- a/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.svelte +++ b/frontend/src/routes/dashboard/general_catalogs/classification_concepts/+page.svelte @@ -89,7 +89,6 @@ />
diff --git a/frontend/src/routes/dashboard/general_catalogs/concepts/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/concepts/+page.server.ts index ad8d40cc..2ff02a9e 100644 --- a/frontend/src/routes/dashboard/general_catalogs/concepts/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/concepts/+page.server.ts @@ -59,7 +59,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { }); const response = await authenticatedFetch( - `v1/a76/concepts?${queryParams.toString()}`, + `v1/a76/concepts/?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch diff --git a/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.server.ts index 56f48a8d..e9bb5588 100644 --- a/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.server.ts @@ -2,20 +2,25 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { - return { error: 'No authenticated', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 }, activeCompanyId: null }; + return { error: 'No authenticated', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; } try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { - return { error: 'No company selected', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 }, activeCompanyId: null }; + return { error: 'No company selected', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; } const filters: Record = {}; @@ -28,22 +33,22 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); - const response = await authenticatedFetch(`v1/a76/customs-broker-concepts?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); + const response = await authenticatedFetch(`v1/a76/customs-broker-concepts/?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); if (!response.ok) { - return { error: 'Failed to load', concepts: { items: [], total: 0, page, page_size: pageSize, pages: 0 }, activeCompanyId: companyId }; + return { error: 'Failed to load', concepts: { items: [], total: 0, page, page_size: pageSize, pages: 0 } }; } const data = await response.json(); // Calculate pages if not provided by API const pages = data.pages || Math.ceil(data.total / pageSize); - return { concepts: { ...data, pages }, activeCompanyId: parseInt(companyId) }; + return { concepts: { ...data, pages } }; } catch (error) { console.error('Error loading customs broker concepts:', error); - return { error: 'Error loading', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 }, activeCompanyId: null }; + return { error: 'Error loading', concepts: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; } }; diff --git a/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.svelte b/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.svelte index 4070f937..0f19a0c1 100644 --- a/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.svelte +++ b/frontend/src/routes/dashboard/general_catalogs/customs_broker_concepts/+page.svelte @@ -10,8 +10,11 @@ import { browser } from '$app/environment'; import { useShortcuts } from '$lib/hooks/use-shortcuts'; import { obtenerAtajosListaConceptosAA } from '$lib/config/shortcuts/dashboard/general_catalogs/customs_broker_concepts/list'; + import { companyStore } from '$lib/stores/company.svelte'; let { data } = $props(); + + const activeCompanyId = $derived(companyStore.activeCompany?.id); let dialogOpen = $state(false); // Atajos @@ -92,9 +95,11 @@ />
- + {#if activeCompanyId} + + {/if}
diff --git a/frontend/src/routes/dashboard/general_catalogs/doda/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/doda/+page.server.ts index 6b220633..e3c9a28f 100644 --- a/frontend/src/routes/dashboard/general_catalogs/doda/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/doda/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', dodas: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -26,7 +31,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); const response = await authenticatedFetch(`v1/a76/doda?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); diff --git a/frontend/src/routes/dashboard/general_catalogs/electronic_notices/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/electronic_notices/+page.server.ts index 5c862256..c801c44a 100644 --- a/frontend/src/routes/dashboard/general_catalogs/electronic_notices/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/electronic_notices/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', notices: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -28,7 +33,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); const response = await authenticatedFetch(`v1/a76/electronic-notices?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); diff --git a/frontend/src/routes/dashboard/general_catalogs/equivalencies/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/equivalencies/+page.server.ts index efae176a..b1b1a5c7 100644 --- a/frontend/src/routes/dashboard/general_catalogs/equivalencies/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/equivalencies/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', equivalencies: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -28,7 +33,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); diff --git a/frontend/src/routes/dashboard/general_catalogs/identifiers/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/identifiers/+page.server.ts index 06db1266..38a1865f 100644 --- a/frontend/src/routes/dashboard/general_catalogs/identifiers/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/identifiers/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', identifiers: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -28,11 +33,11 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); - const response = await authenticatedFetch(`v1/a76/identifiers?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); + const response = await authenticatedFetch(`v1/a76/identifiers/?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); if (!response.ok) { return { error: 'Failed to load', identifiers: { items: [], total: 0, page, page_size: pageSize, pages: 0 } }; diff --git a/frontend/src/routes/dashboard/general_catalogs/inpc/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/inpc/+page.server.ts index f85f60f6..97c8b44a 100644 --- a/frontend/src/routes/dashboard/general_catalogs/inpc/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/inpc/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', inpc: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -28,7 +33,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); diff --git a/frontend/src/routes/dashboard/general_catalogs/packages/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/packages/+page.server.ts index 5ca0c933..1d3f1082 100644 --- a/frontend/src/routes/dashboard/general_catalogs/packages/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/packages/+page.server.ts @@ -59,7 +59,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { }); const response = await authenticatedFetch( - `v1/a76/packages?${queryParams.toString()}`, + `v1/a76/packages/?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch diff --git a/frontend/src/routes/dashboard/general_catalogs/ports/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/ports/+page.server.ts index 3f8e57dd..917a60db 100644 --- a/frontend/src/routes/dashboard/general_catalogs/ports/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/ports/+page.server.ts @@ -2,7 +2,8 @@ import { getServerApiUrl, getAuthTokens } from '$lib/server/api'; import type { PageServerLoad } from './$types'; import { redirect } from '@sveltejs/kit'; -export const load: PageServerLoad = async ({ cookies, fetch, url }) => { +export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { throw redirect(302, '/login'); @@ -10,7 +11,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url }) => { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('page_size')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { @@ -27,7 +33,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url }) => { const query = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId + company_id: companyId.toString() }); const endpoint = `${apiUrl}v1/a76/ports?${query.toString()}`; diff --git a/frontend/src/routes/dashboard/general_catalogs/prevalidators/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/prevalidators/+page.server.ts index 7e18fd83..0f2da684 100644 --- a/frontend/src/routes/dashboard/general_catalogs/prevalidators/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/prevalidators/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', prevalidators: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -28,7 +33,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), - company_id: companyId, + company_id: companyId.toString(), ...filters }); const response = await authenticatedFetch(`v1/a76/prevalidators?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); diff --git a/frontend/src/routes/dashboard/general_catalogs/signatures/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/signatures/+page.server.ts index 3a18dde6..35e6c600 100644 --- a/frontend/src/routes/dashboard/general_catalogs/signatures/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/signatures/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -12,7 +12,12 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { try { const page = Number(url.searchParams.get('page')) || 1; const pageSize = Number(url.searchParams.get('pageSize')) || 50; - const companyId = url.searchParams.get('company_id') || cookies.get('active_company_id'); + + // Obtener company_id de la cookie o usar el primero disponible + const cookieCompanyId = cookies.get('active_company_id'); + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { error: 'No company selected', signatures: { items: [], total: 0, page: 1, page_size: 50, pages: 0 } }; @@ -23,7 +28,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { if (code) filters.code = code; - const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), company_id: companyId, ...filters }); + const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), company_id: companyId.toString(), ...filters }); const response = await authenticatedFetch(`v1/a76/signatures?${queryParams.toString()}`, { method: 'GET' }, cookies, fetch); if (!response.ok) { diff --git a/frontend/src/routes/dashboard/general_catalogs/unit_conversions/+page.server.ts b/frontend/src/routes/dashboard/general_catalogs/unit_conversions/+page.server.ts index 30053552..92468805 100644 --- a/frontend/src/routes/dashboard/general_catalogs/unit_conversions/+page.server.ts +++ b/frontend/src/routes/dashboard/general_catalogs/unit_conversions/+page.server.ts @@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types'; import { getAuthTokens, authenticatedFetch } from '$lib/server/api'; export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { - await parent(); + const parentData = await parent(); const { accessToken } = getAuthTokens(cookies); if (!accessToken) { @@ -17,9 +17,11 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { const pageSize = Number(url.searchParams.get('pageSize')) || 50; const filters: Record = {}; - // Obtener company_id + // Obtener company_id de la cookie o usar el primero disponible const cookieCompanyId = cookies.get('active_company_id'); - const companyId = cookieCompanyId ? parseInt(cookieCompanyId) : undefined; + const companyId = cookieCompanyId + ? parseInt(cookieCompanyId) + : parentData.companies?.[0]?.id; if (!companyId) { return { 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 1e1d88b1..506ec342 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 @@ -314,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/src/routes/dashboard/invoices/items/presets/+page.svelte b/frontend/src/routes/dashboard/invoices/items/presets/+page.svelte index d9192f2e..41c8a056 100644 --- a/frontend/src/routes/dashboard/invoices/items/presets/+page.svelte +++ b/frontend/src/routes/dashboard/invoices/items/presets/+page.svelte @@ -496,7 +496,7 @@ onclick={() => handleDeleteItem(i)} class="h-8 w-8 text-zinc-500 hover:text-destructive" > - +
diff --git a/frontend/src/routes/dashboard/reference_data/incoterms/+page.server.ts b/frontend/src/routes/dashboard/reference_data/incoterms/+page.server.ts index bb15f72e..776fe196 100644 --- a/frontend/src/routes/dashboard/reference_data/incoterms/+page.server.ts +++ b/frontend/src/routes/dashboard/reference_data/incoterms/+page.server.ts @@ -24,7 +24,7 @@ export const load: PageServerLoad = async ({ cookies, fetch, url, parent }) => { // Usar authenticatedFetch para manejar automáticamente el refresh de tokens const response = await authenticatedFetch( - `v1/public/reference_data/incoterms?page=${page}&page_size=${pageSize}`, + `v1/public/reference_data/incoterms/?page=${page}&page_size=${pageSize}`, {}, cookies, fetch diff --git a/frontend/src/routes/dashboard/reference_data/incoterms/+page.svelte b/frontend/src/routes/dashboard/reference_data/incoterms/+page.svelte index a1bd8c0a..9a1b417c 100644 --- a/frontend/src/routes/dashboard/reference_data/incoterms/+page.svelte +++ b/frontend/src/routes/dashboard/reference_data/incoterms/+page.svelte @@ -2,7 +2,7 @@ import { page } from '$app/stores'; import { goto } from '$app/navigation'; import { browser } from '$app/environment'; - import { createColumns } from '$lib/components/dashboard/reference_data/incoterms/columns.js'; + import { createColumns } from '$lib/components/dashboard/reference_data/incoterms/columns'; import DataTable from '$lib/components/dashboard/reference_data/incoterms/data-table.svelte'; import CreateEditDialog from '$lib/components/dashboard/reference_data/incoterms/create-edit-dialog.svelte'; import { Button } from '$lib/components/ui/button'; @@ -59,11 +59,7 @@

Catálogo de Incoterms

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