diff --git a/templates/index.html b/templates/index.html
index 9dd87b8..f0855a3 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -642,6 +642,12 @@ function qtyToPacks(s) {
const m = (s || '').match(/([\d.]+)\s*stk/i);
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) {
const inp = row.querySelector('.item-qty input');
return inp ? (inp.value.trim() || inp.placeholder) : '';
@@ -702,7 +708,15 @@ function recalcAll() {
let est = 0;
document.querySelectorAll('[data-est]').forEach(r => {
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') : '—';