From 5e1170839e5942661e75bf052d42758eed07217d Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Mon, 1 Jun 2020 21:11:15 +0200 Subject: [PATCH] Update Gross Price in Article Edit View. Fixes #31 --- .../main/resources/static/js/editViewUpdateTax.js | 15 +++++++++++++++ .../templates/intern/listedArticles/id.html | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 prototype/src/main/resources/static/js/editViewUpdateTax.js diff --git a/prototype/src/main/resources/static/js/editViewUpdateTax.js b/prototype/src/main/resources/static/js/editViewUpdateTax.js new file mode 100644 index 0000000..0724150 --- /dev/null +++ b/prototype/src/main/resources/static/js/editViewUpdateTax.js @@ -0,0 +1,15 @@ +document.addEventListener("DOMContentLoaded", function() { + let priceElm = document.getElementById("price"); + let priceGrossElm = document.getElementById("priceGross"); + let vatPercent = parseInt(document.getElementById("vatPercent").value); + + let updateFn = () => { + let net = Math.floor(priceElm.value*100); + let vat = Math.floor((net * vatPercent) / 100); + let gross = net + vat; + + priceGrossElm.innerText = (gross / 100.0).toFixed(2).replace("\\.", ","); + }; + + priceElm.onchange = updateFn; +}); diff --git a/prototype/src/main/resources/templates/intern/listedArticles/id.html b/prototype/src/main/resources/templates/intern/listedArticles/id.html index e34e41c..e1cd1a7 100644 --- a/prototype/src/main/resources/templates/intern/listedArticles/id.html +++ b/prototype/src/main/resources/templates/intern/listedArticles/id.html @@ -5,6 +5,7 @@ Bearbeiten: Artikel + @@ -50,8 +51,9 @@  EUR
(% Mwst.) +
- =  EUR Brutto + =  EUR Brutto