test(statements): test_inn_not_taken_from_auditor_block_above_organization_inn (Fix round 3)

Добавлен тест, проверяющий, что ИНН аудитора НИКОГДА не берётся, даже когда
аудиторский блок расположен РАНЬШЕ (выше) строк с ИНН организации.

Лист:
- Строка 3-5: блок аудитора (auditor_from=3)
  - Строка 4: аудиторский ИНН = 7716021332
- Строки 6-8: организация
  - Строка 8: org ИНН = 3249004697

С охраной min(last_row, auditor_from-1) = min(9, 2) = 2:
  Поиск в строках 1-2, ИНН не найден → header.inn is None ✓ GREEN

Без охраны (поиск в строках 1-9):
  Аудиторский ИНН найден первым → header.inn = 7716021332 ✗ RED

Этот тест доказывает, что guard критически важен для исключения аудитора.

Refs #14

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Claude-Session: cedd7915-2efe-41e5-988c-a9117033598b
This commit is contained in:
Andrey Epifancev 2026-10-06 16:42:03 +04:00
parent e6696fa440
commit cb0bd062d4

View File

@ -184,3 +184,47 @@ def test_inn_from_auditor_block_only_is_none(rules: Rules) -> None:
header, _ = parse_header(sheet, rules, 1, 9, _block(sheet, rules))
assert header.inn is None, f"Should not pick up auditor INN 9999999999, got {header.inn}"
def test_inn_not_taken_from_auditor_block_above_organization_inn(rules: Rules) -> None:
"""Guard test (b): auditor block ABOVE org INN; guard excludes auditor INN.
Layout (intentionally reversed from real files):
- Auditor block starts at row 3 (auditor_from=3)
- Auditor INN at row 4: value 7716021332
- Organization INN at row 8: value 3249004697
With guard (search 1..auditor_from-1=1..2): Neither INN found → header.inn is None ✓
Without guard (search 1..last_row=1..9): Auditor INN at row 4 found first → **FAIL** ✗
This test verifies auditor INN is never taken, even when it appears before org INN.
"""
sheet = sheet_from_rows(
[
[*at({3: "Бухгалтерский баланс"})],
[*at({3: "на 31 декабря 2024 г."})],
[*at({2: "Наименование аудиторской организации"})],
[*at({2: 'АО "ЮНИКОН"'})],
[
*at(
{
2: "Идентификационный номер налогоплательщика аудиторской организации",
33: "ИНН",
34: "7716021332",
}
)
],
[*at({7: 'ООО "ЗАВОД"'})],
[*at({3: "Организация", 7: 'ООО "ЗАВОД"', 13: "по ОКПО", 14: "16098811"})],
[*at({2: "Идентификационный номер налогоплательщика", 33: "ИНН", 34: "3249004697"})],
[*at({2: "Единица измерения", 7: "в тыс. рублей", 33: "по ОКЕИ", 34: "384"})],
]
)
header, _ = parse_header(sheet, rules, 1, 9, _block(sheet, rules))
assert header.inn is None, (
f"Auditor INN 7716021332 at row 4 is above auditor_from boundary; "
f"org INN 3249004697 at row 8 is below. Guard excludes both. "
f"Got {header.inn}"
)