fix(деньги): взносы на счёт входят в поступления, карточка сходится

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-10 01:34:29 +10:00
co-authored by Claude Code
parent bfdb7ce3d2
commit 33c289845d
9 changed files with 70 additions and 16 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ DASH = {"user": "boss@x", "generated_at": 1794000000, "last_visit": None,
"limit_hits": 0, "latency_qa_ms": 200, "latency_qa_p95_ms": 500,
"latency_agent_ms": 3000, "latency_agent_p95_ms": 9000},
"money": {"revenue_rub": 1000, "flow_rub": 400, "accounts_total_rub": 2500,
"topups_included": False, "unpriced": 0},
"topups_included": True, "unpriced": 0},
"customers": {"total": 12, "active_24h": 3},
"attention": {"failures": 1, "limit_hits": 0, "unpriced": 0}}
ATT = {"items": [{"key": "failures:24h", "severity": "high", "title": "Сбои",
@@ -86,7 +86,7 @@ def test_five_cards_money_badge_and_done(browser, site):
page.goto(site + "/admin/v2")
page.wait_for_selector(".grid .card")
assert page.locator(".grid .card").count() == 5
assert "предварительно" in page.locator(".badge").first.inner_text()
assert "предварительно" not in page.locator("main").inner_text()
assert "1\u00a0000" in page.locator(".grid").inner_text()
assert page.locator(".task").count() == 2
assert "первый визит" not in page.locator(".grid").inner_text()
+1 -1
View File
@@ -15,7 +15,7 @@ from test_admin_design_ui import browser # noqa: E402,F401
MONEY = {"period_days": 30, "revenue_rub": 1000, "refunded_rub": 0, "cost_rub": 250,
"flow_rub": 750, "charged_rub": 800, "accounts_total_rub": 2000,
"accounts_count": 2, "unpriced": 0}
"accounts_count": 2, "unpriced": 0, "topups_rub": 0}
MONTHS = [{"month": "2026-09", "revenue_rub": 500, "cost_rub": 100},
{"month": "2026-10", "revenue_rub": 500, "cost_rub": 150}]
PAYMENTS = [
+1 -1
View File
@@ -24,7 +24,7 @@ DASH = {"user": "boss@x", "generated_at": 1794000000, "last_visit": None,
"attention": {"failures": 0, "limit_hits": 0, "unpriced": 0}}
MONEY = {"period_days": 30, "revenue_rub": 100, "refunded_rub": 0, "cost_rub": 50,
"flow_rub": 50, "charged_rub": 80, "accounts_total_rub": 200,
"accounts_count": 1, "unpriced": 0}
"accounts_count": 1, "unpriced": 0, "topups_rub": 0}
# Один закрытый месяц — тот случай, на котором графики разъезжались: ширина viewBox
# зависела от числа точек, и при одной точке SVG растягивался в многоэкранную полосу.
FIN = {"months": [{"month": "2026-11", "revenue_rub": 0, "cost_rub": 714.31}], "days": 30}
+10 -4
View File
@@ -48,12 +48,18 @@ def test_money_kopecks_and_period(env):
d = r.json()
assert d["period_days"] == 30
assert d["accounts_total_kop"] == 1000
assert d["revenue_kop"] == 1000
# Взнос 10 ₽ + платёж 10 ₽: поступления — это и предоплата, и платёж.
assert d["topups_kop"] == 1000
assert d["revenue_kop"] == 2000
assert d["cost_kop"] == 250
assert d["flow_kop"] == 750
assert d["flow_kop"] == 1750
assert d["topups_included"] is True
assert isinstance(d["revenue_kop"], int)
assert isinstance(d["flow_kop"], int) or d["flow_kop"] is None
assert d["flow_kop"] == d["revenue_kop"] - d["cost_kop"]
# График по месяцам считает то же, что карточка: иначе «не сходится».
series = client.get("/api/admin/v2/finance?days=30", headers=h).json()["months"]
assert sum(m["revenue_rub"] for m in series) == pytest.approx(20.0)
assert client.get("/api/admin/v2/money?days=0", headers=h).json()["period_days"] == 1
assert client.get("/api/admin/v2/money?days=9999", headers=h).json()["period_days"] == 366
@@ -75,5 +81,5 @@ def test_monthly_rounding_happens_once(env):
"status, updated_at) VALUES (?,?,?,?,?,?,?)",
(ts, "joe@x", "p", "0.125", "m-" + str(ts), "succeeded", ts))
d = client.get("/api/admin/v2/money?days=60", headers=h).json()
# 10,00 + 0,125 + 0,125 = 10,25 → 1025, а не 10,26 от помесячного округления
assert d["revenue_kop"] == 1025
# Взнос 10,00 + платежи 0,125 + 0,125 = 20,25 → 2025, а не 20,26 от помесячного округления
assert d["revenue_kop"] == 2025