gemcap-be-common 1.5.23 → 1.5.24
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 +1 -1
- package/services/pdf.service.js +28 -27
- package/services/pdf.service.ts +36 -33
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
package/services/pdf.service.js
CHANGED
|
@@ -419,8 +419,8 @@ class PdfService {
|
|
|
419
419
|
const warningText = product.type === loan_types_enum_1.ELoanTypes.REVOLVER
|
|
420
420
|
? `AMOUNT WILL BE ADDED TO THE LOAN ON 1ST. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THERE IS INSUFFICIENT AVAILABILITY TO ADD IT TO THE LOAN.`
|
|
421
421
|
: `PAYABLE BY 7TH. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THE STATEMENT IS NOT PAID.`;
|
|
422
|
-
|
|
423
|
-
this.addHeaderNew(organization.subfolder),
|
|
422
|
+
const baseContent = [
|
|
423
|
+
this.addHeaderNew(organization.subfolder),
|
|
424
424
|
emptyString,
|
|
425
425
|
...preparedStatementHeader,
|
|
426
426
|
emptyString,
|
|
@@ -439,6 +439,32 @@ class PdfService {
|
|
|
439
439
|
preparedTransactions,
|
|
440
440
|
productForPeriod.length === index + 1 ? emptyString : pageBreaker,
|
|
441
441
|
];
|
|
442
|
+
if (product.type === loan_types_enum_1.ELoanTypes.TERM) {
|
|
443
|
+
const { termLoanTableData, monthlyPrincipal, dueDate, } = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
444
|
+
if (monthlyPrincipal !== null) {
|
|
445
|
+
totalStatementValue = new decimal_js_1.default(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
446
|
+
principalData.push([
|
|
447
|
+
{ text: `Principal (${product.name})` },
|
|
448
|
+
{ text: (0, numbers_helper_1.formatNumbers)(monthlyPrincipal), alignment: 'right' },
|
|
449
|
+
{ text: '' },
|
|
450
|
+
]);
|
|
451
|
+
paymentDueDate = dueDate;
|
|
452
|
+
productTotals[product._id.toString()] = new decimal_js_1.default(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
453
|
+
}
|
|
454
|
+
return [
|
|
455
|
+
...baseContent,
|
|
456
|
+
pageBreaker,
|
|
457
|
+
this.addHeaderNew(organization.subfolder),
|
|
458
|
+
emptyString,
|
|
459
|
+
{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
460
|
+
emptyString,
|
|
461
|
+
{
|
|
462
|
+
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
463
|
+
layout: 'lightHorizontalLines',
|
|
464
|
+
},
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
return baseContent;
|
|
442
468
|
}));
|
|
443
469
|
let totalStatementValue = 0;
|
|
444
470
|
const preparedTotal = Object.entries(totalGroupedData).map(([chargeType, amount]) => {
|
|
@@ -458,31 +484,6 @@ class PdfService {
|
|
|
458
484
|
: [];
|
|
459
485
|
const principalData = [];
|
|
460
486
|
let paymentDueDate = null;
|
|
461
|
-
const termLoanProducts = productForPeriod.filter((product) => product.type === loan_types_enum_1.ELoanTypes.TERM);
|
|
462
|
-
await Promise.all(termLoanProducts.map(async (product) => {
|
|
463
|
-
const { termLoanTableData, monthlyPrincipal, dueDate, } = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
464
|
-
if (monthlyPrincipal !== null) {
|
|
465
|
-
totalStatementValue = new decimal_js_1.default(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
466
|
-
principalData.push([
|
|
467
|
-
{ text: 'Principal' },
|
|
468
|
-
{ text: (0, numbers_helper_1.formatNumbers)(monthlyPrincipal), alignment: 'right' },
|
|
469
|
-
{ text: '' },
|
|
470
|
-
]);
|
|
471
|
-
paymentDueDate = dueDate;
|
|
472
|
-
productTotals[product._id.toString()] = new decimal_js_1.default(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
473
|
-
}
|
|
474
|
-
docContent.push([
|
|
475
|
-
pageBreaker,
|
|
476
|
-
this.addHeaderNew(organization.subfolder),
|
|
477
|
-
emptyString,
|
|
478
|
-
{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
479
|
-
emptyString,
|
|
480
|
-
{
|
|
481
|
-
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
482
|
-
layout: 'lightHorizontalLines',
|
|
483
|
-
},
|
|
484
|
-
]);
|
|
485
|
-
}));
|
|
486
487
|
const totalOwed = new decimal_js_1.default(totalStatementValue).add(totalOverDueStatementBalance).toNumber();
|
|
487
488
|
if (getOnlyTotal) {
|
|
488
489
|
return { total: totalOwed, dueDate: paymentDueDate, productTotals };
|
package/services/pdf.service.ts
CHANGED
|
@@ -500,8 +500,8 @@ export class PdfService {
|
|
|
500
500
|
? `AMOUNT WILL BE ADDED TO THE LOAN ON 1ST. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THERE IS INSUFFICIENT AVAILABILITY TO ADD IT TO THE LOAN.`
|
|
501
501
|
: `PAYABLE BY 7TH. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THE STATEMENT IS NOT PAID.`;
|
|
502
502
|
|
|
503
|
-
|
|
504
|
-
this.addHeaderNew(organization.subfolder),
|
|
503
|
+
const baseContent = [
|
|
504
|
+
this.addHeaderNew(organization.subfolder),
|
|
505
505
|
emptyString,
|
|
506
506
|
...preparedStatementHeader,
|
|
507
507
|
emptyString,
|
|
@@ -520,6 +520,40 @@ export class PdfService {
|
|
|
520
520
|
preparedTransactions,
|
|
521
521
|
productForPeriod.length === index + 1 ? emptyString : pageBreaker,
|
|
522
522
|
];
|
|
523
|
+
|
|
524
|
+
if (product.type === ELoanTypes.TERM) {
|
|
525
|
+
const {
|
|
526
|
+
termLoanTableData,
|
|
527
|
+
monthlyPrincipal,
|
|
528
|
+
dueDate,
|
|
529
|
+
} = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
530
|
+
|
|
531
|
+
if (monthlyPrincipal !== null) {
|
|
532
|
+
totalStatementValue = new Decimal(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
533
|
+
principalData.push([
|
|
534
|
+
{ text: `Principal (${product.name})` },
|
|
535
|
+
{ text: formatNumbers(monthlyPrincipal), alignment: 'right' },
|
|
536
|
+
{ text: '' },
|
|
537
|
+
]);
|
|
538
|
+
paymentDueDate = dueDate;
|
|
539
|
+
productTotals[product._id.toString()] = new Decimal(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return [
|
|
543
|
+
...baseContent,
|
|
544
|
+
pageBreaker,
|
|
545
|
+
this.addHeaderNew(organization.subfolder),
|
|
546
|
+
emptyString,
|
|
547
|
+
<any>{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
548
|
+
emptyString,
|
|
549
|
+
{
|
|
550
|
+
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
551
|
+
layout: 'lightHorizontalLines',
|
|
552
|
+
},
|
|
553
|
+
];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return baseContent;
|
|
523
557
|
}));
|
|
524
558
|
|
|
525
559
|
let totalStatementValue = 0;
|
|
@@ -541,37 +575,6 @@ export class PdfService {
|
|
|
541
575
|
|
|
542
576
|
const principalData = [];
|
|
543
577
|
let paymentDueDate: Date = null;
|
|
544
|
-
const termLoanProducts = productForPeriod.filter((product) => product.type === ELoanTypes.TERM);
|
|
545
|
-
await Promise.all(termLoanProducts.map(async (product) => {
|
|
546
|
-
const {
|
|
547
|
-
termLoanTableData,
|
|
548
|
-
monthlyPrincipal,
|
|
549
|
-
dueDate,
|
|
550
|
-
} = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
551
|
-
|
|
552
|
-
if (monthlyPrincipal !== null) {
|
|
553
|
-
totalStatementValue = new Decimal(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
554
|
-
principalData.push([
|
|
555
|
-
{ text: 'Principal' },
|
|
556
|
-
{ text: formatNumbers(monthlyPrincipal), alignment: 'right' },
|
|
557
|
-
{ text: '' },
|
|
558
|
-
]);
|
|
559
|
-
paymentDueDate = dueDate;
|
|
560
|
-
productTotals[product._id.toString()] = new Decimal(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
docContent.push([
|
|
564
|
-
pageBreaker,
|
|
565
|
-
this.addHeaderNew(organization.subfolder),
|
|
566
|
-
emptyString,
|
|
567
|
-
<any>{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
568
|
-
emptyString,
|
|
569
|
-
{
|
|
570
|
-
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
571
|
-
layout: 'lightHorizontalLines',
|
|
572
|
-
},
|
|
573
|
-
]);
|
|
574
|
-
}));
|
|
575
578
|
|
|
576
579
|
const totalOwed = new Decimal(totalStatementValue).add(totalOverDueStatementBalance).toNumber();
|
|
577
580
|
|