@dynamatix/gb-schemas 2.3.292 → 2.3.293
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicant-welcome-call.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-welcome-call.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"applicant-welcome-call.model.d.ts","sourceRoot":"","sources":["../../applicants/applicant-welcome-call.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAytBhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA4D,CAAC;AAEnF,eAAe,gBAAgB,CAAC"}
|
|
@@ -572,7 +572,7 @@ welcomeCallSchema.virtual('initialRatePercentage').get(function () {
|
|
|
572
572
|
return null;
|
|
573
573
|
});
|
|
574
574
|
// Virtual property for finance summary HTML
|
|
575
|
-
welcomeCallSchema.virtual('financeSummaryHtml').get(function () {
|
|
575
|
+
welcomeCallSchema.virtual('financeSummaryHtml').get(async function () {
|
|
576
576
|
let application = null;
|
|
577
577
|
if (this.applicantId && typeof this.applicantId === 'object' && !(typeof this.applicantId.toHexString === 'function') && this.applicantId.applicationId) {
|
|
578
578
|
application = this.applicantId.applicationId;
|
|
@@ -587,7 +587,7 @@ welcomeCallSchema.virtual('financeSummaryHtml').get(function () {
|
|
|
587
587
|
// Initialize summary data
|
|
588
588
|
let product = '';
|
|
589
589
|
let financeTerm = '';
|
|
590
|
-
let
|
|
590
|
+
let monthlyRepayment = '';
|
|
591
591
|
let rentalIncome = '';
|
|
592
592
|
let occupancy = '';
|
|
593
593
|
// Get product information (first 3 characters)
|
|
@@ -611,6 +611,25 @@ welcomeCallSchema.virtual('financeSummaryHtml').get(function () {
|
|
|
611
611
|
else {
|
|
612
612
|
financeTerm = '-';
|
|
613
613
|
}
|
|
614
|
+
// Get monthly repayment amount from productFeatures collection
|
|
615
|
+
try {
|
|
616
|
+
const ApplicationProductFeatures = mongoose.model('ApplicationProductFeatures');
|
|
617
|
+
const productFeatures = await ApplicationProductFeatures.findOne({
|
|
618
|
+
applicationId: application
|
|
619
|
+
});
|
|
620
|
+
if (productFeatures && productFeatures.repayment !== undefined && productFeatures.repayment !== null) {
|
|
621
|
+
const numericValue = Number(productFeatures.repayment);
|
|
622
|
+
const repaymentValue = isNaN(numericValue) ? '0.00' : numericValue.toFixed(2);
|
|
623
|
+
monthlyRepayment = `£${repaymentValue}`;
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
monthlyRepayment = '-';
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
console.log('Error fetching product features:', error);
|
|
631
|
+
monthlyRepayment = '-';
|
|
632
|
+
}
|
|
614
633
|
// Get rental income from mortgage - mortgageId is at application level
|
|
615
634
|
let mortgage = null;
|
|
616
635
|
if (application.mortgageId && typeof application.mortgageId === 'object') {
|
|
@@ -624,12 +643,6 @@ welcomeCallSchema.virtual('financeSummaryHtml').get(function () {
|
|
|
624
643
|
const rentalValue = isNaN(numericValue) ? '0.00' : numericValue.toFixed(2);
|
|
625
644
|
rentalIncome = `£${rentalValue}`;
|
|
626
645
|
}
|
|
627
|
-
// Get finance amount from loanRequired
|
|
628
|
-
if (mortgage.loanRequired !== undefined && mortgage.loanRequired !== null) {
|
|
629
|
-
const numericValue = Number(mortgage.loanRequired);
|
|
630
|
-
const financeValue = isNaN(numericValue) ? '0.00' : numericValue.toFixed(2);
|
|
631
|
-
monthlyFinance = `£${financeValue}`;
|
|
632
|
-
}
|
|
633
646
|
// Get occupancy information from mortgage
|
|
634
647
|
if (mortgage.proposedTenantsLids && Array.isArray(mortgage.proposedTenantsLids) && mortgage.proposedTenantsLids.length > 0) {
|
|
635
648
|
// Get the first proposed tenant type
|
|
@@ -646,12 +659,12 @@ welcomeCallSchema.virtual('financeSummaryHtml').get(function () {
|
|
|
646
659
|
const isBTL = application.lendingTypeLid &&
|
|
647
660
|
typeof application.lendingTypeLid === 'object' &&
|
|
648
661
|
application.lendingTypeLid.name === 'BTL';
|
|
649
|
-
const
|
|
662
|
+
const monthlyRepaymentClass = isBTL ? 'mb-2' : '';
|
|
650
663
|
// Create HTML content
|
|
651
664
|
let summaryContent = `
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
665
|
+
<div class="flex align-items-center mb-2"><p class="text-bold m-0 readonly-data">Product:</p> <span class="readonly-data ml-2">${product}</span></div>
|
|
666
|
+
<div class="flex align-items-center mb-2"><p class="text-bold m-0 readonly-data">Finance Term:</p> <span class="readonly-data ml-2">${financeTerm}</span></div>
|
|
667
|
+
<div class="flex align-items-center ${monthlyRepaymentClass}"><p class="text-bold m-0 readonly-data">Monthly Repayment:</p> <span class="readonly-data ml-2">${monthlyRepayment}</span></div>`;
|
|
655
668
|
// Only show rental income and occupancy for BTL applications
|
|
656
669
|
if (isBTL) {
|
|
657
670
|
summaryContent += `
|