feat: вкладка Аренда — колонки Estimate/Цена продажи; lot_description для прайслистов
Вкладка «Аренда»: добавлены колонки Estimate и Цена продажи (+ итоги), чекбокс «БУ» перенесён первым слева, таблица переведена на тот же разметку/классы, что и таблицы вкладки «Ценообразование». Прайслисты: local_pricelist_items получает lot_description (синхронизируется из qt_pricelist_items.lot_description) вместо устаревших available_qty/ partnumbers, которые нигде не заполнялись. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7edb80e498
commit
39e6fd5642
+43
-23
@@ -315,7 +315,7 @@
|
||||
<div class="flex items-baseline gap-3 mb-1">
|
||||
<h3 class="text-base font-semibold text-gray-800">Расчёт стоимости платного тестирования / аренды</h3>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mb-3">Черновая методика — параметры и коэффициенты могут измениться. Цена всегда за 1 неделю: разовый платёж (один раз) + еженедельный платёж (за каждую неделю теста/аренды). Цена берётся из Estimate, увеличенного на аплифт ниже. Поддержка сюда не входит.</p>
|
||||
<p class="text-xs text-gray-500 mb-3">Черновая методика — параметры и коэффициенты могут измениться. Цена всегда за 1 неделю: разовый платёж (один раз) + еженедельный платёж (за каждую неделю теста/аренды), с НДС. Цена продажи = Estimate, увеличенный на аплифт ниже. Поддержка сюда не входит.</p>
|
||||
<div class="flex flex-wrap items-end gap-4 mb-4">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-700 mb-1">Аплифт к Estimate, %</label>
|
||||
@@ -333,21 +333,25 @@
|
||||
<table class="w-full text-sm border-collapse">
|
||||
<thead class="bg-gray-50 text-gray-700">
|
||||
<tr>
|
||||
<th class="px-3 py-2 text-center border-b">БУ</th>
|
||||
<th class="px-3 py-2 text-left border-b">LOT</th>
|
||||
<th class="px-3 py-2 text-left border-b">Описание</th>
|
||||
<th class="px-3 py-2 text-left border-b">Категория</th>
|
||||
<th class="px-3 py-2 text-right border-b">Кол-во</th>
|
||||
<th class="px-3 py-2 text-center border-b">БУ</th>
|
||||
<th class="px-3 py-2 text-right border-b">Estimate</th>
|
||||
<th class="px-3 py-2 text-right border-b">Цена продажи</th>
|
||||
<th class="px-3 py-2 text-right border-b">Разовый платёж</th>
|
||||
<th class="px-3 py-2 text-right border-b">Еженедельный платёж</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="rental-body">
|
||||
<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>
|
||||
<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>
|
||||
</tbody>
|
||||
<tfoot id="rental-foot" class="hidden bg-gray-50 font-semibold">
|
||||
<tr>
|
||||
<td colspan="5" class="px-3 py-2 text-right">Итого (с НДС):</td>
|
||||
<td colspan="5" class="px-3 py-2 text-right">Итого:</td>
|
||||
<td class="px-3 py-2 text-right" id="rental-total-estimate">—</td>
|
||||
<td class="px-3 py-2 text-right" id="rental-total-sale">—</td>
|
||||
<td class="px-3 py-2 text-right" id="rental-total-onetime">—</td>
|
||||
<td class="px-3 py-2 text-right" id="rental-total-weekly">—</td>
|
||||
</tr>
|
||||
@@ -3358,7 +3362,7 @@ async function renderRentalTab() {
|
||||
const foot = document.getElementById('rental-foot');
|
||||
const warningsEl = document.getElementById('rental-warnings');
|
||||
if (!configUUID || cart.length === 0) {
|
||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>';
|
||||
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Загрузите компоненты во вкладке «Estimate»</td></tr>';
|
||||
foot.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
@@ -3378,13 +3382,13 @@ async function renderRentalTab() {
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!resp.ok) {
|
||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||
foot.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
result = await resp.json();
|
||||
} catch (e) {
|
||||
body.innerHTML = '<tr><td colspan="7" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-red-500">Не удалось рассчитать стоимость аренды</td></tr>';
|
||||
foot.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
@@ -3399,26 +3403,42 @@ async function renderRentalTab() {
|
||||
const descByLot = {};
|
||||
cart.forEach(c => { descByLot[(c.lot_name || '').toUpperCase()] = c.description || ''; });
|
||||
|
||||
const rows = (result.items || []).map(item => {
|
||||
const items = result.items || [];
|
||||
if (!items.length) {
|
||||
body.innerHTML = '<tr><td colspan="9" class="px-3 py-8 text-center text-gray-400">Нет компонентов</td></tr>';
|
||||
foot.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
let totEst = 0, totSale = 0;
|
||||
body.innerHTML = items.map(item => {
|
||||
const isUsed = item.condition === 'used';
|
||||
const desc = descByLot[(item.lot_name || '').toUpperCase()] || '';
|
||||
return '<tr class="border-b">' +
|
||||
'<td class="px-3 py-2">' + escapeHtml(item.lot_name) + '</td>' +
|
||||
'<td class="px-3 py-2 text-gray-500">' + escapeHtml(desc) + '</td>' +
|
||||
'<td class="px-3 py-2 text-gray-500">' + escapeHtml(item.category || '') + '</td>' +
|
||||
'<td class="px-3 py-2 text-right">' + item.quantity + '</td>' +
|
||||
'<td class="px-3 py-2 text-center">' +
|
||||
'<input type="checkbox" ' + (isUsed ? 'checked' : '') +
|
||||
' onchange="onRentalConditionChange(\'' + escapeHtml(item.lot_name).replace(/'/g, "\\'") + '\', this.checked)" class="rounded border-gray-300">' +
|
||||
'</td>' +
|
||||
'<td class="px-3 py-2 text-right">' + formatMoney(item.one_time) + '</td>' +
|
||||
'<td class="px-3 py-2 text-right">' + formatMoney(item.weekly) + '</td>' +
|
||||
'</tr>';
|
||||
const estTotal = item.buy_price * item.quantity;
|
||||
const saleTotal = item.price * item.quantity;
|
||||
totEst += estTotal;
|
||||
totSale += saleTotal;
|
||||
return `<tr class="pricing-row-buy">
|
||||
<td class="px-3 py-1.5 text-center text-xs border-t border-gray-200">
|
||||
<input type="checkbox" ${isUsed ? 'checked' : ''}
|
||||
onchange="onRentalConditionChange('${escapeHtml(item.lot_name).replace(/'/g, "\\'")}', this.checked)"
|
||||
class="rounded border-gray-300">
|
||||
</td>
|
||||
<td class="px-3 py-1.5 text-xs border-t border-gray-200">${escapeHtml(item.lot_name)}</td>
|
||||
<td class="px-3 py-1.5 text-xs text-gray-500 truncate max-w-xs border-t border-gray-200">${escapeHtml(desc)}</td>
|
||||
<td class="px-3 py-1.5 text-xs text-gray-500 border-t border-gray-200">${escapeHtml(item.category || '')}</td>
|
||||
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${item.quantity}</td>
|
||||
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(estTotal)}</td>
|
||||
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(saleTotal)}</td>
|
||||
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(item.one_time)}</td>
|
||||
<td class="px-3 py-1.5 text-right text-xs border-t border-gray-200">${formatCurrency(item.weekly)}</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
body.innerHTML = rows || '<tr><td colspan="7" class="px-3 py-8 text-center text-gray-400">Нет компонентов</td></tr>';
|
||||
|
||||
document.getElementById('rental-total-onetime').textContent = formatMoney(result.one_time_total);
|
||||
document.getElementById('rental-total-weekly').textContent = formatMoney(result.weekly_total);
|
||||
document.getElementById('rental-total-estimate').textContent = formatCurrency(totEst);
|
||||
document.getElementById('rental-total-sale').textContent = formatCurrency(totSale);
|
||||
document.getElementById('rental-total-onetime').textContent = formatCurrency(result.one_time_total);
|
||||
document.getElementById('rental-total-weekly').textContent = formatCurrency(result.weekly_total);
|
||||
foot.classList.remove('hidden');
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Артикул</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Категория</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Описание</th>
|
||||
<th id="th-qty" class="hidden px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Доступно</th>
|
||||
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Цена, $</th>
|
||||
<th id="th-settings" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Настройки</th>
|
||||
</tr>
|
||||
@@ -164,16 +163,9 @@
|
||||
|
||||
function toggleWarehouseColumns() {
|
||||
const stock = isStockSource();
|
||||
document.getElementById('th-qty').classList.toggle('hidden', true);
|
||||
document.getElementById('th-settings').classList.toggle('hidden', stock);
|
||||
}
|
||||
|
||||
function formatQty(qty) {
|
||||
if (typeof qty !== 'number') return '—';
|
||||
if (Number.isInteger(qty)) return qty.toString();
|
||||
return qty.toLocaleString('ru-RU', { minimumFractionDigits: 0, maximumFractionDigits: 3 });
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
if (text === null || text === undefined) return '';
|
||||
return String(text)
|
||||
|
||||
Reference in New Issue
Block a user