fix: rename minmal total sum

This commit is contained in:
2026-06-17 21:03:26 +03:00
parent 20e0dc6db6
commit 8f60637e8d
2 changed files with 11 additions and 5 deletions

View File

@@ -7,8 +7,9 @@ from src.application.contracts import ILogger
from src.application.contracts import IItPayService from src.application.contracts import IItPayService
from src.application.domain.entities.order import OrderEntity from src.application.domain.entities.order import OrderEntity
from src.application.domain.enums import OrderStatus from src.application.domain.enums import OrderStatus
from src.application.domain.exceptions import ApplicationException, ForbiddenException, PriceChangedException from src.application.domain.exceptions import ApplicationException, ForbiddenException, OrderTotalOutOfRangeException, PriceChangedException
from src.application.services import PaymentQuoteService from src.application.services import PaymentQuoteService
from src.application.services.payment_quote_service import MIN_TOTAL_RUB
from src.infrastructure.database.decorators import transactional from src.infrastructure.database.decorators import transactional
from src.presentation.schemas.order import CreateOrder from src.presentation.schemas.order import CreateOrder
@@ -39,7 +40,12 @@ class CreateOrderCommand:
client_payment_id = str(ULID()) client_payment_id = str(ULID())
quote = await self._payment_quote_service.get_quote(payment_data.usdt_amount) if payment_data.total_price < MIN_TOTAL_RUB:
raise OrderTotalOutOfRangeException(
message='Order total is below minimum allowed amount',
)
quote = await self._payment_quote_service.get_reference_quote(payment_data.usdt_amount)
actual_gas_fee = quote.gas_fee actual_gas_fee = quote.gas_fee
actual_usdt_exchange_rate = quote.usdt_exchange_rate actual_usdt_exchange_rate = quote.usdt_exchange_rate
actual_service_fee = quote.service_fee actual_service_fee = quote.service_fee

View File

@@ -6,7 +6,7 @@ from src.application.contracts import ICache, ILogger
from src.application.domain.exceptions import OrderTotalOutOfRangeException, ServiceUnavailableException from src.application.domain.exceptions import OrderTotalOutOfRangeException, ServiceUnavailableException
_MIN_TOTAL_RUB: Decimal = Decimal('5000') MIN_TOTAL_RUB: Decimal = Decimal('5000')
_MAX_TOTAL_RUB: Decimal = Decimal('600000') _MAX_TOTAL_RUB: Decimal = Decimal('600000')
@@ -122,7 +122,7 @@ class PaymentQuoteService:
async def get_quote(self, usdt_amount: Decimal) -> PaymentQuote: async def get_quote(self, usdt_amount: Decimal) -> PaymentQuote:
quote = await self.get_reference_quote(usdt_amount) quote = await self.get_reference_quote(usdt_amount)
if quote.total_price < _MIN_TOTAL_RUB: if quote.total_price < MIN_TOTAL_RUB:
raise OrderTotalOutOfRangeException( raise OrderTotalOutOfRangeException(
message='Order total is below minimum allowed amount', message='Order total is below minimum allowed amount',
) )
@@ -130,7 +130,7 @@ class PaymentQuoteService:
async def get_quote_from_total_rub(self, total_rub: Decimal) -> PaymentQuote: async def get_quote_from_total_rub(self, total_rub: Decimal) -> PaymentQuote:
if total_rub < _MIN_TOTAL_RUB: if total_rub < MIN_TOTAL_RUB:
raise OrderTotalOutOfRangeException( raise OrderTotalOutOfRangeException(
message='Order total is below minimum allowed amount', message='Order total is below minimum allowed amount',
) )