From b9066880b0ea7270e3df8ccf65c296ed019cbb32 Mon Sep 17 00:00:00 2001
From: Kevin_Ramirez
Date: Fri, 2 Jan 2026 09:17:32 -0600
Subject: [PATCH 1/6] Se arreglo la actualizacion de clientes y proveedores,
ademas de integrarlo en una misma ruta URL
---
.../a76/clients_and_providers/routes.py | 21 +-
.../api/dashboard/a76/clients-providers.ts | 21 +-
.../data-table-actions.svelte | 173 ++++---
.../clients_and_providers/+page.svelte | 2 +-
.../edit/[[id]]/+page.svelte | 363 +++++++++++++++
.../clients_and_providers/new/+page.svelte | 438 ------------------
6 files changed, 482 insertions(+), 536 deletions(-)
create mode 100644 frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte
delete mode 100644 frontend/src/routes/dashboard/clients_and_providers/new/+page.svelte
diff --git a/backend/api/v1/modules/a76/clients_and_providers/routes.py b/backend/api/v1/modules/a76/clients_and_providers/routes.py
index 970b71ad..e1db85d7 100644
--- a/backend/api/v1/modules/a76/clients_and_providers/routes.py
+++ b/backend/api/v1/modules/a76/clients_and_providers/routes.py
@@ -61,7 +61,6 @@ async def get_clients_and_providers(
"page_size": limit,
}
-
@router.get("/{client_id}/basic", response_model=ClientProviderBasicDTO)
async def get_clients_and_providers_basic_info(
client_id: int,
@@ -111,6 +110,26 @@ async def update_client_provider(
return client
+@router.get("/{client_id}", response_model=ClientProviderResponseDTO)
+async def get_client_provider_detail(
+ client_id: int,
+ company_id: int = Query(..., description="Company ID"),
+ db: Session = Depends(get_core_db),
+ current_user: dict = Depends(get_current_user),
+):
+ """
+ Obtener un cliente/proveedor completo por ID.
+ Esta es la ruta que tu formulario necesita para cargar los datos.
+ """
+ tenant_id = validate_access_to_resource(db, company_id, current_user)
+
+ # Usamos el servicio para buscar por ID
+ client = ClientProviderService.get_by_id(db, client_id, tenant_id, company_id)
+
+ if not client:
+ raise HTTPException(status_code=404, detail="Client/Provider not found")
+
+ return client
@router.delete("/{client_id}", response_model=bool)
async def delete_client_provider(
diff --git a/frontend/src/lib/api/dashboard/a76/clients-providers.ts b/frontend/src/lib/api/dashboard/a76/clients-providers.ts
index 26d31d69..292e9844 100644
--- a/frontend/src/lib/api/dashboard/a76/clients-providers.ts
+++ b/frontend/src/lib/api/dashboard/a76/clients-providers.ts
@@ -5,14 +5,17 @@
import { api } from '$lib/api';
export interface ClientProviderAddress {
- id?: number;
- street?: string | null;
- neighborhood?: string | null;
- city?: string | null;
- state?: string | null;
- country?: string | null;
- zip_code?: string | null;
- client_id?: number;
+ id?: number;
+ streets?: string | null;
+ neighborhood?: string | null;
+ city?: string | null;
+ state?: string | null;
+ country?: string | null;
+ zip_code?: string | null;
+ client_id?: number;
+ interior_number?: string | null;
+ exterior_number?: string | null;
+ municipality?: string | null;
}
export interface ClientProviderPrograms {
@@ -25,7 +28,7 @@ export interface ClientProviderPrograms {
export interface ClientProvider {
id: number;
rfc: string;
- name: string;
+ name: string;
curp?: string | null;
residence_country?: string | null;
domicile_fiscal?: string | null;
diff --git a/frontend/src/lib/components/dashboard/clients_and_providers/data-table-actions.svelte b/frontend/src/lib/components/dashboard/clients_and_providers/data-table-actions.svelte
index 888b9488..980c6749 100644
--- a/frontend/src/lib/components/dashboard/clients_and_providers/data-table-actions.svelte
+++ b/frontend/src/lib/components/dashboard/clients_and_providers/data-table-actions.svelte
@@ -1,103 +1,102 @@
-
- {#snippet child({ props })}
-
- {/snippet}
-
-
-
- Acciones
-
- Copiar ID
-
-
- Copiar RFC
-
-
-
- Ver detalles
- Editar
-
- {isToggling ? 'Cambiando...' : item.is_active === true ? 'Desactivar' : 'Activar'}
-
-
- Eliminar
-
+
+ {#snippet child({ props })}
+
+ {/snippet}
+
+
+
+ Acciones
+
+ Copiar ID
+
+
+ Copiar RFC
+
+
+
+ Ver detalles
+
+ goto(`/dashboard/clients_and_providers/edit/${item.id}`)}>
+ Editar
+
+
+ {isToggling ? 'Cambiando...' : item.is_active === true ? 'Desactivar' : 'Activar'}
+
+
+ Eliminar
+
-
-
-
+
\ No newline at end of file
diff --git a/frontend/src/routes/dashboard/clients_and_providers/+page.svelte b/frontend/src/routes/dashboard/clients_and_providers/+page.svelte
index ca02a3f0..7d438230 100644
--- a/frontend/src/routes/dashboard/clients_and_providers/+page.svelte
+++ b/frontend/src/routes/dashboard/clients_and_providers/+page.svelte
@@ -195,7 +195,7 @@
Gestiona el catálogo de clientes y proveedores de tu empresa
-