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

Commit

Permalink
docs: half of the models
Browse files Browse the repository at this point in the history
  • Loading branch information
kndonetm committed Nov 28, 2023
1 parent dc9f686 commit 940a974
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/models/deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ DepositSchema.pre(['find', 'findOne'], function () {
* @prop {Date} nextInterestDate - Next date the deposit will gain interest.
* @prop {Decimal128} originalDepositAmount - Original amount that was deposited.
* @prop {Decimal128} runningAmount - Current balance of the deposit.
* @prop {[DepositTransactionSchema]} ledger - Deposit transaction ledger.
* @prop {DepositTransactionSchema[]} ledger - Deposit transaction ledger.
* @prop {String} status - Current deposit status. One of 'pending', 'accepted', 'rejected', or 'complete'.
* @prop {String} category - Deposit category. One of 'shareCapital', 'savings', or 'timeDeposit'.
* @prop {Boolean} deleted - Whether or not the deposit is deleted.
Expand Down
8 changes: 8 additions & 0 deletions src/models/depositSettings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Database model for Deposit Settings
* @module models/depositSettings
*/

// Packages
Expand All @@ -8,6 +9,13 @@ import { Schema, model } from 'mongoose'
// Import schema
import DepositSettingsSchema from './depositSettingsSchema.js'

/**
* Deposit settings Mongoose model. Stores the current deposit settings.
* @prop {DepositSettingsSchema} shareCapital - Settings for share capital deposits.
* @prop {DepositSettingsSchema} savings - Settings for savings deposits.
* @prop {DepositSettingsSchema} timeDeposit - Settings for time deposits.
*
*/
const DepositSettings = model(
'DepositSettings',
new Schema({
Expand Down
11 changes: 11 additions & 0 deletions src/models/depositSettingsSchema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/**
* Schema to represent deposit settings for a single deposit category.
* @module models/depositSettingsSchema
*/

// Packages
import { Schema } from 'mongoose'

// Import schema
import MandatoryIndividualSettingSchema from './mandatoryIndividualSettingSchema.js'
import TimeSettingSchema from './timeSettingSchema.js'

/**
* Schema to represent deposit settings for a single deposit category.
*
* @prop {MandatoryIndividualSettingSchema} interest_rate - Interest rate of the deposit type.
* @prop {TimeSettingSchema} time - Time period between interest applications.
*/
const DepositSettingsSchema = new Schema(
{
interest_rate: MandatoryIndividualSettingSchema,
Expand Down
18 changes: 18 additions & 0 deletions src/models/depositTransactionSchema.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/**
* Schema to represent a single transaction in a deposit's transaction ledger.
* @module models/depositTransactionSchema
*/

// Import packages
import { Schema, Decimal128 } from 'mongoose'

import NameSchema from './nameSchema.js'

/**
* Schema to represent deposit settings for a single deposit category.
*
* @prop {String} transactionID - Autogenerated transaction ID. Uses base36.
* @prop {String} ORNumber - Deposit OR number. Manually inputted, duplicates are allowed.
* @prop {Date} transactionDate - Date the transaction was made.
* @prop {Date} submissionDate - Date the transaction was submitted to the system.
* @prop {String} transactionType - Type of transaction. Must be either 'Deposit' or 'Withdrawal'.
* @prop {Decimal128} amount - Amount paid during transaction.
* @prop {Decimal128} interest - Interest gained during transaction. Separate transactions are made every time interest is calculated.
* @prop {Decimal128} balance - Remaining balance in the deposit account after transaction.
* @prop {NameSchema} officerInCharge - Name of the officer in charge of the transaction.
*/
const DepositTransactionSchema = new Schema({
transactionID: {
type: String,
Expand Down
12 changes: 12 additions & 0 deletions src/models/individualSettingSchema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/**
* Schema to represent an individual setting for financial values, such as interest or fees.
* @module models/individualSettingsSchema
*/

// Packages
import { Schema, Decimal128 } from 'mongoose'

/**
* Schema to represent deposit settings for a single deposit category.
*
* @prop {String} unit - Unit of the setting amount. Either '%' or 'Fixed'.
* @prop {Decimal128} value - Value of the setting amount. If unit is '%', how many percent the value represents. If unit is 'Fixed', how much money (in pesos) the value represents.
* @prop {Boolean} enabled - Whether or not this particular setting is active.
*/
const InvidualSettingSchema = new Schema(
{
unit: {
Expand Down
27 changes: 27 additions & 0 deletions src/models/loan.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Model to represent loans.
* @module models/loan
*/

// Import packages
import { Schema, model, Decimal128 } from 'mongoose'
import { v5 as uuidV5 } from 'uuid'
Expand Down Expand Up @@ -126,6 +131,28 @@ LoanSchema.pre('save', function (next) {
next()
})

/**
* Model to represent a single loan in the database.
*
* @prop {String} loanID - Automatically generated ID of the loan. Uses uuidv5.
* @prop {String} username - Username of the loanee.
* @prop {String} loanType - Type of loan. Can be "emergency", "multipurpose", "educational", "pettyCash", "commercial", or "livelihood".
* @prop {Number} term - Term of the loan. How many payments are to be made to complete the loan.
* @prop {String} paymentFrequency - How often payments are made for the loan.
* @prop {Date} submissionDate - Date when the loan was submitted to the system.
* @prop {Date} approvalDate - Date when the loan was approved by an officer.
* @prop {Date} dueDate - Date when the loan is due 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 {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".
* @prop {String} classification - Classification of the loan. Must be "new" or "renewal".
* @prop {Decimal128} balance - Current outstanding loan balance.
* @prop {Boolean} deleted - Whether or not the loan is deleted.
*/
const Loan = model('Loan', LoanSchema)

export default Loan
25 changes: 23 additions & 2 deletions src/models/loanee.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Model to represent users (loanees) in the system.
* @module models/loanee
*/

import { Schema, model } from 'mongoose'
import NameSchema from './nameSchema.js'
import SpouseSchema from './spouseSchema.js'
Expand Down Expand Up @@ -55,13 +60,12 @@ const LoaneeSchema = new Schema({
type: LocationSchema,
required: [true, 'Address is required']
},
occupation: {
onanimationstartccupation: {
type: String,
required: [true, 'Occupation is required']
},
spouse: { type: SpouseSchema },
deleted: { type: Boolean, default: false }
// loans: [Loan]
})

// Finding by text will search both username and name fields
Expand All @@ -86,6 +90,23 @@ LoaneeSchema.pre(['find', 'findOne'], function () {
this.where({ deleted: false })
})

/**
* Model to represent deposit settings for a single deposit category.
*
* @prop {String} username - Username, unique identifier per user.
* @prop {NameSchema} name - User's full name.
* @prop {Date} birthday - User's birthday.
* @prop {String} birthplace - User's birthplace.
* @prop {String} sex - User's sex. Must be either 'M' or 'F'
* @prop {String} civil_status - User's civil status. Must be either 'Single' or 'Married'
* @prop {String} tin_no - TIN number of the user. Must be of the format XXX-XXX-XXX-XXX where X is a number from 0 to 9
* @prop {String} contact_no - User's contact number..
* @prop {Number} monthly_income - Users' monthly income.
* @prop {LocationSchema} address - Users' address.
* @prop {String} occupation - Users' occupation.
* @prop {SpouseSchema} spouse - Users' spouse, if any.
* @prop {Boolean} deleted - Whether or not the user is deleted.
*/
const Loanee = model('Loanee', LoaneeSchema)

export default Loanee

0 comments on commit 940a974

Please sign in to comment.