From 8dd8a5086839d05735d7362bac2e7b8a02080d04 Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Mon, 19 Oct 2026 11:57:31 +0400 Subject: [PATCH] =?UTF-8?q?fix(osv):=20=D0=BC=D0=B5=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D1=8E=D1=82=D1=8B=20=D0=B1=D0=B5=D0=B7=20?= =?UTF-8?q?=D0=B4=D0=B2=D0=BE=D0=B5=D1=82=D0=BE=D1=87=D0=B8=D1=8F=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=B8=D0=B4=D0=BE=D0=BC=20=D1=81=D1=83=D0=B1?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=BE=20(#59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- api/src/parser/header.py | 5 +++-- api/tests/unit/parser/test_header.py | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) 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", "Субконто")]