Overview
The Daily Operations module (Registro Diario) is where you record:- Student attendance for each meal service
- Which products (rubros) were cooked
- Automatic inventory consumption using FIFO batch tracking
Required Role: Director or Madre ProcesadoraSupervisors can view operations but cannot create them.
How Daily Operations Work
Automatic Calculations
- You provide: Attendance count + Products cooked
- System calculates: Quantity needed = attendance ÷ portion yield
- System consumes: Uses FIFO to deduct from oldest batches first
- System updates: Stock levels decrease automatically
Registering a Daily Operation
Enter operation details
Fill in the basic information:
- Fecha: Date of the meal service (defaults to today)
- Turno: Select the meal period:
- Desayuno (Breakfast)
- Almuerzo (Lunch)
- Merienda (Snack)
- Asistencia (alumnos): Number of students present
Add products cooked
For each product used:
- Click + Agregar Rubro
- Select the product from the dropdown
- The system will show:
- Current stock level
- Calculated quantity needed (based on attendance)
- Whether stock is sufficient
Verify calculations
The system displays real-time feedback for each product:✓ Green check = Sufficient stock available⚠️ Red warning = Insufficient stockExample:
- Product: Arroz (stock: 100 kg)
- Attendance: 120 students
- Portion yield: 12 portions/kg
- Calculation: 120 ÷ 12 = 10 kg needed
- Result: ✓ 10.00 kg necesarios
Submit the operation
Click 🍴 Registrar Operación.The system will:
- Create a registro_diario record
- Calculate exact quantities needed for each product
- Use FIFO to consume batches (oldest first)
- Create output records for each product
- Deduct quantities from stock
Success message:“Operación registrada: 3 rubros procesados para 120 alumnos.”
Example from Code (RegistroDiario.jsx:117-160)
Real-Time Calculation Display (RegistroDiario.jsx:103-114)
Database Processing Function
The core logic is handled by theprocesar_operacion_diaria() RPC function.
procesar_operacion_diaria() (supabase_schema.sql:570-706)
Key Features:
- Permission check - Only Director/Madre Procesadora can register
- Portion validation - All products must have configured yields
- FIFO consumption - Oldest batches consumed first
- Batch locking - Uses
FOR UPDATEto prevent race conditions - Stock deduction - Automatic via
update_stock_on_output()trigger - Atomic transaction - All or nothing (rolls back on error)
Stock Deduction Trigger (supabase_schema.sql:293-322)
When an output record is created, this trigger automatically updates stock:- Stock cannot go negative
- Updates are atomic
- Errors are raised if insufficient stock
Viewing Operation History
The bottom section of the Registro Diario page shows all past operations:- Date and meal period (Desayuno/Almuerzo/Merienda)
- Attendance count
- Who registered the operation
- Expandable detail showing all products consumed
Example from Code (RegistroDiario.jsx:61-76)
Common Errors and Solutions
Error: 'El rubro no tiene rendimiento configurado'
Error: 'El rubro no tiene rendimiento configurado'
Cause: You selected a product that doesn’t have a portion yield set up.Solution: Go to Configuración > Porciones and configure the portion yield for this product first.See: Portion Management
Error: 'Lotes insuficientes para [producto]'
Error: 'Lotes insuficientes para [producto]'
Cause: Not enough inventory stock to fulfill the calculated quantity.Example: Need 15 kg of Arroz, but only 10 kg available in approved batches.Solution:
- Check if there are pending entry guides that need approval
- Reduce the attendance count or remove this product
- Request a new delivery of this product
Warning: Red warning icon shows insufficient stock
Warning: Red warning icon shows insufficient stock
Cause: The real-time calculation detected you don’t have enough stock.Solution: This is a pre-submission warning. The system will block submission if you try to proceed. Either:
- Remove this product from the list
- Get more stock approved first
Can't select a product in the dropdown
Can't select a product in the dropdown
Cause: The product doesn’t have a configured portion yield.Solution: Only products with portion yields appear in the dropdown. Configure the yield first in Porciones.
Best Practices
Register operations on the same day
Register operations on the same day
Record meal services on the day they occur. This keeps inventory data current and accurate.
One operation per turno per day
One operation per turno per day
Create separate operations for each meal period:
- Desayuno (morning)
- Almuerzo (midday)
- Merienda (afternoon)
Verify attendance counts
Verify attendance counts
Double-check the student count before submitting. Incorrect attendance leads to incorrect inventory consumption.
Configure portion yields before cooking season starts
Configure portion yields before cooking season starts
Set up all portion yields at the beginning of the school year. This prevents errors during busy meal service times.
Check stock levels before meal planning
Check stock levels before meal planning
Use the Products page to verify you have sufficient stock of all planned items before starting food preparation.
Related Resources
Portion Management
Configure how many servings each product yields
FIFO System
How batch tracking ensures oldest items are used first
Managing Products
View stock levels and product information
Entry Approval
How to add inventory through approved entry guides