fix(payments): stop doubling the pack size in buyer mail
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 23s
CI / ui (pull_request) Successful in 1m16s
CI / conformance (pull_request) Successful in 11s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m50s

Catalog titles already name the pack ("50 фишек"), so appending the chip count
produced "50 фишек — 50 фишек, 79.00 ₽". The letter now carries the title
exactly as the storefront shows it, then the price.

The tax receipt is unaffected: it states the quantity in the wording the tax
service wants, which is a separate surface with separate requirements.
This commit is contained in:
Ilia Denisov
2026-07-28 16:14:53 +02:00
parent f8efa21158
commit 4d4452596d
4 changed files with 19 additions and 13 deletions
+11 -8
View File
@@ -185,15 +185,18 @@ func (m *Mailer) stampReceipt(ctx context.Context, mark func(context.Context, uu
}
}
// describe renders what was bought in one line.
func describe(title string, chips int, amountMinor int64, currency string) string {
// describe renders what was bought in one line: the catalog title exactly as the buyer saw it on
// the storefront, then the price.
//
// The pack size is deliberately NOT appended. Catalog titles already name it ("50 фишек"), so
// adding it produced "50 фишек — 50 фишек". The title is the single source of that wording; the
// tax receipt states the quantity separately in the form the tax service wants (see
// mynalog.IncomeName), which is a different surface with different requirements.
func describe(title string, amountMinor int64, currency string) string {
what := strings.TrimSpace(title)
if what == "" {
what = "покупка в игре"
}
if chips > 0 {
what = fmt.Sprintf("%s — %d фишек", what, chips)
}
return fmt.Sprintf("%s, %s", what, formatAmount(amountMinor, currency))
}
@@ -224,7 +227,7 @@ func purchaseText(p payments.PurchaseMail) string {
отдельным письмом: обычно в течение часа, но иногда это занимает до нескольких дней.
Спасибо, что играете в «Эрудит».
`, describe(p.Title, p.Chips, p.AmountMinor, p.Currency), p.OrderID)
`, describe(p.Title, p.AmountMinor, p.Currency), p.OrderID)
}
// receiptText is the fiscal receipt letter, which is how the receipt is actually handed to the
@@ -240,7 +243,7 @@ func receiptText(r payments.ReceiptMail, inn, baseURL string, loc *time.Location
Продавец применяет налог на профессиональный доход; чек сформирован в сервисе
«Мой налог» Федеральной налоговой службы.
`, describe(r.Title, r.Chips, r.AmountMinor, r.Currency),
`, describe(r.Title, r.AmountMinor, r.Currency),
r.OperationTime.In(loc).Format("02.01.2006 15:04"),
mynalog.ReceiptURL(baseURL, inn, r.ReceiptUUID))
}
@@ -255,6 +258,6 @@ func cancelText(r payments.ReceiptMail, loc *time.Location) string {
%s
Дата покупки: %s
`, describe(r.Title, r.Chips, r.AmountMinor, r.Currency),
`, describe(r.Title, r.AmountMinor, r.Currency),
r.OperationTime.In(loc).Format("02.01.2006 15:04"))
}