Overview
Catalogs are the foundation of data standardization in the Procurement Calendar application. They provide centralized, reusable reference data that ensures consistency across all requisitions. Instead of entering supplier names or product descriptions manually each time, users select from predefined catalog entries.All catalogs are managed at
/dashboard/catalogos and require admin or coordinadora permissions to modify.Benefits of Catalog Management
Data Consistency
Eliminates typos and variations in supplier names, product descriptions, and other reference data
Simplified Entry
Dropdown selections are faster than typing and reduce data entry errors
Reporting Accuracy
Standardized data enables accurate filtering, grouping, and analytics
Maintenance
Update a supplier’s name once in the catalog, and it reflects across all requisitions
Available Catalog Types
The application includes six core catalog types:1. Proveedores (Suppliers)
Stores information about suppliers and vendors.- Proveedora Química Nacional
- Distribuidora del Centro
- Importadora Técnica
- Soluciones Industriales SA
- Comercial de Insumos
Inactive suppliers are hidden from dropdowns but remain in the database to preserve historical requisition data.
2. Productos (Products)
Defines the materials and products being procured.- Sosa Cáustica (Hidróxido de sodio en escamas)
- LABSA (Ácido sulfonico lineal de benceno)
- Texapon (Lauril éter sulfato de sodio)
- Colorante Azul
- Fragancia Lavanda
- Cloruro de Sodio
- Glucamato
- Alcohol Cetílico
3. Presentaciones (Presentations)
Describes how products are packaged or presented.- Granel (Bulk)
- Tambor 200 L (200L Drum)
- Cuñete 20 L (20L Container)
- Garrafón 19 L (19L Jug)
- Saco 25 kg (25kg Bag)
- Bolsa 1 kg (1kg Bag)
- Caja 12 pzas (Box of 12 pieces)
- Pallet
4. Destinos (Destinations)
Defines delivery locations within the organization.- Almacén General
- Línea de Producción 1
- Línea de Producción 2
- Laboratorio de Calidad
- Almacén Materia Prima
- Planta Amozoc
- Planta Apizaco
5. Estatus (Status)
Defines requisition status options with color coding.| Status | Color | Hex Code |
|---|---|---|
| Pendiente | Orange | #F59E0B |
| Confirmado | Blue | #3B82F6 |
| En Tránsito | Purple | #8B5CF6 |
| Recibido | Green | #10B981 |
| Cancelado | Red | #EF4444 |
| En Revisión | Orange | #F97316 |
6. Unidades (Units of Measure)
Defines measurement units for quantities.| Nombre | Abreviatura |
|---|---|
| Kilogramos | kg |
| Litros | L |
| Piezas | pzs |
| Toneladas | ton |
| Cajas | caj |
| Sacos | sac |
| Tambos | tam |
| Gramos | g |
CRUD Operations
All catalog operations are handled through server actions inlib/actions/catalogos.ts.
Creating Catalog Entries
Create new entries in any catalog table:All new entries are automatically created with
activo: true. The created_by field is not tracked for catalog entries.Updating Catalog Entries
Modify existing catalog entries:Toggling Active Status
Deactivate entries without deleting them:Deleting Catalog Entries
Permanently remove catalog entries (admin only):Permission Requirements
Admin
Full Access
- Create entries
- Update entries
- Toggle active status
- Delete entries
Coordinadora
Modify Access
- Create entries
- Update entries
- Toggle active status
- Cannot delete
Consulta
Read Only
- View catalogs
- Use in dropdowns
- No modifications
Row-Level Security (RLS)
Catalogs are protected by Supabase RLS policies defined insupabase/schema.sql:184-199:
proveedoresproductospresentacionesdestinosestatusunidades
The
get_my_role() function retrieves the current user’s role from the profiles table, enabling role-based access control at the database level.Using Catalogs in Forms
Catalogs populate dropdown selections throughout the application:- Only active entries shown in dropdowns
- Currently selected value remains visible even if inactive
- Prevents data inconsistency when editing existing requisitions
Quick-Add Functionality
The requisition form includes “Quick Add” buttons for creating catalog entries on-the-fly:QuickAddModal that:
- Creates the new catalog entry
- Refreshes the catalog data
- Automatically selects the new entry in the form
- Closes the modal
Fetching All Catalogs
Retrieve all catalog data in a single request:Promise.all() to fetch all catalogs concurrently for optimal performance:
Auto-Revalidation
All catalog mutations automatically revalidate dependent pages:- Catalog page shows updated data immediately
- Form dropdowns reflect new entries
- No manual refresh required
Database Schema
All catalogs follow a consistent table structure:- productos includes
descripcion TEXTfield - estatus includes
color_hex TEXT NOT NULL DEFAULT '#6366F1' - unidades includes
abreviatura TEXT NOT NULL
Best Practices
Naming conventions
Naming conventions
- Use consistent capitalization (e.g., “Proveedor ABC SA” not “proveedor abc sa”)
- Include full legal names for suppliers
- Use descriptive names for products (“Sosa Cáustica” not “SC01”)
- Keep abbreviations short (2-4 characters) for units
- Use standard color names or hex codes for status
When to deactivate vs delete
When to deactivate vs delete
Deactivate when:
- The entry has been used in past requisitions
- You may need to reactivate it in the future
- You want to maintain historical data integrity
- Entry was created by mistake and never used
- Entry contains incorrect or duplicate data
- You’re certain it will never be needed
Managing status colors
Managing status colors
- Use consistent colors across your organization
- Choose high-contrast colors for accessibility
- Test colors in both light and dark modes
- Document color meanings in a style guide
- Avoid similar colors for different statuses
- Consider color blindness when selecting palettes
Organizing products
Organizing products
- Group related products using prefixes (e.g., “Fragancia - Lavanda”, “Fragancia - Limón”)
- Use the description field for technical specs
- Create separate products for different grades/purities
- Combine with presentations to fully describe SKUs
