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

- diff --git a/frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte new file mode 100644 index 00000000..bb94079f --- /dev/null +++ b/frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte @@ -0,0 +1,363 @@ + + +
+
+ +
+

{title}

+

+ {isEditing ? "Modifica los datos del registro existente." : "Completa los datos para el nuevo registro."} +

+
+
+ + + + Información General + Los campos marcados con * son obligatorios + + + {#if loading && isEditing && !formData.name} +
+ +
+ {:else} +
+ {#if error} +
+ 🚨 {error} +
+ {/if} + +
+

Información Básica

+ +
+
+ + +
+ +
+ + + + {typeLabels[formData.client_or_provider] || "Selecciona un tipo"} + + + Cliente + Proveedor + Ambos + + +
+
+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+
+ +
+

Datos Fiscales

+
+
+ + +
+
+ + +
+
+
+ +
+

Dirección Física

+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+

Programas de Fomento

+
+
+ + +
+
+ + +
+
+
+ +
+ {/if} +
+
+
+ +
+ + + {#if !isEditing} + + {/if} + + +
\ No newline at end of file diff --git a/frontend/src/routes/dashboard/clients_and_providers/new/+page.svelte b/frontend/src/routes/dashboard/clients_and_providers/new/+page.svelte deleted file mode 100644 index 2888f15a..00000000 --- a/frontend/src/routes/dashboard/clients_and_providers/new/+page.svelte +++ /dev/null @@ -1,438 +0,0 @@ - - -
- -
- -
-

Nuevo Cliente/Proveedor

-

- Completa los datos para crear un nuevo cliente o proveedor -

-
-
- - - - - Información del Cliente/Proveedor - - Todos los campos marcados con * son obligatorios - - - -
- {#if error} -
- {error} -
- {/if} - - -
-

Información Básica

- -
-
- - -
- -
- - (formData.client_or_provider = value || "client")}> - - - - - Cliente - Proveedor - Ambos - - -
-
- -
- - -
- -
-
- - -
- -
- - -
-
-
- - -
-

Información Fiscal

- -
- - -
- -
- - -
-
- - -
-

Dirección

- -
- - -
- -
-
- - -
- -
- - -
-
- -
-
- - -
- -
- - -
-
- -
- - -
-
- - -
-

Programas

- -
-
- - -
- -
- - -
-
-
-
-
-
-
- - -
- - - -
- - -