Transaction.js 628 B

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