The Ventas module is the core transactional engine of Tiendas Mi Cholo. Every sale creates a fully-audited record with auto-generated comprobante number, automatic IGV (18%) calculation, and real-time stock deduction for each line item. RolesDocumentation 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.
ADMIN and VENDEDOR can register sales; only ADMIN may void them. All authenticated roles can read the sales list.
GET /api/ventas
List all sales recorded in the system, sorted by the default JPA fetch order. Accessible by all authenticated roles.GET http://localhost:8080/api/ventas
Authorization
Bearer token —
Authorization: Bearer <token>Response 200 OK
Internal database identifier for the sale.
Auto-generated sale number in the format
V-{year}-{sequence} (e.g. V-2024-0001).Document type:
BOLETA, FACTURA, or TICKET.Current sale status:
PENDIENTE, COMPLETADA, or ANULADA.Pre-tax subtotal amount, calculated from line items minus any discounts.
18% tax amount (
subtotal × 0.18).Final amount charged (
subtotal + igv).Optional free-text notes attached to the sale.
Embedded customer snapshot:
id, nombres, apellidos, nroDoc.Embedded user snapshot:
id, nombre, apellido, username.Timestamp when the sale was persisted (
@PrePersist).Example response
cURL
GET /api/ventas/{id}
Retrieve a single sale by its database ID. Returns404 if the sale does not exist.
GET http://localhost:8080/api/ventas/{id}
Authorization
Bearer token —
Authorization: Bearer <token>Path Parameters
The internal ID of the sale to retrieve.
Response 200 OK
Returns the same sale object shape as GET /api/ventas.
Error Codes
| Status | Error |
|---|---|
401 Unauthorized | Token missing, invalid, or expired. |
404 Not Found | "Venta no encontrada: {id}" |
cURL
POST /api/ventas
Register a new sale. The service resolves the authenticated user from the JWT, validates each line item’s stock availability, calculates subtotal/IGV/total, decrements stock for every product, and writes anInventario SALIDA movement — all within a single database transaction.
POST http://localhost:8080/api/ventas
Authorization
Bearer token — requires
ADMIN or VENDEDOR role.Request Body
ID of the customer associated with this sale.
Comprobante type. Accepted values:
BOLETA, FACTURA, TICKET.Optional free-text notes (e.g. payment terms, delivery instructions).
Line items array. Must contain at least one item (
@NotEmpty).IGV is always computed server-side at a fixed rate of 18%.
Do not send tax values in the request body; they will be ignored.
igv = subtotal × 0.18 — total = subtotal + igvDo not send tax values in the request body; they will be ignored.
Response 200 OK
Returns the persisted Venta object including the auto-generated numeroVenta and computed subtotal, igv, and total.
Error Codes
| Status | Meaning |
|---|---|
400 Bad Request | Validation failure or insufficient stock (see example below). |
401 Unauthorized | Token missing or invalid. |
403 Forbidden | Authenticated user does not have ADMIN or VENDEDOR role. |
404 Not Found | clienteId or any productoId does not exist. |
400 — Insufficient stock
cURL — 2-item sale
Response — 200 OK
PATCH /api/ventas/{id}/anular
Void an existing sale. The service restores stock for every line item and creates a correspondingInventario ENTRADA movement (reversal). The sale record is never deleted — its estado is set to ANULADA.
PATCH http://localhost:8080/api/ventas/{id}/anular
Authorization
Bearer token — requires
ADMIN role only.Path Parameters
ID of the sale to void.
Response 200 OK
Returns the updated Venta object with "estado": "ANULADA".
Error Codes
| Status | Meaning |
|---|---|
400 Bad Request | Sale is already in ANULADA state. |
401 Unauthorized | Token missing or invalid. |
403 Forbidden | User does not have ADMIN role. |
404 Not Found | Sale ID does not exist. |
cURL
Response — 200 OK