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

Commit

Permalink
Revert "chore: revert to before the deploy broke"
Browse files Browse the repository at this point in the history
This reverts commit 6735408.
  • Loading branch information
Dwigoric committed Nov 29, 2023
1 parent 6735408 commit d00dbe2
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/models/loan.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ LoanSchema.pre('save', function (next) {
* @prop {Date} releaseDate - Date when the loan cash was released to the loanee.
* @prop {Date} nextInterestDate - When the loan will next gain interest.
* @prop {Boolean} isPaidForCurrentPeriod - Whether or not the loan is already paid for the current payment period.
* @prop {Object} coborrower - Loan coborrower. Contains the name (NameSchema), birthday (Date), occupation, and contact number (both Strings) of the coborrower.
* @prop {Object} coborrower - Loan coborrower. Contains the `name` (NameSchema), `birthday` (Date), `occupation`, and `contact_no` (both Strings) of the coborrower.
* @prop {mongoose.Decimal128} originalLoanAmount - Original amount loaned.
* @prop {LoanTransactionSchema[]} ledger - List of transactions making up the loan.
* @prop {String} status - Status of the loan. Must be "pending", "approved", "released", "rejected", or "complete".
Expand Down
5 changes: 5 additions & 0 deletions src/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ router.post('/login', (req, res, next) => {
* @function
* @memberof module:routes/auth~router-auth
* @inner
*
* @param {String} username - Officer's username for account logins.
* @param {String} password - Password of officer for account logins.
* @param {NameSchema} name - Officer's name. An object that follows the `nameSchema` schema.
* @param {String} role - Officer's role. Can either be "manager", "treasurer", or "credit committee".
*/
router.post('/register-officer', (req, res, next) => {
passport.authenticate('admin', { session: false }, async (err, admin, info) => {
Expand Down
20 changes: 18 additions & 2 deletions src/routes/deposit-ledgers.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,22 @@ router.get('/:txID', async (req, res, next) => {
/**
* PUT /
*
* Create a new transaction under this deposit. req.body must be a valid document following the .
* Create a new transaction under this deposit. Also updates the deposit's balance accordingly.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
* @name put
* @function
* @memberof module:routes/deposit-ledgers~router-deposit-ledgers
* @inner
* @param {String} ORNumber - Deposit OR number. Manually inputted, duplicates are allowed.
* @param {Date} transactionDate - Date the transaction was made.
* @param {Date} submissionDate - Date the transaction was submitted to the system.
* @param {String} transactionType - Type of transaction. Must be either 'Deposit' or 'Withdrawal'.
* @param {mongoose.Decimal128} amount - Amount paid during transaction.
* @param {mongoose.Decimal128} interest - Interest gained during transaction. Separate transactions are made every time interest is calculated.
* @param {mongoose.Decimal128} balance - Remaining balance in the deposit account after transaction.
* @param {NameSchema} officerInCharge - Name of the officer in charge of the transaction. Object following the `NameSchema` schema.
*/
router.put('/', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -149,14 +157,22 @@ router.put('/', async (req, res, next) => {
/**
* PATCH /:txID
*
* Update a transaction.
* Update a transaction in this deposit.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
* txID is the transaction ID of the deposit.
*
* @name patch/:txID
* @function
* @memberof module:routes/deposit-ledgers~router-deposit-ledgers
* @inner
* @param {String} ORNumber - Deposit OR number. Manually inputted, duplicates are allowed.
* @param {Date} transactionDate - Date the transaction was made.
* @param {Date} submissionDate - Date the transaction was submitted to the system.
* @param {mongoose.Decimal128} amount - Amount paid during transaction.
* @param {mongoose.Decimal128} interest - Interest gained during transaction. Separate transactions are made every time interest is calculated.
* @param {mongoose.Decimal128} balance - Remaining balance in the deposit account after transaction.
* @param {NameSchema} officerInCharge - Name of the officer in charge of the transaction.
*/
router.patch('/:txID', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down
39 changes: 26 additions & 13 deletions src/routes/deposits.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ router.get('/', async (req, res, next) => {
/**
* GET /get/:depositid
*
* Get a deposit given its deposit ID
* Get a deposit given its deposit ID.
* depositID is the ID of the deposit.
*
* @name get/:depositid
* @function
* @memberof module:routes/deposits~router-deposits
* @inner
*/
router.get('/:depositID', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand All @@ -84,7 +90,9 @@ router.get('/:depositID', async (req, res, next) => {
/**
* GET /:username
*
* Get all deposits of a member given their username
* Get all deposits of a member given their username.
* username is the username to search by.
*
* @name get/:username
* @function
* @memberof module:routes/deposits~router-deposits
Expand Down Expand Up @@ -121,15 +129,21 @@ router.get('/user/:username', async (req, res, next) => {
/**
* PUT /:username
*
* Create a new deposit of a member given their username
*
*
* Create a new deposit of a member given their username.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
* username is the username of the member that owns the deposit.
*
* @name put/:username
* @function
* @memberof module:routes/deposits~router-deposits
* @inner
*
* @param {String} username - Username of the user that owns this deposit.
* @param {Date} approvalDate - Date the deposit was approved.
* @param {mongoose.Decimal128} originalDepositAmount - Original amount that was deposited.
* @param {String} status - Current deposit status. One of 'pending', 'accepted', 'rejected', or 'complete'.
* @param {String} category - Deposit category. One of 'shareCapital', 'savings', or 'timeDeposit'.
*/
router.put('/user/:username', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand All @@ -146,8 +160,6 @@ router.put('/user/:username', async (req, res, next) => {

const submissionDate = Date.now()

console.log(req.body.category)

const allSettings = await DepositSettings.findOne().lean()
if (!allSettings[req.body.category]) {
return res.status(400).json({
Expand Down Expand Up @@ -207,16 +219,19 @@ router.put('/user/:username', async (req, res, next) => {
/**
* PATCH /:depositID
*
* Edit a deposit
* Edit a deposit (except the deposit's ledger).
*
* req.body contains the data of the deposit to edit. Finds a deposit in the database using depositID.
* NOTE: Does not edit deposit IDs.
* depositID represents the ID of the deposit to edit.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
* @name patch/:depositID
* @function
* @memberof module:routes/deposits~router-deposits
* @inner
*
* @param {mongoose.Decimal128} originalDepositAmount - Original amount that was deposited.
* @param {String} status - Current deposit status. One of 'pending', 'accepted', 'rejected', or 'complete'.
* @param {String} category - Deposit category. One of 'shareCapital', 'savings', or 'timeDeposit'.
*/
router.patch('/:depositID', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -258,9 +273,7 @@ router.patch('/:depositID', async (req, res, next) => {
/**
* DELETE /:depositID
*
* Delete a deposit.
*
* This functionality only soft deletes the deposit.
* Marks a deposit as deleted.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
Expand Down
24 changes: 22 additions & 2 deletions src/routes/loan-ledgers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,25 @@ router.get('/:txID', (req, res, next) => {
/**
* PUT /
*
* Create a new transaction
* Create a new transaction. Also updates the loan's outstanding balance.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
* @name put
* @function
* @memberof module:routes/loan-ledgers~router-loan-ledgers
* @inner
*
* @param {String} ORNumber - OR number of transaction. Does not have to be unique.
* @param {Date} transactionDate - Date the transaction was made.
* @param {mongoose.Decimal128} amountPaid - Amount paid during transaction.
* @param {mongoose.Decimal128} amountDue - Other amounts due in this transaction outside of interests or fines.
* @param {mongoose.Decimal128} balance - Outstanding loan balance after transaction.
* @param {mongoose.Decimal128} interestPaid - Amount of interest paid during transaction.
* @param {mongoose.Decimal128} interestDue - Amount of interest added to the loan during transaction.
* @param {mongoose.Decimal128} finesDue - Amount of fines paid during transaction.
* @param {mongoose.Decimal128} finesPaid - Amount of fines added to the loan during transaction.
* @param {NameSchema} officerInCharge - Name of the officer in charge of the transaction.
*/
router.put('/', (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -162,14 +173,23 @@ router.put('/', (req, res, next) => {
/**
* PATCH /:txID
*
* Update a transaction
* Update a transaction. txID is the ID of the transaction to update.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
* @name patch/:txID
* @function
* @memberof module:routes/loan-ledgers~router-loan-ledgers
* @inner
*
* @param {String} ORNumber - OR number of transaction. Does not have to be unique.
* @param {Date} transactionDate - Date the transaction was made.
* @param {Date} submissionDate - Date the transaction was submitted to the system.
* @param {mongoose.Decimal128} amountPaid - Amount paid during transaction.
* @param {mongoose.Decimal128} balance - Outstanding loan balance after transaction.
* @param {mongoose.Decimal128} interestPaid - Amount of interest paid during transaction.
* @param {mongoose.Decimal128} finesPaid - Amount of fines added to the loan during transaction.
* @param {NameSchema} officerInCharge - Name of the officer in charge of the transaction.
*/
router.patch('/:txID', (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down
39 changes: 24 additions & 15 deletions src/routes/loans.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ router.use(
/**
* GET /
*
* Get all loans
* Get all loans.
*
* @name get
* @function
Expand Down Expand Up @@ -81,7 +81,8 @@ router.get('/', async (req, res, next) => {
/**
* GET /:loanID
*
* Get a loan given its loan ID
* Get a loan given its loan ID.
*
* @name get
* @function
* @memberof module:routes/loans~router-loans
Expand Down Expand Up @@ -121,7 +122,7 @@ router.get('/:loanID', async (req, res, next) => {
/**
* GET /user/:username
*
* Get all loans for a loanee given their username
* Get all loans for a loanee given their username.
* @name get/user/:username
* @function
* @memberof module:routes/loans~router-loans
Expand Down Expand Up @@ -166,14 +167,23 @@ router.get('/user/:username', async (req, res, next) => {
/**
* PUT /user/:username
*
* Create a new loan application for a loanee
* Create a new loan application for a loanee.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
* @name put/user/:username
* @function
* @memberof module:routes/loans~router-loans
* @inner
*
* @param {String} username - Username of the loanee.
* @param {String} loanType - Type of loan. Can be "emergency", "multipurpose", "educational", "pettyCash", "commercial", or "livelihood".
* @param {Number} term - Term of the loan. How many payments are to be made to complete the loan.
* @param {String} paymentFrequency - How often payments are made for the loan.
* @param {Object} coborrower - Loan coborrower. Contains the `name` (NameSchema), `birthday` (Date), `occupation`, and `contact_no` (both Strings) of the coborrower.
* @param {mongoose.Decimal128} amount - Original amount loaned.
* @param {String} status - Status of the loan. Must be "pending", "approved", "released", "rejected", or "complete".
* @param {String} classification - Classification of the loan. Must be "new" or "renewal".
*/
router.put('/user/:username', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -236,24 +246,18 @@ router.put('/user/:username', async (req, res, next) => {
/**
* POST /:loanID/review
*
* Approve or reject a loan application
* Approve or reject a loan application, then automatically insert a transaction for initial deductions if approved.
*
* req.body must be of the form:
* {
* approved: boolean
* oic: {
* last:
* middle:
* first:
* }
* }
* loanID is the loan ID to review.
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
* @name post/:loanID/review
* @function
* @memberof module:routes/loans~router-loans
* @inner
* @param {boolean} approved - Whether or not the loan is approved. Value is true if approved, and false if rejected.
* @param {NameSchema} oic - The name of the officer in charge of the review. Is an object that follows the NameSchema.
*/
router.post('/:loanID/review', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -374,6 +378,11 @@ router.post('/:loanID/review', async (req, res, next) => {
* @function
* @memberof module:routes/loans~router-loans
* @inner
*
* @param {String} loanType - Type of loan. Can be "emergency", "multipurpose", "educational", "pettyCash", "commercial", or "livelihood".
* @param {Number} term - Term of the loan. How many payments are to be made to complete the loan.
* @param {String} paymentFrequency - How often payments are made for the loan.
* @param {Object} coborrower - Loan coborrower. Contains the `name` (NameSchema), `birthday` (Date), `occupation`, and `contact_no` (both Strings) of the coborrower.
*/
router.patch('/:loanID', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
Expand Down Expand Up @@ -473,7 +482,7 @@ router.patch('/:loanID', async (req, res, next) => {
* the deleted loan will still be visible in the database
*
* Request body must be a JSON object containing the fields specified in the `parameters` section.
*
*
* @name delete/:loanID
* @function
* @memberof module:routes/loans~router-loans
Expand Down

0 comments on commit d00dbe2

Please sign in to comment.