25 lines
742 B
Plaintext
25 lines
742 B
Plaintext
FUNCTION clasificar_producto_abc(bodega_id)
|
|
DEFINE bodega_id STRING
|
|
-- Array para almacenar info por producto
|
|
DEFINE arr DYNAMIC ARRAY OF RECORD
|
|
producto_id STRING,
|
|
valor_total DECIMAL,
|
|
rotacion FLOAT,
|
|
porcentaje_acumulado FLOAT,
|
|
clase CHAR(1)
|
|
END RECORD
|
|
|
|
-- 1. Leer los productos de la bodega con existencia y costo
|
|
CALL cargar_valores_bodega(arr, bodega_id)
|
|
|
|
-- 2. Ordenar por valor_total descendente
|
|
CALL ordenar_array_por_valor(arr)
|
|
|
|
-- 3. Calcular porcentaje acumulado y asignar clase A, B, C
|
|
CALL asignar_clasificacion_abc(arr)
|
|
|
|
-- 4. Guardar la clasificación
|
|
CALL guardar_clasificacion_bodega(arr, bodega_id)
|
|
|
|
END FUNCTION
|