From f0327b264c11455fad772f44ffeeab3f52fa378c Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Fri, 2 Jan 2026 17:51:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B5=D0=B4=D0=B8=D0=BD=D0=B8=D1=86=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=D0=B6=D0=B8=20=D0=B2=20POS=20checkout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - При создании OrderItem теперь передаётся sales_unit из данных корзины - Это позволяет корректно рассчитывать total_amount для товаров с единицами продажи - Исправлена ошибка когда сумма заказа была 0 при использовании единиц продажи --- myproject/pos/views.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/myproject/pos/views.py b/myproject/pos/views.py index 199ca12..07f7507 100644 --- a/myproject/pos/views.py +++ b/myproject/pos/views.py @@ -1475,12 +1475,23 @@ def pos_checkout(request): if item_type == 'product': product = Product.objects.get(id=item_id) + # Получаем sales_unit_id если передан + sales_unit_id = item_data.get('sales_unit_id') + sales_unit = None + if sales_unit_id: + from products.models import ProductSalesUnit + try: + sales_unit = ProductSalesUnit.objects.get(id=sales_unit_id, product=product) + except ProductSalesUnit.DoesNotExist: + pass + OrderItem.objects.create( order=order, product=product, quantity=quantity, price=price, - is_custom_price=False + is_custom_price=False, + sales_unit=sales_unit ) elif item_type == 'kit': # Обычный комплект (не витринный) @@ -1529,6 +1540,8 @@ def pos_checkout(request): raise ValidationError(result['message']) # 3. Пересчитываем итоговую стоимость + # Обновляем объект заказа из БД, чтобы получить все связанные товары + order.refresh_from_db() order.calculate_total() # 4. Проводим платежи