The sales API processes point-of-sale transactions atomically — stock is decremented and the DTE is generated in a single operation. Sales can be registered by ADMIN and CAJERO roles, restricted to their assigned branch.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 DTE (electronic invoice) is sent to Hacienda asynchronously after the sale is created. If the submission fails, the sale is not rolled back — the
estado field on the returned factura will be SIMULADO or ERROR_HACIENDA, and you can retry with POST /api/dte/:id/reenviar.POST /api/ventas
Creates a sale, decrements stock for each item in the branch, and triggers DTE generation. Roles: ADMIN, CAJEROBody
ID of the branch where the sale takes place. Non-admin users must belong to this branch.
Line items in the sale. Must contain at least one entry.
Customer name for the invoice.
Payment method. Free-form string (e.g.,
"efectivo", "tarjeta").Response 201
Always
true on success.The created
FacturaDte record, including line item details and branch information.Calculated sale totals.
Errors
| Status | Condition |
|---|---|
| 400 | Request body fails Zod validation (missing fields, wrong types). |
| 404 | One or more productoId values do not exist or are inactive. |
| 409 | Insufficient stock in the branch, or cantidad is fractional for a UNIDAD/LOTE product. |
| 500 | Unexpected server error. |
Example
GET /api/ventas/:id/ticket
Retrieves the full ticket data for an existing invoice, suitable for reprinting at the POS. Roles: ADMIN, CAJEROPath parameters
ID of the invoice (
FacturaDte) to retrieve.Response 200
Invoice ID.
UUID assigned during DTE generation.
Hacienda control number.
ISO 8601 timestamp of when the sale was created.
Branch information.
Name of the user who processed the sale, or
"Sistema" if not available.Customer name on the invoice.
DTE type code (e.g.,
"01").Current DTE state.
Line items on the ticket.
The full DTE JSON payload submitted to Hacienda, or
null if not yet generated.GET /api/ventas/estadisticas/semanales
Returns aggregated daily sales totals for a rolling window of up to 14 days. ADMIN users see totals across all branches; other roles see only their assigned branch. Roles: ADMIN, CAJERO, BODEGAQuery parameters
Number of days to include in the window. Must be between 1 and 14.
Response
One entry per day in the requested window, ordered chronologically.
Sum of all
total values across the entire window.Total number of individual sales across the window.