Fix POS card display: show free qty (available-reserved) instead of available qty

This commit is contained in:
2025-11-17 16:27:49 +03:00
parent c06e569cbd
commit 4c66a6f8f4

View File

@@ -189,17 +189,18 @@ function renderProducts() {
stock.style.color = '#856404';
stock.style.fontWeight = 'bold';
} else if (item.type === 'product' && item.available_qty !== undefined && item.reserved_qty !== undefined) {
// Для обычных товаров показываем остатки: X(-Y)
// Для обычных товаров показываем остатки: FREE(-RESERVED)
// FREE = доступно для продажи (available - reserved)
const available = parseFloat(item.available_qty) || 0;
const reserved = parseFloat(item.reserved_qty) || 0;
const free = available - reserved;
// Создаём элементы для стилизации разных размеров
const availableSpan = document.createElement('span');
availableSpan.textContent = available;
availableSpan.style.fontSize = '1.1em';
availableSpan.style.fontWeight = 'bold';
availableSpan.style.fontStyle = 'normal';
const freeSpan = document.createElement('span');
freeSpan.textContent = free;
freeSpan.style.fontSize = '1.1em';
freeSpan.style.fontWeight = 'bold';
freeSpan.style.fontStyle = 'normal';
// Отображаем резерв только если он есть
if (reserved > 0) {
@@ -209,10 +210,10 @@ function renderProducts() {
reservedSpan.style.marginLeft = '3px';
reservedSpan.style.fontStyle = 'normal';
stock.appendChild(availableSpan);
stock.appendChild(freeSpan);
stock.appendChild(reservedSpan);
} else {
stock.appendChild(availableSpan);
stock.appendChild(freeSpan);
}
// Цветовая индикация: красный если свободных остатков нет или отрицательные