From 49146a8ba6fd8e188089f42f1abca22061a8e1fe Mon Sep 17 00:00:00 2001 From: TLRZ Seyfferth Date: Wed, 10 Jan 2018 17:29:27 +0100 Subject: [PATCH] updates --- data/test_articles.json | 314 +--------------------------------- index.html | 182 +++++++++++--------- js/app.js | 11 +- js/model/inventory_article.js | 4 + js/vue.js | 39 ++++- 5 files changed, 148 insertions(+), 402 deletions(-) diff --git a/data/test_articles.json b/data/test_articles.json index 9ae679a..69477d5 100644 --- a/data/test_articles.json +++ b/data/test_articles.json @@ -1,313 +1 @@ -[{ - "name": "Edelpils", - "dimension": "l", - "content": { - "size": 0.33, - "price": 0 - }, - "portion": { - "size": 0.33, - "price": 3.5, - "type": "Fl." - } -}, { - "name": "Schwarzbier", - "dimension": "l", - "content": { - "size": 0.33, - "price": 0 - }, - "portion": { - "size": 0.33, - "price": 3.5, - "type": "Fl." - } -}, { - "name": "Schöfferhofer", - "dimension": "l", - "content": { - "size": 0.33, - "price": 0 - }, - "portion": { - "size": 0.33, - "price": 3.5, - "type": "Fl." - } -}, { - "name": "Bitburger af.", - "dimension": "l", - "content": { - "size": 0.33, - "price": 0 - }, - "portion": { - "size": 0.33, - "price": 3.5, - "type": "Fl." - } -}, { - "name": "Riesling", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 6, - "type": "Gl." - } -}, { - "name": "Amareno", - "dimension": "l", - "content": { - "size": 0.75, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 6.5, - "type": "Gl." - } -}, { - "name": "Secco", - "dimension": "l", - "content": { - "size": 0.75, - "price": 0 - }, - "portion": { - "size": 0.1, - "price": 6, - "type": "Gl." - } -}, { - "name": "B-Saft", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 3.5, - "type": "Gl." - } -}, { - "name": "K-Saft", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 3.5, - "type": "Gl." - } -}, { - "name": "O-Saft", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 3.5, - "type": "Gl." - } -}, { - "name": "G-Saft", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 3.5, - "type": "Gl." - } -}, { - "name": "Vita Cola", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 2.5, - "type": "Gl." - } -}, { - "name": "Vita Orange", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 2.5, - "type": "Gl." - } -}, { - "name": "Vita Zitrone", - "dimension": "l", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 0.2, - "price": 2.5, - "type": "Gl." - } -}, { - "name": "Tonic", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 3, - "type": "Fl." - } -}, { - "name": "Bitter Lemon", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 3, - "type": "Fl." - } -}, { - "name": "Ginger Ale", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 3, - "type": "Fl." - } -}, { - "name": "Apfelschorle", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 3, - "type": "Fl." - } -}, { - "name": "TWQ naturell", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 2.5, - "type": "Fl." - } -}, { - "name": "TWQ medium", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 2.5, - "type": "Fl." - } -}, { - "name": "TWQ classic", - "dimension": "l", - "content": { - "size": 0.25, - "price": 0 - }, - "portion": { - "size": 0.25, - "price": 2.5, - "type": "Fl." - } -}, { - "name": "Kaffee", - "dimension": "Tasse", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 1, - "price": 2.5, - "type": "T" - } -}, { - "name": "Latte Macchiato", - "dimension": "Glas", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 1, - "price": 3.5, - "type": "Gl." - } -}, { - "name": "dopp. Esp.", - "dimension": "Tasse", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 1, - "price": 3.5, - "type": "T" - } -}, { - "name": "Brezel", - "dimension": "Stück", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 1, - "price": 2.5, - "type": "Stk." - } -}, { - "name": "Schokoriegel", - "dimension": "Stück", - "content": { - "size": 1, - "price": 0 - }, - "portion": { - "size": 1, - "price": 2, - "type": "Stk." - } -}] \ No newline at end of file +[{"name":"Edelpils","dimension":"l","content":{"size":0.33,"price":0},"portion":{"size":0.33,"price":3.5,"type":"Fl."}},{"name":"Schwarzbier","dimension":"l","content":{"size":0.33,"price":0},"portion":{"size":0.33,"price":3.5,"type":"Fl."}},{"name":"Schöfferhofer","dimension":"l","content":{"size":0.33,"price":0},"portion":{"size":0.33,"price":3.5,"type":"Fl."}},{"name":"Bitburger af.","dimension":"l","content":{"size":0.33,"price":0},"portion":{"size":0.33,"price":3.5,"type":"Fl."}},{"name":"Weiswein","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":6,"type":"Gl."}},{"name":"Rotwein","dimension":"l","content":{"size":0.75,"price":0},"portion":{"size":0.2,"price":6.5,"type":"Gl."}},{"name":"Secco","dimension":"l","content":{"size":0.75,"price":0},"portion":{"size":0.1,"price":6,"type":"Gl."}},{"name":"B-Saft","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":3.5,"type":"Gl."}},{"name":"K-Saft","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":3.5,"type":"Gl."}},{"name":"O-Saft","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":3.5,"type":"Gl."}},{"name":"G-Saft","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":3.5,"type":"Gl."}},{"name":"Vita Cola","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":2.5,"type":"Gl."}},{"name":"Vita Orange","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":2.5,"type":"Gl."}},{"name":"Vita Zitrone","dimension":"l","content":{"size":1,"price":0},"portion":{"size":0.2,"price":2.5,"type":"Gl."}},{"name":"Tonic","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":3,"type":"Fl."}},{"name":"Bitter Lemon","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":3,"type":"Fl."}},{"name":"Ginger Ale","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":3,"type":"Fl."}},{"name":"Apfelschorle","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":3,"type":"Fl."}},{"name":"TWQ naturell","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":2.5,"type":"Fl."}},{"name":"TWQ medium","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":2.5,"type":"Fl."}},{"name":"TWQ classic","dimension":"l","content":{"size":0.25,"price":0},"portion":{"size":0.25,"price":2.5,"type":"Fl."}},{"name":"Kaffee","dimension":"Tasse","content":{"size":1,"price":0},"portion":{"size":1,"price":2.5,"type":"T"}},{"name":"Latte Macchiato","dimension":"Glas","content":{"size":1,"price":0},"portion":{"size":1,"price":3.5,"type":"Gl."}},{"name":"dopp. Esp.","dimension":"Tasse","content":{"size":1,"price":0},"portion":{"size":1,"price":3.5,"type":"T"}},{"name":"Brezel","dimension":"Stück","content":{"size":1,"price":0},"portion":{"size":1,"price":2.5,"type":"Stk."}},{"name":"Schokoriegel","dimension":"Stück","content":{"size":1,"price":0},"portion":{"size":1,"price":2,"type":"Stk."}}] \ No newline at end of file diff --git a/index.html b/index.html index 44d7901..b77a260 100644 --- a/index.html +++ b/index.html @@ -9,20 +9,20 @@ - + -
+
-
- - - - - - - - - - - - - - - - - - - - -
ArtikelnameGesamtmengePortionsmengeGesamtpreis
-
- -
-
-
- -
-
- -
- -
-
- -
-
- -
-
- -
- -
-
- {{ a.ContentPrice.toFixed(2) }} € -
-
- -
+
+
+
+
+
+ + +
+
+ + +
+
+ + + z.B. Liter(l), Stück(Stk.) +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ Gesamtpreis {{ a.ContentPrice | currency }} +
+
+
+
+ +
+ + + +
+
+
{{ a.article.name }}
{{a.article.portion.price.toFixed(2)}} €
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
{{ a.Sold | number }} {{ a.article.PortionType }}
{{ a.Sale | currency }}
+
+
+
+ {{ sales_ug | currency }} +
+
+
+
+
+
+ + + + + + + + + + + +
{{ item.count }} ×{{ item.name }}{{ item.price * item.count | currency }}
{{ bon_sum > 0 ?bon_sum: "" }}{{ bon_sum > 0 ? "Artikel": ""}}{{ bon_price }}
+
+
+
+
+ +
+ +
+
+
- - -
-
-
{{ a.article.name }}
{{a.article.portion.price.toFixed(2)}} €
-
-
- -
-
- -
-
- -
-
- -
-
-
{{ a.Sold }} {{ a.article.PortionType }}
{{ a.Sale.toFixed(2) }} €
-
-
-
- {{ sales_ug.toFixed(2) }} € -
-
+
- + - + diff --git a/js/app.js b/js/app.js index 4cec38b..66500d6 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,16 @@ accounting.settings = { decimal: ",", thousand: ".", precision: 2 - } + }, + number: { + precision : 2, // default precision on numbers is 0 + thousand: ".", + decimal : "," + } } +$(document).ready(function(){ + $('.tabs').tabs(); + $('.fixed-action-btn').floatingActionButton(); +}) \ No newline at end of file diff --git a/js/model/inventory_article.js b/js/model/inventory_article.js index 3e34cde..ad8f18a 100644 --- a/js/model/inventory_article.js +++ b/js/model/inventory_article.js @@ -46,6 +46,10 @@ InventoryArticle.prototype = { }, get Sale() { return this.Sold * this.article.PortionPrice; + }, + get StepSize() { + singlePack = this.article.Portions == 1; + return singlePack ? 1 : 0.05; } }; diff --git a/js/vue.js b/js/vue.js index 420c19e..1c5d61b 100644 --- a/js/vue.js +++ b/js/vue.js @@ -1,3 +1,10 @@ +Vue.filter('currency', function(money){ + return accounting.formatMoney(money); +}); +Vue.filter('number', function(number){ + return accounting.formatNumber(number); +}); + var app = new Vue({ el: "#app", data : { @@ -13,7 +20,8 @@ var app = new Vue({ ug : [], mob : [], stud : [] - } + }, + bon: [] }, computed: { sales_ug: function (){ @@ -21,7 +29,19 @@ var app = new Vue({ return total + item.Sale; }, 0); return total_sales; - } + }, + bon_price: function() { + var total = this.bon.reduce(function(total, item) { + return total + item.count * item.price; + }, 0); + return accounting.formatMoney(total); + }, + bon_sum: function() { + var total = this.bon.reduce(function(total, item) { + return total + item.count; + }, 0); + return total; + } }, methods: { addArticle: function() { @@ -30,7 +50,7 @@ var app = new Vue({ storeArticles: function() { this.$http.post('./backend?controller=Article&action=store', JSON.stringify(this.articles)) .then(response => { - Materialize.toast(response.body, 2000); + M.toast({html: response.body}); }) }, loadArticles: function() { @@ -41,15 +61,24 @@ var app = new Vue({ this.articles.push(Article.thaw(element)); }); }).then( x => { - Materialize.toast('Artikel wurden geladen.', 2000); + M.toast({ html: 'Artikel wurden geladen.'}); }).then( x => { this.articles.forEach(a => { ia = new InventoryArticle(); ia.article = a; this.inventory.ug.push(ia); + this.bon.push({count: 0, name: a.name, price: a.portion.price}); }); }).then( x => { - Materialize.updateTextFields(); + M.updateTextFields(); + }); + }, + bonArticle: function(article) { + + }, + bonned: function (items) { + return items.filter(function (item) { + return item.count > 0; }); } },