Approval Workflow System
Creation
Madre Procesadora or Director registers a new entry guide with delivery details and product batches. Status: Pendiente
Review
Director reviews the guide details, product quantities, and batch information in the approval interface
Important: Inventory stock does NOT update when the guide is created. It only updates after Director approval.
Creating an Entry Guide
Header Information
SUNAGRO guide number (unique identifier)Validation: Must be unique in the system. Duplicate guide numbers are rejected.
SISECAL guide number (optional secondary reference)
Delivery dateDefault: Current date using
getLocalDate()Name of the vocera (community representative) who received the deliveryExample: “María Villalobos”
Contact phone numberFormat: Venezuelan phone format (e.g., “0412-XXX-XXXX”)
General observations about the delivery
Product Details (Rubros Recibidos)
Each entry guide can include multiple products. For each product:Product selection from catalogValidation: Cannot select the same product twice in one guide
Total quantity receivedFormat: Decimal with 2 places (e.g., 100.50)
Number of physical packages/bags/boxesPurpose: Track bulk packaging (e.g., “10 sacos”)
Batch Tracking (Lotes)
For each batch within a product:Quantity in this batchValidation: Sum of all batch quantities must equal total
amountExpiration date or maximum consumption dateNote: For perishables without printed dates, enter estimated maximum shelf life
Multiple Batches
Example scenario: 100 kg of rice arrives:- 60 kg expires on 2026-12-31
- 40 kg expires on 2027-03-15
Batch Validation
The form validates batch data before submission:Submitting the Guide
When the form is submitted (src/pages/GuiasEntrada.jsx:150-238):
- Validate: Check batch quantities and required fields
- Create guide record:
- Insert input details with JSONB batch data:
Success Notification
Duplicate Guide Error
Ifnumero_guia_sunagro already exists:
Viewing Entry Guides
Filter Options
The history view includes filters:Nº Guía SUNAGRO
Search by guide number (partial match supported)
Desde
Start date filter (default: 30 days ago)
Hasta
End date filter (default: today)
Guide Status Badges
Pendiente
Yellow/Amber: Awaiting Director approval
Aprobada
Green: Approved - inventory updated
Rechazada
Red: Rejected - no inventory change
Guide Card Details
Each guide displays:- Header: Guide number(s), status badge, creation date
- Vocera info: Name and phone of person who received delivery
- Product list: All items with quantities and batch details
- Approval metadata (if approved/rejected):
- Approver name
- Approval/rejection date
- Comments/rejection reason
Product Line Item Format
Data Structure
guia_entrada Table
input Table (Details)
JSONB Batch Format
GIN Index: The
lotes_detalle field has a GIN index (idx_input_lotes_detalle) for efficient JSONB queries when implementing FIFO consumption.Role-Based Permissions
| Role | Create Guides | View Guides | Approve/Reject |
|---|---|---|---|
| Director (id_rol=1) | ✅ | ✅ | ✅ |
| Madre Procesadora (id_rol=2) | ✅ | ✅ | ❌ |
| Supervisor (id_rol=3) | ❌ | ✅ | ❌ |
| Desarrollador (id_rol=4) | ✅ | ✅ | ✅ |
Next Step: Approval
After creating a guide, the Director must approve it before inventory updates. See Entry Guides - Approval Workflow above or the Entry Approval Workflow Guide for detailed instructions.Technical Details
File location:
src/pages/GuiasEntrada.jsx:1-937Key Functions
- loadGuias(): Fetches guides with filters, joins product/user data
- loadProducts(): Gets product catalog for dropdown
- handleSubmit(): Validates and creates guide + input details
- addDetalle(): Adds new product row to form
- addLote(): Adds batch to a product
- handleLoteChange(): Updates batch quantity/date with live validation