From aabe19639a3e7c49cb8658b0cf1d90728978c5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Markovi=C4=87?= Date: Sun, 21 Jun 2026 01:05:45 +0200 Subject: [PATCH] Dinari: formatiranje iznosa u Alpine tabelama stavki (nova nabavka i prodaja) preko fmtDin --- web/static/js/ntech.js | 14 ++++++++++++++ web/templates/stranice/nabavka_forma.html | 10 +++++----- web/templates/stranice/prodaja_forma.html | 8 ++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/web/static/js/ntech.js b/web/static/js/ntech.js index 2e936e5..2c27170 100644 --- a/web/static/js/ntech.js +++ b/web/static/js/ntech.js @@ -181,6 +181,13 @@ document.addEventListener('alpine:init', () => { }, ukupnoSvega() { return this.stavke.reduce((z, s) => z + (parseFloat(s.kolicina) * parseFloat(s.cena) || 0), 0).toFixed(2) + }, + // fmtDin formatira broj sa separatorom hiljada (tačka) i 2 decimale (zarez): 1234567.5 → "1.234.567,50" + fmtDin(v) { + const n = parseFloat(v) || 0 + const [ceo, dec] = Math.abs(n).toFixed(2).split('.') + const saTackama = ceo.replace(/\B(?=(\d{3})+(?!\d))/g, '.') + return (n < 0 ? '-' : '') + saTackama + ',' + dec } })) @@ -327,6 +334,13 @@ document.addEventListener('alpine:init', () => { ukupnoSvega() { return this.stavke.reduce((z, s) => z + (parseFloat(s.kolicina) * parseFloat(s.cena) || 0), 0).toFixed(2) }, + // fmtDin formatira broj sa separatorom hiljada (tačka) i 2 decimale (zarez): 1234567.5 → "1.234.567,50" + fmtDin(v) { + const n = parseFloat(v) || 0 + const [ceo, dec] = Math.abs(n).toFixed(2).split('.') + const saTackama = ceo.replace(/\B(?=(\d{3})+(?!\d))/g, '.') + return (n < 0 ? '-' : '') + saTackama + ',' + dec + }, otvoriModal() { this.modal = true this.modalGreska = '' diff --git a/web/templates/stranice/nabavka_forma.html b/web/templates/stranice/nabavka_forma.html index a594cfb..04da5be 100644 --- a/web/templates/stranice/nabavka_forma.html +++ b/web/templates/stranice/nabavka_forma.html @@ -130,7 +130,7 @@ min="0" step="0.01" :disabled="isMobile" style="width:100%;text-align:right;"> - +
- Ukupno: + Ukupno:
@@ -251,7 +251,7 @@
- Ukupno troškovi: + Ukupno troškovi:
diff --git a/web/templates/stranice/prodaja_forma.html b/web/templates/stranice/prodaja_forma.html index 11ba2cd..5ac55b8 100644 --- a/web/templates/stranice/prodaja_forma.html +++ b/web/templates/stranice/prodaja_forma.html @@ -217,7 +217,7 @@ font-weight: 500; color: var(--tekst-glavni); "> - +