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

- 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

- -
-
- - -
- -
- - -
-
-
-
-
-
-
- - -
- - - -
- - -
From d5d35aa23d72b956713862a284f52633fd846eec Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Fri, 2 Jan 2026 09:31:22 -0600 Subject: [PATCH 2/6] s --- .../clients_and_providers/data-table-actions.svelte | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 980c6749..03550b05 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 @@ -3,12 +3,11 @@ import { Button } from "$lib/components/ui/button/index.js"; import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js"; import type { ClientProvider } from "./columns.js"; - // import CreateEditDialog from "./create-edit-dialog.svelte"; // <-- Ya no lo necesitas aquí import DetailsDialog from "./details-dialog.svelte"; import DeleteDialog from "./delete-dialog.svelte"; import { clientsProvidersApi } from "$lib/api/dashboard/a76/clients-providers"; import { companyStore } from "$lib/stores/company.svelte"; - import { goto } from "$app/navigation"; // <-- Importación importante + import { goto } from "$app/navigation"; let { item, @@ -19,7 +18,6 @@ } = $props(); let showDetailsDialog = $state(false); - // let showEditDialog = $state(false); // <-- Eliminado let showDeleteDialog = $state(false); let isToggling = $state(false); @@ -35,8 +33,6 @@ showDetailsDialog = true; } - // function handleEdit() { showEditDialog = true; } // <-- Eliminado - function handleDelete() { showDeleteDialog = true; } From f935bfb8acbef5df06cc9b3655d6f796239df0ad Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Fri, 2 Jan 2026 11:05:50 -0600 Subject: [PATCH 3/6] Se eliminaron archivos inecesarios y se puso nombre a la tabla de acciones en catalogos generales --- .../dashboard/customs_brokers/columns.ts | 1 + .../general_catalogs/doda/columns.ts | 1 + .../electronic_notices/columns.ts | 2 + .../general_catalogs/equivalencies/columns.ts | 2 + .../general_catalogs/identifiers/columns.ts | 2 + .../general_catalogs/inpc/columns.ts | 1 + .../general_catalogs/prevalidators/columns.ts | 2 + .../unit_conversions/columns.ts | 2 + .../units_of_measure/american/columns.ts | 1 + .../units_of_measure/customs/columns.ts | 1 + .../units_of_measure/oma/columns.ts | 1 + .../dashboard/identifiers/columns.ts | 1 + .../lib/components/dashboard/seal/columns.ts | 41 ++++--- .../dashboard/units_of_measure/ace/columns.ts | 27 ----- .../ace/create-edit-dialog.svelte | 110 ----------------- .../ace/data-table-actions.svelte | 79 ------------ .../units_of_measure/ace/data-table.svelte | 106 ---------------- .../units_of_measure/american/columns.ts | 27 ----- .../american/create-edit-dialog.svelte | 110 ----------------- .../american/data-table-actions.svelte | 79 ------------ .../units_of_measure/customs/columns.ts | 32 ----- .../customs/create-edit-dialog.svelte | 113 ------------------ .../customs/data-table-actions.svelte | 79 ------------ .../customs/data-table.svelte | 106 ---------------- .../units_of_measure/general/columns.ts | 32 ----- .../general/create-edit-dialog.svelte | 113 ------------------ .../general/data-table-actions.svelte | 79 ------------ .../general/data-table.svelte | 106 ---------------- .../dashboard/units_of_measure/oma/columns.ts | 27 ----- .../oma/create-edit-dialog.svelte | 110 ----------------- .../oma/data-table-actions.svelte | 79 ------------ 31 files changed, 37 insertions(+), 1435 deletions(-) delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/ace/columns.ts delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/ace/create-edit-dialog.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/ace/data-table-actions.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/ace/data-table.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/american/columns.ts delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/american/create-edit-dialog.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/american/data-table-actions.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/customs/columns.ts delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/customs/create-edit-dialog.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/customs/data-table-actions.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/customs/data-table.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/general/columns.ts delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/general/create-edit-dialog.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/general/data-table-actions.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/general/data-table.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/oma/columns.ts delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/oma/create-edit-dialog.svelte delete mode 100644 frontend/src/lib/components/dashboard/units_of_measure/oma/data-table-actions.svelte diff --git a/frontend/src/lib/components/dashboard/customs_brokers/columns.ts b/frontend/src/lib/components/dashboard/customs_brokers/columns.ts index 993c6763..4f099fd3 100644 --- a/frontend/src/lib/components/dashboard/customs_brokers/columns.ts +++ b/frontend/src/lib/components/dashboard/customs_brokers/columns.ts @@ -118,6 +118,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[ }, { id: "actions", + header: "Acciones", cell: ({ row }) => { return renderComponent(DataTableActions, { broker: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/doda/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/doda/columns.ts index e9751ef3..946aed85 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/doda/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/doda/columns.ts @@ -32,6 +32,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { }, { id: 'actions', + Headers: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/electronic_notices/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/electronic_notices/columns.ts index 3a07231a..3ebec0cb 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/electronic_notices/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/electronic_notices/columns.ts @@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/table-core'; import type { ElectronicNotice } from '$lib/api/dashboard/a76/general_catalogs/electronic-notices'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; +import { Head } from '$lib/components/ui/table'; export function createColumns(onSuccess?: () => void): ColumnDef[] { return [ @@ -32,6 +33,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/equivalencies/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/equivalencies/columns.ts index 704f2210..f4a92c75 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/equivalencies/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/equivalencies/columns.ts @@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/table-core'; import type { Equivalency } from '$lib/api/dashboard/a76/general_catalogs/equivalencies'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; +import { Header } from '$lib/components/ui/alert-dialog'; export function createColumns(onSuccess?: () => void): ColumnDef[] { return [ @@ -22,6 +23,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] }, { id: 'actions', + Header: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/identifiers/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/identifiers/columns.ts index 8247aeb7..6aa1997c 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/identifiers/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/identifiers/columns.ts @@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/table-core'; import type { Identifier } from '$lib/api/dashboard/a76/general_catalogs/identifiers'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; +import { Header } from '$lib/components/ui/alert-dialog'; export function createColumns(onSuccess?: () => void): ColumnDef[] { return [ @@ -27,6 +28,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { }, { id: 'actions', + Header: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/inpc/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/inpc/columns.ts index 34d58e58..c6828b12 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/inpc/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/inpc/columns.ts @@ -22,6 +22,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { }, { id: 'actions', + header: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/prevalidators/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/prevalidators/columns.ts index 1c8b2ab5..404a0752 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/prevalidators/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/prevalidators/columns.ts @@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/table-core'; import type { Prevalidator } from '$lib/api/dashboard/a76/general_catalogs/prevalidators'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; +import { Header } from '$lib/components/ui/alert-dialog'; export function createColumns(onSuccess?: () => void): ColumnDef[] { return [ @@ -27,6 +28,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] }, { id: 'actions', + Header: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/unit_conversions/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/unit_conversions/columns.ts index a251e9fa..34d970a0 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/unit_conversions/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/unit_conversions/columns.ts @@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/table-core'; import type { UnitConversion } from '$lib/api/dashboard/a76/general_catalogs/unit-conversions'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; +import { Header } from '$lib/components/ui/alert-dialog'; export function createColumns(onSuccess?: () => void): ColumnDef[] { return [ @@ -19,6 +20,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef }, { id: 'actions', + header: 'Acciones', cell: ({ row }) => renderComponent(DataTableActions, { conversion: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/american/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/american/columns.ts index d9f1124e..f9d51db1 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/american/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/american/columns.ts @@ -15,6 +15,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef renderComponent(DataTableActions, { unit: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/customs/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/customs/columns.ts index 5fcde59a..6f5d2136 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/customs/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/customs/columns.ts @@ -19,6 +19,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef renderComponent(DataTableActions, { unit: row.original, diff --git a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/oma/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/oma/columns.ts index b3f5c0b8..a24ccbea 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/oma/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/units_of_measure/oma/columns.ts @@ -15,6 +15,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef renderComponent(DataTableActions, { unit: row.original, diff --git a/frontend/src/lib/components/dashboard/identifiers/columns.ts b/frontend/src/lib/components/dashboard/identifiers/columns.ts index d1feb995..c1b371ed 100644 --- a/frontend/src/lib/components/dashboard/identifiers/columns.ts +++ b/frontend/src/lib/components/dashboard/identifiers/columns.ts @@ -26,6 +26,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { }, { id: 'actions', + header: 'Acciones', cell: ({ row }) => { return renderComponent(DataTableActions, { item: row.original, diff --git a/frontend/src/lib/components/dashboard/seal/columns.ts b/frontend/src/lib/components/dashboard/seal/columns.ts index dbe33b26..bf68d94e 100644 --- a/frontend/src/lib/components/dashboard/seal/columns.ts +++ b/frontend/src/lib/components/dashboard/seal/columns.ts @@ -1,27 +1,26 @@ -/** - * Column definitions for Seal table - */ import type { ColumnDef } from '@tanstack/table-core'; import type { Seal } from '$lib/api/dashboard/a76/general_catalogs/seal'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'seal', - header: 'Sello', - cell: ({ row }) => row.original.seal - }, - { - id: 'actions', - header: 'Acciones', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} + return [ + + { + accessorKey: 'seal', + header: 'Sello', + cell: ({ row }) => row.original.seal, + }, + { + id: 'actions', + header: 'Acciones', + meta: { + class: 'w-[100px] text-right' + }, + cell: ({ row }) => renderComponent(DataTableActions, { + item: row.original, + onSuccess + }) + } + ]; +} \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/units_of_measure/ace/columns.ts b/frontend/src/lib/components/dashboard/units_of_measure/ace/columns.ts deleted file mode 100644 index d88fb3a2..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/ace/columns.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { UnitOfMeasureACE } from '$lib/api/dashboard/a76/general_catalogs/units-of-measure'; -import type { ColumnDef } from '@tanstack/table-core'; -import { renderComponent } from '$lib/components/ui/data-table'; -import DataTableActions from './data-table-actions.svelte'; - -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'code', - header: 'Código', - }, - { - accessorKey: 'description', - header: 'Descripción', - cell: ({ row }) => row.original.description || '-' - }, - { - id: 'actions', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} diff --git a/frontend/src/lib/components/dashboard/units_of_measure/ace/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/units_of_measure/ace/create-edit-dialog.svelte deleted file mode 100644 index f0bd92f2..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/ace/create-edit-dialog.svelte +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - {title} - - -
- {#if error} -
{error}
- {/if} - -
- - -
- -
- - -
-
- - - - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table-actions.svelte b/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table-actions.svelte deleted file mode 100644 index 49e2eb59..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table-actions.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {#snippet child({ props })} - - {/snippet} - - - Acciones - dialogOpen = true}> - - Editar - - - {#if loading} - - {:else} - - {/if} - Eliminar - - - - - diff --git a/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table.svelte b/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table.svelte deleted file mode 100644 index ea8886c5..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/ace/data-table.svelte +++ /dev/null @@ -1,106 +0,0 @@ - - -
- - - {#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} - - {:else} - - - No hay resultados. - - - {/each} - - -
- -
-
- Total: {totalItems} -
-
- - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/american/columns.ts b/frontend/src/lib/components/dashboard/units_of_measure/american/columns.ts deleted file mode 100644 index e3a4bff7..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/american/columns.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { UnitOfMeasureAmerican } from '$lib/api/dashboard/a76/general_catalogs/units-of-measure'; -import type { ColumnDef } from '@tanstack/table-core'; -import { renderComponent } from '$lib/components/ui/data-table'; -import DataTableActions from './data-table-actions.svelte'; - -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'code', - header: 'Código', - }, - { - accessorKey: 'description', - header: 'Descripción', - cell: ({ row }) => row.original.description || '-' - }, - { - id: 'actions', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} diff --git a/frontend/src/lib/components/dashboard/units_of_measure/american/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/units_of_measure/american/create-edit-dialog.svelte deleted file mode 100644 index 8ef1d6fb..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/american/create-edit-dialog.svelte +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - {title} - - -
- {#if error} -
{error}
- {/if} - -
- - -
- -
- - -
-
- - - - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/american/data-table-actions.svelte b/frontend/src/lib/components/dashboard/units_of_measure/american/data-table-actions.svelte deleted file mode 100644 index 74912f4e..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/american/data-table-actions.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {#snippet child({ props })} - - {/snippet} - - - Acciones - dialogOpen = true}> - - Editar - - - {#if loading} - - {:else} - - {/if} - Eliminar - - - - - diff --git a/frontend/src/lib/components/dashboard/units_of_measure/customs/columns.ts b/frontend/src/lib/components/dashboard/units_of_measure/customs/columns.ts deleted file mode 100644 index db580d6b..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/customs/columns.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ColumnDef } from '@tanstack/table-core'; -import { renderComponent } from '$lib/components/ui/data-table'; -import DataTableActions from './data-table-actions.svelte'; - -export interface UMCustomsMex { - id: number; - code: string; - description: string | null; -} - -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'code', - header: 'Código', - }, - { - accessorKey: 'description', - header: 'Descripción', - cell: ({ row }) => row.original.description || '-' - }, - { - id: 'actions', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} diff --git a/frontend/src/lib/components/dashboard/units_of_measure/customs/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/units_of_measure/customs/create-edit-dialog.svelte deleted file mode 100644 index 46319d69..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/customs/create-edit-dialog.svelte +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - {title} - - -
- {#if error} -
{error}
- {/if} - -
- - -
- -
- - -
-
- -
- - -
-
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table-actions.svelte b/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table-actions.svelte deleted file mode 100644 index 0e845518..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table-actions.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {#snippet child({ props })} - - {/snippet} - - - Acciones - dialogOpen = true}> - - Editar - - - {#if loading} - - {:else} - - {/if} - Eliminar - - - - - diff --git a/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table.svelte b/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table.svelte deleted file mode 100644 index ea8886c5..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/customs/data-table.svelte +++ /dev/null @@ -1,106 +0,0 @@ - - -
- - - {#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} - - {:else} - - - No hay resultados. - - - {/each} - - -
- -
-
- Total: {totalItems} -
-
- - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/general/columns.ts b/frontend/src/lib/components/dashboard/units_of_measure/general/columns.ts deleted file mode 100644 index 710cb488..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/general/columns.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ColumnDef } from '@tanstack/table-core'; -import { renderComponent } from '$lib/components/ui/data-table'; -import DataTableActions from './data-table-actions.svelte'; - -export interface UnitMeasure { - id: number; - code: string; - description: string | null; -} - -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'code', - header: 'Código', - }, - { - accessorKey: 'description', - header: 'Descripción', - cell: ({ row }) => row.original.description || '-' - }, - { - id: 'actions', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} diff --git a/frontend/src/lib/components/dashboard/units_of_measure/general/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/units_of_measure/general/create-edit-dialog.svelte deleted file mode 100644 index ffbb4054..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/general/create-edit-dialog.svelte +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - {title} - - -
- {#if error} -
{error}
- {/if} - -
- - -
- -
- - -
-
- -
- - -
-
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/general/data-table-actions.svelte b/frontend/src/lib/components/dashboard/units_of_measure/general/data-table-actions.svelte deleted file mode 100644 index 66641d66..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/general/data-table-actions.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {#snippet child({ props })} - - {/snippet} - - - Acciones - dialogOpen = true}> - - Editar - - - {#if loading} - - {:else} - - {/if} - Eliminar - - - - - diff --git a/frontend/src/lib/components/dashboard/units_of_measure/general/data-table.svelte b/frontend/src/lib/components/dashboard/units_of_measure/general/data-table.svelte deleted file mode 100644 index ea8886c5..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/general/data-table.svelte +++ /dev/null @@ -1,106 +0,0 @@ - - -
- - - {#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} - - {:else} - - - No hay resultados. - - - {/each} - - -
- -
-
- Total: {totalItems} -
-
- - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/oma/columns.ts b/frontend/src/lib/components/dashboard/units_of_measure/oma/columns.ts deleted file mode 100644 index 4b28f780..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/oma/columns.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { UnitOfMeasureOMA } from '$lib/api/dashboard/a76/general_catalogs/units-of-measure'; -import type { ColumnDef } from '@tanstack/table-core'; -import { renderComponent } from '$lib/components/ui/data-table'; -import DataTableActions from './data-table-actions.svelte'; - -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: 'code', - header: 'Código', - }, - { - accessorKey: 'description', - header: 'Descripción', - cell: ({ row }) => row.original.description || '-' - }, - { - id: 'actions', - cell: ({ row }) => { - return renderComponent(DataTableActions, { - item: row.original, - onSuccess - }); - } - } - ]; -} diff --git a/frontend/src/lib/components/dashboard/units_of_measure/oma/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/units_of_measure/oma/create-edit-dialog.svelte deleted file mode 100644 index 2917b9fa..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/oma/create-edit-dialog.svelte +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - {title} - - -
- {#if error} -
{error}
- {/if} - -
- - -
- -
- - -
-
- - - - -
-
diff --git a/frontend/src/lib/components/dashboard/units_of_measure/oma/data-table-actions.svelte b/frontend/src/lib/components/dashboard/units_of_measure/oma/data-table-actions.svelte deleted file mode 100644 index 7627fe6d..00000000 --- a/frontend/src/lib/components/dashboard/units_of_measure/oma/data-table-actions.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {#snippet child({ props })} - - {/snippet} - - - Acciones - dialogOpen = true}> - - Editar - - - {#if loading} - - {:else} - - {/if} - Eliminar - - - - - From d0603348e97432aff8416b972e8e8ad797ed9428 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Fri, 2 Jan 2026 12:03:07 -0600 Subject: [PATCH 4/6] Se elimino un componene inecesario --- .../src/routes/dashboard/clients_and_providers/+page.svelte | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/src/routes/dashboard/clients_and_providers/+page.svelte b/frontend/src/routes/dashboard/clients_and_providers/+page.svelte index 7d438230..a2401c3e 100644 --- a/frontend/src/routes/dashboard/clients_and_providers/+page.svelte +++ b/frontend/src/routes/dashboard/clients_and_providers/+page.svelte @@ -3,7 +3,6 @@ import { clientsProvidersApi, type ClientProvider } from '$lib/api/dashboard/a76/clients-providers'; import DataTable from '$lib/components/dashboard/clients_and_providers/data-table.svelte'; import { createColumns } from '$lib/components/dashboard/clients_and_providers/columns.js'; - import CreateEditDialog from '$lib/components/dashboard/clients_and_providers/create-edit-dialog.svelte'; import * as Card from '$lib/components/ui/card'; import { Button } from '$lib/components/ui/button'; import * as Select from '$lib/components/ui/select'; @@ -254,6 +253,3 @@ - - - From ec8f6606ad094feef62a52ee63c6b039d919ee79 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Tue, 6 Jan 2026 12:04:04 -0600 Subject: [PATCH 5/6] Se corrigio y expandio los datos de clientes y proveedores --- .../modules/a76/clients_and_providers/dto.py | 10 +- .../api/dashboard/a76/clients-providers.ts | 220 ++---- .../clients_and_providers/columns.ts | 202 +++--- .../edit/[[id]]/+page.svelte | 638 ++++++++++-------- 4 files changed, 535 insertions(+), 535 deletions(-) diff --git a/backend/api/v1/modules/a76/clients_and_providers/dto.py b/backend/api/v1/modules/a76/clients_and_providers/dto.py index f77df843..624c99f1 100644 --- a/backend/api/v1/modules/a76/clients_and_providers/dto.py +++ b/backend/api/v1/modules/a76/clients_and_providers/dto.py @@ -116,9 +116,7 @@ class ClientProviderCreateDTO(BaseModel): ) position: Optional[str] = Field(None, max_length=30, description="Position") incoterm: Optional[str] = Field(None, max_length=19, description="Incoterm") - is_national_provider: Optional[str] = Field( - None, max_length=2, description="Is national provider" - ) + is_national_provider: Optional[bool] = None is_active: Optional[bool] = Field(None, description="Enabled/Disabled status") # Nested DTOs @@ -159,9 +157,7 @@ class ClientProviderUpdateDTO(BaseModel): ) position: Optional[str] = Field(None, max_length=30, description="Position") incoterm: Optional[str] = Field(None, max_length=19, description="Incoterm") - is_national_provider: Optional[str] = Field( - None, max_length=2, description="Is national provider" - ) + is_national_provider: Optional[bool] = None is_active: Optional[bool] = Field(None, description="Enabled/Disabled status") # Nested DTOs @@ -193,7 +189,7 @@ class ClientProviderResponseDTO(BaseModel): responsible: Optional[str] = None position: Optional[str] = None incoterm: Optional[str] = None - is_national_provider: Optional[str] = None + is_national_provider: Optional[bool] = None is_active: Optional[bool] = None tenant_id: int company_id: int diff --git a/frontend/src/lib/api/dashboard/a76/clients-providers.ts b/frontend/src/lib/api/dashboard/a76/clients-providers.ts index 292e9844..af66c1c5 100644 --- a/frontend/src/lib/api/dashboard/a76/clients-providers.ts +++ b/frontend/src/lib/api/dashboard/a76/clients-providers.ts @@ -1,173 +1,97 @@ -/** - * API Client para Clientes y Proveedores - * Gestiona las operaciones CRUD para clientes y proveedores - */ import { api } from '$lib/api'; +// --- Interfaces para Tablas Hijas --- + export interface ClientProviderAddress { id?: number; - streets?: string | null; + streets?: string | null; + exterior_number?: string | null; + interior_number?: string | null; neighborhood?: string | null; + municipality?: 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; + postal_code?: string | null; + email?: string | null; + phone?: string | null; + contact?: string | null; } export interface ClientProviderPrograms { - id?: number; - program_code?: string | null; - authorization_date?: string | null; - client_id?: number; + id?: number; + program?: string | null; + program_number?: string | null; + secon_auth_date?: number | null; // YYYYMMDD + prosec?: number | null; + manufacturer_id?: string | null; + tax_id?: string | null; + ctpat_svi?: string | null; + is_certified_company?: string | null; } +// --- Interfaz Principal --- + export interface ClientProvider { - id: number; - rfc: string; - name: string; - curp?: string | null; - residence_country?: string | null; - domicile_fiscal?: string | null; - foreign_tax_id?: string | null; - client_or_provider?: string | null; - is_active?: boolean; - tenant_id: number; - address?: ClientProviderAddress | null; - programs?: ClientProviderPrograms | null; -} - -export interface ClientProviderBasic { - id: number; - rfc: string; - name: string; - curp?: string | null; - residence_country?: string | null; - domicile_fiscal?: string | null; - foreign_tax_id?: string | null; - client_or_provider?: string | null; - is_active?: boolean; - tenant_id: number; + id: number; + rfc: string; + name: string; + short_name?: string | null; + curp?: string | null; + client_or_provider: 'client' | 'provider' | 'both'; + + // Campos planos de la tabla principal + type_nat_foreign?: string | null; + responsible?: string | null; + position?: string | null; + + // Booleanos (Coincidiendo con la BD) + is_national_provider?: boolean | null; + is_active?: boolean; + + // Relaciones Anidadas + address?: ClientProviderAddress | null; + programs?: ClientProviderPrograms | null; } export interface ClientProviderListResponse { - items: ClientProvider[]; - total: number; - page: number; - page_size: number; + items: ClientProvider[]; + total: number; + page: number; + page_size: number; } -export interface CreateClientProviderData { - rfc: string; - name: string; - curp?: string | null; - residence_country?: string | null; - domicile_fiscal?: string | null; - foreign_tax_id?: string | null; - client_or_provider?: string | null; - is_active?: boolean; - address?: Omit | null; - programs?: Omit | null; +// DTOs de Envío (excluyendo IDs automáticos) +export interface CreateClientProviderData extends Omit { + address?: ClientProviderAddress | null; + programs?: ClientProviderPrograms | null; } -export interface UpdateClientProviderData { - rfc?: string; - name?: string; - curp?: string | null; - residence_country?: string | null; - domicile_fiscal?: string | null; - foreign_tax_id?: string | null; - client_or_provider?: string | null; - is_active?: boolean; - address?: Partial | null; - programs?: Partial | null; -} +export interface UpdateClientProviderData extends Partial {} -/** - * API para Clientes y Proveedores - */ export const clientsProvidersApi = { - /** - * Lista todos los clientes y proveedores con paginación - * @param companyId - ID de la compañía - * @param page - Número de página (por defecto 1) - * @param pageSize - Tamaño de página (por defecto 50) - * @param filters - Filtros opcionales - */ - list: (companyId: number, page = 1, pageSize = 50, filters?: Record) => { - const params = new URLSearchParams({ - company_id: companyId.toString(), - page: page.toString(), - page_size: pageSize.toString() - }); + list: (companyId: number, page = 1, pageSize = 50, filters?: Record) => { + const params = new URLSearchParams({ + company_id: companyId.toString(), + page: page.toString(), + page_size: pageSize.toString() + }); + if (filters) { + Object.entries(filters).forEach(([key, value]) => { + if (value) params.append(key, value.toString()); + }); + } + return api.get(`/v1/a76/clients-providers?${params.toString()}`); + }, + get: (id: number, companyId: number) => + api.get(`/v1/a76/clients-providers/${id}?company_id=${companyId}`), + + create: (companyId: number, data: any) => + api.post(`/v1/a76/clients-providers?company_id=${companyId}`, data), - if (filters) { - Object.entries(filters).forEach(([key, value]) => { - if (value !== undefined && value !== null && value !== '') { - params.append(key, value.toString()); - } - }); - } + update: (id: number, companyId: number, data: any) => + api.patch(`/v1/a76/clients-providers/${id}?company_id=${companyId}`, data), - return api.get( - `/v1/a76/clients-providers?${params.toString()}` - ); - }, - - /** - * Obtiene un cliente/proveedor por ID - * @param id - ID del cliente/proveedor - * @param companyId - ID de la compañía - */ - get: (id: number, companyId: number) => - api.get(`/v1/a76/clients-providers/${id}?company_id=${companyId}`), - - /** - * Obtiene información básica de un cliente/proveedor - * @param id - ID del cliente/proveedor - * @param companyId - ID de la compañía - */ - getBasic: (id: number, companyId: number) => - api.get( - `/v1/a76/clients-providers/${id}/basic?company_id=${companyId}` - ), - - /** - * Crea un nuevo cliente/proveedor - * @param companyId - ID de la compañía - * @param data - Datos del cliente/proveedor a crear - */ - create: (companyId: number, data: CreateClientProviderData) => - api.post(`/v1/a76/clients-providers?company_id=${companyId}`, data), - - /** - * Actualiza un cliente/proveedor existente - * @param id - ID del cliente/proveedor a actualizar - * @param companyId - ID de la compañía - * @param data - Datos a actualizar - */ - update: (id: number, companyId: number, data: UpdateClientProviderData) => - api.patch(`/v1/a76/clients-providers/${id}?company_id=${companyId}`, data), - - /** - * Alterna el estado activo/inactivo de un cliente/proveedor - * @param id - ID del cliente/proveedor - * @param companyId - ID de la compañía - */ - toggleStatus: (id: number, companyId: number) => - api.put( - `/v1/a76/clients-providers/${id}/toggle-status?company_id=${companyId}`, - {} - ), - - /** - * Elimina un cliente/proveedor - * @param id - ID del cliente/proveedor a eliminar - * @param companyId - ID de la compañía - */ - delete: (id: number, companyId: number) => - api.delete(`/v1/a76/clients-providers/${id}?company_id=${companyId}`) -}; + delete: (id: number, companyId: number) => + api.delete(`/v1/a76/clients-providers/${id}?company_id=${companyId}`) +}; \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts b/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts index ef8ea700..abc3af01 100644 --- a/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts +++ b/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts @@ -1,111 +1,101 @@ -import type { ColumnDef } from "@tanstack/table-core"; import { renderComponent, renderSnippet } from "$lib/components/ui/data-table/index.js"; import { createRawSnippet } from "svelte"; import DataTableActions from "./data-table-actions.svelte"; -import type { ClientProvider } from "$lib/api/dashboard/a76/clients-providers"; -export type { ClientProvider }; +export function createColumns(onSuccess) { + return [ + { + accessorKey: "id", + header: "ID", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + return { render: () => `${val}` }; + }); + return renderSnippet(snippet, { val: row.original.id }); + } + }, + { + accessorKey: "rfc", + header: "RFC", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + return { render: () => `${val}` }; + }); + return renderSnippet(snippet, { val: row.original.rfc }); + } + }, + { + accessorKey: "name", + header: "Nombre", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + return { render: () => `
${val}
` }; + }); + return renderSnippet(snippet, { val: row.original.name }); + } + }, + { + id: "country", + header: "País", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + return { render: () => `
${val || '-'}
` }; + }); + // Busca en address.country, si no existe pone null + const country = row.original.address?.country; + return renderSnippet(snippet, { val: country }); + } + }, + { + accessorKey: "client_or_provider", + header: "Tipo", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + const map = { client: 'Cliente', provider: 'Proveedor', both: 'Ambos' }; + const colors = { + client: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300', + provider: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300', + both: 'bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-300' + }; + return { + render: () => `${map[val] || val}` + }; + }); + return renderSnippet(snippet, { val: row.original.client_or_provider }); + } + }, + // --- CORRECCIÓN AQUÍ --- + { + accessorKey: "is_active", + header: "Estado", + cell: ({ row }) => { + const snippet = createRawSnippet((getData) => { + const { val } = getData(); + + // CORRECCIÓN: Usamos !!val para convertir cualquier valor positivo (true, 1) a true. + // Si val es null, undefined, false o 0, será false. + const isActive = !!val; -export function createColumns(onSuccess?: () => void): ColumnDef[] { - return [ - { - accessorKey: "id", - header: "ID", - cell: ({ row }) => { - const idSnippet = createRawSnippet<[{ id: number }]>((getId) => { - const { id } = getId(); - return { - render: () => - `${id}` - }; - }); - return renderSnippet(idSnippet, { id: row.original.id }); - } - }, - { - accessorKey: "rfc", - header: "RFC", - cell: ({ row }) => { - const rfcSnippet = createRawSnippet<[{ rfc: string }]>((getRfc) => { - const { rfc } = getRfc(); - return { - render: () => - `${rfc}` - }; - }); - return renderSnippet(rfcSnippet, { rfc: row.original.rfc }); - } - }, - { - accessorKey: "name", - header: "Nombre", - cell: ({ row }) => { - const nameSnippet = createRawSnippet<[{ name: string }]>((getName) => { - const { name } = getName(); - return { - render: () => `
${name}
` - }; - }); - return renderSnippet(nameSnippet, { name: row.original.name }); - } - }, - { - accessorKey: "client_or_provider", - header: "Tipo", - cell: ({ row }) => { - const typeSnippet = createRawSnippet<[{ type: string | null | undefined }]>((getType) => { - const { type } = getType(); - const displayType = type === 'client' ? 'Cliente' : type === 'provider' ? 'Proveedor' : type === 'both' ? 'Ambos' : 'N/A'; - const colorClass = type === 'client' ? 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300' - : type === 'provider' ? 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300' - : type === 'both' ? 'bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-300' - : 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-300'; - return { - render: () => `${displayType}` - }; - }); - return renderSnippet(typeSnippet, { type: row.original.client_or_provider }); - } - }, - { - accessorKey: "residence_country", - header: "País", - cell: ({ row }) => { - const countrySnippet = createRawSnippet<[{ country: string | null | undefined }]>((getCountry) => { - const { country } = getCountry(); - return { - render: () => `
${country || '-'}
` - }; - }); - return renderSnippet(countrySnippet, { country: row.original.residence_country }); - } - }, - { - accessorKey: "is_active", - header: "Estado", - cell: ({ row }) => { - const statusSnippet = createRawSnippet<[{ status: number | undefined }]>((getStatus) => { - const { status } = getStatus(); - const isEnabled = status === 1; - const statusText = isEnabled ? 'Activo' : 'Inactivo'; - const colorClass = isEnabled - ? 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300' - : 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300'; - return { - render: () => `${statusText}` - }; - }); - return renderSnippet(statusSnippet, { status: row.original.is_active }); - } - }, - { - id: "actions", - cell: ({ row }) => { - return renderComponent(DataTableActions, { item: row.original, onSuccess }); - } - } - ]; -} - -// Mantener compatibilidad hacia atrás -export const columns = createColumns(); + const text = isActive ? 'Activo' : 'Inactivo'; + const color = isActive + ? 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300' + : 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300'; + + return { + render: () => `${text}` + }; + }); + return renderSnippet(snippet, { val: row.original.is_active }); + } + }, + { + id: "actions", + cell: ({ row }) => renderComponent(DataTableActions, { item: row.original, onSuccess }) + } + ]; +} \ No newline at end of file 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 index bb94079f..d2953bb1 100644 --- a/frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/clients_and_providers/edit/[[id]]/+page.svelte @@ -1,363 +1,453 @@ -
+
-
-

{title}

-

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

+

{title}

+

Gestión integral del catálogo de socios comerciales.

- - - 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 error} +
+ ⚠️ {error} +
{/if} - +
{ e.preventDefault(); handleSubmit(); }} class="space-y-6"> + + + + +
+ + +
+
+ + +
+
+ + + + {typeLabels[formData.client_or_provider] || "Selecciona un tipo"} + + + Cliente + Proveedor + Ambos + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + + + {formData.type_nat_foreign === 'N' ? 'Nacional' : formData.type_nat_foreign === 'E' ? 'Extranjero' : 'Seleccione'} + + + Nacional + Extranjero + + +
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+ +

Habilitar o deshabilitar este socio comercial

+
+
+
+ +
+ +

Marcar si es un proveedor nacional

+
+
+
+
+
+ + + + + + + + + + + + +
+
+
+ +
+
+ + + {#if !isEditing} + + {/if} + + +
+
+
\ No newline at end of file From 532b8c23ace12c84dd6e622174bea270f0e6d460 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Tue, 6 Jan 2026 12:08:38 -0600 Subject: [PATCH 6/6] Se coloco nombre de la columna de acciones --- .../lib/components/dashboard/clients_and_providers/columns.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts b/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts index abc3af01..a09246ab 100644 --- a/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts +++ b/frontend/src/lib/components/dashboard/clients_and_providers/columns.ts @@ -77,8 +77,7 @@ export function createColumns(onSuccess) { const snippet = createRawSnippet((getData) => { const { val } = getData(); - // CORRECCIÓN: Usamos !!val para convertir cualquier valor positivo (true, 1) a true. - // Si val es null, undefined, false o 0, será false. + const isActive = !!val; const text = isActive ? 'Activo' : 'Inactivo'; @@ -95,6 +94,7 @@ export function createColumns(onSuccess) { }, { id: "actions", + header: "Acciones", cell: ({ row }) => renderComponent(DataTableActions, { item: row.original, onSuccess }) } ];