Добавлено свойство overpayment для корректного отображения переплаты
This commit is contained in:
@@ -372,6 +372,11 @@ class Order(models.Model):
|
||||
"""Остаток к оплате"""
|
||||
return max(self.total_amount - self.amount_paid, 0)
|
||||
|
||||
@property
|
||||
def overpayment(self):
|
||||
"""Переплата (если amount_paid > total_amount)"""
|
||||
return max(self.amount_paid - self.total_amount, 0)
|
||||
|
||||
@property
|
||||
def subtotal(self):
|
||||
"""Сумма только товаров (без доставки)"""
|
||||
|
||||
@@ -612,17 +612,15 @@
|
||||
|
||||
<!-- Предупреждение о переплате -->
|
||||
{% if order.amount_paid > order.total_amount %}
|
||||
{% with overpayment=order.amount_paid|add:"-"|add:order.total_amount %}
|
||||
<div class="alert alert-warning mb-3">
|
||||
<i class="bi bi-exclamation-triangle-fill"></i> <strong>Обнаружена переплата!</strong><br>
|
||||
<small>
|
||||
Оплачено <strong>{{ order.amount_paid|floatformat:2 }} руб.</strong>,
|
||||
сумма заказа <strong>{{ order.total_amount|floatformat:2 }} руб.</strong><br>
|
||||
Переплата: <strong class="text-danger">{{ overpayment|floatformat:2 }} руб.</strong><br>
|
||||
Переплата: <strong class="text-danger">{{ order.overpayment|floatformat:2 }} руб.</strong><br>
|
||||
Создайте возврат в кошелёк клиента во вкладке «Создать возврат» ниже.
|
||||
</small>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
|
||||
Reference in New Issue
Block a user