gemcap-be-common 1.5.23 → 1.5.25
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 +29 -28
- package/services/pdf.service.ts +38 -34
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
package/services/pdf.service.js
CHANGED
|
@@ -403,6 +403,7 @@ class PdfService {
|
|
|
403
403
|
...acc,
|
|
404
404
|
[p._id.toString()]: 0,
|
|
405
405
|
}), {});
|
|
406
|
+
let totalStatementValue = 0;
|
|
406
407
|
const docContent = await Promise.all(productForPeriod.map(async (product, index) => {
|
|
407
408
|
const { startStatementBalance, preparedStatementHeader, preparedStatement, preparedTransactionsHeader, preparedTransactions, groupedData, otherStatements, } = await this.getProductStatementData(product._id.toString(), start, end);
|
|
408
409
|
totalOverDueStatementBalance = new decimal_js_1.default(totalOverDueStatementBalance).add(startStatementBalance).toNumber();
|
|
@@ -419,8 +420,8 @@ class PdfService {
|
|
|
419
420
|
const warningText = product.type === loan_types_enum_1.ELoanTypes.REVOLVER
|
|
420
421
|
? `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
422
|
: `PAYABLE BY 7TH. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THE STATEMENT IS NOT PAID.`;
|
|
422
|
-
|
|
423
|
-
this.addHeaderNew(organization.subfolder),
|
|
423
|
+
const baseContent = [
|
|
424
|
+
this.addHeaderNew(organization.subfolder),
|
|
424
425
|
emptyString,
|
|
425
426
|
...preparedStatementHeader,
|
|
426
427
|
emptyString,
|
|
@@ -439,8 +440,33 @@ class PdfService {
|
|
|
439
440
|
preparedTransactions,
|
|
440
441
|
productForPeriod.length === index + 1 ? emptyString : pageBreaker,
|
|
441
442
|
];
|
|
443
|
+
if (product.type === loan_types_enum_1.ELoanTypes.TERM) {
|
|
444
|
+
const { termLoanTableData, monthlyPrincipal, dueDate, } = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
445
|
+
if (monthlyPrincipal !== null) {
|
|
446
|
+
totalStatementValue = new decimal_js_1.default(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
447
|
+
principalData.push([
|
|
448
|
+
{ text: `Principal (${product.name})` },
|
|
449
|
+
{ text: (0, numbers_helper_1.formatNumbers)(monthlyPrincipal), alignment: 'right' },
|
|
450
|
+
{ text: '' },
|
|
451
|
+
]);
|
|
452
|
+
paymentDueDate = dueDate;
|
|
453
|
+
productTotals[product._id.toString()] = new decimal_js_1.default(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
454
|
+
}
|
|
455
|
+
return [
|
|
456
|
+
...baseContent,
|
|
457
|
+
pageBreaker,
|
|
458
|
+
this.addHeaderNew(organization.subfolder),
|
|
459
|
+
emptyString,
|
|
460
|
+
{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
461
|
+
emptyString,
|
|
462
|
+
{
|
|
463
|
+
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
464
|
+
layout: 'lightHorizontalLines',
|
|
465
|
+
},
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
return baseContent;
|
|
442
469
|
}));
|
|
443
|
-
let totalStatementValue = 0;
|
|
444
470
|
const preparedTotal = Object.entries(totalGroupedData).map(([chargeType, amount]) => {
|
|
445
471
|
totalStatementValue = new decimal_js_1.default(totalStatementValue).add(amount).toNumber();
|
|
446
472
|
return [
|
|
@@ -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
|
@@ -472,6 +472,8 @@ export class PdfService {
|
|
|
472
472
|
[p._id.toString()]: 0,
|
|
473
473
|
}), {});
|
|
474
474
|
|
|
475
|
+
let totalStatementValue = 0;
|
|
476
|
+
|
|
475
477
|
const docContent = await Promise.all(productForPeriod.map(async (product, index) => {
|
|
476
478
|
const {
|
|
477
479
|
startStatementBalance,
|
|
@@ -500,8 +502,8 @@ export class PdfService {
|
|
|
500
502
|
? `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
503
|
: `PAYABLE BY 7TH. ${organization.name.toUpperCase()} RESERVES THE RIGHT TO STOP FUNDING IF THE STATEMENT IS NOT PAID.`;
|
|
502
504
|
|
|
503
|
-
|
|
504
|
-
this.addHeaderNew(organization.subfolder),
|
|
505
|
+
const baseContent = [
|
|
506
|
+
this.addHeaderNew(organization.subfolder),
|
|
505
507
|
emptyString,
|
|
506
508
|
...preparedStatementHeader,
|
|
507
509
|
emptyString,
|
|
@@ -520,9 +522,42 @@ export class PdfService {
|
|
|
520
522
|
preparedTransactions,
|
|
521
523
|
productForPeriod.length === index + 1 ? emptyString : pageBreaker,
|
|
522
524
|
];
|
|
525
|
+
|
|
526
|
+
if (product.type === ELoanTypes.TERM) {
|
|
527
|
+
const {
|
|
528
|
+
termLoanTableData,
|
|
529
|
+
monthlyPrincipal,
|
|
530
|
+
dueDate,
|
|
531
|
+
} = await this.getTermLoan(product._id.toString(), new Date(start));
|
|
532
|
+
|
|
533
|
+
if (monthlyPrincipal !== null) {
|
|
534
|
+
totalStatementValue = new Decimal(totalStatementValue).add(monthlyPrincipal).toNumber();
|
|
535
|
+
principalData.push([
|
|
536
|
+
{ text: `Principal (${product.name})` },
|
|
537
|
+
{ text: formatNumbers(monthlyPrincipal), alignment: 'right' },
|
|
538
|
+
{ text: '' },
|
|
539
|
+
]);
|
|
540
|
+
paymentDueDate = dueDate;
|
|
541
|
+
productTotals[product._id.toString()] = new Decimal(productTotals[product._id.toString()]).add(monthlyPrincipal).toNumber();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return [
|
|
545
|
+
...baseContent,
|
|
546
|
+
pageBreaker,
|
|
547
|
+
this.addHeaderNew(organization.subfolder),
|
|
548
|
+
emptyString,
|
|
549
|
+
<any>{ text: `Term loan schedule: `, fontSize: 15, bold: true },
|
|
550
|
+
emptyString,
|
|
551
|
+
{
|
|
552
|
+
table: { widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*'], body: termLoanTableData },
|
|
553
|
+
layout: 'lightHorizontalLines',
|
|
554
|
+
},
|
|
555
|
+
];
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
return baseContent;
|
|
523
559
|
}));
|
|
524
560
|
|
|
525
|
-
let totalStatementValue = 0;
|
|
526
561
|
const preparedTotal = Object.entries(totalGroupedData).map(([chargeType, amount]) => {
|
|
527
562
|
totalStatementValue = new Decimal(totalStatementValue).add(amount).toNumber();
|
|
528
563
|
return [
|
|
@@ -541,37 +576,6 @@ export class PdfService {
|
|
|
541
576
|
|
|
542
577
|
const principalData = [];
|
|
543
578
|
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
579
|
|
|
576
580
|
const totalOwed = new Decimal(totalStatementValue).add(totalOverDueStatementBalance).toNumber();
|
|
577
581
|
|