58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
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;
|
|
}; |