diff --git a/api/src/parser/header.py b/api/src/parser/header.py index 4512e3a..acbadb7 100644 --- a/api/src/parser/header.py +++ b/api/src/parser/header.py @@ -584,10 +584,11 @@ def _kind_row_groups(sheet: Sheet, header: TableHeader, rules: Rules) -> list[Os """Виды субконто из строки шапки между названием и периодом: только узнанные явной записью словаря групп, не ACCOUNT; метки шапки (в том числе валюта) видом субконто не считаются.""" cells = _head_cells(sheet, header) - currency = _currency_cells(cells, rules) + currency = rules.headers.header_markers["currency"] groups: list[OsvGroup] = [] for cell in _kind_row_cells(cells, rules): - if cell in currency or _is_structural_marker(cell, rules): + # Метка валюты — с двоеточием или без него: «Валюта БУ, НУ» вид субконто не называет + if _find(currency, cell.text) is not None or _is_structural_marker(cell, rules): continue for item in (part.strip() for part in cell.text.split(_LIST_SEPARATOR)): known = rules.groups.known(item) if item else None diff --git a/api/tests/unit/parser/test_header.py b/api/tests/unit/parser/test_header.py index e0079fc..61a2fc9 100644 --- a/api/tests/unit/parser/test_header.py +++ b/api/tests/unit/parser/test_header.py @@ -649,5 +649,13 @@ def test_currency_row_between_title_and_period_is_not_added_to_schema(rules: Rul assert _flat_schema(rules, "Валюта БУ, НУ: RUB") == [("ACCOUNT", "Субконто")] +def test_currency_row_without_colon_is_not_added_to_schema(rules: Rules) -> None: + assert _flat_schema(rules, "Валюта БУ, НУ") == [("ACCOUNT", "Субконто")] + + +def test_account_cell_between_title_and_period_does_not_add_second_account(rules: Rules) -> None: + assert _flat_schema(rules, "Счет") == [("ACCOUNT", "Субконто")] + + def test_subkonto_cell_between_title_and_period_does_not_add_second_account(rules: Rules) -> None: assert _flat_schema(rules, "Субконто") == [("ACCOUNT", "Субконто")]