worktree-citti-arkiver-tur #11
@@ -642,6 +642,12 @@ function qtyToPacks(s) {
|
|||||||
const m = (s || '').match(/([\d.]+)\s*stk/i);
|
const m = (s || '').match(/([\d.]+)\s*stk/i);
|
||||||
return m ? parseFloat(m[1]) : 0;
|
return m ? parseFloat(m[1]) : 0;
|
||||||
}
|
}
|
||||||
|
// Leading number of a quantity string ("6 × ½ kg" -> 6, "8 dåser" -> 8), used to
|
||||||
|
// scale a fixed line estimate when the quantity changes.
|
||||||
|
function qtyNum(s) {
|
||||||
|
const m = (s || '').replace(',', '.').replace(/~/g, '').replace(/½/g, '0.5').match(/([\d.]+)/);
|
||||||
|
return m ? parseFloat(m[1]) : null;
|
||||||
|
}
|
||||||
function curQty(row) {
|
function curQty(row) {
|
||||||
const inp = row.querySelector('.item-qty input');
|
const inp = row.querySelector('.item-qty input');
|
||||||
return inp ? (inp.value.trim() || inp.placeholder) : '';
|
return inp ? (inp.value.trim() || inp.placeholder) : '';
|
||||||
@@ -702,7 +708,15 @@ function recalcAll() {
|
|||||||
let est = 0;
|
let est = 0;
|
||||||
document.querySelectorAll('[data-est]').forEach(r => {
|
document.querySelectorAll('[data-est]').forEach(r => {
|
||||||
const offer = offerLineDkk(r); // real offer price if matched
|
const offer = offerLineDkk(r); // real offer price if matched
|
||||||
est += (offer != null) ? offer : (parseFloat(r.dataset.est) || 0);
|
if (offer != null) { est += offer; return; }
|
||||||
|
let base = parseFloat(r.dataset.est) || 0;
|
||||||
|
const qi = r.querySelector('.item-qty input'); // scale estimate with quantity
|
||||||
|
if (qi) {
|
||||||
|
const cur = qtyNum(qi.value.trim() || qi.placeholder);
|
||||||
|
const def = qtyNum(qi.placeholder);
|
||||||
|
if (cur != null && def != null && def > 0) base = base * (cur / def);
|
||||||
|
}
|
||||||
|
est += base;
|
||||||
});
|
});
|
||||||
document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';
|
document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user