Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/interezante456-pixel/Miercoles-Proyecto/llms.txt

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

The Inventario module is a read-only ledger that records every change to product stock in Tiendas Mi Cholo. Movements are created automatically by the system — a SALIDA is written each time a sale is registered (or reversed when a sale is voided), and an ENTRADA is written each time a purchase order is received. This audit trail lets you trace every unit in and out of the warehouse, who performed the operation, and which transaction triggered it. All authenticated roles can query inventory movements; no role may create or modify movements directly through the API.

GET /api/inventario

List all inventory movements across all products, in default database order. GET http://localhost:8080/api/inventario

Authorization

Authorization
string
required
Bearer token — Authorization: Bearer <token>

Response 200 OK

id
Long
Internal identifier of the movement record.
tipo
string
Movement direction: ENTRADA (stock in), SALIDA (stock out), or AJUSTE (manual adjustment).
cantidad
Integer
Number of units moved in this event.
stockAnterior
Integer
Product’s stockActual value before this movement was applied.
stockNuevo
Integer
Product’s stockActual value after this movement was applied.
motivo
string
Human-readable description of why the movement occurred (e.g. "Venta VNT-00001" or "Recepción compra CMP-00003").
referenciaId
Long
Primary key of the source transaction (Venta ID or Compra ID) that triggered this movement.
referenciaTipo
string
Source transaction type: VENTA, COMPRA, or AJUSTE.
producto
object
Embedded product snapshot: id, codigo, nombre.
usuario
object
Embedded user who triggered the operation: id, nombre, apellido.
fecha
string (ISO 8601)
Timestamp when the movement was persisted (@PrePersist).
Example response
[
  {
    "id": 1,
    "tipo": "SALIDA",
    "cantidad": 1,
    "stockAnterior": 11,
    "stockNuevo": 10,
    "motivo": "Venta VNT-00001",
    "referenciaId": 1,
    "referenciaTipo": "VENTA",
    "producto": {
      "id": 1,
      "codigo": "PROD-001",
      "nombre": "Laptop HP 15"
    },
    "usuario": {
      "id": 2,
      "nombre": "Luis",
      "apellido": "Mendoza"
    },
    "fecha": "2024-01-15T14:30:00"
  },
  {
    "id": 2,
    "tipo": "ENTRADA",
    "cantidad": 5,
    "stockAnterior": 10,
    "stockNuevo": 15,
    "motivo": "Recepción compra CMP-00003",
    "referenciaId": 3,
    "referenciaTipo": "COMPRA",
    "producto": {
      "id": 1,
      "codigo": "PROD-001",
      "nombre": "Laptop HP 15"
    },
    "usuario": {
      "id": 1,
      "nombre": "Juan",
      "apellido": "Pérez"
    },
    "fecha": "2024-01-16T09:10:44"
  }
]
cURL
curl -X GET http://localhost:8080/api/inventario \
  -H "Authorization: Bearer <token>"

GET /api/inventario/producto/{productoId}

Retrieve the complete movement history for a specific product, ordered by fecha descending (most recent first). Use this endpoint to audit stock changes for an individual SKU. GET http://localhost:8080/api/inventario/producto/{productoId}

Authorization

Authorization
string
required
Bearer token — Authorization: Bearer <token>

Path Parameters

productoId
Long
required
The internal ID of the product whose movement history you want to retrieve.

Response 200 OK

Returns an array of movement objects (same shape as GET /api/inventario) ordered by fecha DESC. Returns an empty array [] if no movements exist for the given product ID.
Example response — product 1 history
[
  {
    "id": 8,
    "tipo": "ENTRADA",
    "cantidad": 5,
    "stockAnterior": 10,
    "stockNuevo": 15,
    "motivo": "Recepción compra CMP-00003",
    "referenciaId": 3,
    "referenciaTipo": "COMPRA",
    "producto": {
      "id": 1,
      "codigo": "PROD-001",
      "nombre": "Laptop HP 15"
    },
    "usuario": {
      "id": 1,
      "nombre": "Juan",
      "apellido": "Pérez"
    },
    "fecha": "2024-01-16T09:10:44"
  },
  {
    "id": 1,
    "tipo": "SALIDA",
    "cantidad": 1,
    "stockAnterior": 11,
    "stockNuevo": 10,
    "motivo": "Venta VNT-00001",
    "referenciaId": 1,
    "referenciaTipo": "VENTA",
    "producto": {
      "id": 1,
      "codigo": "PROD-001",
      "nombre": "Laptop HP 15"
    },
    "usuario": {
      "id": 2,
      "nombre": "Luis",
      "apellido": "Mendoza"
    },
    "fecha": "2024-01-15T14:30:00"
  }
]
cURL
curl -X GET http://localhost:8080/api/inventario/producto/1 \
  -H "Authorization: Bearer <token>"

Error Codes

StatusMeaning
401 UnauthorizedToken missing, invalid, or expired.

How Movements Are Created

Inventory movements are created automatically by the system in response to transactional events. You cannot POST, PUT, or DELETE movements through the API — the /api/inventario endpoints are intentionally read-only.
EventMovement TypeTriggered by
POST /api/ventasSALIDA per line itemVentaService.registrarVenta()
PATCH /api/ventas/{id}/anularENTRADA per line item (reversal)VentaService.anularVenta()
PATCH /api/compras/{id}/recibirENTRADA per line itemCompraService.recibirCompra()
Manual adjustmentAJUSTEFuture back-office flow
The referenciaTipo field tells you what kind of transaction triggered the movement, and referenciaId gives you its primary key so you can cross-reference with /api/ventas/{id} or /api/compras/{id} for the full context.

Build docs developers (and LLMs) love