diff --git a/myproject/products/templates/products/productkit_detail.html b/myproject/products/templates/products/productkit_detail.html index 9c0e364..7e92c82 100644 --- a/myproject/products/templates/products/productkit_detail.html +++ b/myproject/products/templates/products/productkit_detail.html @@ -49,40 +49,37 @@ {% endif %} -
Цена:
+
Базовая цена:
+
+ {{ kit.base_price|floatformat:2 }} руб. + (сумма компонентов) +
+ +
Итоговая цена:
{% if kit.sale_price %} - {{ kit.calculated_price|floatformat:2 }} руб. + {{ kit.price|floatformat:2 }} руб. +
{{ kit.sale_price|floatformat:2 }} руб. Акция {% else %} - {{ kit.actual_price|floatformat:2 }} руб. + {{ kit.price|floatformat:2 }} руб. {% endif %}
-
Себестоимость:
+ {% if kit.price_adjustment_type != 'none' and kit.price_adjustment_value > 0 %} +
Корректировка цены:
- {{ kit.calculate_cost|floatformat:2 }} руб. + {% if kit.price_adjustment_type == 'increase_percent' %} + Увеличить на {{ kit.price_adjustment_value }}% + {% elif kit.price_adjustment_type == 'increase_amount' %} + Увеличить на {{ kit.price_adjustment_value }} руб. + {% elif kit.price_adjustment_type == 'decrease_percent' %} + Уменьшить на {{ kit.price_adjustment_value }}% + {% elif kit.price_adjustment_type == 'decrease_amount' %} + Уменьшить на {{ kit.price_adjustment_value }} руб. + {% endif %}
- -
Ценообразование:
-
- {{ kit.get_pricing_method_display }} -
- - {% if kit.price %} -
Ручная цена:
-
{{ kit.price }} руб.
- {% endif %} - - {% if kit.markup_percent %} -
Процент наценки:
-
{{ kit.markup_percent }}%
- {% endif %} - - {% if kit.markup_amount %} -
Фиксированная наценка:
-
{{ kit.markup_amount }} руб.
{% endif %}
Статус:
diff --git a/myproject/products/templates/products/productkit_edit.html b/myproject/products/templates/products/productkit_edit.html index ade4117..cc8bf34 100644 --- a/myproject/products/templates/products/productkit_edit.html +++ b/myproject/products/templates/products/productkit_edit.html @@ -887,17 +887,29 @@ document.addEventListener('DOMContentLoaded', function() { const currentAdjustmentType = adjustmentTypeInput.value; const currentAdjustmentValue = parseFloat(adjustmentValueInput.value) || 0; + console.log('Loading saved adjustment values:', { + type: currentAdjustmentType, + value: currentAdjustmentValue + }); + if (currentAdjustmentType && currentAdjustmentType !== 'none' && currentAdjustmentValue > 0) { // Заполняем соответствующее поле ввода в зависимости от сохранённого типа if (currentAdjustmentType === 'increase_percent') { increasePercentInput.value = currentAdjustmentValue; + console.log('Loaded increase_percent:', currentAdjustmentValue); } else if (currentAdjustmentType === 'increase_amount') { increaseAmountInput.value = currentAdjustmentValue; + console.log('Loaded increase_amount:', currentAdjustmentValue); } else if (currentAdjustmentType === 'decrease_percent') { decreasePercentInput.value = currentAdjustmentValue; + console.log('Loaded decrease_percent:', currentAdjustmentValue); } else if (currentAdjustmentType === 'decrease_amount') { decreaseAmountInput.value = currentAdjustmentValue; + console.log('Loaded decrease_amount:', currentAdjustmentValue); } + + // Обновляем состояние полей (отключаем остальные, помечаем как валидные) + validateSingleAdjustment(); } // Пересчитываем цену после загрузки значений diff --git a/myproject/products/views/productkit_views.py b/myproject/products/views/productkit_views.py index 7a346b5..f7bc295 100644 --- a/myproject/products/views/productkit_views.py +++ b/myproject/products/views/productkit_views.py @@ -163,8 +163,8 @@ class ProductKitCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateVi kititem_formset.instance = self.object saved_items = kititem_formset.save() - # Валидация ценообразования больше не требуется в новой системе - # (новая система использует простой расчёт на основе actual_price компонентов) + # Пересчитываем базовую цену после сохранения всех компонентов + self.object.recalculate_base_price() # Обработка фотографий handle_photos(self.request, self.object, ProductKitPhoto, 'kit') @@ -232,6 +232,9 @@ class ProductKitUpdateView(LoginRequiredMixin, PermissionRequiredMixin, UpdateVi kititem_formset.instance = self.object kititem_formset.save() + # Пересчитываем базовую цену после сохранения всех компонентов + self.object.recalculate_base_price() + # Обработка фотографий handle_photos(self.request, self.object, ProductKitPhoto, 'kit')