Skip to main content

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.

The Reports module (/reporte) is the primary interface for MINSA inspectors and the financial transparency tool for admins and collectors. It reads directly from the local IndexedDB store, so every report can be generated fully offline without any server connection.
RoleAccess Level
minsaPrimary user — redirected here automatically on login, read-only
cobradorSecondary — can view and export financial summaries
adminSecondary — full access to reports and export

Route

/reporte
The ROLE_HOME constant in src/utils/constants.js maps the minsa role directly to this route:
export const ROLE_HOME = {
  admin:    '/admin',
  cobrador: '/cobros',
  minsa:    '/reporte',   // Inspector lands here automatically
  cliente:  '/historial',
  dev:      '/admin',
};

Dashboard Metrics

The page surfaces four live summary cards populated via Dexie useLiveQuery hooks:
CardCalculation
Ingresos (Pagos)Sum of all pagos.monto values (fallback: B/.3.00 per record)
Egresos (Gastos)Sum of all gastos.monto values
Balance NetototalIngresos − totalEgresos
ComunidadCount of all entries in db.usuarios
All values are formatted in Panamanian balboa (B/.) using formatMonto() from src/utils/formatters.js.

Export: Excel (.xlsx)

The Excel export uses SheetJS (xlsx), bundled locally so it works without internet. The exported workbook contains two sheets:
#Sheet NameContents
1IngresosAll payment records with date, type, and amount
2EgresosAll expense records with date, description, and amount
import * as XLSX from 'xlsx';

const wb = XLSX.utils.book_new();

const ingresosData = pagos.map(p => ({
  Fecha:   formatFecha(p.fecha),
  Detalle: `Pago ${p.tipo || 'Cuota'}`,
  Monto:   parseFloat(p.monto) || 3
}));

const wsIngresos = XLSX.utils.json_to_sheet(ingresosData);
wsIngresos['!cols'] = [{ wch: 15 }, { wch: 30 }, { wch: 15 }];
XLSX.utils.book_append_sheet(wb, wsIngresos, "Ingresos");

const egresosData = gastos.map(g => ({
  Fecha:   formatFecha(g.fecha),
  Detalle: g.descripcion || 'Gasto',
  Monto:   parseFloat(g.monto) || 0
}));

const wsEgresos = XLSX.utils.json_to_sheet(egresosData);
wsEgresos['!cols'] = [{ wch: 15 }, { wch: 40 }, { wch: 15 }];
XLSX.utils.book_append_sheet(wb, wsEgresos, "Egresos");

XLSX.writeFile(wb, `Reporte_SIMAP_${new Date().toISOString().split('T')[0]}.xlsx`);
Filename format: Reporte_SIMAP_YYYY-MM-DD.xlsx

Export: PDF

The PDF export uses jsPDF + jsPDF-autotable, also bundled locally.
import jsPDF from 'jspdf';
import autoTable from 'jspdf-autotable';

const doc = new jsPDF();

doc.setFontSize(18);
doc.text("Junta Administradora de Acueducto Rural (SIMAP)", 14, 20);
doc.text(`Reporte Financiero Oficial`, 14, 28);
doc.text(`Fecha de Corte: ${new Date().toLocaleDateString()}`, 14, 34);

autoTable(doc, {
  startY: 50,
  head: [['Fecha', 'Detalle', 'Monto']],
  body: ingresosBody,
  theme: 'grid',
  styles: { fontSize: 10 }
});

// Signature line
doc.text("_________________________", 14, finalY + 60);
doc.text("Firma del Presidente / Tesorero", 14, finalY + 66);

doc.save(`Reporte_SIMAP_${new Date().toISOString().split('T')[0]}.pdf`);
The PDF includes:
  • Institution header with report date
  • Resumen de Ingresos table with grid theme
  • Resumen de Egresos table appended below
  • Summary totals (Total Ingresos, Total Egresos, Saldo a Favor in bold)
  • Signature line for the President / Treasurer
Filename format: Reporte_SIMAP_YYYY-MM-DD.pdf

Report Data Sources

The export pulls data from two Dexie tables:

Ingresos

All pagos records, drawn from db.pagos:
FieldSourceDescription
fechapagos.fechaDate of payment
tipopagos.tipoPayment type (e.g., mensual, parcial, multi_mes)
montopagos.montoAmount paid in B/. (fallback: 3.00)

Egresos

All gastos records, drawn from db.gastos:
FieldSourceDescription
fechagastos.fechaDate of expense
descripciongastos.descripcionDescription of the expense
montogastos.montoAmount in B/.

MINSA Inspector Workflow

The following scenario matches Escenario 4 from the project requirements (docs/requisitos.md):
1

Log in as minsa

Use credentials minsa / 1234. The system authenticates via authService.js and reads the ROLE_HOME mapping.
2

Automatic redirect to /reporte

The router guard detects the minsa role and redirects immediately to /reporte — no navigation required.
3

Review dashboard metrics

The four summary cards (Ingresos, Egresos, Balance Neto, Comunidad) update live via useLiveQuery, giving an instant financial snapshot without any interaction.
4

Download Excel or PDF

  • Click 📊 Descargar Excel to download the 2-sheet workbook (Reporte_SIMAP_2026-03-31.xlsx) containing Ingresos and Egresos sheets.
  • Click 📄 Descargar PDF Oficial to download a formatted PDF with signature line.

Offline Report Generation

Reports are generated entirely from local IndexedDB data via Dexie.js — no network request is made during export. A MINSA inspector can download a complete Excel or PDF report even when the device has no internet connection, as long as the data has been synced at least once beforehand. Both the SheetJS and jsPDF libraries are bundled locally in the app.

Export Libraries Reference

LibraryVersionPurposeBundle
xlsx (SheetJS)included locally.xlsx multi-sheet workbook generationLocal
jspdfnpm packagePDF document creationBundled
jspdf-autotablenpm packageAuto-formatted tables in PDFBundled

Build docs developers (and LLMs) love