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.

Fee management sits at the heart of Comunidades Vecinos. When an ADMIN creates a fee (Cuota), the platform automatically generates individual receipts (Recibo) for every active resident in the community, applying each resident’s ownership share (coeficiente) to calculate the exact amount due. This eliminates manual data entry and ensures every resident always has a corresponding payment record.

Fee Types

The TipoCuota enum defines three kinds of fees:

ORDINARIA

Regular recurring fee. Used for monthly or quarterly community charges that apply to all residents equally in proportion to their coeficiente. Example: monthly maintenance contribution.

EXTRAORDINARIA

One-time special assessment. Applied to the whole community for unplanned expenses such as a major repair or emergency fund top-up. Receipts are still generated for every active resident based on their coeficiente.

INDIVIDUAL

Single-resident charge. Assigned to one specific user, bypassing the community-wide distribution. The full importe of the fee is assigned to that resident (equivalent to a coeficiente of 100%). Requires the ?idUsuario= query parameter on creation.

The Cuota Entity

FieldColumnTypeDescription
idid_cuotaLong (auto)Primary key
nombrenombreStringDescriptive name of the fee
fechaEmisionfecha_emisionLocalDateDate the fee was issued
fechaVencimientofecha_vencimientoLocalDatePayment due date
importeimporte_totalBigDecimalTotal fee amount in euros
tipotipoTipoCuota enumORDINARIA, EXTRAORDINARIA, or INDIVIDUAL
comunidadid_comunidad (FK)ComunidadThe community this fee belongs to

The Recibo Entity

FieldColumnTypeDescription
idid_reciboLong (auto)Primary key
cuotaid_cuota (FK)CuotaThe fee this receipt belongs to
comunidadid_comunidad (FK)ComunidadThe community
usuarioid_usuario (FK)UsuarioThe resident charged
importeimporteBigDecimalAmount due from this specific resident
estadoReciboestadoEstadoRecibo enumPENDIENTE or PAGADO

Receipt States

PENDIENTE  ──(admin marks as paid)──►  PAGADO
Receipts are marked as PAGADO when an ADMIN creates an INGRESO financial movement and links it to a receipt. The movement service calls marcarPagado on the receipt at save time. See Finances for details on how this feeds the community ledger.

How Receipt Generation Works

1

Admin creates a fee

The ADMIN calls POST /api/cuotas with the fee details. For INDIVIDUAL fees, the target user ID is passed as ?idUsuario={id}.
POST /api/cuotas?idUsuario=12
Authorization: Bearer <admin_token>
Content-Type: application/json
{
  "nombre": "Derrama ascensor julio 2025",
  "fechaEmision": "2025-07-01",
  "fechaVencimiento": "2025-07-31",
  "importe": 2400.00,
  "tipo": "EXTRAORDINARIA"
}
2

Backend calculates per-resident amounts

For ORDINARIA and EXTRAORDINARIA fees, the service iterates over all active users in the community. Any user with a null or zero coeficiente is skipped. Each receipt’s importe is:
importe_recibo = importe_cuota × coeficiente / 100
For an INDIVIDUAL fee, coeficiente is treated as 100, so the receipt amount equals the full importe of the fee.
3

Receipts are persisted

One Recibo record is saved per eligible resident, with estadoRecibo = PENDIENTE. The receipts are immediately visible to the ADMIN and to each individual resident.

Example: fee for a 3-resident community

// POST /api/cuotas — creating an ORDINARIA fee of €300
{
  "nombre": "Cuota ordinaria junio 2025",
  "fechaEmision": "2025-06-01",
  "fechaVencimiento": "2025-06-30",
  "importe": 300.00,
  "tipo": "ORDINARIA"
}
Automatically generated receipts:
ResidentcoeficienteReceipt importeState
María García (3B)35.0105.00 €PENDIENTE
Carlos Ruiz (1A)40.0120.00 €PENDIENTE
Ana Torres (2C)25.075.00 €PENDIENTE

Querying Receipts

GET /api/recibos/me
Authorization: Bearer <user_token>
Returns all receipts for the authenticated user, regardless of state. Available to USER and ADMIN. The frontend RecibosPage uses this endpoint to display the resident’s payment history and outstanding balance.

Fee Lifecycle and Constraints

Modifying a fee

Fees can be updated via PUT /api/cuotas/{id}. If the importe changes, the service automatically deletes all existing receipts for that fee and regenerates them with the new amount. Modifications are blocked if any receipt has already been linked to a financial movement (i.e., at least one payment has been recorded).

Deleting a fee

DELETE /api/cuotas/{id} deletes the fee and all its associated receipts. Deletion is blocked if any movement references a receipt from that fee, preserving financial history integrity.
A fee cannot be modified or deleted once any of its receipts has been marked as paid and a corresponding financial movement exists. This safeguard prevents retroactive changes to the community’s accounting ledger.

Build docs developers (and LLMs) love