class Transaction{ constructor(id, date, recipes, parent){ this.id = id; this.parent = parent; this.date = new Date(date); this.recipes = []; for(let i = 0; i < recipes.length; i++){ for(let j = 0; j < parent.recipes.length; j++){ if(recipes[i].recipe === parent.recipes[j].id){ this.recipes.push({ recipe: parent.recipes[j], quantity: recipes[i].quantity }); break; } } } } } module.exports = Transaction;