Browse Source

Bug fix: Creating a new transaction was allowing no date.

Lee Morgan 5 years ago
parent
commit
2ea85ed8c8
1 changed files with 5 additions and 7 deletions
  1. 5 7
      controllers/transactionData.js

+ 5 - 7
controllers/transactionData.js

@@ -76,13 +76,7 @@ module.exports = {
             req.session.error = "MUST BE LOGGED IN TO DO THAT";
             return res.redirect("/");
         }
-
-        let newTransaction = new Transaction({
-            merchant: req.session.user,
-            date: new Date(req.body.date),
-            device: "none",
-            recipes: req.body.recipes
-        });
+        
 
         Merchant.findOne({_id: req.session.user})
             .then((merchant)=>{
@@ -101,6 +95,10 @@ module.exports = {
                 return merchant.save();
             })
             .then((merchant)=>{
+                if(req.body.date === null){
+                    throw "NEW TRANSACTIONS MUST CONTAIN A DATE";
+                }
+
                 return new Transaction({
                     merchant: req.session.user,
                     date: new Date(req.body.date),