Fixed calculate of discount in premium subscription options.

This commit is contained in:
23rd 2023-02-07 04:40:51 +03:00 committed by John Preston
parent 5f3e7235a5
commit e486cf1afa
1 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Api { namespace Api {
constexpr auto kDiscountDivider = 5.; constexpr auto kDiscountDivider = 1.;
Data::SubscriptionOption CreateSubscriptionOption( Data::SubscriptionOption CreateSubscriptionOption(
int months, int months,
@ -20,7 +20,7 @@ Data::SubscriptionOption CreateSubscriptionOption(
const QString &currency, const QString &currency,
const QString &botUrl) { const QString &botUrl) {
const auto discount = [&] { const auto discount = [&] {
const auto percent = monthlyAmount * months / float64(amount) - 1.; const auto percent = 1. - float64(amount) / (monthlyAmount * months);
return std::round(percent * 100. / kDiscountDivider) return std::round(percent * 100. / kDiscountDivider)
* kDiscountDivider; * kDiscountDivider;
}(); }();