CafeteriaPM tracks two financial flows: sales (revenue from completed orders) and expenses (operational costs such as supplies, utilities, or miscellaneous costs). The cashier role processes payments and logs expenses; the admin role can view all financial data and export reports. Both flows are time-stamped and filterable by date range, making end-of-day reconciliation and monthly reporting straightforward.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
Processing a Sale
To charge an order, a cashier callsPOST /ventas/. The order must already be in either listo or entregado state — the API rejects payment attempts on orders in any other state.
What happens internally:
- The API validates that the order exists and is in
listoorentregado - It checks that the order has not already been paid (no existing
ventasrecord) - It validates the provided
id_metodo_pago monto_totalis calculated by summing all line itemsubtotalvalues from the order- A
Ventarecord is created in theventastable - The order state is automatically transitioned to
pagadoand recorded inhistorial_estados_pedido
| Field | Type | Description |
|---|---|---|
id_pedido | integer | The order being charged |
id_metodo_pago | integer | Payment method ID (see GET /ventas/metodos-pago) |
monto_recibido | decimal | (optional) Amount handed over by the customer |
cambio (change due) calculated as monto_recibido - monto_total. If monto_recibido is not provided (common for card or digital payments), cambio will be null.
A successful response returns 201 Created with the full sale record.
Payment Methods
Available payment methods are seeded into themetodos_pago table during setup. To retrieve the current list, call:
id value in POST /ventas/. This endpoint is accessible to any authenticated user.
Listing Sales
GET /ventas/ returns the sales history, ordered newest-first. Roles: admin, caja.
Optional query parameters:
| Parameter | Type | Description |
|---|---|---|
fecha_inicio | string | ISO date string — include sales on or after this date |
fecha_fin | string | ISO date string — include sales on or before this date |
- Order ID
- Cashier name
- Payment method name
monto_total— calculated order totalmonto_recibido— amount provided by the customercambio— change returnedfecha— payment timestamp
GET /ventas/{venta_id} (any authenticated user).
Recording Expenses
POST /gastos/ records an operational expense such as a gas purchase, utility payment, or supply cost. Roles: admin, caja.
| Field | Type | Description |
|---|---|---|
descripcion | string | Free-text description of the expense |
monto | decimal | Amount spent (must be > 0) |
id_categoria | integer | (optional) Category ID for grouping in reports |
fecha | date | Date the expense occurred (ISO date string) |
id_usuario). The category is optional but recommended — categorized expenses produce more meaningful breakdowns in financial reports.
Expense categories come from the same
categorias table used for products. The tipo column on each category ('producto', 'gasto', or 'ambos') is informational — the API does not enforce that only 'gasto' or 'ambos' categories are used for expenses. It only checks that the category ID exists. Ask your admin to create dedicated expense categories and use them consistently for accurate report breakdowns.GET /gastos/ lists all recorded expenses, ordered newest-first, and accepts the same fecha_inicio / fecha_fin query parameters as the sales list. Roles: admin, caja.
Financial Summary
Several stats endpoints aggregate sales and expense data for dashboards and reports.GET /stats/dashboard (admin, caja)Returns today’s key performance indicators:
GET /stats/resumen-mes (admin, caja)Returns month-to-date financial totals, calculated from the first day of the current month through today:
GET /stats/ventas-diarias?dias=7 (admin, caja)Returns an array of daily sales totals for the past
dias days (default: 7). Each item has fecha (formatted as DD/MM) and total. Useful for rendering sales trend charts.
GET /stats/gastos-diarios?dias=7 (admin, caja)Same structure as
ventas-diarias but for operational expenses. Both endpoints accept any integer value for dias.