gemcap-be-common 1.5.25 → 1.5.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.25",
3
+ "version": "1.5.27",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -404,6 +404,8 @@ class PdfService {
404
404
  [p._id.toString()]: 0,
405
405
  }), {});
406
406
  let totalStatementValue = 0;
407
+ const principalData = [];
408
+ let paymentDueDate = null;
407
409
  const docContent = await Promise.all(productForPeriod.map(async (product, index) => {
408
410
  const { startStatementBalance, preparedStatementHeader, preparedStatement, preparedTransactionsHeader, preparedTransactions, groupedData, otherStatements, } = await this.getProductStatementData(product._id.toString(), start, end);
409
411
  totalOverDueStatementBalance = new decimal_js_1.default(totalOverDueStatementBalance).add(startStatementBalance).toNumber();
@@ -438,8 +440,10 @@ class PdfService {
438
440
  emptyString,
439
441
  ...preparedTransactionsHeader,
440
442
  preparedTransactions,
441
- productForPeriod.length === index + 1 ? emptyString : pageBreaker,
442
443
  ];
444
+ const productPageEnd = productForPeriod.length === index + 1
445
+ ? emptyString
446
+ : pageBreaker;
443
447
  if (product.type === loan_types_enum_1.ELoanTypes.TERM) {
444
448
  const { termLoanTableData, monthlyPrincipal, dueDate, } = await this.getTermLoan(product._id.toString(), new Date(start));
445
449
  if (monthlyPrincipal !== null) {
@@ -463,9 +467,13 @@ class PdfService {
463
467
  table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
464
468
  layout: 'lightHorizontalLines',
465
469
  },
470
+ productPageEnd,
466
471
  ];
467
472
  }
468
- return baseContent;
473
+ return [
474
+ ...baseContent,
475
+ productPageEnd,
476
+ ];
469
477
  }));
470
478
  const preparedTotal = Object.entries(totalGroupedData).map(([chargeType, amount]) => {
471
479
  totalStatementValue = new decimal_js_1.default(totalStatementValue).add(amount).toNumber();
@@ -482,8 +490,6 @@ class PdfService {
482
490
  { text: '' }
483
491
  ]
484
492
  : [];
485
- const principalData = [];
486
- let paymentDueDate = null;
487
493
  const totalOwed = new decimal_js_1.default(totalStatementValue).add(totalOverDueStatementBalance).toNumber();
488
494
  if (getOnlyTotal) {
489
495
  return { total: totalOwed, dueDate: paymentDueDate, productTotals };
@@ -473,6 +473,8 @@ export class PdfService {
473
473
  }), {});
474
474
 
475
475
  let totalStatementValue = 0;
476
+ const principalData = [];
477
+ let paymentDueDate: Date = null;
476
478
 
477
479
  const docContent = await Promise.all(productForPeriod.map(async (product, index) => {
478
480
  const {
@@ -520,9 +522,12 @@ export class PdfService {
520
522
  emptyString,
521
523
  ...preparedTransactionsHeader,
522
524
  preparedTransactions,
523
- productForPeriod.length === index + 1 ? emptyString : pageBreaker,
524
525
  ];
525
526
 
527
+ const productPageEnd = productForPeriod.length === index + 1
528
+ ? emptyString
529
+ : pageBreaker;
530
+
526
531
  if (product.type === ELoanTypes.TERM) {
527
532
  const {
528
533
  termLoanTableData,
@@ -552,10 +557,14 @@ export class PdfService {
552
557
  table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
553
558
  layout: 'lightHorizontalLines',
554
559
  },
560
+ productPageEnd,
555
561
  ];
556
562
  }
557
563
 
558
- return baseContent;
564
+ return [
565
+ ...baseContent,
566
+ productPageEnd,
567
+ ];
559
568
  }));
560
569
 
561
570
  const preparedTotal = Object.entries(totalGroupedData).map(([chargeType, amount]) => {
@@ -574,9 +583,6 @@ export class PdfService {
574
583
  { text: '' }]
575
584
  : [];
576
585
 
577
- const principalData = [];
578
- let paymentDueDate: Date = null;
579
-
580
586
  const totalOwed = new Decimal(totalStatementValue).add(totalOverDueStatementBalance).toNumber();
581
587
 
582
588
  if (getOnlyTotal) {