gemcap-be-common 1.3.4 → 1.3.6

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/new-summary.js CHANGED
@@ -215,7 +215,6 @@ class NewSummaryExcel {
215
215
  totalIncomeReceived: 'Total Income Received',
216
216
  loanLifeIRR: 'Loan Life IRR',
217
217
  MOIC: 'MOIC',
218
- participantBalance: 'Participant Balance',
219
218
  };
220
219
  const headerKeys = Object.keys(header);
221
220
  const allBorrowersSummary = [];
@@ -237,7 +236,7 @@ class NewSummaryExcel {
237
236
  const daysHeld = (0, dayjs_1.default)(periodEnd).diff((0, dayjs_1.default)(product.startDate), 'day');
238
237
  const lastTransaction = await (0, loan_transactions_db_1.getLastTransactionForDate)(product._id.toString(), periodEnd);
239
238
  const endingBalance = lastTransaction ? lastTransaction.balance : 0;
240
- const endingParticipationBalance = product.isParticipant ? endingBalance : 0;
239
+ const endingParticipationBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
241
240
  const netExposure = new decimal_js_1.default(endingBalance).sub(endingParticipationBalance).toNumber();
242
241
  const lastSignedBBC = await this.signsService.getLatestSignedBBCDate(borrowerId, periodEnd);
243
242
  const lastSignedBBCDate = lastSignedBBC ? (0, dayjs_1.default)(lastSignedBBC.bbcDate).format(dateFormat) : '';
@@ -249,7 +248,6 @@ class NewSummaryExcel {
249
248
  const MOIC = averageBalanceSinceInception ? new decimal_js_1.default(totalIncomeReceived).add(Math.abs(averageBalanceSinceInception)).div(Math.abs(averageBalanceSinceInception)).toDP(2).toNumber() : 0;
250
249
  const loanLifeIRRMul = daysHeld ? new decimal_js_1.default(periodDays).div(daysHeld).toNumber() : 0;
251
250
  const loanLifeIRR = MOIC ? new decimal_js_1.default(MOIC).pow(loanLifeIRRMul).sub(1).toDP(4).toNumber() : 0;
252
- const participantBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
253
251
  const newDataRow = {
254
252
  borrowerName: borrower.name,
255
253
  productName: product.name,
@@ -265,7 +263,6 @@ class NewSummaryExcel {
265
263
  totalIncomeReceived,
266
264
  loanLifeIRR,
267
265
  MOIC,
268
- participantBalance
269
266
  };
270
267
  productsDataMap.set(product._id.toString(), newDataRow);
271
268
  allBorrowersSummary.push(newDataRow);
package/db/new-summary.ts CHANGED
@@ -63,7 +63,6 @@ type ReportRow = {
63
63
  totalIncomeReceived: string | number;
64
64
  loanLifeIRR: string | number;
65
65
  MOIC: string | number;
66
- participantBalance: string | number;
67
66
  }
68
67
 
69
68
  type BorrowerSummaryRow = {
@@ -283,7 +282,6 @@ export class NewSummaryExcel {
283
282
  totalIncomeReceived: 'Total Income Received',
284
283
  loanLifeIRR: 'Loan Life IRR',
285
284
  MOIC: 'MOIC',
286
- participantBalance: 'Participant Balance',
287
285
  };
288
286
 
289
287
  const headerKeys = Object.keys(header);
@@ -308,7 +306,7 @@ export class NewSummaryExcel {
308
306
  const daysHeld = dayjs(periodEnd).diff(dayjs(product.startDate), 'day');
309
307
  const lastTransaction = await getLastTransactionForDate(product._id.toString(), periodEnd);
310
308
  const endingBalance = lastTransaction ? lastTransaction.balance : 0;
311
- const endingParticipationBalance = product.isParticipant ? endingBalance : 0;
309
+ const endingParticipationBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
312
310
  const netExposure = new Decimal(endingBalance).sub(endingParticipationBalance).toNumber();
313
311
  const lastSignedBBC = await this.signsService.getLatestSignedBBCDate(borrowerId, periodEnd);
314
312
  const lastSignedBBCDate = lastSignedBBC ? dayjs(lastSignedBBC.bbcDate).format(dateFormat) : '';
@@ -321,7 +319,6 @@ export class NewSummaryExcel {
321
319
  const MOIC = averageBalanceSinceInception ? new Decimal(totalIncomeReceived).add(Math.abs(averageBalanceSinceInception)).div(Math.abs(averageBalanceSinceInception)).toDP(2).toNumber() : 0;
322
320
  const loanLifeIRRMul = daysHeld ? new Decimal(periodDays).div(daysHeld).toNumber() : 0;
323
321
  const loanLifeIRR = MOIC ? new Decimal(MOIC).pow(loanLifeIRRMul).sub(1).toDP(4).toNumber() : 0;
324
- const participantBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
325
322
 
326
323
  const newDataRow: ReportRow = {
327
324
  borrowerName: borrower.name,
@@ -338,7 +335,6 @@ export class NewSummaryExcel {
338
335
  totalIncomeReceived,
339
336
  loanLifeIRR,
340
337
  MOIC,
341
- participantBalance
342
338
  };
343
339
  productsDataMap.set(product._id.toString(), newDataRow);
344
340
  allBorrowersSummary.push(newDataRow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -893,9 +893,11 @@ class LoanTransactionsService {
893
893
  const dailyTransactions = await this.getUnsentTransactionForDate(borrower._id.toString(), effectiveDate);
894
894
  const transactionIds = dailyTransactions.map((tr) => tr._id.toString());
895
895
  const { transactions, transactionIdsToMark, } = await this.getTransactionReport(transactionIds, borrower._id.toString(), effectiveDate);
896
- if (transactions.length === 0 || transactionIdsToMark.length === 0) {
896
+ console.log(borrower.name, transactions.length, transactionIdsToMark.length);
897
+ if (transactionIdsToMark.length === 0) {
897
898
  return;
898
899
  }
900
+ console.log(borrower.name, '========> will be sent');
899
901
  const attachedFile = await this.uploadsService.convertDataToFile(transactions);
900
902
  const attachment = { filename: `${fileName}.xlsx`, content: attachedFile };
901
903
  const attachedPDFs = await this.attachedFilesService.getAttachedRealFilesByTransactionFileId(borrower._id.toString(), (0, dayjs_1.default)(effectiveDate).format('YYYY-MM-DD'));
@@ -994,9 +994,11 @@ export class LoanTransactionsService {
994
994
  transactions,
995
995
  transactionIdsToMark,
996
996
  } = await this.getTransactionReport(transactionIds, borrower._id.toString(), effectiveDate);
997
- if (transactions.length === 0 || transactionIdsToMark.length === 0) {
997
+ console.log(borrower.name, transactions.length, transactionIdsToMark.length);
998
+ if (transactionIdsToMark.length === 0) {
998
999
  return;
999
1000
  }
1001
+ console.log(borrower.name, '========> will be sent');
1000
1002
  const attachedFile = await this.uploadsService.convertDataToFile(transactions);
1001
1003
  const attachment = { filename: `${fileName}.xlsx`, content: attachedFile };
1002
1004
  const attachedPDFs = await this.attachedFilesService.getAttachedRealFilesByTransactionFileId(borrower._id.toString(), dayjs(effectiveDate).format('YYYY-MM-DD'));