Upload and validation
Expense sources
Expenses in Contafy can originate from:- XML upload - CFDI expense receipts from suppliers (
tipo_origen: 'XML') - Manual entry - Manually created expense records (
tipo_origen: 'MANUAL')
CFDI expense types
Like invoices, expenses support all Mexican CFDI payment types:- PUE - Paid in full at time of expense
- PPD - Deferred or partial payment
- COMPLEMENTO_PAGO - Payment complements referencing PPD expenses
Validation process
- RFC matching (receptor should match profile RFC)
- Tax regime compatibility
- UUID uniqueness
- Profile-specific validation rules
Manual expense entry
Manual expenses allow you to track costs without formal CFDI receipts.Requirements
- A specific profile must be selected (not “Todas las empresas”)
- The period must have a valid period_id
- Period cannot be “aggregated”
Manual expense fields
- Concept - Description of the expense
- Subtotal - Base amount before tax
- IVA amount - Value-added tax (optional)
- Date - When the expense occurred
- Category - Optional expense categorization
Payment status tracking
Manual expenses include payment tracking:is_paid- Boolean indicating if expense has been paidpayment_date- Date when expense was paid (nullable)
Manual expenses have
uuid: null and tipo_origen: 'MANUAL'. They appear alongside XML-based expenses in the expenses list with a “Manual” badge.Automatic payment status
For XML-based expenses, Contafy calculates payment status automatically:- Links payment complements to parent PPD expenses
- Calculates cumulative payments
- Tracks outstanding balance
- Determines payment percentage
Expense list interface
Filtering and search
The expenses page supports:- Profile selector - View specific business or aggregate view
- Month/year selection - Filter by time period
- Régimen fiscal filter - Filter by tax regime
- Text search - Search across expense fields
- Pagination - 10 expenses per page with TanStack Query
Summary metrics
The expenses page displays:- Total expenses - Count of all expenses in the period
- Total egresos devengados - Sum of accrued expenses
- Gastos pendientes de pago - Count of unpaid/partially paid expenses
Expense metrics are calculated from the PeriodMetricsResponse which includes both cash flow (pagados) and accrual (devengados) metrics.
Data table columns
- Date and concept/description
- Emisor (supplier) information
- Total amount with tax breakdown
- Payment type (PUE/PPD/COMPLEMENTO_PAGO)
- Payment status badge
- Origin badge (XML or Manual)
- Actions menu
Bulk upload
The expense upload interface (/dashboard/expenses/upload) provides:
Upload features
- Drag-and-drop zone for XML files
- Multiple file selection
- Profile selection dropdown
- Upload queue with real-time progress
- Validation feedback per file
- “Did You Know” educational cards
Upload workflow
- Navigate to “Subir gastos”
- Select the profile to associate expenses with
- Drop or select expense XML files
- Review files in queue
- Start upload
- View validation results
Tax information extraction
Contafy extracts comprehensive tax data from CFDI expenses:- IVA trasladado (iva_amount) - Input VAT, eligible for credit
- Retención IVA (retencion_iva_amount) - VAT withheld
- Retención ISR (retencion_isr_amount) - Income tax withheld
Subscription limits
Expense tracking respects subscription plan limits:- The
ExpensesPageClientcomponent checksexpensesUsedagainst plan limits - Users see warnings when approaching limits
- Upload is restricted when limits are reached
Accrued expenses API
Manual expenses use a separate API endpoint (/api/accrued-expenses):
- POST - Create new manual expense
- PUT - Update manual expense (including payment status)
- DELETE - Remove manual expense
- GET - List manual expenses for a period
Update example
Related features
Dashboard
View expense metrics on the main dashboard
Multi-Profile
Track expenses across multiple businesses
Reports & Analytics
Generate expense reports and analysis