Feature/pdf import transaction rows
Merged
MK
10mo ago+777+777+012345678901234567890123456789-315-315-012345678901234567890123456789
Add import row generation from PDF extracted data
This PR implements step 2 of the AI-powered bank statement import feature (#844).
What this does
When a user uploads a bank statement PDF, the AI extracts transaction data. This PR takes that extracted data and creates actual import rows that can be reviewed and published.
The flow now works like this:
- User uploads PDF → AI processes it and extracts transactions
- NEW: Extracted transactions become import rows automatically
- User reviews the rows and publishes them as real transactions
Changes
- Added
generate_rows_from_extracted_datamethod to convert AI-extracted transactions into import rows - Added
import!method to create transactions from the import rows - Updated the job to generate rows after extraction and set status to "pending" for review
- Fixed
supports_pdf_processing?to validate the actual model being used (not just the default) - Moved the model validation inside
with_provider_responseso errors are handled consistently
Tests
Added tests for the BankStatementExtractor covering:
- Transaction extraction
- Deduplication across page boundaries
- Amount normalization (handles various formats like "$1,234.56")
- Error handling
All tests pass: 39 runs, 116 assertions, 0 failures.
Closes #844
Screenshots
Summary by CodeRabbit
-
New Features
- Bank-statement PDF imports now extract transactions, generate import rows, and show a “Ready for Review” UI with row counts, transaction summaries, account selection, and publish/review actions; import update action added.
-
Bug Fixes
- Improved status transitions, error handling and logging for PDF processing; clearer validation and error messages when a PDF model is unsupported.
-
Tests
- Expanded coverage for extraction, row generation, mapping steps, provider extraction, normalization, deduplication, and edge cases; new fixtures added.
-
Chores
- DB migrations to add category fields/icons to import rows; navigation/step UI streamlined for PDF flows.