Skip to main content

Documentation 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.

The financial ledger in Comunidades Vecinos is built from 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

The TipoMovimiento 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

FieldColumnTypeDescription
idid_movimientoLong (auto)Primary key
nombrenombreStringDescription / concept of the movement
comunidadid_comunidad (FK)ComunidadThe community this movement belongs to
usuarioid_usuario (FK, nullable)UsuarioResident linked to the movement (null for expenses)
fechafechaLocalDateDate of the movement
importeimporteBigDecimalAmount in euros (always positive)
tipotipoTipoMovimiento enumGASTO or INGRESO
reciboid_recibo (FK, nullable)ReciboThe receipt that originated this movement, if any

Linking a Receipt Payment to a Movement

When an ADMIN records an INGRESO 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.
ADMIN creates INGRESO Movimiento
    │  (with recibo reference in body)

Movimiento saved ──────────────► Receipt marked PAGADO
                                    via reciboService.marcarPagado()
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 creating GASTO movements directly:
POST /api/movimientos
Authorization: Bearer <admin_token>
Content-Type: application/json
{
  "nombre": "Reparación portal principal",
  "fecha": "2025-06-15",
  "importe": 850.00,
  "tipo": "GASTO"
}
The community is resolved from the JWT — do not include it in the request body. The usuario and recibo fields are optional and can be omitted for pure expenses.

Querying Movements

GET /api/movimientos/comunidad
Authorization: Bearer <user_or_admin_token>
Returns all movements for the authenticated user’s community. Available to both USER and ADMIN. This is the data source for the CuentasPage frontend, which groups movements by year and month and calculates a running balance.
[
  {
    "id": 101,
    "nombre": "Cuota ordinaria mayo 2025 - María García",
    "fecha": "2025-05-03",
    "importe": 105.00,
    "tipo": "INGRESO",
    "usuario": { "nombre": "María", "apellidos": "García López" },
    "recibo": { "id": 47, "estadoRecibo": "PAGADO" }
  },
  {
    "id": 98,
    "nombre": "Empresa limpieza — mayo",
    "fecha": "2025-05-01",
    "importe": 320.00,
    "tipo": "GASTO",
    "usuario": null,
    "recibo": null
  }
]

Dashboard Balance

The CuentasPage frontend calculates three summary figures from the movement list returned by GET /api/movimientos/comunidad:
MetricCalculation
Total IngresadoSum of importe for all INGRESO movements
Total GastadoSum of importe for all GASTO movements
Saldo ActualTotal Ingresado − Total Gastado
Movements are then grouped by calendar year and month, each month showing its own income, expense, and net balance line, collapsed in an accordion for easy navigation.

Access Control Summary

ActionUSERADMINSUPER_ADMIN
Read community movements
Read own movements
Read movement by ID
Create a movement
Read all movements (global)
Delete a movement
Movements cannot be deleted by any role. Once a financial record is created — whether automatically (from a paid receipt) or manually (an expense entry) — it is permanent. This is a deliberate design decision to preserve the integrity of the community’s accounting history.

Build docs developers (and LLMs) love