diff --git a/static/chat.html b/static/chat.html index 982988c..3fda0f5 100644 --- a/static/chat.html +++ b/static/chat.html @@ -3229,8 +3229,12 @@ function addEstimatePanel(data, prevData, host) { const editable = !!(data.positions || []).some(p => p.code); // движок сможет пересчитать (data.positions || []).forEach((p, i) => { const tr = document.createElement('tr'); + // Движок отдаёт стоимость позиции и объём, но не всегда отдельную цену за единицу. + const unitPrice = typeof p.unit_cost === 'number' ? p.unit_cost + : typeof p.total === 'number' && typeof p.qty === 'number' && p.qty > 0 + ? p.total / p.qty : null; const cells = [i + 1, p.code || '', p.name || '', p.unit || '', - p.qty != null ? p.qty : '', fmtMoney(p.unit_cost), fmtMoney(p.total)]; + p.qty != null ? p.qty : '', fmtMoney(unitPrice), fmtMoney(p.total)]; cells.forEach((c, ci) => { const td = document.createElement('td'); td.dataset.label = ['№', 'Код', 'Наименование', 'Ед.', 'Кол-во', 'Цена/ед', 'Стоимость'][ci]; diff --git a/tests/test_inline_estimate_ui.py b/tests/test_inline_estimate_ui.py index 6745412..4bc6ebd 100644 --- a/tests/test_inline_estimate_ui.py +++ b/tests/test_inline_estimate_ui.py @@ -77,6 +77,7 @@ def test_choice_replaces_current_answer_without_new_bubble(browser, site): cssWidth: window.innerWidth, headDisplay: getComputedStyle(window._answer.querySelector('.est-header-row')).display, hostClass: window._answer.className, + unitPrice: window._answer.querySelector('.est-table tr:not(.est-header-row) td:nth-child(6)')?.textContent, horizontalOverflow: document.documentElement.scrollWidth > window.innerWidth })""") screenshot_dir = os.environ.get("INLINE_ESTIMATE_SCREENSHOTS") @@ -93,6 +94,7 @@ def test_choice_replaces_current_answer_without_new_bubble(browser, site): assert "240" in state["text"] and "4 квартал 2026" in state["text"] assert state["posts"][0]["zone_id"] == 12 assert state["posts"][0]["period_id"] == 404 + assert state["unitPrice"] == "120,00" assert state["headDisplay"] == "none", state assert not state["horizontalOverflow"]