gemcap-be-common 1.5.58 → 1.5.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/db/reports.db.js CHANGED
@@ -207,7 +207,7 @@ const getLedgerData = async (params, options = defaultReportLedgerOptions) => {
207
207
  };
208
208
  }))
209
209
  : statementTransactions.slice();
210
- const isParticipant = group.product.masterLoanProductId !== undefined;
210
+ const isParticipant = group.product.masterLoanProductId != null;
211
211
  const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
212
212
  const transactions = [];
213
213
  if (statement.amountPaid > 0) {
package/db/reports.db.ts CHANGED
@@ -285,7 +285,7 @@ const getLedgerData = async (params: ReportLedgerParams, options = defaultReport
285
285
  }))
286
286
  : statementTransactions.slice();
287
287
 
288
- const isParticipant = group.product.masterLoanProductId !== undefined;
288
+ const isParticipant = group.product.masterLoanProductId != null;
289
289
  const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
290
290
 
291
291
  const transactions = [];
@@ -40,7 +40,7 @@ export interface ILoanProduct {
40
40
  isBalanceActual: boolean;
41
41
  isFloatedBalanceActual: boolean;
42
42
  isParticipant?: boolean;
43
- masterLoanProductId?: mongoose.Types.ObjectId;
43
+ masterLoanProductId: mongoose.Types.ObjectId;
44
44
  minPercent: number;
45
45
  maxPercent: number;
46
46
  prepaymentDate?: Date;
@@ -60,9 +60,10 @@ export interface ILoanProductLean extends ILoanProduct {
60
60
  createdAt: Date;
61
61
  updatedAt: Date;
62
62
  }
63
- export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId'> {
63
+ export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | 'masterLoanProductId'> {
64
64
  _id: string;
65
65
  borrowerId: string;
66
+ masterLoanProductId: string;
66
67
  }
67
68
  export interface ILoanProductWithId extends ILoanProduct {
68
69
  _id: mongoose.Types.ObjectId;
@@ -83,6 +84,7 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
83
84
  updatedAt: NativeDate;
84
85
  } & {
85
86
  borrowerId: mongoose.Types.ObjectId;
87
+ masterLoanProductId: mongoose.Types.ObjectId;
86
88
  order: number;
87
89
  active: boolean;
88
90
  code: string;
@@ -97,7 +99,6 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
97
99
  masterCode?: string;
98
100
  payoffDate?: Date;
99
101
  isParticipant?: boolean;
100
- masterLoanProductId?: mongoose.Types.ObjectId;
101
102
  minPercent?: number;
102
103
  maxPercent?: number;
103
104
  prepaymentDate?: Date;
@@ -110,6 +111,7 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
110
111
  updatedAt: NativeDate;
111
112
  } & {
112
113
  borrowerId: mongoose.Types.ObjectId;
114
+ masterLoanProductId: mongoose.Types.ObjectId;
113
115
  order: number;
114
116
  active: boolean;
115
117
  code: string;
@@ -124,7 +126,6 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
124
126
  masterCode?: string;
125
127
  payoffDate?: Date;
126
128
  isParticipant?: boolean;
127
- masterLoanProductId?: mongoose.Types.ObjectId;
128
129
  minPercent?: number;
129
130
  maxPercent?: number;
130
131
  prepaymentDate?: Date;
@@ -137,6 +138,7 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
137
138
  updatedAt: NativeDate;
138
139
  } & {
139
140
  borrowerId: mongoose.Types.ObjectId;
141
+ masterLoanProductId: mongoose.Types.ObjectId;
140
142
  order: number;
141
143
  active: boolean;
142
144
  code: string;
@@ -151,7 +153,6 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
151
153
  masterCode?: string;
152
154
  payoffDate?: Date;
153
155
  isParticipant?: boolean;
154
- masterLoanProductId?: mongoose.Types.ObjectId;
155
156
  minPercent?: number;
156
157
  maxPercent?: number;
157
158
  prepaymentDate?: Date;
@@ -71,7 +71,7 @@ exports.LoanProductSchema = new mongoose_1.default.Schema({
71
71
  masterLoanProductId: {
72
72
  type: mongoose_1.default.Schema.Types.ObjectId,
73
73
  ref: _models_1.MODEL_NAMES.loanProducts,
74
- required: false,
74
+ default: null,
75
75
  },
76
76
  minPercent: {
77
77
  type: Number,
@@ -19,7 +19,7 @@ export interface ILoanProduct {
19
19
  isBalanceActual: boolean;
20
20
  isFloatedBalanceActual: boolean;
21
21
  isParticipant?: boolean;
22
- masterLoanProductId?: mongoose.Types.ObjectId;
22
+ masterLoanProductId: mongoose.Types.ObjectId;
23
23
  minPercent: number;
24
24
  maxPercent: number;
25
25
  prepaymentDate?: Date;
@@ -42,9 +42,10 @@ export interface ILoanProductLean extends ILoanProduct {
42
42
  updatedAt: Date;
43
43
  }
44
44
 
45
- export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId'> {
45
+ export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | 'masterLoanProductId'> {
46
46
  _id: string;
47
47
  borrowerId: string;
48
+ masterLoanProductId: string;
48
49
  }
49
50
 
50
51
  export interface ILoanProductWithId extends ILoanProduct {
@@ -130,7 +131,7 @@ export const LoanProductSchema = new mongoose.Schema(
130
131
  masterLoanProductId: {
131
132
  type: mongoose.Schema.Types.ObjectId,
132
133
  ref: MODEL_NAMES.loanProducts,
133
- required: false,
134
+ default: null,
134
135
  },
135
136
  minPercent: {
136
137
  type: Number,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.58",
3
+ "version": "1.5.60",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -357,7 +357,7 @@ class QuickbooksService {
357
357
  if (totalAmountValue === 0) {
358
358
  return;
359
359
  }
360
- let totalAmount = product.masterLoanProductId !== undefined ? -totalAmountValue : totalAmountValue;
360
+ let totalAmount = product.masterLoanProductId != null ? -totalAmountValue : totalAmountValue;
361
361
  totalAmount = isAccrual ? totalAmount : -totalAmount;
362
362
  const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
363
363
  const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
@@ -374,7 +374,7 @@ class QuickbooksService {
374
374
  ...trTemplate,
375
375
  productId,
376
376
  class: borrower.code,
377
- memo: `${borrower.code} ${product.masterLoanProductId !== undefined ? 'PARTICIPANT' : ''} ${reports_db_1.EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
377
+ memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} ${reports_db_1.EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
378
378
  };
379
379
  tr.account = quickbooksAccountBS.fullName;
380
380
  tr.amount = totalAmount;
@@ -429,8 +429,8 @@ class QuickbooksService {
429
429
  ...trTemplate,
430
430
  productId,
431
431
  class: borrower.code,
432
- amount: product.masterLoanProductId !== undefined ? +amount : -+amount,
433
- memo: `${borrower.code} ${product.masterLoanProductId !== undefined ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
432
+ amount: product.masterLoanProductId != null ? +amount : -+amount,
433
+ memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
434
434
  };
435
435
  if (settlementCode === 'null') {
436
436
  const products = await this.loanChargesService.getLoanProducts(borrower._id.toString());
@@ -416,7 +416,7 @@ export class QuickbooksService {
416
416
  if (totalAmountValue === 0) {
417
417
  return;
418
418
  }
419
- let totalAmount = product.masterLoanProductId !== undefined ? -totalAmountValue : totalAmountValue;
419
+ let totalAmount = product.masterLoanProductId != null ? -totalAmountValue : totalAmountValue;
420
420
  totalAmount = isAccrual ? totalAmount : -totalAmount;
421
421
  const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
422
422
  const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
@@ -433,7 +433,7 @@ export class QuickbooksService {
433
433
  ...trTemplate,
434
434
  productId,
435
435
  class: borrower.code,
436
- memo: `${borrower.code} ${product.masterLoanProductId !== undefined ? 'PARTICIPANT' : ''} ${EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
436
+ memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} ${EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
437
437
  };
438
438
 
439
439
  tr.account = quickbooksAccountBS.fullName;
@@ -500,8 +500,8 @@ export class QuickbooksService {
500
500
  ...trTemplate,
501
501
  productId,
502
502
  class: borrower.code,
503
- amount: product.masterLoanProductId !== undefined ? +amount : -+amount,
504
- memo: `${borrower.code} ${product.masterLoanProductId !== undefined ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
503
+ amount: product.masterLoanProductId != null ? +amount : -+amount,
504
+ memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
505
505
  };
506
506
 
507
507
  if (settlementCode === 'null') {
@@ -76,7 +76,7 @@ class InvestorSummaryService {
76
76
  await Promise.all(borrowerIds.map(async (borrowerId) => {
77
77
  const borrower = await Borrower_model_1.BorrowerModel.findById(borrowerId).lean();
78
78
  const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
79
- await Promise.all(borrowerProducts.filter((product) => product.masterLoanProductId === undefined).map(async (product) => {
79
+ await Promise.all(borrowerProducts.filter((product) => product.masterLoanProductId == null).map(async (product) => {
80
80
  const productId = product._id.toString();
81
81
  const isRevolver = product.type === loan_types_enum_1.ELoanTypes.REVOLVER;
82
82
  const { balance: balanceEnd } = await this.loanChargesService.getLoanProductBalance(productId, end);
@@ -100,7 +100,7 @@ export class InvestorSummaryService {
100
100
  await Promise.all(borrowerIds.map(async (borrowerId) => {
101
101
  const borrower = await BorrowerModel.findById(borrowerId).lean();
102
102
  const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
103
- await Promise.all(borrowerProducts.filter((product) => product.masterLoanProductId === undefined).map(async (product) => {
103
+ await Promise.all(borrowerProducts.filter((product) => product.masterLoanProductId == null).map(async (product) => {
104
104
  const productId = product._id.toString();
105
105
  const isRevolver = product.type === ELoanTypes.REVOLVER;
106
106
  const { balance: balanceEnd } = await this.loanChargesService.getLoanProductBalance(productId, end);
@@ -323,7 +323,7 @@ class ReportsService {
323
323
  const hasTermProduct = products.some((product) => product.type === loan_types_enum_1.ELoanTypes.TERM);
324
324
  const manyTermProduct = products.filter((product) => product.type === loan_types_enum_1.ELoanTypes.TERM).length > 1;
325
325
  return await Promise.all(products.map(async (product) => {
326
- if (product.masterLoanProductId !== undefined) {
326
+ if (product.masterLoanProductId != null) {
327
327
  return null;
328
328
  }
329
329
  if ((0, dayjs_1.default)(product.deactivationDate).isBefore((0, dayjs_1.default)(date))) {
@@ -426,7 +426,7 @@ export class ReportsService {
426
426
  const manyTermProduct = products.filter((product) => product.type === ELoanTypes.TERM).length > 1;
427
427
 
428
428
  return await Promise.all(products.map(async (product) => {
429
- if (product.masterLoanProductId !== undefined) {
429
+ if (product.masterLoanProductId != null) {
430
430
  return null as IBankReportData;
431
431
  }
432
432
  if (dayjs(product.deactivationDate).isBefore(dayjs(date))) {