fix: update quote sum
This commit is contained in:
@@ -142,13 +142,11 @@ class PaymentQuoteService:
|
|||||||
|
|
||||||
usdt_exchange_rate, gas_fee = await self._load_prices()
|
usdt_exchange_rate, gas_fee = await self._load_prices()
|
||||||
|
|
||||||
u_budget = ((total_rub - gas_fee) / usdt_exchange_rate).quantize(Decimal('0.01'), rounding=ROUND_DOWN)
|
|
||||||
u_cap = ((_MAX_TOTAL_RUB - gas_fee) / (usdt_exchange_rate * Decimal('1.04'))).quantize(
|
u_cap = ((_MAX_TOTAL_RUB - gas_fee) / (usdt_exchange_rate * Decimal('1.04'))).quantize(
|
||||||
Decimal('0.01'),
|
Decimal('0.01'),
|
||||||
rounding=ROUND_DOWN,
|
rounding=ROUND_DOWN,
|
||||||
)
|
)
|
||||||
u_upper = min(u_budget, u_cap)
|
n_hi = int((u_cap * 100).to_integral_value(rounding=ROUND_DOWN))
|
||||||
n_hi = int((u_upper * 100).to_integral_value(rounding=ROUND_DOWN))
|
|
||||||
if n_hi < 1:
|
if n_hi < 1:
|
||||||
raise OrderTotalOutOfRangeException(
|
raise OrderTotalOutOfRangeException(
|
||||||
message='Order total is below minimum allowed amount',
|
message='Order total is below minimum allowed amount',
|
||||||
@@ -163,15 +161,15 @@ class PaymentQuoteService:
|
|||||||
if quote is None:
|
if quote is None:
|
||||||
n_hi = mid - 1
|
n_hi = mid - 1
|
||||||
continue
|
continue
|
||||||
if quote.total_price <= total_rub:
|
if quote.total_price >= total_rub:
|
||||||
best_cent = mid
|
best_cent = mid
|
||||||
n_lo = mid + 1
|
|
||||||
else:
|
|
||||||
n_hi = mid - 1
|
n_hi = mid - 1
|
||||||
|
else:
|
||||||
|
n_lo = mid + 1
|
||||||
|
|
||||||
if best_cent is None:
|
if best_cent is None:
|
||||||
raise OrderTotalOutOfRangeException(
|
raise OrderTotalOutOfRangeException(
|
||||||
message='Order total is below minimum allowed amount',
|
message='Order total exceeds maximum allowed amount',
|
||||||
)
|
)
|
||||||
|
|
||||||
final = self._compose_quote(
|
final = self._compose_quote(
|
||||||
|
|||||||
Reference in New Issue
Block a user