Удалить поле discount_amount из модели Order
Убрано поле скидки из системы для последующей реализации полноценной системы скидок. Изменения: - Удалено поле discount_amount из модели Order - Убрано из формы OrderForm - Удалено из шаблонов order_form.html и order_detail.html - Убрано из админки OrderAdmin - Обновлен метод calculate_total() (без вычитания скидки) В будущем будет создана отдельная модель Discount с промокодами, процентными скидками и автоматическими акциями. ВАЖНО: После этого коммита нужно создать и применить миграцию: python manage.py makemigrations orders -n remove_discount_amount python manage.py migrate orders
This commit is contained in:
@@ -95,7 +95,6 @@ class OrderAdmin(admin.ModelAdmin):
|
|||||||
('Оплата', {
|
('Оплата', {
|
||||||
'fields': (
|
'fields': (
|
||||||
'total_amount',
|
'total_amount',
|
||||||
'discount_amount',
|
|
||||||
'amount_paid',
|
'amount_paid',
|
||||||
'amount_due',
|
'amount_due',
|
||||||
'payment_status',
|
'payment_status',
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ class OrderForm(forms.ModelForm):
|
|||||||
'recipient_name',
|
'recipient_name',
|
||||||
'recipient_phone',
|
'recipient_phone',
|
||||||
'status',
|
'status',
|
||||||
'discount_amount',
|
|
||||||
'is_anonymous',
|
'is_anonymous',
|
||||||
'special_instructions',
|
'special_instructions',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -137,15 +137,6 @@ class Order(models.Model):
|
|||||||
help_text="Общая сумма заказа включая доставку"
|
help_text="Общая сумма заказа включая доставку"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Скидки
|
|
||||||
discount_amount = models.DecimalField(
|
|
||||||
max_digits=10,
|
|
||||||
decimal_places=2,
|
|
||||||
default=0,
|
|
||||||
verbose_name="Сумма скидки",
|
|
||||||
help_text="Применяется вручную или через систему скидок"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Частичная оплата
|
# Частичная оплата
|
||||||
amount_paid = models.DecimalField(
|
amount_paid = models.DecimalField(
|
||||||
max_digits=10,
|
max_digits=10,
|
||||||
@@ -332,8 +323,7 @@ class Order(models.Model):
|
|||||||
# Пересчитываем стоимость доставки если она автоматическая
|
# Пересчитываем стоимость доставки если она автоматическая
|
||||||
self.recalculate_delivery_cost()
|
self.recalculate_delivery_cost()
|
||||||
|
|
||||||
subtotal = items_total + self.delivery_cost
|
self.total_amount = items_total + self.delivery_cost
|
||||||
self.total_amount = subtotal - self.discount_amount
|
|
||||||
return self.total_amount
|
return self.total_amount
|
||||||
|
|
||||||
def update_payment_status(self):
|
def update_payment_status(self):
|
||||||
|
|||||||
@@ -312,12 +312,6 @@
|
|||||||
<div class="col-6 text-end">{{ order.delivery_cost|floatformat:2 }} руб.</div>
|
<div class="col-6 text-end">{{ order.delivery_cost|floatformat:2 }} руб.</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if order.discount_amount > 0 %}
|
|
||||||
<div class="row mb-2">
|
|
||||||
<div class="col-6"><strong>Скидка:</strong></div>
|
|
||||||
<div class="col-6 text-end text-danger">-{{ order.discount_amount|floatformat:2 }} руб.</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-6"><strong>Итого:</strong></div>
|
<div class="col-6"><strong>Итого:</strong></div>
|
||||||
|
|||||||
@@ -700,16 +700,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Скидка -->
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="{{ form.discount_amount.id_for_label }}" class="form-label">Скидка</label>
|
|
||||||
{{ form.discount_amount }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user