From 940a9742b26daded71637cc9d602c3b46673fbaa Mon Sep 17 00:00:00 2001 From: kndone Date: Tue, 28 Nov 2023 18:44:39 +0800 Subject: [PATCH] docs: half of the models --- src/models/deposit.js | 2 +- src/models/depositSettings.js | 8 ++++++++ src/models/depositSettingsSchema.js | 11 +++++++++++ src/models/depositTransactionSchema.js | 18 +++++++++++++++++ src/models/individualSettingSchema.js | 12 ++++++++++++ src/models/loan.js | 27 ++++++++++++++++++++++++++ src/models/loanee.js | 25 ++++++++++++++++++++++-- 7 files changed, 100 insertions(+), 3 deletions(-) diff --git a/src/models/deposit.js b/src/models/deposit.js index 41f2af9..b4f7c49 100644 --- a/src/models/deposit.js +++ b/src/models/deposit.js @@ -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. diff --git a/src/models/depositSettings.js b/src/models/depositSettings.js index 82d9d15..302ef89 100644 --- a/src/models/depositSettings.js +++ b/src/models/depositSettings.js @@ -1,5 +1,6 @@ /** * Database model for Deposit Settings + * @module models/depositSettings */ // Packages @@ -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({ diff --git a/src/models/depositSettingsSchema.js b/src/models/depositSettingsSchema.js index 6fa6b31..723aacb 100644 --- a/src/models/depositSettingsSchema.js +++ b/src/models/depositSettingsSchema.js @@ -1,3 +1,8 @@ +/** + * Schema to represent deposit settings for a single deposit category. + * @module models/depositSettingsSchema + */ + // Packages import { Schema } from 'mongoose' @@ -5,6 +10,12 @@ import { Schema } from 'mongoose' 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, diff --git a/src/models/depositTransactionSchema.js b/src/models/depositTransactionSchema.js index bf18368..da3a34c 100644 --- a/src/models/depositTransactionSchema.js +++ b/src/models/depositTransactionSchema.js @@ -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, diff --git a/src/models/individualSettingSchema.js b/src/models/individualSettingSchema.js index 583907e..0b7d131 100644 --- a/src/models/individualSettingSchema.js +++ b/src/models/individualSettingSchema.js @@ -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: { diff --git a/src/models/loan.js b/src/models/loan.js index a2fd33b..d95e402 100644 --- a/src/models/loan.js +++ b/src/models/loan.js @@ -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' @@ -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 diff --git a/src/models/loanee.js b/src/models/loanee.js index 24c2d5e..33aff98 100644 --- a/src/models/loanee.js +++ b/src/models/loanee.js @@ -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' @@ -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 @@ -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