Metrics API
All reports are powered by the/api/metrics endpoint which returns comprehensive period-based metrics:
Cash flow metrics (Flujo)
Real cash movements during the period:Cash flow components
- ingresos_cobrados - Total cash collected from invoices and payment complements
- egresos_pagados - Total cash paid out for expenses
- flujo_neto - Net cash flow (ingresos - egresos)
- sin_conciliar fields - Payment complements without linked PPD invoices/expenses
The “sin conciliar” (unreconciled) amounts help identify payment complements that couldn’t be matched to their parent PPD documents. These are still included in the totals but flagged for review.
Accrual metrics (Devengado)
Accounting metrics based on invoice/expense issue dates:- ingresos_devengados - Total invoices issued (regardless of payment status)
- egresos_devengados - Total expenses received (regardless of payment status)
- resultado_devengado - Estimated profit before taxes (ingresos - egresos)
Tax tracking (Impuestos)
Detailed tax breakdown with cash and accrual views:Tax metric categories
IVA trasladado (Sales VAT)
- Extracted from invoice
iva_amountfield - Tracked on both cash (cobrado) and accrual (devengado) basis
- VAT you charged to customers
IVA acreditable (Input VAT)
- Extracted from expense
iva_amountfield - VAT paid to suppliers that you can credit
- Critical for VAT return calculations
Retenciones (Withholdings)
- IVA and ISR withholdings from both invoices and expenses
- Tracked separately for accurate tax filing
- Includes
retencion_iva_amountandretencion_isr_amountfrom CFDI
Pending transactions (Pendientes)
Outstanding receivables and payables:- por_cobrar - Unpaid or partially paid invoices
- por_pagar - Unpaid or partially paid expenses
estadoPago of each invoice/expense.
Monthly report template
TheReporteMensualTemplate component generates comprehensive monthly reports:
Report sections
Cash flow section
- Visual cards showing ingresos cobrados, egresos pagados, flujo neto
- Progress bar for operating margin percentage
- Highlights negative cash flow with red styling
Pending transactions section
- Accounts receivable (por cobrar)
- Accounts payable (por pagar)
- Links to full invoice/expense lists
Accrual accounting section
- Income statement format
- Ingresos devengados, egresos devengados, resultado devengado
- Color-coded for positive/negative results
The monthly report can optionally include
estadoPorRegimen which breaks down the income statement by tax regime when a profile has multiple regimes.Report by tax regime
For profiles with multiple tax regimes, reports can show per-regime breakdown:- Régimen de Actividades Profesionales
- Arrendamiento
- Régimen de Incorporación Fiscal
- Other SAT regimes
PDF report generation
Reports are exported to PDF using jsPDF with custom templates:Invoice report
- Generated from
/dashboard/invoices/reporte/preview - Uses
ReporteFacturasTemplatecomponent - Includes invoice list with payment status
- Shows invoice metrics and tax breakdown
Expense report
- Generated from
/dashboard/expenses/reporte/preview - Uses
ReporteGastosTemplatecomponent - Lists expenses with categories
- Shows expense metrics and deductibility
Monthly consolidated report
- Generated from
/dashboard/reporte/preview - Uses
ReporteMensualTemplatecomponent - Comprehensive view of all financial activity
- Includes charts and trend analysis
Excel exports
Contafy also supports Excel export for data analysis:- Transaction lists (invoices/expenses) to XLSX
- Includes all fields from the database
- Filterable and sortable in Excel
- Compatible with accounting software import
Trend analysis
The trend API provides time-series data:Trend views
- año-actual - Current year month-by-month
- últimos-12-meses - Rolling 12-month window
- año-completo - Full calendar year
- comparar-anterior - Current year vs previous year comparison
Report filtering
All reports support comprehensive filtering:Filter dimensions
- Profile - Specific business or all businesses
- Time period - Month and year selection
- Tax regime - Filter by specific regime (when profile has multiple)
Aggregate reports
When “Todas las empresas” is selected:- Metrics sum across all profiles
- Profile column added to transaction lists
- Separate subtotals per profile
- Combined tax calculations
Export dashboard metrics
The dashboard includes an “Export PDF” button that generates a snapshot report:- All metric cards
- Trend chart as image
- Recent transactions tables
- Period information and filters applied
Related features
Dashboard
View real-time metrics and charts
Invoice Management
Data source for invoice reports
Expense Tracking
Data source for expense reports
Multi-Profile
Generate per-profile or aggregate reports
Metrics calculation notes
Cash vs Accrual
- Cash basis (flujo) uses payment date from complementos de pago
- Accrual basis (devengado) uses invoice/expense issue date (fecha)
- Both views are essential for complete financial picture
Period boundaries
- Metrics are calculated per calendar month
- Transactions assigned to month based on relevant date (issue or payment)
- Period IDs are UUIDs that map to specific profile + month + year