Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: mark repayments as paid
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Nov 26, 2023
1 parent 8dee59d commit 7d76166
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/routes/loan-ledgers.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ router.put('/', (req, res, next) => {
}

const query = {
$push: { ledger: transactionInfo }
$push: { ledger: transactionInfo },
$set: {}
}

// Determine if transaction is payment, and mark as paid if so
if (transactionInfo.transactionType === 'payment') {
query.$set = { ...query.$set, isPaidForCurrentPeriod: true }
}

// Update balance depending on whether transaction is readjustment or not
if (loan.balance) {
query.$set = { balance: req.body.balance }
query.$set = { ...query.$set, balance: req.body.balance }
}

try {
Expand Down

0 comments on commit 7d76166

Please sign in to comment.