The treasury module gives you a global, cross-invoice view of every due date (vencimiento) in your company. Rather than navigating invoice by invoice, you can see all pending, overdue, and collected instalments in one place, register payments directly, and group vencimientos from different invoices into a single collection event — ideal for remesas and batch payment runs. The module also provides an aggregated cash-flow summary for financial forecasting.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eme2dev/Eme2App/llms.txt
Use this file to discover all available pages before exploring further.
What the Treasury Module Covers
Thefacturas_vencimientos table is the backbone of the treasury view. Each row represents one instalment of an invoice’s payment schedule, generated automatically when an invoice is confirmed. Treasury adds a layer on top:
- Global listing — filter vencimientos across all invoices by date range, state, and client.
- Inline editing — update date, amount, notes, or payment instrument on a pending vencimiento without going back into the invoice.
- Direct cobro registration — register a payment against any vencimiento directly from the treasury view.
- Grouping — consolidate multiple vencimientos (from different invoices) under a single agrupador vencimiento for one-shot collection.
- Cash-flow summary — aggregated view of pending, collected, and overdue amounts.
Cash-Flow Summary
GET /api/tesoreria/resumen
Returns aggregated cash-flow data for the authenticated company.
Listing Vencimientos
GET /api/tesoreria/vencimientos
Returns the full list of due dates, optionally filtered. All filters are query parameters:
| Parameter | Description | Example |
|---|---|---|
fecha_desde | Start of date range | 2025-06-01 |
fecha_hasta | End of date range | 2025-06-30 |
estado_vencimiento | Filter by vencimiento state | pending / cobrado / partial / overdue |
estado_factura | Filter by the parent invoice’s state | confirmada / borrador |
cliente_id | Filter by client UUID |
| Estado | Meaning |
|---|---|
pending | Awaiting payment, not yet due |
partial | Partially collected; a remainder vencimiento has been created |
cobrado | Fully collected |
overdue | Past fecha_vencimiento with no payment |
Inline Editing of Vencimientos
PATCH /api/tesoreria/vencimientos/:id
Edit a pending vencimiento’s date, amount, notes, or payment instrument without opening the invoice. Only pending vencimientos are editable.
Registering a Cobro
POST /api/tesoreria/cobros
Register a payment against a specific vencimiento. The instrumento_id (payment instrument) is mandatory.
Required fields:
| Field | Type | Notes |
|---|---|---|
vencimiento_id | string (UUID) | The vencimiento being paid |
importe | number | Amount paid — must be > 0 and ≤ vencimiento amount |
fecha_pago | string | Payment date (YYYY-MM-DD) |
instrumento_id | string (UUID) | Active payment instrument |
fecha_vencimiento_resto (required for partial payments), notas.
importe is less than the full vencimiento amount, you must also supply fecha_vencimiento_resto. The backend marks the current vencimiento as partial and creates a new vencimiento for the remainder:
Reverting a Cobro
POST /api/tesoreria/vencimientos/:id/revertir-cobro
Undoes all cobros linked to a vencimiento and restores it to pending state. Use this to correct a mistakenly registered payment.
Grouping Vencimientos
POST /api/tesoreria/cobros/agrupar
Consolidate two or more vencimientos (from any invoices, same client or different) into a single collection event. This creates an agrupador vencimiento — a virtual due date that represents the combined amount — and links all child vencimientos to it via agrupador_id.
Required fields:
| Field | Type | Notes |
|---|---|---|
vencimiento_ids | string[] | At least two vencimiento UUIDs |
importe | number | Total amount of the grouped collection |
fecha_vencimiento | string | Due date for the group |
instrumento_id, notas.
Viewing Grouped Children
GET /api/tesoreria/vencimientos/:id/hijos
Returns all vencimientos that belong to a given agrupador:
Ungrouping Vencimientos
POST /api/tesoreria/vencimientos/:id/desagrupar
Dissolves a group by removing agrupador_id from all child vencimientos and deleting the agrupador row. The children return to pending and become individually editable again.
If the agrupador vencimiento already has a cobro registered, the cobro must be reverted before ungrouping is possible. Attempting to ungroup with an active cobro returns a
400 error.Payment Instruments (Instrumentos de Pago)
Payment instruments (instrumentos_pago) define the means of collection — bank transfer, direct debit, cheque, card, etc. They are referenced by both facturas_vencimientos (expected instrument) and cobros (actual instrument used).
Each instrument has:
| Field | Description |
|---|---|
nombre | Descriptive name (e.g. "Transferencia bancaria") |
codigo | Short code (e.g. "TRF") |
remesable | If true, the instrument supports batch remittance files |
activo | Only active instruments can be assigned to vencimientos or cobros |
empresa_id | Company-scoped, or null for system-wide defaults |
activo = false will be rejected when registering a cobro.
Typical Treasury Workflow
Review upcoming due dates
Call
GET /api/tesoreria/vencimientos?estado_vencimiento=pending&fecha_hasta=2025-06-30 to see all payments due before month end.Check the cash-flow summary
Call
GET /api/tesoreria/resumen to compare pending inflows against overdue amounts.Optionally group vencimientos
If several clients are paying via the same remesa run, call
POST /api/tesoreria/cobros/agrupar to consolidate them into one collection event.Register each cobro
As payments are received, call
POST /api/tesoreria/cobros with the vencimiento_id, importe, fecha_pago, and instrumento_id.Handle partial payments
For short payments, include
fecha_vencimiento_resto in the cobro body. A remainder vencimiento is created automatically for the unpaid balance.API Quick Reference
| Method | Endpoint | Description |
|---|---|---|
GET | /api/tesoreria/resumen | Cash-flow summary (pending, collected, overdue) |
GET | /api/tesoreria/vencimientos | Filterable global due-date list |
PATCH | /api/tesoreria/vencimientos/:id | Inline-edit a pending vencimiento |
POST | /api/tesoreria/cobros | Register a cobro against a vencimiento |
POST | /api/tesoreria/vencimientos/:id/revertir-cobro | Revert all cobros on a vencimiento |
POST | /api/tesoreria/cobros/agrupar | Group vencimientos into one collection event |
GET | /api/tesoreria/vencimientos/:id/hijos | List children of an agrupador vencimiento |
POST | /api/tesoreria/vencimientos/:id/desagrupar | Dissolve a vencimiento group |