Overview
The Procurement Calendar data model is built around a centralRequisicion entity that references multiple catalog tables. This normalized design ensures data consistency and simplifies maintenance.
Entity Relationship Diagram
The data model follows this structure:Each requisition references 6 catalog tables plus the user who created it, forming a star schema pattern.
Core Entities
Requisicion (Requisition)
The main business entity representing a purchase requisition.Field Descriptions
Field Descriptions
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
fecha_recepcion | Date | Date the requisition was received |
proveedor_id | UUID | Foreign key to supplier |
producto_id | UUID | Foreign key to product |
presentacion_id | UUID | Foreign key to presentation format |
destino_id | UUID | Foreign key to destination |
estatus_id | UUID | Foreign key to current status |
cantidad_solicitada | Numeric | Requested quantity (must be > 0) |
unidad_cantidad_id | UUID | Foreign key to unit of measurement |
numero_oc | Text | Purchase order number (optional) |
comentarios | Text | Additional comments (optional) |
created_by | UUID | Foreign key to user who created record |
created_at | Timestamp | Record creation timestamp |
updated_at | Timestamp | Last update timestamp (auto-updated) |
The optional relation properties (
proveedor?, producto?, etc.) are populated when using Supabase joins in queries.Requisicion Historial (Audit History)
Tracks all changes made to requisitions.Field Descriptions
Field Descriptions
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
requisicion_id | UUID | Foreign key to requisition being tracked |
campo_modificado | Text | Name of the field that was changed |
valor_anterior | Text | Previous value (serialized as text) |
valor_nuevo | Text | New value (serialized as text) |
usuario_id | UUID | User who made the change |
created_at | Timestamp | When the change occurred |
Catalog Entities
All catalog entities share a similar structure with common fields.Proveedor (Supplier)
Producto (Product)
Products include an optional
descripcion field for additional details like chemical composition.Presentacion (Presentation)
Destino (Destination)
Estatus (Status)
Default Status Values
Default Status Values
| Status | Color Hex | Description |
|---|---|---|
| Pendiente | #F59E0B | Requisition pending review |
| Confirmado | #3B82F6 | Order confirmed with supplier |
| En Tránsito | #8B5CF6 | Shipment in transit |
| Recibido | #10B981 | Product received at destination |
| Cancelado | #EF4444 | Requisition cancelled |
| En Revisión | #F97316 | Under review or audit |
Unidad (Unit)
Default Units
Default Units
| Unit | Abbreviation |
|---|---|
| Kilogramos | kg |
| Litros | L |
| Piezas | pzs |
| Toneladas | ton |
| Cajas | caj |
| Sacos | sac |
| Tambos | tam |
| Gramos | g |
User Management
Profile
Extends Supabase authentication with application-specific data.User Roles
admin
Full system access and user management
coordinadora
Create and update requisitions
consulta
Read-only access to data
Form Data Types
Requisicion Form Data
Used when creating or updating requisitions.Form data omits system-managed fields like
id, created_by, created_at, and updated_at.Requisicion Filters
Used for filtering requisitions in list views.Calendar Integration
Calendar Event
Transforms requisition data for FullCalendar display.The
backgroundColor and borderColor are derived from the estatus.color_hex field.Aggregated Types
Catalogos
Convenience type for passing all catalog data together.Usage Example
Usage Example
Relationships Summary
One-to-Many
Each catalog entry can be referenced by many requisitions
Many-to-One
Each requisition references exactly one entry from each catalog
Cascade Deletes
Deleting a requisition cascades to its history records
Foreign Key Constraints
All relationships enforced at database level
Next Steps
Database Schema
View the complete SQL schema
Row Level Security
Learn about access control policies
