The financial ledger in Comunidades Vecinos is built fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/GuillermoNavarro/Proyecto_comunidades/llms.txt
Use this file to discover all available pages before exploring further.
Movimiento records. Every euro that enters or leaves the community is captured as a movement with a type, a date, an amount, and an optional link to the resident and receipt that originated it. The ledger is append-only: movements can be created but never deleted, which preserves a complete and tamper-proof financial history.
Movement Types
TheTipoMovimiento enum contains two values:
INGRESO
Income. Created by an ADMIN to record a payment. When the movement includes a
recibo reference, the service automatically marks that receipt as PAGADO. Can also be created without a receipt for non-fee income such as grants or room rentals.GASTO
Expense. Created manually by an ADMIN to record community expenditure — maintenance work, cleaning services, insurance premiums, utilities, etc. The
usuario and recibo fields are null for expense movements.The Movimiento Entity
| Field | Column | Type | Description |
|---|---|---|---|
id | id_movimiento | Long (auto) | Primary key |
nombre | nombre | String | Description / concept of the movement |
comunidad | id_comunidad (FK) | Comunidad | The community this movement belongs to |
usuario | id_usuario (FK, nullable) | Usuario | Resident linked to the movement (null for expenses) |
fecha | fecha | LocalDate | Date of the movement |
importe | importe | BigDecimal | Amount in euros (always positive) |
tipo | tipo | TipoMovimiento enum | GASTO or INGRESO |
recibo | id_recibo (FK, nullable) | Recibo | The receipt that originated this movement, if any |
Linking a Receipt Payment to a Movement
When an ADMIN records anINGRESO movement and includes a recibo reference in the request body, the service automatically marks that receipt as PAGADO. This means the community ledger and the receipt status are kept in sync: creating the movement is the single action that records both the income and the payment.
Only movements of type
INGRESO may carry a recibo reference. Attempting to attach a receipt to a GASTO movement returns 400 Bad Request from the service layer.Manual Expense Entry
ADMINs record community expenses by creatingGASTO movements directly:
usuario and recibo fields are optional and can be omitted for pure expenses.
Querying Movements
- Community ledger
- My movements
- Movement by ID
- All movements (SUPER_ADMIN)
USER and ADMIN. This is the data source for the CuentasPage frontend, which groups movements by year and month and calculates a running balance.Dashboard Balance
TheCuentasPage frontend calculates three summary figures from the movement list returned by GET /api/movimientos/comunidad:
| Metric | Calculation |
|---|---|
| Total Ingresado | Sum of importe for all INGRESO movements |
| Total Gastado | Sum of importe for all GASTO movements |
| Saldo Actual | Total Ingresado − Total Gastado |
Access Control Summary
| Action | USER | ADMIN | SUPER_ADMIN |
|---|---|---|---|
| Read community movements | ✅ | ✅ | ✅ |
| Read own movements | ✅ | ✅ | — |
| Read movement by ID | — | ✅ | — |
| Create a movement | — | ✅ | ✅ |
| Read all movements (global) | — | — | ✅ |
| Delete a movement | ❌ | ❌ | ❌ |