fix(срез 2.1): дубль без раздела → warning (не ложная ошибка на .gge); checked считает код-инвариант

Probe на 173 реальных .gge показал 604 ложных 'дубль тот же раздел' — parse_gge_file
не даёт раздел, штатные повторы схлопывались. Теперь section=None → warning. 16 passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-07-17 20:45:54 +10:00
co-authored by Claude Opus 4.8
parent c2a52591a3
commit ad3edf0e5a
2 changed files with 36 additions and 16 deletions
+20 -7
View File
@@ -68,15 +68,28 @@ def test_pz_nr_sp_mismatch():
assert any("ПЗ+НР+СП" in x["rule"] for x in r["errors"])
def test_duplicate_position():
def _dup_totals() -> dict:
return {"grand_total": 550.0, "vat_pct": 22.0,
"vat": round(550 * 0.22, 2), "total_with_vat": round(550 * 1.22, 2)}
def test_duplicate_position_same_section():
est = _clean()
est["positions"].append(dict(est["positions"][0])) # точный дубль
# чтобы итог не срабатывал раньше — подгоняем сумму под 3 позиции
est["totals"]["grand_total"] = 550.0
est["totals"]["vat"] = round(550 * 0.22, 2)
est["totals"]["total_with_vat"] = round(550 * 1.22, 2)
est["positions"][0]["section"] = "Раздел 1"
est["positions"].append(dict(est["positions"][0])) # тот же раздел → точный дубль → error
est["totals"] = _dup_totals()
r = ev.verify(est)
assert any("дубль позиции" in x["rule"] for x in r["errors"])
assert any("дубль позиции (тот же раздел)" in x["rule"] for x in r["errors"])
def test_duplicate_without_section_is_warning():
# раздел не указан (как в parse_gge_file) → нельзя отличить дубль от повтора → warning
est = _clean()
est["positions"].append(dict(est["positions"][0])) # section=None у обеих
est["totals"] = _dup_totals()
r = ev.verify(est)
assert any("возможный дубль" in x["rule"] for x in r["warnings"])
assert not any("дубль" in x["rule"] for x in r["errors"])
def test_cross_section_repeat_is_warning_not_error():