From b2a29bf1aa48a0366281b16df6c253b5ddcfca4a Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Thu, 11 Dec 2025 00:17:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D0=BD=D1=83=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B0=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Используется фильтр smart_quantity вместо floatformat - Целые числа отображаются без дробной части: 2 вместо 2,000 - Дробные числа без лишних нулей: 2,5 вместо 2,500 - Запятая используется вместо точки (русский формат) - JavaScript также форматирует количество после сохранения - Улучшена читаемость для работы с цветами и штучными товарами --- .../inventory/writeoff_document/detail.html | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/myproject/inventory/templates/inventory/writeoff_document/detail.html b/myproject/inventory/templates/inventory/writeoff_document/detail.html index 217b69c..58549e4 100644 --- a/myproject/inventory/templates/inventory/writeoff_document/detail.html +++ b/myproject/inventory/templates/inventory/writeoff_document/detail.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load static %} +{% load inventory_filters %} {% block title %}Документ списания {{ document.document_number }}{% endblock %} @@ -194,7 +195,7 @@ {{ item.product.name }} - {{ item.quantity }} + {{ item.quantity|smart_quantity }} {% if document.can_edit %} Итого: - {{ document.total_quantity }} + {{ document.total_quantity|smart_quantity }} @@ -465,7 +466,16 @@ document.addEventListener('DOMContentLoaded', function() { .then(data => { if (data.success) { // Обновляем отображение - row.querySelector('.item-quantity-display').textContent = quantity; + // Форматируем количество: убираем лишние нули, целые без дробной части + let formattedQty = parseFloat(quantity); + if (formattedQty === Math.floor(formattedQty)) { + // Целое число - без дробной части + formattedQty = Math.floor(formattedQty).toString(); + } else { + // Дробное - убираем лишние нули и заменяем точку на запятую + formattedQty = formattedQty.toString().replace('.', ','); + } + row.querySelector('.item-quantity-display').textContent = formattedQty; const reasonSelect = row.querySelector('.item-reason-input'); const reasonLabel = reasonSelect.options[reasonSelect.selectedIndex].text; row.querySelector('.item-reason-display').innerHTML = `${reasonLabel}`;