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.
pagosService is the core financial engine of SIMAP Digital. It writes payment records and saldo ledger entries directly to the local Dexie database, queues them in pendingSync for cloud upload, and maintains each resident’s payment status — all without requiring network connectivity.
getPaymentConfig()
Returns the current tariff configuration stored in the Dexie config table.
Monthly water fee in Panamanian balboas (B/.). Default:
3.00.Whether partial payments are enabled for this water board. Default:
true.Number of unpaid months before a resident’s status escalates to
'corte'. Default: 3.getCuotaDiaria()
Calculates the daily tariff by dividing the configured monthly fee by 30, then rounding.
number representing the daily fee in balboas, rounded to two decimal places (e.g., 0.10 for a B/.3.00 monthly rate).
Example
registrarPago(userId, opciones)
Main entry point for the CobrosPage. Registers a payment of any supported type, updates the Dexie saldos ledger, queues a pendingSync record, awards gamification points where applicable, and recalculates the resident’s status.
The unique identifier of the resident in the local Dexie
usuarios table.Payment type. One of:
| Value | Description |
|---|---|
mensual | Full payment for one calendar month (awards 5 points). |
diario | Partial payment calculated in daily increments. |
parcial | Arbitrary partial amount applied to a single month. |
multi_mes | One transaction covering multiple past or current months (awards 10 pts × months). |
adelanto | Pre-payment for future months starting next month (awards 10 pts × months). |
puesta_al_dia | Catches up all outstanding unpaid months in a single operation. |
Amount tendered in balboas. Required for
diario, parcial, multi_mes, and adelanto. Ignored for mensual and puesta_al_dia (which calculate the amount internally).Target month string (
'YYYY-MM') or array of month strings for multi_mes / adelanto. If omitted, the service generates the month list automatically from the current date.Optional free-text note attached to the receipt (e.g.,
'Cliente pagó con billete de 5').Recibo objects, one per month covered:
Auto-generated unique payment ID (
Date.now() + random).The resident’s ID as passed to
registrarPago.Rounded amount applied in this receipt (balboas).
ISO 8601 timestamp of when the payment was recorded.
The payment type string (mirrors
opciones.tipo).The
'YYYY-MM' string of the month this receipt is applied to.Array of all month strings covered by the transaction. For single-month types, this is a one-element array.
The note string passed in
opciones.nota, or an empty string.Email (or
'cobrador' fallback) of the logged-in collector, read from sessionStorage.Every call to
registrarPago also inserts a record into the Dexie pendingSync table. Those records are uploaded to Supabase the next time the device has connectivity and syncFromSupabase() is called.calcularEstado(userId)
Derives the current payment status of a resident by inspecting their saldos records in Dexie and comparing against the grace-period threshold from the board’s configuration.
The resident’s ID.
string — one of:
| Value | Meaning |
|---|---|
'activo' | Current month is fully paid and no prior months are outstanding. |
'parcial' | Current month has been partially paid. |
'moroso' | One or more months are unpaid but below the cut-off threshold. |
'corte' | Unpaid months ≥ mesesGraciaCorte (default 3) — service cut eligible. |
getDeudaTotal(userId)
Walks backwards through up to 36 months of saldos records to sum all outstanding balances, stopping at the first fully-paid month.
The resident’s ID.
number — the total unpaid balance in balboas, rounded to two decimal places. For months with no saldo record, the full cuotaMensual is added to the total.
Example
getMesesAdelantados(userId)
Counts how many consecutive future months — starting from the month after the current one — are already fully paid.
The resident’s ID.
number — count of advance-paid future months (0 if none). Stops counting at the first month that has no payment record.
Example
getResumenUsuario(userId)
Returns a complete financial summary for a resident in a single call. Internally it calls calcularEstado, getDeudaTotal, and queries the pagos table.
The resident’s ID.
Payment status:
'activo' | 'parcial' | 'moroso' | 'corte'.Total outstanding balance in balboas.
Number of consecutive months with unpaid or partial balances.
Number of future months already paid ahead of time.
ISO 8601 timestamp of the resident’s most recent payment, or
null if no payments exist.Total count of payment records for this resident.
hasPaidMonth(userId, mes)
Checks whether a resident has a fully-paid (estado === 'pagado') saldo record for a given month.
The resident’s ID.
Month string in
'YYYY-MM' format (e.g., '2025-07').true if a saldo record exists and saldo.estado === 'pagado'; false otherwise.
Example
getPagosUsuario(userId)
Retrieves the full payment history for a resident from the local Dexie pagos table.
The resident’s ID.
Recibo objects (see registrarPago for the full shape). Returns an empty array if no payments have been recorded.
Example
getPendingSyncCount()
Returns the number of payment records currently queued in the Dexie pendingSync table that have not yet been uploaded to Supabase.
number — count of pending sync records. Useful for displaying an offline-indicator badge in the UI.
Example
clearPendingSync()
Empties the Dexie pendingSync table entirely. Should only be called after all pending records have been successfully uploaded to Supabase.
void. Resolves once the table has been cleared.
Example