diff --git a/src/models/loan.js b/src/models/loan.js index 500f4cf..1b83e89 100644 --- a/src/models/loan.js +++ b/src/models/loan.js @@ -56,8 +56,7 @@ const LoanSchema = new Schema({ immutable: true }, approvalDate: { - type: Date, - immutable: true + type: Date }, coborrower: { name: NameSchema, diff --git a/src/routes/loans.js b/src/routes/loans.js index b901352..1d0aaa1 100644 --- a/src/routes/loans.js +++ b/src/routes/loans.js @@ -150,6 +150,7 @@ router.put('/new/:username', async (req, res, next) => { term: req.body.term, paymentFrequency: req.body.paymentFrequency, submissionDate: Date.now(), + approvalDate: null, coborrower: req.body.coborrower, originalLoanAmount: req.body.amount, ledger: [], @@ -204,7 +205,10 @@ router.post('/review-application/:loanID', async (req, res, next) => { await Loan.updateOne( { loanID: req.params.loanID }, { - status: req.body.approved ? 'approved' : 'rejected' + $set: { + status: req.body.approved ? 'approved' : 'rejected', + approvalDate: Date.now() + } }, { runValidators: true