export class Article{ constructor() { this.id = 0; this.name = ""; this.short = ""; this.dimension = 0; this.group = 0; this.content = { size : 0, price: 0 }; this.portion = { size : 0, price : 0, type : 0 }; } 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 Group() { return this.group; } set Group(value) { this.group = 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.content_dimension; article.ContentSize = json.content_size; article.PortionPrice = json.portion_price; article.PortionSize = json.portion_size; article.PortionType = json.portion_dimension; article.Group = json.group_id; article.variants = json.variants; return article; }; export const thawArticle = Article.thaw;