Убраны лишние нули в отображении количества товаров
- Используется фильтр smart_quantity вместо floatformat - Целые числа отображаются без дробной части: 2 вместо 2,000 - Дробные числа без лишних нулей: 2,5 вместо 2,500 - Запятая используется вместо точки (русский формат) - JavaScript также форматирует количество после сохранения - Улучшена читаемость для работы с цветами и штучными товарами
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% load inventory_filters %}
|
||||
|
||||
{% block title %}Документ списания {{ document.document_number }}{% endblock %}
|
||||
|
||||
@@ -194,7 +195,7 @@
|
||||
<a href="{% url 'products:product-detail' item.product.id %}">{{ item.product.name }}</a>
|
||||
</td>
|
||||
<td class="px-3 py-2 text-end">
|
||||
<span class="item-quantity-display">{{ item.quantity }}</span>
|
||||
<span class="item-quantity-display">{{ item.quantity|smart_quantity }}</span>
|
||||
{% if document.can_edit %}
|
||||
<input type="number" class="form-control form-control-sm item-quantity-input"
|
||||
value="{{ item.quantity }}" step="0.001" min="0.001"
|
||||
@@ -260,7 +261,7 @@
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<td class="px-3 py-2 fw-semibold">Итого:</td>
|
||||
<td class="px-3 py-2 text-end fw-semibold">{{ document.total_quantity }}</td>
|
||||
<td class="px-3 py-2 fw-semibold">{{ document.total_quantity|smart_quantity }}</td>
|
||||
<td colspan="{% if document.can_edit %}3{% else %}2{% endif %}"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@@ -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 = `<span class="badge bg-light text-dark">${reasonLabel}</span>`;
|
||||
|
||||
Reference in New Issue
Block a user