Fixed calculate of discount in premium subscription options.
This commit is contained in:
parent
5f3e7235a5
commit
e486cf1afa
|
@ -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 ¤cy,
|
const QString ¤cy,
|
||||||
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;
|
||||||
}();
|
}();
|
||||||
|
|
Loading…
Reference in New Issue