fix(пополнение): имя услуги в чеке без пробелов — снимает двусмысленность кодирования Receipt

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-20 23:58:15 +10:00
co-authored by Claude Code
parent cbb0f12312
commit 67fd1c84fb
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -73,7 +73,8 @@ def _receipt(order: dict) -> str:
"""Чек НПД: одна услуга, количество 1, сумма платежа, без НДС. """Чек НПД: одна услуга, количество 1, сумма платежа, без НДС.
Robokassa без Receipt чек не формирует (docs/fiscalization).""" Robokassa без Receipt чек не формирует (docs/fiscalization)."""
amount = Decimal(int(order["amount_kop"])) / 100 amount = Decimal(int(order["amount_kop"])) / 100
name = (order.get("description") or "Пополнение счёта infosmeta.ru")[:128] name = ((order.get("description") or "Пополнение счёта infosmeta.ru")
.replace(" ", "_"))[:128]
return json.dumps({ return json.dumps({
"items": [{ "items": [{
"name": name, "name": name,
+2 -2
View File
@@ -57,7 +57,7 @@ def _order(**kw):
def _receipt(amount_kop: int, description: str = "Пополнение счёта infosmeta.ru") -> str: def _receipt(amount_kop: int, description: str = "Пополнение счёта infosmeta.ru") -> str:
return json.dumps({ return json.dumps({
"items": [{ "items": [{
"name": description, "quantity": 1, "sum": amount_kop / 100, "name": description.replace(" ", "_"), "quantity": 1, "sum": amount_kop / 100,
"payment_method": "full_payment", "payment_object": "service", "tax": "none", "payment_method": "full_payment", "payment_object": "service", "tax": "none",
}] }]
}, ensure_ascii=False, separators=(",", ":")) }, ensure_ascii=False, separators=(",", ":"))
@@ -103,7 +103,7 @@ def test_receipt_has_service_nomenclature_and_amount(rk):
_, q = _q(rk.create(_order())["pay_url"]) _, q = _q(rk.create(_order())["pay_url"])
data = json.loads(q["Receipt"]) data = json.loads(q["Receipt"])
item = data["items"][0] item = data["items"][0]
assert item["name"] == "Пополнение счёта infosmeta.ru" assert item["name"] == "Пополнение_счёта_infosmeta.ru"
assert item["quantity"] == 1 and item["sum"] == 1000.0 assert item["quantity"] == 1 and item["sum"] == 1000.0
assert item["payment_method"] == "full_payment" assert item["payment_method"] == "full_payment"
assert item["payment_object"] == "service" assert item["payment_object"] == "service"