Understanding Batches
A batch is created when production is recorded against an order:- Batch Code:
{codigo_orden}-{correlativo} - Example: Order 2000145 → Batches 2000145-001, 2000145-002, 2000145-003
- Scope: One batch per order + shift combination
- Lifecycle: activo → pausado → cerrado
Why Batches Matter
- Quality Control: Batches are the unit of quality testing and hold/release decisions
- Traceability: Track materials from raw input to finished goods
- Recall Management: Identify and isolate specific production runs
- Inventory Control: Manage stock by discrete, testable units
- Customer Shipments: Ship and invoice by batch
Automatic Batch Generation
Batches are created automatically during shift log recording.Record Production
During shift log (Bitácora de Turno), log production against an order:
- Select production order
- Enter quantity produced
- Save process data
System Generates Batch
The
generarOObtenerLote() service method:- Checks if a batch already exists for this bitácora + orden
- If yes: Returns existing batch
- If no: Creates new batch:
- Calculates next correlativo (max + 1)
- Generates código_lote:
{codigo_orden}-{correlativo} - Sets estado: “activo”
- Links to bitácora_id and orden_produccion_id
- Records creation user and timestamp
Batches are created per order + bitácora (shift). If the same order runs across multiple shifts, each shift gets its own batch with incrementing correlativo.
Viewing Batches
Navigate to Control → Trazabilidad or access the internal lotes module.Batch List
The batch table displays:| Column | Description |
|---|---|
| Código Lote | Format: - |
| Proceso | Source production process |
| Orden | Linked production order (codigo_orden) |
| Estado | activo, pausado, cerrado |
| Acciones | View details, change status, traceability |
Filtering
Available batches only:Batch Status Management
Batches move through a controlled lifecycle:Active (activo)
Initial state after creation:- Available for consumption by downstream processes
- Quality testing in progress or completed
- Can be used in production
Paused (pausado)
Temporarily held:- Quality issue under investigation
- Material verification pending
- Customer specification review needed
- Inventory hold for administrative reasons
Closed (cerrado)
Final state:- All material consumed or shipped
- Quality approved and documented
- No longer available for use
- Irreversible status
Changing Status
Select New Status
Choose the target status:
- activo → pausado (hold batch)
- activo → cerrado (finalize batch)
- pausado → activo (release hold)
- pausado → cerrado (finalize held batch)
Provide Comment
For pausado or cerrado status:Example (cerrado):
- Comment is mandatory
- Explain the reason for status change
- Include any test results, approvals, or justifications
Batch Consumption (Process Inputs)
Downstream processes consume upstream batches:Example: Telares Consuming Extrusor PP Output
Record Production
Enter production data:
- Select weaving order
- Choose machine (T-01, T-02, etc.)
- Enter quantity produced
Declare Input Batches
Select which extruder batches were consumed:
- System queries available batches (estado = activo or pausado)
- Operator selects batches used on this machine
- Multiple batches can be selected
Consumption Validation
Only batches with estado “activo” or “pausado” can be consumed. Closed batches are blocked.
Special Batch Formats
Standard Format (Most Processes)
Format:{codigo_orden}-{correlativo}
Example:
- Order: 1000234 (Extrusor PP)
- Batches: 1000234-001, 1000234-002, 1000234-003
generarOObtenerLote()
Laminado Format (Custom)
Format:{codigo_rollo_entrada}-L{correlativo}
Example:
- Input batch: 2000145-001 (fabric roll from Telares)
- Laminated batches: 2000145-001-L1, 2000145-001-L2
crearLoteDirecto() with custom código_lote
This preserves the input-output relationship in the batch code itself.
Batch History
Every status change is recorded inhistorial_estado_lote:
Viewing History
This provides complete audit trail for regulatory compliance and quality investigations.
Batch Traceability
The traceability query links all related data:View Complete Chain
The system displays:
- Upstream: Raw materials or input batches consumed to make this batch
- This Batch: Production details (order, shift, date, quantity, quality results)
- Downstream: Where this batch was consumed and what output batches it produced
- Status History: All state transitions with timestamps and users
Integration with Quality Control
Batches are the unit of quality sampling:Quality Sample Linkage
- Production creates batch (lote)
- Quality team takes samples from batch
- Samples are tested and recorded in
muestrastable - Samples linked to batch via bitacora_id + orden_produccion_id
- Quality results determine batch disposition:
- Cumple: Batch approved, remains activo
- Rechazo: Batch held, status → pausado
- En espera: Batch held pending retest
Quality Hold Workflow
Supervisor Reviews
Supervisor evaluates:
- Sample results
- Batch disposition (rework, scrap, conditional release)
- Corrective actions
Update Batch Status
Based on decision:
- Rework possible: Keep activo, add observations
- Investigation needed: Change to pausado with comment
- Scrapped: Change to cerrado with comment
Best Practices
Let the system generate batch codes automatically - don’t override correlativo
Update batch status immediately when quality decisions are made
Provide detailed comments for all status changes (especially pausado and cerrado)
Close batches promptly when fully consumed or shipped
Use batch consumption tracking to validate material usage against production
Review batch traceability before shipment to ensure quality compliance
Reporting and KPIs
Batch Yield Analysis
Compare:- Input batch quantities (from upstream process)
- Output quantities (from downstream process)
- Calculate material utilization %
Quality Performance
Track:- % batches with zero quality rejections
- Average time from production to quality approval
- % batches requiring hold or rework
Inventory Accuracy
Reconcile:- Batches created (from registros_trabajo)
- Batches consumed (from consumo_lote tables)
- Batches in activo state (current inventory)
Troubleshooting
Batch Not Generated
Issue: Production recorded but no batch created- Check if production was saved successfully
- Verify orden_produccion_id is valid
- Ensure bitacora_id is present
- Review application logs for errors
Cannot Consume Batch
Error: “El lote está cerrado y no puede ser declarado como consumido”- The batch status is “cerrado”
- Cannot reopen closed batches
- Use a different batch or contact supervisor
Duplicate Batch Codes
Issue: Two batches with same código_lote- Should never happen - indicates data integrity issue
- Check correlativo calculation logic
- Review database constraints
- Contact system administrator
Missing Traceability Data
Issue: Batch shows no consumption records- Batch may not have been used yet
- Downstream process may not have declared consumption
- Check if consumo_lote records were created
- Verify process contract supports consumption tracking
Related Topics
- Shift Logs - Recording production that generates batches
- Traceability - Following batches through production chain
- Production Orders - Orders that batches fulfill