The Compras API handles stock procurement — recording purchases from suppliers, updating inventory levels, and optionally registering the cash outflow through the active cash register session. When a purchase is submitted, the system automatically incrementsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt
Use this file to discover all available pages before exploring further.
stock_actual and updates costo_compra for each product in the order. If pagar_con_caja is set to true, an EGRESO cash movement is automatically created on the specified session, keeping the cash register balance accurate without manual intervention.
All endpoints require a valid
Authorization: Bearer <access_token> header.Create a Purchase
total automatically (sum of cantidad × costo_unitario for each line item), increments stock_actual on each referenced product, and updates the product’s costo_compra to reflect the latest unit cost paid.
Side Effects
- Inventory update:
stock_actual += cantidadandcosto_compra = costo_unitarioare applied to each product indetalles. - Cash movement (conditional): If
pagar_con_caja: true, anEGRESOMovimientoCajais automatically created onid_sesion_cajafor the purchase total. Requires an active (ABIERTA) session.
Request Body
Name of the supplier or store where goods were purchased (e.g.,
"Proveedor Central"). Optional but recommended for record-keeping.Set to
true to deduct the purchase total from the active cash register session. Set to false if the purchase was paid externally (bank transfer, credit, etc.).ID of the active session to deduct from. Required when
pagar_con_caja is true.Array of purchase line items. Each must include
id_producto, cantidad, and costo_unitario.ID of the product being restocked.
Number of units received. Minimum
1.Cost paid per unit. Minimum
0. This value is written back to the product’s costo_compra.ID of the user recording the purchase (audit trail).
Example Request
Response
Returns the createdCompra object with all line items.
Unique identifier of the purchase record.
Auto-calculated sum of all line item subtotals (
cantidad × costo_unitario).Supplier name if provided.
true if the purchase was deducted from a cash register session.Session ID used for deduction, or
null if not paid via caja.ISO 8601 timestamp of the purchase.
Array of line items, each with calculated
subtotal and nested producto data.List All Purchases
detalles array (line items) and the nested producto object for each item — useful for displaying the complete purchase journal.
TypeScript Interfaces
Automatic EGRESO Movement: When
pagar_con_caja: true, the system creates a MovimientoCaja of type EGRESO on the referenced session for the full purchase total. This movement appears in the session’s balance and is reflected in the closing monto_final_teorico. You do not need to call POST /cajas/movimiento separately.