Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Carlos-Gnd/FERRED-Inventario-y-Ventas/llms.txt

Use this file to discover all available pages before exploring further.

The inventory API manages stock levels per branch, supports adjustments and inter-branch transfers, and provides critical stock alerts. All operations are branch-aware — non-admin users can only access their assigned branch.

GET /api/inventario/status

Returns the current online/offline connectivity status of the server. Roles: ADMIN, BODEGA, CAJERO
online
boolean
required
true if the server can reach Supabase; false if operating in offline mode.

GET /api/inventario/stock/:sucursalId

Returns all stock records for a branch, including full product details. When offline, the response is served from the local SQLite snapshot. Roles: ADMIN, BODEGA, CAJERO
When the server cannot reach Supabase — either because online is false or because a Prisma connection error occurs — this endpoint automatically falls back to the local SQLite database. The response shape is identical in both cases.

Path parameters

sucursalId
number
required
ID of the branch whose stock you want to retrieve.

Response

Returns an array of StockSucursal records, each including nested product details.
[]
object[]

Example

curl https://server-production-3252.up.railway.app/api/inventario/stock/1 \
  -H "Authorization: Bearer <token>"

GET /api/inventario/criticos/:sucursalId

Returns all active products in a branch whose current stock is at or below their minimum threshold. Roles: ADMIN, BODEGA

Path parameters

sucursalId
number
required
ID of the branch to check for critical stock.

Response

total
number
Total number of products at or below minimum stock.
criticos
object[]

GET /api/inventario/criticos-detalle

Returns detailed critical stock items with a computed estado field. ADMIN users can filter by branch using the sucursalId query parameter; other roles see only their assigned branch. Roles: ADMIN, BODEGA

Query parameters

sucursalId
number
Filter by branch ID. Only applied when the authenticated user has the ADMIN role.

Response

total
number
Total number of critical items returned.
criticos
object[]

GET /api/inventario/criticos-por-sucursal

Returns the count of critical stock items for every branch. Admin-only. Roles: ADMIN

Response

Returns an array, one entry per branch.
[]
object[]

PATCH /api/inventario/:productoId/ajuste

Applies a stock adjustment for a product in a specific branch. Creates the StockSucursal record if it does not exist (upsert). After adjusting, the product’s aggregate stockActual is recalculated and logged to the sync queue. Roles: ADMIN, BODEGA

Path parameters

productoId
number
required
ID of the product to adjust.

Body

sucursalId
number
required
ID of the branch where the adjustment takes place.
cantidad
number
required
New absolute stock quantity. Can be negative to correct overstock.
minimo
number
default:"0"
Minimum stock threshold to set for this product in this branch.
motivo
string
Optional free-text reason for the adjustment. Stored in the sync log.

Response

ok
boolean
Always true on success.
stock
object
The updated StockSucursal record.
stockTotal
number
Aggregate stock across all branches after the adjustment.

POST /api/inventario/transferencia

Transfers stock of a product from one branch to another in an atomic transaction. Fails if the origin branch does not have enough stock. Roles: ADMIN

Body

productoId
number
required
ID of the product to transfer.
origenId
number
required
ID of the source branch. Must differ from destinoId.
destinoId
number
required
ID of the destination branch.
cantidad
number
required
Number of units to transfer. Must be greater than 0 and cannot exceed the stock available at the origin.

Response

mensaje
string
Confirmation message: "Transferencia realizada".
origen
object
Updated StockSucursal record for the source branch.
destino
object
Updated StockSucursal record for the destination branch.

Errors

StatusCondition
400Missing or invalid fields, or origenId === destinoId.
409Insufficient stock in the origin branch.

Example

curl -X POST https://server-production-3252.up.railway.app/api/inventario/transferencia \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "productoId": 42,
    "origenId": 1,
    "destinoId": 2,
    "cantidad": 10
  }'

GET /api/inventario/stock-comparativo

Returns all active products with their stock levels broken down per branch, along with a computed estado per branch entry. Roles: ADMIN, BODEGA

Response

Returns an array, one entry per active product.
[]
object[]

GET /api/inventario/sync-pendientes

Returns counts of sync log entries grouped by status for the current user. ADMIN users see all entries; other roles see only their own. Roles: All authenticated users

Response

pendientes
number
Number of sync log entries with status PENDIENTE.
sincronizados
number
Number of entries successfully synced (SINCRONIZADO).
errores
number
Number of entries that failed to sync (ERROR).
online
boolean
Current connectivity status of the server.
sucursalId
number
The branch ID of the authenticated user, or null for ADMIN users without an assigned branch.

Build docs developers (and LLMs) love