"""Неизменённые источники 58.01 и отрицательные примеры 58.03.""" import json from decimal import Decimal from pathlib import Path import pytest pytestmark = pytest.mark.fixtures def investment_rows(fixtures_dir: Path) -> list[dict]: path = next((fixtures_dir / "golden/expected_osv_parse/osv-dkb/primanych/2025-Q3").glob("*58*.json")) return [ r for d in json.loads(path.read_text())["documents"] for r in d["rows"] if r["group_type"] == "COUNTERPARTY" and r["data_type"] in ("BU", "SUM") and (r.get("account_code_raw") or "").startswith("58.01") ] def test_real_equity_investment(fixtures_dir: Path) -> None: rows = investment_rows(fixtures_dir) assert len(rows) == 1 assert rows[0]["counterparty_name"] == "СЕМИКАРАКОРСКИЙ ЭЛЕВАТОР ООО" assert Decimal(rows[0]["closing_debit"]) == Decimal("269997300.00") @pytest.mark.parametrize("period", ["2025-Q1", "2024-Q3"]) def test_biscuit_contains_loans_only(fixtures_dir: Path, period: str) -> None: paths = list((fixtures_dir / "golden/expected_osv_parse/rb" / period).glob("*58*.json")) assert paths rows = [ r for p in paths for d in json.loads(p.read_text())["documents"] for r in d["rows"] if r["group_type"] == "COUNTERPARTY" ] assert rows assert {r["account_code_raw"] for r in rows} == {"58.03"}