initial commit

This commit is contained in:
TLRZ Seyfferth
2018-01-10 10:06:05 +01:00
commit 134137e3a4
12 changed files with 1950 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
function Article() {
this.name = "";
this.dimension = "";
this.content = {
size : 0,
price: 0
};
this.portion = {
size : 0,
price : 0,
type : ""
};
}
Article.prototype = {
get Name() {
return this.name;
},
set Name(value) {
this.name = value;
},
get ContentSize() {
return this.content.size;
},
set ContentSize(value) {
this.content.size = value;
},
get Dimension() {
return this.dimension;
},
set Dimension(value) {
this.dimension = value;
},
get PortionSize() {
return this.portion.size;
},
set PortionSize(value) {
this.portion.size = value;
},
get PortionType() {
return this.portion.type;
},
set PortionType(value) {
this.portion.type = value;
},
get PortionPrice() {
return this.portion.price;
},
set PortionPrice(value) {
this.portion.price = value;
},
get ContentPrice() {
return this.Portions * this.portion.price;
},
get Portions() {
return this.content.size / (this.portion.size || 1);
}
};
Article.thaw = function (json) {
var article = new Article();
article.id = json.id;
article.Name = json.name;
article.Dimension = json.dimension;
article.ContentSize = json.content.size;
article.PortionPrice = json.portion.price;
article.PortionSize = json.portion.size;
article.PortionType = json.portion.type;
return article;
};
+58
View File
@@ -0,0 +1,58 @@
function InventoryArticle(){
this.article = new Article();
this.end = 0,
this.start = 0;
this.fetched = 0;
this.lost = 0;
}
InventoryArticle.prototype = {
get StartPortions() {
countFull = Math.floor(this.start);
fullPortions = countFull * this.article.Portions;
rest = this.start - countFull;
restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
},
get FetchedPortions() {
countFull = Math.floor(this.fetched);
fullPortions = countFull * this.article.Portions;
rest = this.fetched - countFull;
restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
},
get EndPortions() {
countFull = Math.floor(this.end);
fullPortions = countFull * this.article.Portions;
rest = this.end - countFull;
restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
},
get LostPortions() {
countFull = Math.floor(this.lost);
fullPortions = countFull * this.article.Portions;
rest = this.lost - countFull;
restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
},
get Sold() {
adds = this.StartPortions + this.FetchedPortions;
subs = this.EndPortions + this.LostPortions;
return adds - subs;
},
get Sale() {
return this.Sold * this.article.PortionPrice;
}
};
InventoryArticle.thaw = function(json){
this.name = json.name;
this.start = json.start;
this.fetched = json.fetched;
this.end = json.end;
this.lost = json.lost;
};