Existencias (stock levels) represent the current on-hand quantity of each material in the warehouse. Every material registered in the catalog has a corresponding existencia record that tracks itsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/EricMartinez758/corpointa-frontend/llms.txt
Use this file to discover all available pages before exploring further.
cantidad_actual alongside configurable stock_minimo and stock_maximo thresholds. The module is accessible at the /existencias route and provides two views: a live stock table and an Acta-based movement history that aggregates controles perceptivos (entries) and salidas (exits).
Data Model
TheExistencia type is derived from the Zod schema in src/features/existencias/data/schema.ts.
Field Reference
| Field | Type | Description |
|---|---|---|
id_existencia | number | Primary key of the stock record. |
fk_id_material | number | Foreign key linking to the material in the catalog. |
material_descripcion | string | Material name, resolved via JOIN — read-only. |
cantidad_actual | number | Current on-hand quantity. Updated automatically by entry and exit movements. |
stock_minimo | number | Minimum acceptable stock level. Items below this value trigger a low-stock alert. |
stock_maximo | number | Maximum expected stock level, used for reorder planning. |
Acta View
In addition to the stock table, the/existencias route provides an Acta (movement record) view that consolidates all entries and exits into unified records.
Acta Field Reference
| Field | Type | Description |
|---|---|---|
id_acta | number | Internal ID (mirrors the source record’s ID). |
numero_acta | string | Human-readable reference number (e.g., CON-0021, SAL-0042). |
tipo | "Entrada" | "Salida" | Movement direction. |
fecha | string | ISO date of the movement. |
numero_requerimiento | string | null | Associated purchase requisition number, if applicable. |
numero_compra | string | null | Associated purchase order number, if applicable. |
detalles | DetalleActa[] | Line items — one entry per material moved in this act. |
How Actas Are Assembled
ThegetActas() function fetches from two separate API resources and merges them:
- Entries —
GET /controles-perceptivos(perception control records). Each record is then expanded withGET /controles-perceptivos/:idto fetch its detail lines. - Exits —
GET /salidas. Each record is expanded withGET /salidas/:id_salidafor its line items.
Acta shape and returned as a single combined array (entries first, then exits). If the salidas endpoint is unavailable, it gracefully returns an empty array rather than failing.
Low-Stock Alerts
When a material’scantidad_actual falls below its stock_minimo, two things happen:
- Dashboard KPI — The Stock Bajo card on the Dashboard increments its count to include this material, and the value is rendered in destructive red.
- Stock table flag — The row for that material is visually highlighted in the Existencias table so operators can prioritise restocking.
Updating Thresholds
Stock thresholds (stock_minimo and stock_maximo) can be adjusted at any time through the edit dialog in the Existencias table. The cantidad_actual field is read-only and is managed exclusively by entry/exit movement records.
Endpoint
Payload
Example
Only
stock_minimo and stock_maximo are accepted on PUT /existencias/:id. Attempting to set cantidad_actual directly through this endpoint has no effect — quantities are managed through the controles-perceptivos and salidas workflows.API Operations
All functions live insrc/features/existencias/api/existencias.ts.
| Method | Endpoint | Function | Description |
|---|---|---|---|
GET | /existencias | getExistencias() | Returns all stock records with material_descripcion resolved via JOIN. |
PUT | /existencias/:id | updateExistenciaLimits(id, limits) | Updates stock_minimo and stock_maximo for a specific stock record. |
GET | /controles-perceptivos | (internal, used by getActas()) | Fetches all entry perception-control records. |
GET | /controles-perceptivos/:id | (internal, used by getActas()) | Fetches line-item details for a single entry record. |
GET | /salidas | (internal, used by getActas()) | Fetches all exit dispatch records. |
GET | /salidas/:id | (internal, used by getActas()) | Fetches line-item details for a single exit record. |
Example: GET /existencias Response
cantidad_actual (8) is below stock_minimo (10), so this item contributes to the Stock Bajo KPI on the Dashboard.