Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AdriP-maker/JAAR_Antigravity/llms.txt
Use this file to discover all available pages before exploring further.
Why gamification?
Rural water boards depend on two pillars: consistent monthly fees and community labor (jornales). SIMAP Digital’s points engine creates positive reinforcement for both. Instead of relying solely on fines and service cuts, the system rewards residents who pay on time and show up to community workdays. This transforms collection dynamics from purely punitive to a blend of incentives and accountability that rural Juntas have found culturally effective. The points system is defined in RF-19 and RF-20 of the SIMAP requirements spec and is implemented insrc/services/puntosService.js.
How points are earned
Every qualifying action writes aganancia record to the puntos_historial table in the local IndexedDB store. The table below lists all earning events:
| Event | Points awarded |
|---|---|
| Basic monthly payment | 2 pts |
| Punctual payment (paid before the 15th) | 5 pts |
| Multi-month or advance payment | 10 pts per extra month covered |
| Personal jornal attendance | 8 pts |
| Substitute attendance | 3 pts |
| Jornal confirmation submitted in advance | 2 pts |
| Full quarter with zero fines | 15 pts |
| Full calendar year paid without gaps | 30 pts |
Redemption rules
Points convert to Balboa discounts at a fixed rate:- 1 point = B/.0.01 (one centavo)
- Minimum redemption: 10 points (= B/.0.10)
- Maximum discount per month: 150 points (= B/.1.50)
Important — commission integrity (RF-20): The cobrador’s commission is always calculated on the full tariff, not on the discounted amount after points are applied. A resident who redeems B/.1.50 in points off a B/.3.00 bill still generates the full B/.3.00 commission basis. This protects cobrador earnings while rewarding residents.
Utility functions
Two pure functions inpuntosService.js handle the conversion math:
CobroModal.jsx to compute the live discount preview as the cobrador toggles the “Usar puntos” checkbox.
How to redeem: the CobroModal flow
Redemption happens inside the payment modal (src/components/cobros/CobroModal.jsx). The cobrador opens the modal for a resident who has a positive points balance and follows these steps:
Open the Cobro Modal
From the
/cobros screen, tap the resident’s row. The modal loads their payment summary and fetches their current points balance via obtenerSaldoPuntos(userId).Review the points banner
If the resident has any points, a gold banner appears beneath the payment-type tabs:
🌟 Tienes 120 Puntos SIMAP — Equivale a B/.1.20 de descuento.The discount amount is calculated live using
calcularDescuentoBalboas(puntos).Toggle 'Usar puntos'
The cobrador checks the Usar puntos checkbox. The final amount displayed in the cobro total updates immediately — the discount is subtracted from
montoFinal before it is shown:Core service functions
The puntos_historial table
All point activity lives in a single append-only table in the local IndexedDB (Dexie.js) store. There are exactly two transaction types:
tipo_transaccion | Meaning |
|---|---|
ganancia | Points earned — added to the running balance |
canje | Points redeemed — subtracted from the running balance |
The live points balance (
obtenerSaldoPuntos) is computed by iterating all puntos_historial rows for a resident and summing ganancia entries while subtracting canje entries. There is no cached “balance” column — the ledger is the source of truth. This design is intentional: it keeps the history immutable and tamper-evident, consistent with SIMAP’s broader audit philosophy.Admin configuration
The administrator can tune the incentive system from ConfigPage (/puntos-admin, accessible to the admin role). The relevant fields in the “Reglas de Fidelidad (Puntos)” card are:
| Config field | Default | Description |
|---|---|---|
puntosPorPagoPuntual | 10 | Points granted for an on-time payment |
puntosRequeridosDescuento | 100 | Points threshold required to unlock a redemption |
descuentoGenerado | B/.3.00 | Balboa value of the discount applied when a resident redeems |
saveConfig() to the local store and synced to Supabase when the device comes online. The ConfigPage validates that commission splits (splitDevs + splitCobrador) always equal exactly 1.0 (100%) before saving.