[19.0][FIX] account_statement_import_sheet_file: Remaining fixes on top of #958 refactoring - #969
[19.0][FIX] account_statement_import_sheet_file: Remaining fixes on top of #958 refactoring#969cav-adhoc wants to merge 1 commit into
Conversation
|
Hi @alexey-pelykh, |
011cc1f to
fb18373
Compare
|
Hi, Camilla, thanks for the head-up. Please check pre-commit, and write here the changes done and the motivation. |
alexey-pelykh
left a comment
There was a problem hiding this comment.
Thanks for cleaning these up. One small, non-blocking robustness note on the new case-insensitive fallback in _get_column_indexes:
if h.lower() == column_name_or_index.lower()column_name_or_index is safe (it comes from the Char mapping field, so it's always a string by the time it reaches here), but h is a raw header cell. If a header cell arrives as a non-string — which can happen with spreadsheet sources where a header is numeric- or date-typed — then h.lower() raises AttributeError instead of the clean ValueError the exact-match path used to raise. This PR already guards for exactly this shape in _parse_decimal (if not isinstance(value, str): value = str(value)), so str(h).lower() here would keep the two consistent.
Co-Reviewed-By: Claude Opus 4.8 noreply@anthropic.com
refactoring - Remove duplicate amount_column field definition - Fix typo 'igned' -> 'signed' in amount_type help text - Add _clear_amount_columns onchange to clear irrelevant fields on type change - Improve header_lines_skip_count string/help (row number, not skip count) - Add case-insensitive column name matching in _get_column_indexes - Add str() cast in _parse_decimal for non-string cell values - Update es.po translations for changed strings
fb18373 to
72c8ca9
Compare
@alexey-pelykh Done! |
This PR applies the remaining fixes from the closed PR #957 that were not covered by the refactoring PR #958 (which separated XLS/XLSX into standalone modules).
Changes
1.
account_statement_import_sheet_mapping.pyRemove duplicate
amount_columnfieldThe field was defined twice — the first definition was dead code that never took effect because Python class resolution uses the last definition. Removed to avoid confusion and noise.
Fix typo: "igned" → "signed" in
amount_typehelpThe help text read "use igned amount" which is clearly a typo for "use signed amount".
Add
_clear_amount_columnsonchangeWhen the user changes
amount_type, the previously configured column fields (amount_column,debit_credit_column,amount_debit_column,amount_credit_column) become semantically invalid. This onchange clears them automatically, preventing stale/invalid configurations from being submitted.Improve
header_lines_skip_countstring/helpRenamed string from "Header lines skip count" to "Header row number" with help "Row number where the column headers are located (first row is 0)." The old name implied a skip count when it's actually a 0-based row index — the field value IS the row number, not how many rows to skip.
2.
account_statement_import_sheet_parser.pyCase-insensitive column name matching in
_get_column_indexesDifferent banks export files with varying capitalization (e.g., "Date" vs "date" vs "DATE"). The old code only did exact match via
header.index(), which would raiseValueErroron case mismatch. Now tries exact match first, then falls back to case-insensitive matching before raising. This method is inherited by both the XLS and XLSX parsers, so all formats benefit.str()cast in_parse_decimalThe XLS parser (
_get_xls_row_values) does not stringify cell values, so rawint/floatvalues from xlrd can reach_parse_decimalvia_get_values_from_column. Without this cast,re.sub(r"[^\d...]+", "", value)crashes with aTypeError. The XLSX parser already stringifies values, so this is mainly a safety net for XLS and any future parser.3.
i18n/es.poUpdated translations for the new
header_lines_skip_countstring and help text.