fix(деньги): округление один раз
This commit is contained in:
@@ -1316,7 +1316,7 @@ def costs_by_model(since: float, until: float | None = None,
|
||||
return out
|
||||
|
||||
|
||||
def finance_by_month(since: float, until: float | None = None) -> dict:
|
||||
def finance_by_month(since: float, until: float | None = None, round_kop: bool = True) -> dict:
|
||||
"""Финансовый итог: поступления по месяцам и себестоимость ИИ за то же окно.
|
||||
|
||||
Выручка — только успешные платежи минус возвраты; незавершённые не в счёт. Месяцы
|
||||
@@ -1356,13 +1356,17 @@ def finance_by_month(since: float, until: float | None = None) -> dict:
|
||||
months: dict[str, dict] = {}
|
||||
for r in pay:
|
||||
m = months.setdefault(r["month"], {})
|
||||
m["revenue_rub"] = round(r["revenue_rub"] or 0.0, 2)
|
||||
m["refunded_rub"] = round(r["refunded_rub"] or 0.0, 2)
|
||||
m["revenue_rub"] = (round(r["revenue_rub"] or 0.0, 2)
|
||||
if round_kop else float(r["revenue_rub"] or 0.0))
|
||||
m["refunded_rub"] = (round(r["refunded_rub"] or 0.0, 2)
|
||||
if round_kop else float(r["refunded_rub"] or 0.0))
|
||||
m["payers"] = r["payers"] or 0
|
||||
for r in use:
|
||||
m = months.setdefault(r["month"], {})
|
||||
m["cost_rub"] = round(r["cost_rub"], 2) if r["cost_rub"] is not None else None
|
||||
m["price_rub"] = round(r["price_rub"], 2) if r["price_rub"] is not None else None
|
||||
m["cost_rub"] = ((round(r["cost_rub"], 2) if round_kop else float(r["cost_rub"]))
|
||||
if r["cost_rub"] is not None else None)
|
||||
m["price_rub"] = ((round(r["price_rub"], 2) if round_kop else float(r["price_rub"]))
|
||||
if r["price_rub"] is not None else None)
|
||||
m["requests"] = r["requests"]
|
||||
m["people"] = r["people"]
|
||||
m["unpriced"] = r["unpriced"]
|
||||
|
||||
Reference in New Issue
Block a user