[TASK] Inital State

This commit is contained in:
chrosey
2020-01-13 16:09:25 +01:00
parent 0cef46b3b2
commit 42c50342ab
66 changed files with 53145 additions and 12594 deletions
+80
View File
@@ -0,0 +1,80 @@
export class Article{
constructor() {
this.name = "";
this.short = "";
this.dimension = "";
this.content = {
size : 0,
price: 0
};
this.portion = {
size : 0,
price : 0,
type : ""
};
}
get Name() {
return this.name;
}
set Name(value) {
this.name = value;
}
get Short() {
return this.short;
}
set Short(value) {
this.short = 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.Short = json.short;
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;
};
export const thawArticle = Article.thaw;
+72
View File
@@ -0,0 +1,72 @@
export class InventoryArticle {
constructor(article) {
this.article = article;
this.end = 0;
this.start = 0;
this.fetched = 0;
this.lost = 0;
}
get StartPortions() {
var countFull = Math.floor(this.start);
var fullPortions = countFull * this.article.Portions;
var rest = this.start - countFull;
var restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
}
get FetchedPortions() {
var countFull = Math.floor(this.fetched);
var fullPortions = countFull * this.article.Portions;
var rest = this.fetched - countFull;
var restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
}
get EndPortions() {
var countFull = Math.floor(this.end);
var fullPortions = countFull * this.article.Portions;
var rest = this.end - countFull;
var restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
}
get LostPortions() {
var countFull = Math.floor(this.lost);
var fullPortions = countFull * this.article.Portions;
var rest = this.lost - countFull;
var restPortions = rest / this.article.PortionSize;
return fullPortions + restPortions;
}
get Sold() {
var adds = this.StartPortions + this.FetchedPortions;
var subs = this.EndPortions + this.LostPortions;
return adds - subs;
}
get Sale() {
return this.Sold * this.article.PortionPrice;
}
get StepSize() {
var singlePack = this.article.Portions == 1;
return singlePack ? 1 : 0.05;
}
get PortionPrecision() {
var singlePack = this.article.Portions == 1;
return singlePack ? 0 : 2;
}
reset() {
this.start = 0;
this.fetched = 0;
this.end = 0;
this.lost = 0;
}
}
InventoryArticle.thaw = function (json) {
this.name = json.name;
this.start = json.start;
this.fetched = json.fetched;
this.end = json.end;
this.lost = json.lost;
};
export const thawInventoryArticle = InventoryArticle.thaw;