fix(деньги): округление один раз
This commit is contained in:
@@ -63,3 +63,17 @@ def test_money_is_admin_only(env):
|
||||
import auth
|
||||
user = {"Authorization": "Bearer " + auth._make_token("joe@x", "user")}
|
||||
assert client.get("/api/admin/v2/money", headers=user).status_code == 403
|
||||
|
||||
|
||||
def test_monthly_rounding_happens_once(env):
|
||||
db, client, h = env
|
||||
import time as _time
|
||||
now = _time.time()
|
||||
with db._conn() as c:
|
||||
for ts in (now, now - 40 * 86400):
|
||||
c.execute("INSERT INTO payments (ts, username, product, amount_rub, yk_payment_id, "
|
||||
"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
|
||||
|
||||
Reference in New Issue
Block a user