The Analytics API exposes computed inventory and sales metrics for your tenant. All calculations are performed server-side byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/juadariasmar/inventory_project/llms.txt
Use this file to discover all available pages before exploring further.
obtenerTodoAnalisis in src/lib/analisis.ts, which runs multiple Prisma queries in parallel to minimize latency. The primary endpoint returns a rich JSON payload suitable for driving chart components. A companion export endpoint streams the same data as a multi-sheet Excel workbook (.xlsx) for offline analysis or stakeholder reporting.
Access to the analytics data requires the VER_ANALISIS permission. Downloading reports requires the EXPORTAR_REPORTES permission. Both permissions must be granted explicitly by an admin — they are not implicitly held by any role.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/analisis | Return analytics JSON payload for the tenant |
| GET | /api/analisis/exportar | Download a multi-sheet Excel analytics report |
GET /api/analisis
Returns the full analytics dataset for the tenant. All time-windowed calculations use a fixed 30-day lookback window. Sales counts exclude cancelled sales to ensure accurate consumption and revenue figures. Up to 500 products are included in the inventory-general and dormant-product analyses. Required permission:VER_ANALISIS
Response fields
Complete product catalogue with stock status, valuation, and activity age. Up to 500 products, ordered alphabetically by name.
Product ID.
Product SKU code.
Product name.
Category name. Defaults to
"Sin categoría" if unassigned.Current stock quantity.
Configured minimum stock threshold.
Unit sale price.
Total stock value (
precio × cantidad).Stock health:
"Sin stock", "Stock bajo", or "Normal".Days since the last recorded movement.
null if no movement has ever been recorded.Products projected to run out within 7 days based on 30-day average daily consumption, plus any product already below the minimum threshold with no consumption history.
Product ID.
Product name.
SKU code.
Current stock level.
Minimum stock threshold.
Average daily consumption (2 decimal places).
Projected days until stock reaches zero.
null when there is no consumption history but stock is already in the critical zone.Products with stock greater than zero that have had no incoming or outgoing movements in the last 30 days. Sorted by
valorInmovilizado descending.Product ID.
Product name.
SKU code.
Current stock level.
Number of days since the last movement.
Tied-up capital value (
precio × cantidad).Top 10 products by total units sold (outgoing movements excluding cancelled sales) in the last 30 days.
Product ID.
Product name.
SKU code.
Number of outgoing movement records.
Total units sold across all outgoing movements.
Products where
cantidad <= stockMinimo + MARGEN_ALERTA_STOCK. Sorted by sugerenciaCompra descending to prioritize the most urgent replenishment needs.Product ID.
Product name.
SKU code.
Current stock level.
Minimum stock threshold.
Average daily consumption (2 decimal places).
Recommended reorder quantity to cover 14 days of projected demand, calculated by
calcularSugerenciaCompraInteligente.Daily movement summary for the last 30 days. Every calendar day in the range is included, even if activity was zero.
Date in
YYYY-MM-DD format.Total units received (incoming movements) on that day.
Total units dispatched (outgoing movements) on that day.
Daily sales metrics for the last 30 days. Excludes cancelled sales.
Date in
YYYY-MM-DD format.Number of completed sales on that day.
Total revenue on that day (rounded to the nearest integer).
Top 8 product categories by total revenue in the last 30 days, excluding cancelled sales.
Category name.
Total units sold across all products in this category.
Total revenue from this category (rounded).
Count of products in each stock-health bucket across the entire catalogue.
Stock health bucket:
"Sin stock", "Stock bajo", or "Normal".Number of products in this bucket.
GET /api/analisis/exportar
Generates and streams a multi-sheet Excel workbook (.xlsx) containing the full analytics dataset. The file is named with a timestamp suffix in Colombia time (e.g., analisis_inventario_20250115_143022.xlsx). The workbook includes seven sheets: Resumen, Inventario general, Por agotarse, Sin movimientos, Alta rotación, Stock crítico, and Movimientos diarios. Monetary columns are formatted as currency; decimal columns are formatted to two decimal places.
Required permission: EXPORTAR_REPORTES
Response
Returns a binary.xlsx stream with:
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheetContent-Disposition: attachment; filename="analisis_inventario_YYYYMMDD_HHMMSS.xlsx"Cache-Control: no-store