Skip to main content
The Inventory Management module manages your product catalog (rubros) and tracks real-time stock levels. All inventory items are categorized and measured in their respective units.

Product List View

The main inventory page displays all registered products in a sortable table:

Table Columns

ColumnDescriptionData Source
Nº ÍtemProduct ID numberproduct.id_product
NombreProduct nameproduct.product_name
CategoríaProduct categorycategory.category_name (joined)
StockCurrent quantity with status badgeproduct.stock
UnidadUnit of measureproduct.unit_measure
AccionesEdit/Delete buttons-

Stock Status Badges

Stock levels are color-coded for quick visual assessment:

BAJO

Red badge: Stock < 10 units - Immediate reorder needed

MEDIO

Amber badge: Stock between 10-49 units - Monitor closely

OK

Green badge: Stock ≥ 50 units - Adequate supply

Creating Products

Permission required: Director or Madre Procesadora roles only

Product Form Fields

Required Fields

product_name
string
required
Product name (e.g., “Arroz”, “Aceite de girasol”)
unit_measure
select
required
Unit of measurement:
  • kg - Kilogramos
  • lt - Litros
  • unidades - Units

Optional Fields

id_category
select
Category selection from predefined list:
  • Lacteos (Dairy)
  • Proteinas (Proteins)
  • Carbohidratos (Carbohydrates)
  • Legumbres (Legumes)
  • Vegetales (Vegetables)
  • Frutas (Fruits)
  • Aceites y grasas (Oils and fats)
  • Condimentos (Condiments)
  • Otros (Other)
description
textarea
Additional product details or notes

Database Fields

When submitted, the form creates/updates records with:
{
  "product_name": "string",
  "unit_measure": "kg | lt | unidades",
  "description": "string | null",
  "id_category": "integer | null",
  "stock": 0,  // Auto-initialized
  "created_at": "timestamp",
  "updated_at": "timestamp"
}
Stock initialization: New products start with stock = 0. Stock is updated through approved entry guides, not manually.

Editing Products

Click the Editar button to modify product details:
  • Product name
  • Unit of measure
  • Category assignment
  • Description
Stock cannot be edited directly. Stock levels update automatically when:
  • Entry guides are approved (increases stock)
  • Daily operations are registered (decreases stock via FIFO)

Deleting Products

Permission required: Director role only
Attempting to delete a product will:
  1. Show a confirmation dialog: “¿Eliminar rubro? Esta acción no se puede deshacer”
  2. Check for foreign key constraints
  3. Block deletion if the product is referenced in:
    • receta_porcion (portion recipes)
    • input (entry guide details)
    • output (daily operation outputs)

Error Message

If deletion is blocked:
No se puede eliminar
Este rubro ya está siendo usado en Porciones, Entradas o Salidas. 
Para mantener el historial, no debe borrarse.
Reason: The system preserves data integrity and audit trails by preventing deletion of products with transaction history.

Role-Based Access

Supervisor Role (id_rol = 3)

Supervisors have read-only access:
  • ✅ View product list
  • ✅ See stock levels
  • ❌ Cannot create products
  • ❌ Cannot edit products
  • ❌ Cannot delete products
  • ❌ Form hidden entirely

Madre Procesadora (id_rol = 2)

  • ✅ View products
  • ✅ Create new products
  • ✅ Edit existing products
  • ❌ Cannot delete products

Director (id_rol = 1)

  • ✅ Full access to all operations
  • ✅ Can delete products (with constraint validation)

Data Loading

Initial Load

On page mount (src/pages/Products.jsx:22-25):
loadProducts()  // Fetch all products with categories
loadCategories()  // Fetch category options for dropdown
loadUserRole()  // Determine current user permissions

Product Query

SELECT product.*, category.category_name
FROM product
LEFT JOIN category ON product.id_category = category.id_category
ORDER BY product_name

Loading State

Displays global loader while fetching:
<GlobalLoader text="Cargando inventario..." />

Empty State

When no products exist:
<div className="empty-state">
  <p>No hay rubros registrados</p>
  <button onClick={() => setShowForm(true)}>
    Crear primer rubro
  </button>
</div>

Technical Implementation

File location: src/pages/Products.jsx:1-311

Form Validation

  • Required fields: Product name, unit of measure
  • Optional fields: Category, description
  • Client-side: HTML5 required attribute
  • Server-side: Database NOT NULL constraints

Stock Management

Stock is never modified directly through this interface. It updates automatically via:

Use Cases

Catalog Setup

Initial configuration of all food items the school program uses

Stock Monitoring

Real-time visibility into inventory levels for reorder planning

Category Organization

Group products by type for easier reporting and management

Unit Standardization

Ensure consistent measurement units across all operations

Build docs developers (and LLMs) love