fix(price): remove baseprice detection, use directional price match
baseprice > price was wrongly treated as "quantity discount" — it's just GoMag's promotional price. Now: price_gomag <= pret_roa is always OK, only flag when GoMag charges MORE than ROA. Reset cached price_match at startup for re-evaluation. Fix dashboard dot color for mismatches. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -614,11 +614,9 @@ async function renderOrderDetailModal(orderNumber, opts) {
|
||||
const valoare = (Number(item.price || 0) * Number(item.quantity || 0));
|
||||
const clickAttr = opts.onQuickMap ? `onclick="_sharedModalQuickMap('${esc(item.sku)}','${esc(item.product_name||'')}','${esc(orderNumber)}',${idx})"` : '';
|
||||
const priceInfo = { pret_roa: item.pret_roa, match: item.price_match };
|
||||
const priceMismatchHtml = item.quantity_discount
|
||||
? `<div style="font-size:0.7rem"><span class="badge" style="background:var(--warning-light);color:var(--warning-text);font-size:9px;padding:1px 5px" aria-label="Discount aplicat, pret catalog ${fmtNum(item.baseprice)} lei">Disc.</span> <span style="text-decoration:line-through;opacity:0.6">${fmtNum(item.baseprice)}</span> ${fmtNum(item.price)} lei</div>`
|
||||
: (priceInfo.match === false
|
||||
? `<div class="text-danger" style="font-size:0.7rem">ROA: ${fmtNum(priceInfo.pret_roa)} lei</div>`
|
||||
: '');
|
||||
const priceMismatchHtml = priceInfo.match === false
|
||||
? `<div class="text-danger" style="font-size:0.7rem">ROA: ${fmtNum(priceInfo.pret_roa)} lei</div>`
|
||||
: '';
|
||||
return `<div class="dif-item">
|
||||
<div class="dif-row">
|
||||
<span class="dif-sku${opts.onQuickMap ? ' dif-codmat-link' : ''}" ${clickAttr}>${esc(item.sku)}</span>
|
||||
@@ -690,10 +688,6 @@ async function renderOrderDetailModal(orderNumber, opts) {
|
||||
if (item.kit) {
|
||||
matchDot = '<span class="badge" style="background:var(--info-light);color:var(--info-text);font-size:10px;padding:2px 6px">Kit</span>';
|
||||
rowStyle = '';
|
||||
} else if (item.quantity_discount) {
|
||||
const bpTitle = item.baseprice ? `Catalog: ${fmtNum(item.baseprice)} lei` : 'Discount GoMag';
|
||||
matchDot = `<span class="badge" style="background:var(--warning-light);color:var(--warning-text);font-size:10px;padding:2px 6px" title="${bpTitle}" aria-label="Discount aplicat, pret catalog ${fmtNum(item.baseprice)} lei">Disc.</span>`;
|
||||
rowStyle = '';
|
||||
} else if (priceInfo.pret_roa == null && priceInfo.match == null) {
|
||||
matchDot = '<span class="dot dot-gray"></span>';
|
||||
rowStyle = '';
|
||||
@@ -709,7 +703,7 @@ async function renderOrderDetailModal(orderNumber, opts) {
|
||||
<td>${esc(item.product_name || '-')}</td>
|
||||
<td>${renderCodmatCell(item)}</td>
|
||||
<td class="text-end">${item.quantity || 0}</td>
|
||||
<td class="text-end font-data">${item.quantity_discount && item.baseprice ? `<span style="text-decoration:line-through;opacity:0.6;font-size:0.8em">${fmtNum(item.baseprice)}</span> ${fmtNum(item.price)}` : (item.price != null ? fmtNum(item.price) : '-')}</td>
|
||||
<td class="text-end font-data">${item.price != null ? fmtNum(item.price) : '-'}</td>
|
||||
<td class="text-end font-data">${pretRoaHtml}</td>
|
||||
<td class="text-end">${item.vat != null ? Number(item.vat) : '-'}</td>
|
||||
<td class="text-end font-data">${fmtNum(valoare)}</td>
|
||||
|
||||
Reference in New Issue
Block a user