- Add export to Excel button with xlsx library for filtered data
- Add keyboard shortcuts (Esc to close popovers/forms)
- Add print button to invoice viewer modal with optimized print styles
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace "Cargando..." text with animated skeleton rows
- Mimics table structure while loading
- Improves perceived loading speed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Database optimizations:
- Add indexes on fecha_emision, tipo, estado, rfc_emisor, rfc_receptor
- Add trigram indexes for fast ILIKE searches on nombre fields
- Combine COUNT with main query using window function (1 query instead of 2)
Frontend optimizations:
- Add 300ms debounce to autocomplete searches
- Add staleTime (30s) and gcTime (5min) to useCfdis hook
- Reduce unnecessary API calls on every keystroke
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add /cfdi/emisores and /cfdi/receptores API endpoints
- Search by RFC or nombre with ILIKE
- Show suggestions dropdown while typing (min 2 chars)
- Click suggestion to select and populate filter input
- Show loading state while searching
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ::date cast to fechaInicio filter
- Add ::date cast and +1 day interval to fechaFin to include full day
- Fixes "operator does not exist: timestamp >= text" error
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Set z-index to 9999 to ensure popover appears above all elements
- Add explicit white background for better visibility
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create Popover component using Radix UI
- Add filter icon next to Fecha, Emisor, Receptor headers
- Each icon opens a popover with filter inputs
- Show active filters as badges in card header
- Filter icons highlight when filter is active
- Apply filters on Enter or click Apply button
- Remove filters individually with X on badge
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add emisor and receptor filters to CfdiFilters type
- Update backend service to filter by emisor/receptor (RFC or nombre)
- Update controller and API client to pass new filters
- Add toggle button to show/hide column filters in table
- Add date range inputs for fecha filter
- Add text inputs for emisor and receptor filters
- Apply filters on Enter key or search button click
- Add clear filters button when filters are active
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add gradient header with emisor info and prominent serie/folio
- Improve status badges with pill design
- Add receptor section with left accent border
- Show complete uso CFDI descriptions
- Create card grid for payment method, forma pago, moneda
- Improve conceptos table with zebra striping and SAT keys
- Add elegant totals box with blue footer
- Enhance timbre fiscal section with QR placeholder and SAT URL
- Add update-cfdi-xml.js script for bulk XML import
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PostgreSQL requires explicit type cast when comparing UUID columns
with text parameters in raw queries.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Eye button to table rows to view invoice
- Add loading state while fetching CFDI details
- Integrate CfdiViewerModal component
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Detailed step-by-step implementation plan for:
- PDF-like invoice visualization
- PDF download via html2pdf.js
- XML download endpoint
- Modal integration in CFDI page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Design for PDF-like invoice visualization with:
- Modal viewer with invoice preview
- PDF download via html2pdf.js
- XML download from stored data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add explicit IRouter type to all route files
- Add explicit Express type to app.ts
- Fix env.ts by moving getCorsOrigins after parsing
- Fix token.ts SignOptions type for expiresIn
- Cast req.params.id to String() in controllers
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add authentication check using useAuthStore
- Redirect unauthenticated users to /login
- Show loading state while auth store hydrates
- Remove "Demo UI sin backend" text from production
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Wrap token refresh logic in Prisma transaction
- Use deleteMany instead of delete to handle race conditions gracefully
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document current implementation status
- Add pending items to verify after SAT rate limit resets
- Include test tenant info and verification commands
- List known issues and workarounds
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add custom date range support for SAT synchronization
- Fix UUID cast in SQL queries for sat_sync_job_id
- Fix processInitialSync to respect custom dateFrom/dateTo parameters
- Add date picker UI for custom period sync
- Add comprehensive documentation for SAT sync implementation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SAT only allows downloading CFDIs from the last 6 years.
Reduced from 10 to avoid wasted requests.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The StatusRequest class has an isTypeOf method that properly checks
the status. Using getValue() and comparing numbers was unreliable.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace manual SOAP authentication with the official nodecfdi library
which properly handles WS-Security signatures for SAT web services.
- Add sat-client.service.ts using Fiel.create() for authentication
- Update sat.service.ts to use new client
- Update fiel.service.ts to return raw certificate data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The PEM certificate content is already base64 encoded after removing
headers and newlines. We should not re-encode it.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Each piece of data was being encrypted with a different IV, but only
the first IV was saved. Now using encryptFielCredentials/decryptFielCredentials
helper functions that encrypt all data together with a single IV/tag.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The @nodecfdi/credentials library returns date values that aren't
JavaScript Date objects, causing getTime() to fail.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The controllers were looking for x-tenant-id header which the frontend
doesn't send. Now using req.user!.tenantId from the JWT token instead.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Backend:
- Add getAllUsuarios() to get users from all tenants
- Add updateUsuarioGlobal() to edit users and change their tenant
- Add deleteUsuarioGlobal() for global user deletion
- Add global admin check based on tenant RFC
- Add new API routes: /usuarios/global/*
Frontend:
- Add UserListItem.tenantId and tenantName fields
- Add /admin/usuarios page with full user management
- Support filtering by tenant and search
- Inline editing for name, role, and tenant assignment
- Group users by company for better organization
- Add "Admin Usuarios" menu item for admin navigation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a card linking to /configuracion/sat from the main settings page,
making the SAT sync feature discoverable from the navigation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add FielUploadModal component for FIEL credential upload
- Add SyncStatus component showing current sync progress
- Add SyncHistory component with pagination and retry
- Add SAT configuration page at /configuracion/sat
- Add API client functions for FIEL and SAT endpoints
Features:
- File upload with Base64 encoding
- Real-time sync progress tracking
- Manual sync trigger (initial/daily)
- Sync history with retry capability
- FIEL status display with expiration warning
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add FIEL controller with upload, status, and delete endpoints
- Add SAT controller with sync start, status, history, and retry
- Add admin endpoints for cron job info and manual execution
- Register new routes in app.ts
- All endpoints protected with authentication middleware
Endpoints added:
- POST /api/fiel/upload
- GET /api/fiel/status
- DELETE /api/fiel
- POST /api/sat/sync
- GET /api/sat/sync/status
- GET /api/sat/sync/history
- GET /api/sat/sync/:id
- POST /api/sat/sync/:id/retry
- GET /api/sat/cron
- POST /api/sat/cron/run
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sat-sync.job.ts with scheduled daily sync at 3:00 AM
- Automatic detection of tenants with active FIEL
- Initial sync (10 years) for new tenants, daily for existing
- Concurrent processing with configurable batch size
- Integration with app startup for production environment
- Install node-cron dependency
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sat.service.ts as the main orchestrator that coordinates:
- FIEL credential retrieval and token management
- SAT download request workflow
- Package processing and CFDI storage
- Progress tracking and job management
- Support for initial sync (10 years history) and daily sync
- Automatic token refresh during long-running syncs
- Month-by-month processing to avoid SAT limits
- Raw SQL queries for multi-tenant schema isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sat-parser.service.ts for processing SAT packages:
- Extract XML files from ZIP packages
- Parse CFDI 4.0 XML structure with proper namespace handling
- Extract fiscal data: UUID, amounts, taxes, dates, RFC info
- Map SAT types (I/E/T/P/N) to application types
- Handle IVA and ISR retention calculations
- Install @nodecfdi/cfdi-core dependency
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sat-auth.service.ts for SAML token authentication with SAT
using FIEL credentials and SOAP protocol
- Add sat-download.service.ts with full download workflow:
- Request CFDI download (emitted/received)
- Verify request status with polling support
- Download ZIP packages when ready
- Helper functions for status checking
- Install fast-xml-parser and adm-zip dependencies
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sat-crypto.service.ts with AES-256-GCM encryption for secure
credential storage using JWT_SECRET as key derivation source
- Add fiel.service.ts with complete FIEL lifecycle management:
- Upload and validate FIEL credentials (.cer/.key files)
- Verify certificate is FIEL (not CSD) and not expired
- Store encrypted credentials in database
- Retrieve and decrypt credentials for SAT sync operations
- Install @nodecfdi/credentials for FIEL/CSD handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Detailed implementation plan with 9 phases:
1. Database models and migrations
2. Cryptography and FIEL services
3. SAT communication services
4. CFDI XML parser
5. Main orchestrator service
6. Scheduled cron job
7. API endpoints
8. Frontend components
9. Testing and validation
Includes:
- 16 new files to create
- 5 files to modify
- Dependencies list
- Implementation order
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Design document for automatic CFDI synchronization with SAT:
- FIEL (e.firma) authentication
- Download emitted and received CFDIs
- Daily automated sync at 3:00 AM
- Initial extraction of last 10 years
- Encrypted credential storage (AES-256-GCM)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>