diff --git a/frontend/src/lib/api/dashboard/a76/parts.ts b/frontend/src/lib/api/dashboard/a76/parts.ts
index 108934b2..3ae0b2a9 100644
--- a/frontend/src/lib/api/dashboard/a76/parts.ts
+++ b/frontend/src/lib/api/dashboard/a76/parts.ts
@@ -12,6 +12,7 @@ export interface Part {
part_number: string;
commercial_part_number: string | null;
part_class: string | null;
+ material_type?: string | null;
// Descripciones
description_spanish: string | null;
@@ -59,6 +60,7 @@ export interface PartCreate {
description_english?: string | null;
commercial_part_number?: string | null;
part_class?: string | null;
+ material_type?: string | null;
unit_of_measure: string;
alternate_unit_measure?: string | null;
diff --git a/frontend/src/routes/dashboard/classes/+page.svelte b/frontend/src/routes/dashboard/classes/+page.svelte
deleted file mode 100644
index 247de471..00000000
--- a/frontend/src/routes/dashboard/classes/+page.svelte
+++ /dev/null
@@ -1,346 +0,0 @@
-
-
-
-
-
-
-
Clases A76
-
- Gestiona las clases de materiales del sistema
-
-
-
-
-
-
-
-
-
-
- Filtros
- Filtra las clases por diferentes criterios
-
-
-
-
-
-
-
- {#if error}
-
-
- Error
- {error}
-
-
- {/if}
-
-
-
-
-
-
- Listado de Clases
-
- Mostrando {allItems.length} de {totalItems} registros
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte b/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte
index e14df2cc..c870f080 100644
--- a/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte
+++ b/frontend/src/routes/dashboard/general_catalogs/ports/+page.svelte
@@ -4,7 +4,7 @@
import { browser } from '$app/environment';
import { createColumns } from '$lib/components/dashboard/ports/columns';
import CreateEditDialog from '$lib/components/dashboard/ports/create-edit-dialog.svelte';
- import DataTable from '$lib/components/dashboard/units_of_measure/ace/data-table.svelte';
+ import DataTable from '$lib/components/dashboard/general_catalogs/units_of_measure/ace/data-table.svelte';
import { Button } from '$lib/components/ui/button';
import { Input } from '$lib/components/ui/input';
import { Plus } from 'lucide-svelte';
diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
index 13637b32..f78c1d18 100644
--- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
+++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
@@ -17,7 +17,7 @@
import {
ArrowLeft, LoaderCircle, Save, Package, DollarSign,
FileText, Settings, Image as ImageIcon, Search,
- UserCheck, CheckCircle2, XCircle, Tag, Layers
+ UserCheck, CheckCircle2, XCircle, Tag, Layers, Scale
} from 'lucide-svelte';
// Stores & APIs
@@ -25,18 +25,19 @@
import { partsApi, type PartCreate } from '$lib/api/dashboard/a76/parts';
import { clientsProvidersApi } from '$lib/api/dashboard/a76/clients-providers';
import { classesApi } from '$lib/api/dashboard/a76/classes';
- import { materialTypesApi } from '$lib/api/dashboard/a76/material-types';
-
+ import { materialTypesApi } from '$lib/api/dashboard/a76/material-types';
+ // Modales
import ClientSelectorDialog from '$lib/components/dashboard/parts/client-selector-dialog.svelte';
import ClassSelectorDialog from '$lib/components/dashboard/parts/class-selector-dialog.svelte';
import MaterialTypeSelectorDialog from '$lib/components/dashboard/parts/material-type-selector-dialog.svelte';
-
+ // --- 1. IDENTIFICACIÓN ---
let id = $derived($page.params.id === 'new' ? null : Number($page.params.id));
let isEdit = $derived(!!id);
let title = $derived(isEdit ? "Editar Parte" : "Nueva Parte");
+ // --- 2. ESTADOS ---
let loading = $state(false);
let error = $state(null);
@@ -59,10 +60,10 @@
// General
description_spanish: '',
description_english: '',
- part_class: '',
- material_type_key: '',
+ part_class: '',
+ material_type: '', // Corregido: coincide con backend
country_of_origin: 'MEX',
- unit_of_measure: 'PZ',
+ unit_of_measure: 'PZ', // U.M. TIGIE
// Costos y Pesos
unit_weight: 0,
@@ -81,14 +82,17 @@
// Opcionales 2
fda_key: '',
- // Otros
+ // Otros (Comerciales)
commercial_part_number: '',
+ alternate_unit_measure: '', // U.M. Comercial
+
+ // Regulatorios
fraction: '',
eccn: '',
license_code: '',
export_code: '',
exclusion_symbol: '',
- alternate_unit_measure: '',
+
is_active: true
});
@@ -122,8 +126,7 @@
description_english: d.description_english || '',
part_class: d.part_class || '',
- // OJO: Asegúrate que tu backend devuelva este campo si existe en BD
- material_type_key: (d as any).material_type_key || '',
+ material_type: d.material_type || '', // Corregido
country_of_origin: d.country_of_origin || 'MEX',
unit_of_measure: d.unit_of_measure || 'PZ',
@@ -151,7 +154,7 @@
// Cargar datos visuales
if (d.client_id) await fetchClientName(d.client_id, companyId);
if (d.part_class) await fetchClassDesc(d.part_class, companyId);
- if ((d as any).material_type_key) await fetchMaterialName((d as any).material_type_key);
+ if (d.material_type) await fetchMaterialName(d.material_type);
}
} catch (e) {
error = "Error al cargar la parte";
@@ -161,6 +164,7 @@
}
}
+ // --- HELPERS VISUALES ---
async function fetchClientName(clientId: number, companyId: number) {
try {
const res = await clientsProvidersApi.get(clientId, companyId);
@@ -194,8 +198,7 @@
} catch (e) { console.log("Error visual material", e); }
}
-
-
+ // --- HANDLERS ---
function handleClientSelect(client: any) {
formData.client_id = client.id;
selectedClientName = client.name;
@@ -208,10 +211,11 @@
}
function handleMaterialSelect(item: any) {
- formData.material_type_key = item.key;
+ formData.material_type = item.key;
selectedMaterialDesc = item.description;
}
+ // --- SUBMIT ---
async function handleSubmit() {
error = null;
const activeCompanyId = companyStore.activeCompany?.id;
@@ -221,14 +225,12 @@
loading = true;
try {
-
const commonData = {
-
description_spanish: formData.description_spanish || null,
description_english: formData.description_english || null,
- part_class: formData.part_class || null,
- material_type_key: formData.material_type_key || null,
+ part_class: formData.part_class || null,
+ material_type: formData.material_type || null, // Corregido
country_of_origin: formData.country_of_origin || 'MEX',
unit_of_measure: formData.unit_of_measure,
@@ -253,11 +255,9 @@
};
if (isEdit && id) {
-
const response = await partsApi.update(id, commonData, activeCompanyId);
if (response.error) throw new Error(response.error);
} else {
-
const createData: PartCreate = {
...commonData,
company_id: activeCompanyId,
@@ -366,7 +366,7 @@
Opcional: Clasificación adicional por tipo de material.
-
+
+
+
+
+
+
+ {formData.unit_of_measure || 'Seleccione...'}
+
+
+
+ Comunes
+ Pieza (PZ)
+ Kilogramo (KG)
+ Litro (L)
+ Metro Lineal (M)
+ Metro Cuadrado (M2)
+ Juego (JGO)
+ Par (PAR)
+
+
+
@@ -498,6 +519,7 @@
+
@@ -528,15 +550,45 @@
{/if}
-
-
-
+
+
+
+ Datos Comerciales (Factura)
+
+
+
+
+
+
+
+
+
+
+
+
+ {formData.alternate_unit_measure || 'Seleccione...'}
+
+
+
+ Comunes
+ Pieza (PZ)
+ Kilogramo (KG)
+ Litro (L)
+ Metro Lineal (M)
+ Metro Cuadrado (M2)
+ Juego (JGO)
+ Par (PAR)
+ Set (SET)
+ Caja (CAJA)
+ Paquete (PK)
+
+
+
+
+
+
-
-
-
-
+