Order.js 782 B

12345678910111213141516171819202122232425
  1. class Order{
  2. constructor(id, name, date, ingredients, parent){
  3. this.id = id;
  4. this.name = name;
  5. this.date = new Date(date);
  6. this.ingredients = [];
  7. this.parent = parent;
  8. for(let i = 0; i < ingredients.length; i++){
  9. for(let j = 0; j < parent.ingredients.length; j++){
  10. if(ingredients[i].ingredient === parent.ingredients[j].ingredient.id){
  11. this.ingredients.push({
  12. ingredient: parent.ingredients[j].ingredient,
  13. quantity: ingredients[i].quantity,
  14. pricePerUnit: ingredients[i].pricePerUnit
  15. });
  16. break;
  17. }
  18. }
  19. }
  20. }
  21. }
  22. module.exports = Order;