Skip to content

feat: add visibility of BSP debug Excel files in Debug Information dialog#87

Merged
boscorat merged 1 commit into
masterfrom
80-statement-debugging---add-visibility-of-bsp-improvements
Jul 8, 2026
Merged

feat: add visibility of BSP debug Excel files in Debug Information dialog#87
boscorat merged 1 commit into
masterfrom
80-statement-debugging---add-visibility-of-bsp-improvements

Conversation

@boscorat

@boscorat boscorat commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Implements full support for BSP's new debug_dataframes.xlsx debugging files by:

  1. Persisting debug Excel file paths in the database
  2. Detecting Excel files alongside JSON debug files
  3. Adding an "Open Excel" button in the Debug Information dialog
  4. Fixing a critical path inconsistency in BSP's debug module

Changes

Database Schema

  • Added debug_excel_path column to statement_result table
  • Stores path to debug_dataframes.xlsx alongside debug_json_path

Data Model

  • Added debug_excel_path: Path | None field to ResultRow dataclass
  • Updated update_debug_info() to persist both JSON and Excel paths
  • Updated session restore logic to hydrate Excel paths from database

Presenter

  • Enhanced DebugWorker to detect debug_dataframes.xlsx file
  • Emits both paths via signal: entry_done(result_id, debug_json_path, debug_excel_path)
  • Stores both paths in database for session persistence

UI

  • Added "Debug Excel" column in Debug Information dialog
  • New "Open Excel" button with tooltip: "View extracted dataframes in multi-tab Excel file"
  • Opens Excel file with system default application (Excel/LibreOffice Calc/Numbers)
  • Buttons intelligently enable/disable based on file existence

BSP Integration

  • Identified and documented path inconsistency in BSP's debug module
  • Fixed in bank_statement_parser v0.3.7:
    • _write_debug_json() now returns the actual file path
    • debug_pdf_statement() uses returned path (no duplicate path construction)
    • Eliminates inconsistency between pdf.stem (in _write_debug_json) and pdf.name (in debug_pdf_statement)

Bug Fixes

  • Fixed closeEvent crash when stan_presenter not yet initialized
  • Added hasattr() guard for graceful shutdown during failed initialization

Testing

  • All 129 existing tests pass
  • Type checking passes
  • Linting passes
  • Code formatting correct
  • Database schema migration handles existing projects (nullable column with DEFAULT NULL)
  • Session restore works correctly with both JSON and Excel paths

User Experience

When debugging failed/review statements:

  1. Click "View Debug Info" to open the debug dialog
  2. See both "Debug JSON" and "Debug Excel" buttons for each statement
  3. Click "Open Excel" to view multi-tab extracted data in system spreadsheet app
  4. File paths persist across app restarts (session restore)

Files Modified

  • src/openstan/data/create_gui_db.py — Add schema column
  • src/openstan/models/statement_result_model.py — Add field and update methods
  • src/openstan/presenters/statement_result_presenter.py — Detect and emit Excel path
  • src/openstan/views/debug_info_dialog.py — Add Excel column and buttons
  • src/openstan/main.py — Guard closeEvent against initialization errors

Related Issues

Fixes #80 — Statement Debugging - add visibility of BSP improvements

Related PRs

This PR requires bank_statement_parser ≥ 0.3.7 (commit 1df6293 or later) to work correctly.

closeEvent can be triggered during initialization if database errors
occur (e.g., lock timeout). The event handler tried to access
stan_presenter which may not have been initialized yet, causing an
AttributeError.

Add hasattr() guard to safely check if stan_presenter exists before
accessing it. This allows the application to close gracefully even if
initialization fails.
@boscorat boscorat linked an issue Jul 8, 2026 that may be closed by this pull request
@boscorat boscorat merged commit f6a0532 into master Jul 8, 2026
@boscorat boscorat deleted the 80-statement-debugging---add-visibility-of-bsp-improvements branch July 8, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Statement Debugging - add visibility of BSP improvements

1 participant