@dynamatix/gb-schemas 1.2.143 → 1.2.144
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/dist/applicants/applicant-employment.model.js +58 -58
- package/dist/applicants/applicant-income.model.js +55 -55
- package/dist/applicants/applicant-other-income.model.js +46 -46
- package/dist/applicants/applicant.model.js +225 -225
- package/dist/applicants/index.js +1 -0
- package/dist/applications/application-mortgage.model.js +256 -256
- package/package.json +1 -1
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import { Pound } from "../value-objects/pound";
|
|
3
|
-
const applicantEmploymentSchema = new mongoose.Schema({
|
|
4
|
-
applicantId: { type: mongoose.Schema.Types.ObjectId, ref: "Applicant", required: true },
|
|
5
|
-
pageValidFlag: { type: Boolean, default: false },
|
|
6
|
-
acceptableIncomeLids: [{ type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }],
|
|
7
|
-
addressCity: { type: String, default: null },
|
|
8
|
-
addressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
9
|
-
addressLine1: { type: String, required: true },
|
|
10
|
-
addressLine2: { type: String, default: null },
|
|
11
|
-
addressLine3: { type: String, default: null },
|
|
12
|
-
addressPostCode: { type: String, required: true },
|
|
13
|
-
averageBonusPreviousTwoYears: { type: Pound, default: 0.00 },
|
|
14
|
-
basicGrossIncome: { type: Pound, default: 0.00 },
|
|
15
|
-
basicPay: { type: Pound, default: 0.00 },
|
|
16
|
-
carAllowance: { type: Pound, default: 0.00 },
|
|
17
|
-
childBenefit: { type: Pound, default: 0.00 },
|
|
18
|
-
childBenefitOrSchoolAllowance: { type: Pound, default: 0.00 },
|
|
19
|
-
contractRemaining: { type: String },
|
|
20
|
-
dateJoined: { type: String, required: true },
|
|
21
|
-
disabilityLiving: { type: Pound, default: 0.00 },
|
|
22
|
-
employerName: { type: String, required: true },
|
|
23
|
-
employerTelephone: { type: String, default: null },
|
|
24
|
-
housingAllowance: { type: Pound, default: 0.00 },
|
|
25
|
-
industryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
26
|
-
isUnderTerminationNotice: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
default: false,
|
|
29
|
-
},
|
|
30
|
-
jobTitleLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
31
|
-
maintenance: { type: Pound, default: 0.00 },
|
|
32
|
-
maternityIncome: { type: Pound, default: 0.00 },
|
|
33
|
-
natureOfBusiness: { type: String, required: true },
|
|
34
|
-
pensionIncome: { type: Pound, default: 0.00 },
|
|
35
|
-
previousAddressCity: { type: String, default: null },
|
|
36
|
-
previousAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
37
|
-
previousAddressLine1: { type: String, required: true },
|
|
38
|
-
previousAddressLine2: { type: String, default: null },
|
|
39
|
-
previousAddressLine3: { type: String, default: null },
|
|
40
|
-
previousAddressPostCode: { type: String, required: true },
|
|
41
|
-
previousBasicGrossIncome: { type: Pound, default: 0.00, required: true },
|
|
42
|
-
previousDateJoined: { type: String, required: true },
|
|
43
|
-
previousDateLeft: { type: String, required: true },
|
|
44
|
-
previousEmployerName: { type: String, required: true },
|
|
45
|
-
previousEmployerTelephone: { type: String, default: null },
|
|
46
|
-
previousJobTitle: { type: String, required: true },
|
|
47
|
-
previousNatureOfBusiness: { type: String, required: true },
|
|
48
|
-
referenceContact: { type: String, default: null },
|
|
49
|
-
referenceContactEmail: { type: String, required: true },
|
|
50
|
-
secondJob: { type: Pound, default: 0.00 },
|
|
51
|
-
travelAllowance: { type: Pound, default: 0.00 },
|
|
52
|
-
underTerminationNoticeNote: { type: String, default: null }
|
|
53
|
-
}, {
|
|
54
|
-
toJSON: { getters: true },
|
|
55
|
-
toObject: { getters: true }
|
|
56
|
-
});
|
|
57
|
-
const ApplicantEmploymentModel = mongoose.model("Applicant_Employment_Information", applicantEmploymentSchema);
|
|
58
|
-
export default ApplicantEmploymentModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { Pound } from "../value-objects/pound";
|
|
3
|
+
const applicantEmploymentSchema = new mongoose.Schema({
|
|
4
|
+
applicantId: { type: mongoose.Schema.Types.ObjectId, ref: "Applicant", required: true },
|
|
5
|
+
pageValidFlag: { type: Boolean, default: false },
|
|
6
|
+
acceptableIncomeLids: [{ type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }],
|
|
7
|
+
addressCity: { type: String, default: null },
|
|
8
|
+
addressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
9
|
+
addressLine1: { type: String, required: true },
|
|
10
|
+
addressLine2: { type: String, default: null },
|
|
11
|
+
addressLine3: { type: String, default: null },
|
|
12
|
+
addressPostCode: { type: String, required: true },
|
|
13
|
+
averageBonusPreviousTwoYears: { type: Pound, default: 0.00 },
|
|
14
|
+
basicGrossIncome: { type: Pound, default: 0.00 },
|
|
15
|
+
basicPay: { type: Pound, default: 0.00 },
|
|
16
|
+
carAllowance: { type: Pound, default: 0.00 },
|
|
17
|
+
childBenefit: { type: Pound, default: 0.00 },
|
|
18
|
+
childBenefitOrSchoolAllowance: { type: Pound, default: 0.00 },
|
|
19
|
+
contractRemaining: { type: String },
|
|
20
|
+
dateJoined: { type: String, required: true },
|
|
21
|
+
disabilityLiving: { type: Pound, default: 0.00 },
|
|
22
|
+
employerName: { type: String, required: true },
|
|
23
|
+
employerTelephone: { type: String, default: null },
|
|
24
|
+
housingAllowance: { type: Pound, default: 0.00 },
|
|
25
|
+
industryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
26
|
+
isUnderTerminationNotice: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
jobTitleLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
31
|
+
maintenance: { type: Pound, default: 0.00 },
|
|
32
|
+
maternityIncome: { type: Pound, default: 0.00 },
|
|
33
|
+
natureOfBusiness: { type: String, required: true },
|
|
34
|
+
pensionIncome: { type: Pound, default: 0.00 },
|
|
35
|
+
previousAddressCity: { type: String, default: null },
|
|
36
|
+
previousAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
37
|
+
previousAddressLine1: { type: String, required: true },
|
|
38
|
+
previousAddressLine2: { type: String, default: null },
|
|
39
|
+
previousAddressLine3: { type: String, default: null },
|
|
40
|
+
previousAddressPostCode: { type: String, required: true },
|
|
41
|
+
previousBasicGrossIncome: { type: Pound, default: 0.00, required: true },
|
|
42
|
+
previousDateJoined: { type: String, required: true },
|
|
43
|
+
previousDateLeft: { type: String, required: true },
|
|
44
|
+
previousEmployerName: { type: String, required: true },
|
|
45
|
+
previousEmployerTelephone: { type: String, default: null },
|
|
46
|
+
previousJobTitle: { type: String, required: true },
|
|
47
|
+
previousNatureOfBusiness: { type: String, required: true },
|
|
48
|
+
referenceContact: { type: String, default: null },
|
|
49
|
+
referenceContactEmail: { type: String, required: true },
|
|
50
|
+
secondJob: { type: Pound, default: 0.00 },
|
|
51
|
+
travelAllowance: { type: Pound, default: 0.00 },
|
|
52
|
+
underTerminationNoticeNote: { type: String, default: null }
|
|
53
|
+
}, {
|
|
54
|
+
toJSON: { getters: true },
|
|
55
|
+
toObject: { getters: true }
|
|
56
|
+
});
|
|
57
|
+
const ApplicantEmploymentModel = mongoose.model("Applicant_Employment_Information", applicantEmploymentSchema);
|
|
58
|
+
export default ApplicantEmploymentModel;
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import { Pound } from "../value-objects/pound";
|
|
3
|
-
const incomeSchema = new mongoose.Schema({
|
|
4
|
-
accountantsAddressLine1: { type: String, required: true },
|
|
5
|
-
accountantsAddressLine2: { type: String, required: true },
|
|
6
|
-
accountantsAddressLine3: { type: String, required: true },
|
|
7
|
-
accountantsCity: { type: String, default: '' },
|
|
8
|
-
accountantsCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
9
|
-
accountantsEmail: { type: String, required: true },
|
|
10
|
-
accountantsPostCode: { type: String, required: true },
|
|
11
|
-
accountantsPractice: { type: String, required: true },
|
|
12
|
-
accountantsTelephoneNumber: { type: String, required: true },
|
|
13
|
-
businessAddressLine1: { type: String, required: true },
|
|
14
|
-
businessAddressLine2: { type: String, required: true },
|
|
15
|
-
businessAddressLine3: { type: String, required: true },
|
|
16
|
-
businessCity: { type: String, default: '' },
|
|
17
|
-
businessCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
18
|
-
businessPostCode: { type: String, required: true },
|
|
19
|
-
businessTelephoneNumber: { type: String, required: true },
|
|
20
|
-
businessTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
21
|
-
charteredCertifiedOrOtherLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
22
|
-
contactName: { type: String, required: true },
|
|
23
|
-
currentYearEnd: { type: String, required: true },
|
|
24
|
-
dateEstablished: { type: String, required: true },
|
|
25
|
-
doYouHaveAccountant: { type: Boolean, required: true },
|
|
26
|
-
isBusinessAddressDifferent: { type: Boolean, required: true, },
|
|
27
|
-
nameOfBusiness: { type: String, required: true },
|
|
28
|
-
natureOfBusiness: { type: String, required: true },
|
|
29
|
-
netAssets1: { type: Pound, default: 0.00 },
|
|
30
|
-
netAssets2: { type: Pound, default: 0.00 },
|
|
31
|
-
netAssets3: { type: Pound, default: 0.00 },
|
|
32
|
-
pageValidFlag: { type: String, default: true },
|
|
33
|
-
percentageOfShareholding: { type: Number, required: true, min: 0, max: 100 },
|
|
34
|
-
registeredAddressLine1: { type: String, required: true },
|
|
35
|
-
registeredAddressLine2: { type: String, required: true },
|
|
36
|
-
registeredAddressLine3: { type: String, required: true },
|
|
37
|
-
registeredCity: { type: String, default: '' },
|
|
38
|
-
registeredCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
39
|
-
registeredPostCode: { type: String, required: true },
|
|
40
|
-
registeredTelephone: { type: String, required: true },
|
|
41
|
-
selfEmployedDate: { type: String, required: true },
|
|
42
|
-
turnover1: { type: Pound, default: 0.00 },
|
|
43
|
-
turnover2: { type: Pound, default: 0.00 },
|
|
44
|
-
turnover3: { type: Pound, default: 0.00 },
|
|
45
|
-
year1: { type: Pound, default: 0.00 },
|
|
46
|
-
year2: { type: Pound, default: 0.00 },
|
|
47
|
-
year3: { type: Pound, default: 0.00 },
|
|
48
|
-
yearEnd1: { type: Number, default: '' },
|
|
49
|
-
yearEnd2: { type: Number, default: '' },
|
|
50
|
-
yearEnd3: { type: Number, default: '' }
|
|
51
|
-
}, {
|
|
52
|
-
toJSON: { getters: true },
|
|
53
|
-
toObject: { getters: true }
|
|
54
|
-
});
|
|
55
|
-
export default incomeSchema;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { Pound } from "../value-objects/pound";
|
|
3
|
+
const incomeSchema = new mongoose.Schema({
|
|
4
|
+
accountantsAddressLine1: { type: String, required: true },
|
|
5
|
+
accountantsAddressLine2: { type: String, required: true },
|
|
6
|
+
accountantsAddressLine3: { type: String, required: true },
|
|
7
|
+
accountantsCity: { type: String, default: '' },
|
|
8
|
+
accountantsCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
9
|
+
accountantsEmail: { type: String, required: true },
|
|
10
|
+
accountantsPostCode: { type: String, required: true },
|
|
11
|
+
accountantsPractice: { type: String, required: true },
|
|
12
|
+
accountantsTelephoneNumber: { type: String, required: true },
|
|
13
|
+
businessAddressLine1: { type: String, required: true },
|
|
14
|
+
businessAddressLine2: { type: String, required: true },
|
|
15
|
+
businessAddressLine3: { type: String, required: true },
|
|
16
|
+
businessCity: { type: String, default: '' },
|
|
17
|
+
businessCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
18
|
+
businessPostCode: { type: String, required: true },
|
|
19
|
+
businessTelephoneNumber: { type: String, required: true },
|
|
20
|
+
businessTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
21
|
+
charteredCertifiedOrOtherLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
22
|
+
contactName: { type: String, required: true },
|
|
23
|
+
currentYearEnd: { type: String, required: true },
|
|
24
|
+
dateEstablished: { type: String, required: true },
|
|
25
|
+
doYouHaveAccountant: { type: Boolean, required: true },
|
|
26
|
+
isBusinessAddressDifferent: { type: Boolean, required: true, },
|
|
27
|
+
nameOfBusiness: { type: String, required: true },
|
|
28
|
+
natureOfBusiness: { type: String, required: true },
|
|
29
|
+
netAssets1: { type: Pound, default: 0.00 },
|
|
30
|
+
netAssets2: { type: Pound, default: 0.00 },
|
|
31
|
+
netAssets3: { type: Pound, default: 0.00 },
|
|
32
|
+
pageValidFlag: { type: String, default: true },
|
|
33
|
+
percentageOfShareholding: { type: Number, required: true, min: 0, max: 100 },
|
|
34
|
+
registeredAddressLine1: { type: String, required: true },
|
|
35
|
+
registeredAddressLine2: { type: String, required: true },
|
|
36
|
+
registeredAddressLine3: { type: String, required: true },
|
|
37
|
+
registeredCity: { type: String, default: '' },
|
|
38
|
+
registeredCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
39
|
+
registeredPostCode: { type: String, required: true },
|
|
40
|
+
registeredTelephone: { type: String, required: true },
|
|
41
|
+
selfEmployedDate: { type: String, required: true },
|
|
42
|
+
turnover1: { type: Pound, default: 0.00 },
|
|
43
|
+
turnover2: { type: Pound, default: 0.00 },
|
|
44
|
+
turnover3: { type: Pound, default: 0.00 },
|
|
45
|
+
year1: { type: Pound, default: 0.00 },
|
|
46
|
+
year2: { type: Pound, default: 0.00 },
|
|
47
|
+
year3: { type: Pound, default: 0.00 },
|
|
48
|
+
yearEnd1: { type: Number, default: '' },
|
|
49
|
+
yearEnd2: { type: Number, default: '' },
|
|
50
|
+
yearEnd3: { type: Number, default: '' }
|
|
51
|
+
}, {
|
|
52
|
+
toJSON: { getters: true },
|
|
53
|
+
toObject: { getters: true }
|
|
54
|
+
});
|
|
55
|
+
export default incomeSchema;
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import { Pound } from "../value-objects/pound";
|
|
3
|
-
const applicantOtherIncomeSchema = new mongoose.Schema({
|
|
4
|
-
// Income Source 1
|
|
5
|
-
sourceDetails1: { type: String, default: null },
|
|
6
|
-
amount1: { type: Pound, default: 0.00 },
|
|
7
|
-
payFrequency1Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
8
|
-
guaranteed1: {
|
|
9
|
-
type: Boolean,
|
|
10
|
-
default: false
|
|
11
|
-
},
|
|
12
|
-
// Income Source 2
|
|
13
|
-
sourceDetails2: { type: String, default: null },
|
|
14
|
-
amount2: { type: Pound, default: 0.00 },
|
|
15
|
-
payFrequency2Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
16
|
-
guaranteed2: {
|
|
17
|
-
type: Boolean,
|
|
18
|
-
default: false
|
|
19
|
-
},
|
|
20
|
-
// Income Source 3
|
|
21
|
-
sourceDetails3: { type: String, default: null },
|
|
22
|
-
amount3: { type: Pound, default: 0.00 },
|
|
23
|
-
payFrequency3Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
24
|
-
guaranteed3: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: false
|
|
27
|
-
},
|
|
28
|
-
// Income Source 4
|
|
29
|
-
sourceDetails4: { type: String, default: null },
|
|
30
|
-
amount4: { type: Pound, default: 0.00 },
|
|
31
|
-
payFrequency4Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
32
|
-
guaranteed4: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: false
|
|
35
|
-
},
|
|
36
|
-
taxCredits: { type: Pound, default: 0.00 },
|
|
37
|
-
maintenance: { type: Pound, default: 0.00 },
|
|
38
|
-
otherBenefits: { type: Pound, default: 0.00 },
|
|
39
|
-
grossPensionIncome: { type: Pound, default: 0.00 },
|
|
40
|
-
privatePensionIncome: { type: Pound, default: 0.00 },
|
|
41
|
-
statePensionIncome: { type: Pound, default: 0.00 },
|
|
42
|
-
}, {
|
|
43
|
-
toJSON: { getters: true },
|
|
44
|
-
toObject: { getters: true }
|
|
45
|
-
});
|
|
46
|
-
export default applicantOtherIncomeSchema;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { Pound } from "../value-objects/pound";
|
|
3
|
+
const applicantOtherIncomeSchema = new mongoose.Schema({
|
|
4
|
+
// Income Source 1
|
|
5
|
+
sourceDetails1: { type: String, default: null },
|
|
6
|
+
amount1: { type: Pound, default: 0.00 },
|
|
7
|
+
payFrequency1Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
8
|
+
guaranteed1: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false
|
|
11
|
+
},
|
|
12
|
+
// Income Source 2
|
|
13
|
+
sourceDetails2: { type: String, default: null },
|
|
14
|
+
amount2: { type: Pound, default: 0.00 },
|
|
15
|
+
payFrequency2Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
16
|
+
guaranteed2: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
// Income Source 3
|
|
21
|
+
sourceDetails3: { type: String, default: null },
|
|
22
|
+
amount3: { type: Pound, default: 0.00 },
|
|
23
|
+
payFrequency3Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
24
|
+
guaranteed3: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
// Income Source 4
|
|
29
|
+
sourceDetails4: { type: String, default: null },
|
|
30
|
+
amount4: { type: Pound, default: 0.00 },
|
|
31
|
+
payFrequency4Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
32
|
+
guaranteed4: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
taxCredits: { type: Pound, default: 0.00 },
|
|
37
|
+
maintenance: { type: Pound, default: 0.00 },
|
|
38
|
+
otherBenefits: { type: Pound, default: 0.00 },
|
|
39
|
+
grossPensionIncome: { type: Pound, default: 0.00 },
|
|
40
|
+
privatePensionIncome: { type: Pound, default: 0.00 },
|
|
41
|
+
statePensionIncome: { type: Pound, default: 0.00 },
|
|
42
|
+
}, {
|
|
43
|
+
toJSON: { getters: true },
|
|
44
|
+
toObject: { getters: true }
|
|
45
|
+
});
|
|
46
|
+
export default applicantOtherIncomeSchema;
|
|
@@ -1,225 +1,225 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import applicantCreditDataSchema from "./applicant-credit-data.model";
|
|
3
|
-
import applicantRiskNarrativeSchema from "./applicant-risk-narrative.model";
|
|
4
|
-
import applicantOtherIncomeSchema from "./applicant-other-income.model";
|
|
5
|
-
import applicantIncomeSourceSchema from "./applicant-income-source.model";
|
|
6
|
-
import applicantExpenditureSchema from "./applicant-expenditure.model";
|
|
7
|
-
import applicantDirectDebitSchema from "./applicant-direct-debit.model";
|
|
8
|
-
import creditProfileSchema from "./applicant-credit-profile.model";
|
|
9
|
-
import propertyIncomeSchema from "./applicant-property-income.model";
|
|
10
|
-
import incomeSchema from "./applicant-income.model";
|
|
11
|
-
import { Pound } from "../value-objects/pound";
|
|
12
|
-
const applicantSchema = new mongoose.Schema({
|
|
13
|
-
applicantId: { type: String, required: true },
|
|
14
|
-
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true },
|
|
15
|
-
addressCity: { type: String, default: null },
|
|
16
|
-
addressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
17
|
-
addressLine1: { type: String, default: null },
|
|
18
|
-
addressLine2: { type: String, default: null },
|
|
19
|
-
addressLine3: { type: String, default: null },
|
|
20
|
-
addressMovedDate: { type: String, default: null },
|
|
21
|
-
addressPostCode: { type: String, default: null },
|
|
22
|
-
correspondenceAddressCity: { type: String, default: null },
|
|
23
|
-
correspondenceAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
24
|
-
correspondenceAddressLine1: { type: String, default: null },
|
|
25
|
-
correspondenceAddressLine2: { type: String, default: null },
|
|
26
|
-
correspondenceAddressLine3: { type: String, default: null },
|
|
27
|
-
correspondenceAddressPostCode: { type: String, default: null },
|
|
28
|
-
countryOfResidenceLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
29
|
-
dateOfBirth: { type: String, required: true },
|
|
30
|
-
dependant10Age: { type: Number, default: 0 },
|
|
31
|
-
dependant1Age: { type: Number, default: 0 },
|
|
32
|
-
dependant2Age: { type: Number, default: 0 },
|
|
33
|
-
dependant3Age: { type: Number, default: 0 },
|
|
34
|
-
dependant4Age: { type: Number, default: 0 },
|
|
35
|
-
dependant5Age: { type: Number, default: 0 },
|
|
36
|
-
dependant6Age: { type: Number, default: 0 },
|
|
37
|
-
dependant7Age: { type: Number, default: 0 },
|
|
38
|
-
dependant8Age: { type: Number, default: 0 },
|
|
39
|
-
dependant9Age: { type: Number, default: 0 },
|
|
40
|
-
email: { type: String, required: true },
|
|
41
|
-
employmentStatusDetails: { type: String, default: null },
|
|
42
|
-
firstName: { type: String, required: true },
|
|
43
|
-
isFirstTimelandlord: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: false,
|
|
46
|
-
},
|
|
47
|
-
foreignNationalsId: { type: String, default: null },
|
|
48
|
-
gdprEmail: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
gdprPost: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false,
|
|
55
|
-
},
|
|
56
|
-
gdprTelephone: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false,
|
|
59
|
-
},
|
|
60
|
-
gdprTextMessage: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
|
-
},
|
|
64
|
-
gender: { type: String, required: true },
|
|
65
|
-
hasBrokerGivenConsentForVulnerabilities: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
required: true,
|
|
68
|
-
},
|
|
69
|
-
hasLinkedJurisdiction: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
default: false,
|
|
72
|
-
},
|
|
73
|
-
isCorrespondence: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: true,
|
|
76
|
-
},
|
|
77
|
-
isCurrentContract: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: false,
|
|
80
|
-
},
|
|
81
|
-
isCustomerVulnerable: {
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: false,
|
|
84
|
-
},
|
|
85
|
-
isExpat: {
|
|
86
|
-
type: Boolean,
|
|
87
|
-
default: false,
|
|
88
|
-
},
|
|
89
|
-
isFirstApplicant: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: false,
|
|
92
|
-
},
|
|
93
|
-
isUkPassport: {
|
|
94
|
-
type: Boolean,
|
|
95
|
-
default: false,
|
|
96
|
-
},
|
|
97
|
-
isUkResident: {
|
|
98
|
-
type: Boolean,
|
|
99
|
-
required: true,
|
|
100
|
-
},
|
|
101
|
-
classLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
102
|
-
pageValidFlag: { type: Boolean, default: false },
|
|
103
|
-
lastName: { type: String, required: true },
|
|
104
|
-
linkedJurisdictionCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
105
|
-
linkedJurisdictionDetails: { type: String, default: null },
|
|
106
|
-
maidenName: { type: String, default: null },
|
|
107
|
-
maritalStatusLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
108
|
-
mobileNumber: { type: String, default: null },
|
|
109
|
-
nationalityLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
110
|
-
netIncome: { type: Pound, default: 0.00 },
|
|
111
|
-
niNumber: { type: String, required: true },
|
|
112
|
-
numberOfDependants: { type: Number, default: 0 },
|
|
113
|
-
isOneYearPrior: {
|
|
114
|
-
type: Boolean,
|
|
115
|
-
default: false,
|
|
116
|
-
},
|
|
117
|
-
phoneNumber: { type: String, default: null },
|
|
118
|
-
previous1AddressCity: { type: String, default: null },
|
|
119
|
-
previous1AddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
120
|
-
previous1AddressLine1: { type: String, default: null },
|
|
121
|
-
previous1AddressLine2: { type: String, default: null },
|
|
122
|
-
previous1AddressLine3: { type: String, default: null },
|
|
123
|
-
previous1AddressMovedDate: { type: String, default: null },
|
|
124
|
-
previous1AddressPostCode: { type: String, default: null },
|
|
125
|
-
previous1AddressPropertyOwnedBy: { type: String, default: null },
|
|
126
|
-
previous2AddressCity: { type: String, default: null },
|
|
127
|
-
previous2AddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
128
|
-
previous2AddressLine1: { type: String, default: null },
|
|
129
|
-
previous2AddressLine2: { type: String, default: null },
|
|
130
|
-
previous2AddressLine3: { type: String, default: null },
|
|
131
|
-
previous2AddressMovedDate: { type: String, default: null },
|
|
132
|
-
previous2AddressPostCode: { type: String, default: null },
|
|
133
|
-
previous2AddressPropertyOwnedBy: { type: String, default: null },
|
|
134
|
-
relationshipToOthers: { type: String, required: true },
|
|
135
|
-
residentialStatusLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
136
|
-
retirementAge: { type: String, required: true },
|
|
137
|
-
taxJurisdictionLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
138
|
-
taxPayerLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
139
|
-
timeResidedAtCountryOfResidence: { type: Number, required: true },
|
|
140
|
-
title: { type: String, required: true },
|
|
141
|
-
isTwoYearPrior: {
|
|
142
|
-
type: Boolean,
|
|
143
|
-
default: false,
|
|
144
|
-
},
|
|
145
|
-
understandEnglish: {
|
|
146
|
-
type: Boolean,
|
|
147
|
-
required: true,
|
|
148
|
-
},
|
|
149
|
-
vulnerabilityNotes: { type: String, default: null },
|
|
150
|
-
vulnerabilityTypeLids: [{ type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }],
|
|
151
|
-
ukPassportProfession: {
|
|
152
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
153
|
-
ref: "Lookup",
|
|
154
|
-
required: function () {
|
|
155
|
-
return this.isUkResident;
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
creditData: applicantCreditDataSchema,
|
|
159
|
-
riskNarrative: applicantRiskNarrativeSchema,
|
|
160
|
-
otherIncome: applicantOtherIncomeSchema,
|
|
161
|
-
incomeSource: applicantIncomeSourceSchema,
|
|
162
|
-
expenditure: applicantExpenditureSchema,
|
|
163
|
-
directDebit: applicantDirectDebitSchema,
|
|
164
|
-
creditProfile: creditProfileSchema,
|
|
165
|
-
propertyIncome: propertyIncomeSchema,
|
|
166
|
-
income: incomeSchema
|
|
167
|
-
}, {
|
|
168
|
-
timestamps: true,
|
|
169
|
-
toJSON: { virtuals: true, getters: true },
|
|
170
|
-
toObject: { virtuals: true, getters: true }
|
|
171
|
-
});
|
|
172
|
-
applicantSchema.virtual('nationality').get(function () {
|
|
173
|
-
return this.nationalityLid?.name ?? null;
|
|
174
|
-
});
|
|
175
|
-
applicantSchema.virtual('residence').get(function () {
|
|
176
|
-
return this.countryOfResidenceLid?.name ?? null;
|
|
177
|
-
});
|
|
178
|
-
applicantSchema.virtual('employmentClass').get(function () {
|
|
179
|
-
return this.classLid?.name ?? null;
|
|
180
|
-
});
|
|
181
|
-
applicantSchema.virtual('addressCountry').get(function () {
|
|
182
|
-
return this.addressCountryLid?.name ?? null;
|
|
183
|
-
});
|
|
184
|
-
applicantSchema.virtual('previous1AddressCountry').get(function () {
|
|
185
|
-
return this.previous1AddressCountryLid?.name ?? null;
|
|
186
|
-
});
|
|
187
|
-
applicantSchema.virtual('previous2AddressCountry').get(function () {
|
|
188
|
-
return this.previous2AddressCountryLid?.name ?? null;
|
|
189
|
-
});
|
|
190
|
-
applicantSchema.virtual('maritalStatus').get(function () {
|
|
191
|
-
return this.maritalStatusLid?.name ?? null;
|
|
192
|
-
});
|
|
193
|
-
applicantSchema.virtual('residentialStatus').get(function () {
|
|
194
|
-
return this.residentialStatusLid?.name ?? null;
|
|
195
|
-
});
|
|
196
|
-
applicantSchema.virtual('taxPayer').get(function () {
|
|
197
|
-
return this.taxPayerLid?.name ?? null;
|
|
198
|
-
});
|
|
199
|
-
applicantSchema.virtual('vulnerabilityType').get(function () {
|
|
200
|
-
return this.vulnerabilityTypeLids?.map((v) => v.name);
|
|
201
|
-
});
|
|
202
|
-
applicantSchema.virtual('fullName').get(function () {
|
|
203
|
-
return `${this.firstName ?? ''} ${this.lastName ?? ''}`.trim();
|
|
204
|
-
});
|
|
205
|
-
// virtual property 'applicationType'
|
|
206
|
-
applicantSchema.virtual('applicationType').get(function () {
|
|
207
|
-
return this.applicationId?.applicationTypeLid instanceof mongoose.Types.ObjectId
|
|
208
|
-
? null
|
|
209
|
-
: this.applicationId?.applicationTypeLid?.name || null;
|
|
210
|
-
});
|
|
211
|
-
// virtual property 'lendingType'
|
|
212
|
-
applicantSchema.virtual('lendingType').get(function () {
|
|
213
|
-
return this.applicationId?.lendingTypeLid instanceof mongoose.Types.ObjectId
|
|
214
|
-
? null
|
|
215
|
-
: this.applicationId?.lendingTypeLid?.name || null;
|
|
216
|
-
});
|
|
217
|
-
// numberOfApplicants – how many applicants are on the associated Application
|
|
218
|
-
applicantSchema.virtual('numberOfApplicants').get(function () {
|
|
219
|
-
// `this.applicationId` must be populated (with its `applicants` field)
|
|
220
|
-
const app = this.applicationId;
|
|
221
|
-
// if it's populated and has an applicants array, return its length, otherwise 0
|
|
222
|
-
return Array.isArray(app?.applicants) ? app.applicants.length : 0;
|
|
223
|
-
});
|
|
224
|
-
const ApplicantModel = mongoose.model("Applicant", applicantSchema);
|
|
225
|
-
export default ApplicantModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import applicantCreditDataSchema from "./applicant-credit-data.model";
|
|
3
|
+
import applicantRiskNarrativeSchema from "./applicant-risk-narrative.model";
|
|
4
|
+
import applicantOtherIncomeSchema from "./applicant-other-income.model";
|
|
5
|
+
import applicantIncomeSourceSchema from "./applicant-income-source.model";
|
|
6
|
+
import applicantExpenditureSchema from "./applicant-expenditure.model";
|
|
7
|
+
import applicantDirectDebitSchema from "./applicant-direct-debit.model";
|
|
8
|
+
import creditProfileSchema from "./applicant-credit-profile.model";
|
|
9
|
+
import propertyIncomeSchema from "./applicant-property-income.model";
|
|
10
|
+
import incomeSchema from "./applicant-income.model";
|
|
11
|
+
import { Pound } from "../value-objects/pound";
|
|
12
|
+
const applicantSchema = new mongoose.Schema({
|
|
13
|
+
applicantId: { type: String, required: true },
|
|
14
|
+
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true },
|
|
15
|
+
addressCity: { type: String, default: null },
|
|
16
|
+
addressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
17
|
+
addressLine1: { type: String, default: null },
|
|
18
|
+
addressLine2: { type: String, default: null },
|
|
19
|
+
addressLine3: { type: String, default: null },
|
|
20
|
+
addressMovedDate: { type: String, default: null },
|
|
21
|
+
addressPostCode: { type: String, default: null },
|
|
22
|
+
correspondenceAddressCity: { type: String, default: null },
|
|
23
|
+
correspondenceAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
24
|
+
correspondenceAddressLine1: { type: String, default: null },
|
|
25
|
+
correspondenceAddressLine2: { type: String, default: null },
|
|
26
|
+
correspondenceAddressLine3: { type: String, default: null },
|
|
27
|
+
correspondenceAddressPostCode: { type: String, default: null },
|
|
28
|
+
countryOfResidenceLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
29
|
+
dateOfBirth: { type: String, required: true },
|
|
30
|
+
dependant10Age: { type: Number, default: 0 },
|
|
31
|
+
dependant1Age: { type: Number, default: 0 },
|
|
32
|
+
dependant2Age: { type: Number, default: 0 },
|
|
33
|
+
dependant3Age: { type: Number, default: 0 },
|
|
34
|
+
dependant4Age: { type: Number, default: 0 },
|
|
35
|
+
dependant5Age: { type: Number, default: 0 },
|
|
36
|
+
dependant6Age: { type: Number, default: 0 },
|
|
37
|
+
dependant7Age: { type: Number, default: 0 },
|
|
38
|
+
dependant8Age: { type: Number, default: 0 },
|
|
39
|
+
dependant9Age: { type: Number, default: 0 },
|
|
40
|
+
email: { type: String, required: true },
|
|
41
|
+
employmentStatusDetails: { type: String, default: null },
|
|
42
|
+
firstName: { type: String, required: true },
|
|
43
|
+
isFirstTimelandlord: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
foreignNationalsId: { type: String, default: null },
|
|
48
|
+
gdprEmail: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
gdprPost: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
56
|
+
gdprTelephone: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
gdprTextMessage: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
gender: { type: String, required: true },
|
|
65
|
+
hasBrokerGivenConsentForVulnerabilities: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
hasLinkedJurisdiction: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
isCorrespondence: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true,
|
|
76
|
+
},
|
|
77
|
+
isCurrentContract: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
isCustomerVulnerable: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false,
|
|
84
|
+
},
|
|
85
|
+
isExpat: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
isFirstApplicant: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false,
|
|
92
|
+
},
|
|
93
|
+
isUkPassport: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: false,
|
|
96
|
+
},
|
|
97
|
+
isUkResident: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
classLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
102
|
+
pageValidFlag: { type: Boolean, default: false },
|
|
103
|
+
lastName: { type: String, required: true },
|
|
104
|
+
linkedJurisdictionCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
105
|
+
linkedJurisdictionDetails: { type: String, default: null },
|
|
106
|
+
maidenName: { type: String, default: null },
|
|
107
|
+
maritalStatusLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
108
|
+
mobileNumber: { type: String, default: null },
|
|
109
|
+
nationalityLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
110
|
+
netIncome: { type: Pound, default: 0.00 },
|
|
111
|
+
niNumber: { type: String, required: true },
|
|
112
|
+
numberOfDependants: { type: Number, default: 0 },
|
|
113
|
+
isOneYearPrior: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: false,
|
|
116
|
+
},
|
|
117
|
+
phoneNumber: { type: String, default: null },
|
|
118
|
+
previous1AddressCity: { type: String, default: null },
|
|
119
|
+
previous1AddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
120
|
+
previous1AddressLine1: { type: String, default: null },
|
|
121
|
+
previous1AddressLine2: { type: String, default: null },
|
|
122
|
+
previous1AddressLine3: { type: String, default: null },
|
|
123
|
+
previous1AddressMovedDate: { type: String, default: null },
|
|
124
|
+
previous1AddressPostCode: { type: String, default: null },
|
|
125
|
+
previous1AddressPropertyOwnedBy: { type: String, default: null },
|
|
126
|
+
previous2AddressCity: { type: String, default: null },
|
|
127
|
+
previous2AddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
128
|
+
previous2AddressLine1: { type: String, default: null },
|
|
129
|
+
previous2AddressLine2: { type: String, default: null },
|
|
130
|
+
previous2AddressLine3: { type: String, default: null },
|
|
131
|
+
previous2AddressMovedDate: { type: String, default: null },
|
|
132
|
+
previous2AddressPostCode: { type: String, default: null },
|
|
133
|
+
previous2AddressPropertyOwnedBy: { type: String, default: null },
|
|
134
|
+
relationshipToOthers: { type: String, required: true },
|
|
135
|
+
residentialStatusLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
|
|
136
|
+
retirementAge: { type: String, required: true },
|
|
137
|
+
taxJurisdictionLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
138
|
+
taxPayerLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
139
|
+
timeResidedAtCountryOfResidence: { type: Number, required: true },
|
|
140
|
+
title: { type: String, required: true },
|
|
141
|
+
isTwoYearPrior: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: false,
|
|
144
|
+
},
|
|
145
|
+
understandEnglish: {
|
|
146
|
+
type: Boolean,
|
|
147
|
+
required: true,
|
|
148
|
+
},
|
|
149
|
+
vulnerabilityNotes: { type: String, default: null },
|
|
150
|
+
vulnerabilityTypeLids: [{ type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }],
|
|
151
|
+
ukPassportProfession: {
|
|
152
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
153
|
+
ref: "Lookup",
|
|
154
|
+
required: function () {
|
|
155
|
+
return this.isUkResident;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
creditData: applicantCreditDataSchema,
|
|
159
|
+
riskNarrative: applicantRiskNarrativeSchema,
|
|
160
|
+
otherIncome: applicantOtherIncomeSchema,
|
|
161
|
+
incomeSource: applicantIncomeSourceSchema,
|
|
162
|
+
expenditure: applicantExpenditureSchema,
|
|
163
|
+
directDebit: applicantDirectDebitSchema,
|
|
164
|
+
creditProfile: creditProfileSchema,
|
|
165
|
+
propertyIncome: propertyIncomeSchema,
|
|
166
|
+
income: incomeSchema
|
|
167
|
+
}, {
|
|
168
|
+
timestamps: true,
|
|
169
|
+
toJSON: { virtuals: true, getters: true },
|
|
170
|
+
toObject: { virtuals: true, getters: true }
|
|
171
|
+
});
|
|
172
|
+
applicantSchema.virtual('nationality').get(function () {
|
|
173
|
+
return this.nationalityLid?.name ?? null;
|
|
174
|
+
});
|
|
175
|
+
applicantSchema.virtual('residence').get(function () {
|
|
176
|
+
return this.countryOfResidenceLid?.name ?? null;
|
|
177
|
+
});
|
|
178
|
+
applicantSchema.virtual('employmentClass').get(function () {
|
|
179
|
+
return this.classLid?.name ?? null;
|
|
180
|
+
});
|
|
181
|
+
applicantSchema.virtual('addressCountry').get(function () {
|
|
182
|
+
return this.addressCountryLid?.name ?? null;
|
|
183
|
+
});
|
|
184
|
+
applicantSchema.virtual('previous1AddressCountry').get(function () {
|
|
185
|
+
return this.previous1AddressCountryLid?.name ?? null;
|
|
186
|
+
});
|
|
187
|
+
applicantSchema.virtual('previous2AddressCountry').get(function () {
|
|
188
|
+
return this.previous2AddressCountryLid?.name ?? null;
|
|
189
|
+
});
|
|
190
|
+
applicantSchema.virtual('maritalStatus').get(function () {
|
|
191
|
+
return this.maritalStatusLid?.name ?? null;
|
|
192
|
+
});
|
|
193
|
+
applicantSchema.virtual('residentialStatus').get(function () {
|
|
194
|
+
return this.residentialStatusLid?.name ?? null;
|
|
195
|
+
});
|
|
196
|
+
applicantSchema.virtual('taxPayer').get(function () {
|
|
197
|
+
return this.taxPayerLid?.name ?? null;
|
|
198
|
+
});
|
|
199
|
+
applicantSchema.virtual('vulnerabilityType').get(function () {
|
|
200
|
+
return this.vulnerabilityTypeLids?.map((v) => v.name);
|
|
201
|
+
});
|
|
202
|
+
applicantSchema.virtual('fullName').get(function () {
|
|
203
|
+
return `${this.firstName ?? ''} ${this.lastName ?? ''}`.trim();
|
|
204
|
+
});
|
|
205
|
+
// virtual property 'applicationType'
|
|
206
|
+
applicantSchema.virtual('applicationType').get(function () {
|
|
207
|
+
return this.applicationId?.applicationTypeLid instanceof mongoose.Types.ObjectId
|
|
208
|
+
? null
|
|
209
|
+
: this.applicationId?.applicationTypeLid?.name || null;
|
|
210
|
+
});
|
|
211
|
+
// virtual property 'lendingType'
|
|
212
|
+
applicantSchema.virtual('lendingType').get(function () {
|
|
213
|
+
return this.applicationId?.lendingTypeLid instanceof mongoose.Types.ObjectId
|
|
214
|
+
? null
|
|
215
|
+
: this.applicationId?.lendingTypeLid?.name || null;
|
|
216
|
+
});
|
|
217
|
+
// numberOfApplicants – how many applicants are on the associated Application
|
|
218
|
+
applicantSchema.virtual('numberOfApplicants').get(function () {
|
|
219
|
+
// `this.applicationId` must be populated (with its `applicants` field)
|
|
220
|
+
const app = this.applicationId;
|
|
221
|
+
// if it's populated and has an applicants array, return its length, otherwise 0
|
|
222
|
+
return Array.isArray(app?.applicants) ? app.applicants.length : 0;
|
|
223
|
+
});
|
|
224
|
+
const ApplicantModel = mongoose.model("Applicant", applicantSchema);
|
|
225
|
+
export default ApplicantModel;
|
package/dist/applicants/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { default as MortgageCommitmentModel } from './applicant-commitment-mortg
|
|
|
5
5
|
export { default as ResidenceCommitmentModel } from './applicant-commitment-residence.model';
|
|
6
6
|
export { default as SecuredLoanCommitmentModel } from './applicant-commitment-secureLoan.model';
|
|
7
7
|
export { default as UnsecuredLoanCommitmentModel } from './applicant-commitment-unsecuredLoan.model';
|
|
8
|
+
export { default as ApplicantEmploymentModel } from './applicant-employment.model';
|
|
@@ -1,256 +1,256 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import { Pound } from "../value-objects/pound";
|
|
3
|
-
const mortgageSchema = new mongoose.Schema({
|
|
4
|
-
applicationId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: "Application",
|
|
7
|
-
required: true,
|
|
8
|
-
description: "Unique identifier for the application",
|
|
9
|
-
},
|
|
10
|
-
pageValidFlag: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: false,
|
|
13
|
-
description: "True if all mandatory fields have been completed, otherwise false",
|
|
14
|
-
},
|
|
15
|
-
existingMortgageLender: {
|
|
16
|
-
type: String,
|
|
17
|
-
maxlength: 35,
|
|
18
|
-
description: "Name of the existing mortgage lender",
|
|
19
|
-
},
|
|
20
|
-
topSlicing: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false,
|
|
23
|
-
description: "Indicates if the mortgage is being paid off using top slicing",
|
|
24
|
-
},
|
|
25
|
-
purposeOfMortgage: {
|
|
26
|
-
type: String,
|
|
27
|
-
maxlength: 50,
|
|
28
|
-
description: "Purpose of the mortgage (e.g., purchase, refinance)",
|
|
29
|
-
},
|
|
30
|
-
depositComeFromLids: {
|
|
31
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
32
|
-
ref: "Lookup",
|
|
33
|
-
default: null,
|
|
34
|
-
description: "Where the deposit for the mortgage will come from",
|
|
35
|
-
},
|
|
36
|
-
ifOtherDetails: {
|
|
37
|
-
type: String,
|
|
38
|
-
maxlength: 50,
|
|
39
|
-
description: "Details if the deposit comes from 'Other'",
|
|
40
|
-
},
|
|
41
|
-
purchasePrice: {
|
|
42
|
-
type: Pound,
|
|
43
|
-
description: "Purchase price of the property",
|
|
44
|
-
},
|
|
45
|
-
repaymentTypeLid: {
|
|
46
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
47
|
-
ref: "Lookup",
|
|
48
|
-
default: null,
|
|
49
|
-
description: "Lookup ID representing the type of repayment (e.g., interest-only, repayment)",
|
|
50
|
-
},
|
|
51
|
-
exitStrategyLid: {
|
|
52
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
53
|
-
ref: "Lookup",
|
|
54
|
-
default: null,
|
|
55
|
-
description: "Lookup ID representing the Exit strategy for the mortgage)",
|
|
56
|
-
},
|
|
57
|
-
isCapitalRaise: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: false,
|
|
60
|
-
description: "Indicates if capital raising is part of this finance",
|
|
61
|
-
},
|
|
62
|
-
purchaseDate: {
|
|
63
|
-
type: String,
|
|
64
|
-
default: null,
|
|
65
|
-
description: "Purchase date of the property",
|
|
66
|
-
},
|
|
67
|
-
estimatedValue: {
|
|
68
|
-
type: Pound,
|
|
69
|
-
description: "Estimated value of the property",
|
|
70
|
-
},
|
|
71
|
-
loanRequired: {
|
|
72
|
-
type: Pound,
|
|
73
|
-
description: "Amount of finance required",
|
|
74
|
-
},
|
|
75
|
-
monthlyRentalIncome: {
|
|
76
|
-
type: Pound,
|
|
77
|
-
description: "Monthly rental income from the property",
|
|
78
|
-
},
|
|
79
|
-
outstandingBalance: {
|
|
80
|
-
type: Pound,
|
|
81
|
-
description: "Outstanding balance on the existing mortgage",
|
|
82
|
-
},
|
|
83
|
-
fundRaisedFor: {
|
|
84
|
-
type: String,
|
|
85
|
-
maxlength: 250,
|
|
86
|
-
description: "What the funds raised will be used for",
|
|
87
|
-
},
|
|
88
|
-
sourceOfFundsLid: {
|
|
89
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
90
|
-
ref: "Lookup",
|
|
91
|
-
default: null,
|
|
92
|
-
description: "Lookup ID representing the Main source of income for monthly finance payments",
|
|
93
|
-
},
|
|
94
|
-
sourceOfFundDetails: {
|
|
95
|
-
type: String,
|
|
96
|
-
maxlength: 50,
|
|
97
|
-
description: "Additional details if the source of funds is 'Other'",
|
|
98
|
-
},
|
|
99
|
-
propertyValuationDetails: {
|
|
100
|
-
type: String,
|
|
101
|
-
maxlength: 35,
|
|
102
|
-
description: "Details on who to contact for property valuation",
|
|
103
|
-
},
|
|
104
|
-
telephoneNumber: {
|
|
105
|
-
type: String,
|
|
106
|
-
maxlength: 15,
|
|
107
|
-
description: "Contact number for property valuation",
|
|
108
|
-
},
|
|
109
|
-
isDistressedSale: {
|
|
110
|
-
type: Boolean,
|
|
111
|
-
default: false,
|
|
112
|
-
description: "Indicates if this is a distressed sale",
|
|
113
|
-
},
|
|
114
|
-
isPurchasedBelowMarketValue: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
default: false,
|
|
117
|
-
description: "Indicates if the property is purchased below market value",
|
|
118
|
-
},
|
|
119
|
-
isPurchasedAsSale: {
|
|
120
|
-
type: Boolean,
|
|
121
|
-
default: false,
|
|
122
|
-
description: "Indicates if the property is purchased as a sale and rent back",
|
|
123
|
-
},
|
|
124
|
-
isReadyToSell: {
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: false,
|
|
127
|
-
description: "Indicates if the property is ready to sell or let out",
|
|
128
|
-
},
|
|
129
|
-
isGovernmentInitiative: {
|
|
130
|
-
type: Boolean,
|
|
131
|
-
default: false,
|
|
132
|
-
description: "Indicates if this purchase is part of a government initiative",
|
|
133
|
-
},
|
|
134
|
-
vendorsName: {
|
|
135
|
-
type: String,
|
|
136
|
-
maxlength: 35,
|
|
137
|
-
description: "Vendor's name in case of property sale",
|
|
138
|
-
},
|
|
139
|
-
saleMadeLid: {
|
|
140
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
141
|
-
ref: "Lookup",
|
|
142
|
-
description: "Method of sale made",
|
|
143
|
-
},
|
|
144
|
-
isTheIntentionToLet: {
|
|
145
|
-
type: Boolean,
|
|
146
|
-
default: false,
|
|
147
|
-
description: "Indicates if the intention is to let out the property",
|
|
148
|
-
},
|
|
149
|
-
proposedTenantsLids: {
|
|
150
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
151
|
-
ref: "Lookup",
|
|
152
|
-
description: "Proposed tenants for the property",
|
|
153
|
-
},
|
|
154
|
-
leaseTypeLid: {
|
|
155
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
156
|
-
ref: "Lookup",
|
|
157
|
-
default: null,
|
|
158
|
-
description: "Lease type for the property",
|
|
159
|
-
},
|
|
160
|
-
giftDetails: {
|
|
161
|
-
type: String,
|
|
162
|
-
maxlength: 50,
|
|
163
|
-
description: "Details of the gift for the mortgage",
|
|
164
|
-
},
|
|
165
|
-
}, {
|
|
166
|
-
timestamps: true,
|
|
167
|
-
toJSON: { virtuals: true },
|
|
168
|
-
toObject: { virtuals: true },
|
|
169
|
-
});
|
|
170
|
-
// const virtualDepositComeFrom = mortgageSchema.virtual("depositComeFrom", {
|
|
171
|
-
// ref: "Lookup",
|
|
172
|
-
// localField: "depositComeFromLid",
|
|
173
|
-
// foreignField: "_id",
|
|
174
|
-
// justOne: false,
|
|
175
|
-
// }) as VirtualWithDescription;
|
|
176
|
-
// virtualDepositComeFrom.description =
|
|
177
|
-
// "Populated lookup values for where the deposit for the mortgage will come from";
|
|
178
|
-
// const virtualRepaymentType = mortgageSchema.virtual("repaymentType", {
|
|
179
|
-
// ref: "Lookup",
|
|
180
|
-
// localField: "repaymentTypeLid",
|
|
181
|
-
// foreignField: "_id",
|
|
182
|
-
// justOne: true,
|
|
183
|
-
// }) as VirtualWithDescription;
|
|
184
|
-
// virtualRepaymentType.description =
|
|
185
|
-
// "Populated lookup value representing the type of repayment";
|
|
186
|
-
// const virtualExitStrategy = mortgageSchema.virtual("exitStrategy", {
|
|
187
|
-
// ref: "Lookup",
|
|
188
|
-
// localField: "exitStrategyLid",
|
|
189
|
-
// foreignField: "_id",
|
|
190
|
-
// justOne: true,
|
|
191
|
-
// }) as VirtualWithDescription;
|
|
192
|
-
// virtualExitStrategy.description = "Populated lookup value for exit strategy";
|
|
193
|
-
// const virtualSourceOfFunds = mortgageSchema.virtual("sourceOfFunds", {
|
|
194
|
-
// ref: "Lookup",
|
|
195
|
-
// localField: "sourceOfFundsLid",
|
|
196
|
-
// foreignField: "_id",
|
|
197
|
-
// justOne: true,
|
|
198
|
-
// }) as VirtualWithDescription;
|
|
199
|
-
// virtualSourceOfFunds.description =
|
|
200
|
-
// "Populated lookup value for the main source of income for monthly finance payments";
|
|
201
|
-
// const virtualSaleMade = mortgageSchema.virtual("saleMade", {
|
|
202
|
-
// ref: "Lookup",
|
|
203
|
-
// localField: "saleMadeLid",
|
|
204
|
-
// foreignField: "_id",
|
|
205
|
-
// justOne: true,
|
|
206
|
-
// }) as VirtualWithDescription;
|
|
207
|
-
// virtualSaleMade.description = "Populated lookup value for method of sale made";
|
|
208
|
-
// const virtualProposedTenants = mortgageSchema.virtual("proposedTenants", {
|
|
209
|
-
// ref: "Lookup",
|
|
210
|
-
// localField: "proposedTenantsLid",
|
|
211
|
-
// foreignField: "_id",
|
|
212
|
-
// justOne: false,
|
|
213
|
-
// }) as VirtualWithDescription;
|
|
214
|
-
// virtualProposedTenants.description =
|
|
215
|
-
// "Populated lookup values for proposed tenants of the property";
|
|
216
|
-
// const virtualLeaseType = mortgageSchema.virtual("leaseType", {
|
|
217
|
-
// ref: "Lookup",
|
|
218
|
-
// localField: "leaseTypeLid",
|
|
219
|
-
// foreignField: "_id",
|
|
220
|
-
// justOne: true,
|
|
221
|
-
// }) as VirtualWithDescription;
|
|
222
|
-
// virtualLeaseType.description = "Populated lookup value for lease type";
|
|
223
|
-
// virtual property 'applicationType'
|
|
224
|
-
mortgageSchema.virtual("applicationType").get(function () {
|
|
225
|
-
return this.applicationId?.applicationTypeLid instanceof
|
|
226
|
-
mongoose.Types.ObjectId
|
|
227
|
-
? null
|
|
228
|
-
: this.applicationId?.applicationTypeLid?.text || null;
|
|
229
|
-
});
|
|
230
|
-
// virtual property 'lendingType'
|
|
231
|
-
mortgageSchema.virtual("lendingType").get(function () {
|
|
232
|
-
return this.applicationId?.lendingTypeLid instanceof
|
|
233
|
-
mongoose.Types.ObjectId
|
|
234
|
-
? null
|
|
235
|
-
: this.applicationId?.lendingTypeLid?.text || null;
|
|
236
|
-
});
|
|
237
|
-
// virtual property 'purchaseType'
|
|
238
|
-
mortgageSchema.virtual("purchaseType").get(function () {
|
|
239
|
-
return this.applicationId?.purchaseTypeLid instanceof
|
|
240
|
-
mongoose.Types.ObjectId
|
|
241
|
-
? null
|
|
242
|
-
: this.applicationId?.purchaseTypeLid?.text || null;
|
|
243
|
-
});
|
|
244
|
-
// virtual property 'lendingType'
|
|
245
|
-
mortgageSchema.virtual("sourceOfWealth").get(function () {
|
|
246
|
-
const sourceOfWealthLids = this.applicationId?.sourceOfWealthLids;
|
|
247
|
-
if (!Array.isArray(sourceOfWealthLids)) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
return sourceOfWealthLids
|
|
251
|
-
.filter((lid) => !(lid instanceof mongoose.Types.ObjectId))
|
|
252
|
-
.map((lid) => lid?.text || null)
|
|
253
|
-
.filter((text) => text !== null);
|
|
254
|
-
});
|
|
255
|
-
const MortgageModel = mongoose.model("Mortgage", mortgageSchema);
|
|
256
|
-
export default MortgageModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { Pound } from "../value-objects/pound";
|
|
3
|
+
const mortgageSchema = new mongoose.Schema({
|
|
4
|
+
applicationId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: "Application",
|
|
7
|
+
required: true,
|
|
8
|
+
description: "Unique identifier for the application",
|
|
9
|
+
},
|
|
10
|
+
pageValidFlag: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: false,
|
|
13
|
+
description: "True if all mandatory fields have been completed, otherwise false",
|
|
14
|
+
},
|
|
15
|
+
existingMortgageLender: {
|
|
16
|
+
type: String,
|
|
17
|
+
maxlength: 35,
|
|
18
|
+
description: "Name of the existing mortgage lender",
|
|
19
|
+
},
|
|
20
|
+
topSlicing: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false,
|
|
23
|
+
description: "Indicates if the mortgage is being paid off using top slicing",
|
|
24
|
+
},
|
|
25
|
+
purposeOfMortgage: {
|
|
26
|
+
type: String,
|
|
27
|
+
maxlength: 50,
|
|
28
|
+
description: "Purpose of the mortgage (e.g., purchase, refinance)",
|
|
29
|
+
},
|
|
30
|
+
depositComeFromLids: {
|
|
31
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
32
|
+
ref: "Lookup",
|
|
33
|
+
default: null,
|
|
34
|
+
description: "Where the deposit for the mortgage will come from",
|
|
35
|
+
},
|
|
36
|
+
ifOtherDetails: {
|
|
37
|
+
type: String,
|
|
38
|
+
maxlength: 50,
|
|
39
|
+
description: "Details if the deposit comes from 'Other'",
|
|
40
|
+
},
|
|
41
|
+
purchasePrice: {
|
|
42
|
+
type: Pound,
|
|
43
|
+
description: "Purchase price of the property",
|
|
44
|
+
},
|
|
45
|
+
repaymentTypeLid: {
|
|
46
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
47
|
+
ref: "Lookup",
|
|
48
|
+
default: null,
|
|
49
|
+
description: "Lookup ID representing the type of repayment (e.g., interest-only, repayment)",
|
|
50
|
+
},
|
|
51
|
+
exitStrategyLid: {
|
|
52
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
53
|
+
ref: "Lookup",
|
|
54
|
+
default: null,
|
|
55
|
+
description: "Lookup ID representing the Exit strategy for the mortgage)",
|
|
56
|
+
},
|
|
57
|
+
isCapitalRaise: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
description: "Indicates if capital raising is part of this finance",
|
|
61
|
+
},
|
|
62
|
+
purchaseDate: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: null,
|
|
65
|
+
description: "Purchase date of the property",
|
|
66
|
+
},
|
|
67
|
+
estimatedValue: {
|
|
68
|
+
type: Pound,
|
|
69
|
+
description: "Estimated value of the property",
|
|
70
|
+
},
|
|
71
|
+
loanRequired: {
|
|
72
|
+
type: Pound,
|
|
73
|
+
description: "Amount of finance required",
|
|
74
|
+
},
|
|
75
|
+
monthlyRentalIncome: {
|
|
76
|
+
type: Pound,
|
|
77
|
+
description: "Monthly rental income from the property",
|
|
78
|
+
},
|
|
79
|
+
outstandingBalance: {
|
|
80
|
+
type: Pound,
|
|
81
|
+
description: "Outstanding balance on the existing mortgage",
|
|
82
|
+
},
|
|
83
|
+
fundRaisedFor: {
|
|
84
|
+
type: String,
|
|
85
|
+
maxlength: 250,
|
|
86
|
+
description: "What the funds raised will be used for",
|
|
87
|
+
},
|
|
88
|
+
sourceOfFundsLid: {
|
|
89
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
90
|
+
ref: "Lookup",
|
|
91
|
+
default: null,
|
|
92
|
+
description: "Lookup ID representing the Main source of income for monthly finance payments",
|
|
93
|
+
},
|
|
94
|
+
sourceOfFundDetails: {
|
|
95
|
+
type: String,
|
|
96
|
+
maxlength: 50,
|
|
97
|
+
description: "Additional details if the source of funds is 'Other'",
|
|
98
|
+
},
|
|
99
|
+
propertyValuationDetails: {
|
|
100
|
+
type: String,
|
|
101
|
+
maxlength: 35,
|
|
102
|
+
description: "Details on who to contact for property valuation",
|
|
103
|
+
},
|
|
104
|
+
telephoneNumber: {
|
|
105
|
+
type: String,
|
|
106
|
+
maxlength: 15,
|
|
107
|
+
description: "Contact number for property valuation",
|
|
108
|
+
},
|
|
109
|
+
isDistressedSale: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false,
|
|
112
|
+
description: "Indicates if this is a distressed sale",
|
|
113
|
+
},
|
|
114
|
+
isPurchasedBelowMarketValue: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: false,
|
|
117
|
+
description: "Indicates if the property is purchased below market value",
|
|
118
|
+
},
|
|
119
|
+
isPurchasedAsSale: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false,
|
|
122
|
+
description: "Indicates if the property is purchased as a sale and rent back",
|
|
123
|
+
},
|
|
124
|
+
isReadyToSell: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: false,
|
|
127
|
+
description: "Indicates if the property is ready to sell or let out",
|
|
128
|
+
},
|
|
129
|
+
isGovernmentInitiative: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false,
|
|
132
|
+
description: "Indicates if this purchase is part of a government initiative",
|
|
133
|
+
},
|
|
134
|
+
vendorsName: {
|
|
135
|
+
type: String,
|
|
136
|
+
maxlength: 35,
|
|
137
|
+
description: "Vendor's name in case of property sale",
|
|
138
|
+
},
|
|
139
|
+
saleMadeLid: {
|
|
140
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
141
|
+
ref: "Lookup",
|
|
142
|
+
description: "Method of sale made",
|
|
143
|
+
},
|
|
144
|
+
isTheIntentionToLet: {
|
|
145
|
+
type: Boolean,
|
|
146
|
+
default: false,
|
|
147
|
+
description: "Indicates if the intention is to let out the property",
|
|
148
|
+
},
|
|
149
|
+
proposedTenantsLids: {
|
|
150
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
151
|
+
ref: "Lookup",
|
|
152
|
+
description: "Proposed tenants for the property",
|
|
153
|
+
},
|
|
154
|
+
leaseTypeLid: {
|
|
155
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
156
|
+
ref: "Lookup",
|
|
157
|
+
default: null,
|
|
158
|
+
description: "Lease type for the property",
|
|
159
|
+
},
|
|
160
|
+
giftDetails: {
|
|
161
|
+
type: String,
|
|
162
|
+
maxlength: 50,
|
|
163
|
+
description: "Details of the gift for the mortgage",
|
|
164
|
+
},
|
|
165
|
+
}, {
|
|
166
|
+
timestamps: true,
|
|
167
|
+
toJSON: { virtuals: true },
|
|
168
|
+
toObject: { virtuals: true },
|
|
169
|
+
});
|
|
170
|
+
// const virtualDepositComeFrom = mortgageSchema.virtual("depositComeFrom", {
|
|
171
|
+
// ref: "Lookup",
|
|
172
|
+
// localField: "depositComeFromLid",
|
|
173
|
+
// foreignField: "_id",
|
|
174
|
+
// justOne: false,
|
|
175
|
+
// }) as VirtualWithDescription;
|
|
176
|
+
// virtualDepositComeFrom.description =
|
|
177
|
+
// "Populated lookup values for where the deposit for the mortgage will come from";
|
|
178
|
+
// const virtualRepaymentType = mortgageSchema.virtual("repaymentType", {
|
|
179
|
+
// ref: "Lookup",
|
|
180
|
+
// localField: "repaymentTypeLid",
|
|
181
|
+
// foreignField: "_id",
|
|
182
|
+
// justOne: true,
|
|
183
|
+
// }) as VirtualWithDescription;
|
|
184
|
+
// virtualRepaymentType.description =
|
|
185
|
+
// "Populated lookup value representing the type of repayment";
|
|
186
|
+
// const virtualExitStrategy = mortgageSchema.virtual("exitStrategy", {
|
|
187
|
+
// ref: "Lookup",
|
|
188
|
+
// localField: "exitStrategyLid",
|
|
189
|
+
// foreignField: "_id",
|
|
190
|
+
// justOne: true,
|
|
191
|
+
// }) as VirtualWithDescription;
|
|
192
|
+
// virtualExitStrategy.description = "Populated lookup value for exit strategy";
|
|
193
|
+
// const virtualSourceOfFunds = mortgageSchema.virtual("sourceOfFunds", {
|
|
194
|
+
// ref: "Lookup",
|
|
195
|
+
// localField: "sourceOfFundsLid",
|
|
196
|
+
// foreignField: "_id",
|
|
197
|
+
// justOne: true,
|
|
198
|
+
// }) as VirtualWithDescription;
|
|
199
|
+
// virtualSourceOfFunds.description =
|
|
200
|
+
// "Populated lookup value for the main source of income for monthly finance payments";
|
|
201
|
+
// const virtualSaleMade = mortgageSchema.virtual("saleMade", {
|
|
202
|
+
// ref: "Lookup",
|
|
203
|
+
// localField: "saleMadeLid",
|
|
204
|
+
// foreignField: "_id",
|
|
205
|
+
// justOne: true,
|
|
206
|
+
// }) as VirtualWithDescription;
|
|
207
|
+
// virtualSaleMade.description = "Populated lookup value for method of sale made";
|
|
208
|
+
// const virtualProposedTenants = mortgageSchema.virtual("proposedTenants", {
|
|
209
|
+
// ref: "Lookup",
|
|
210
|
+
// localField: "proposedTenantsLid",
|
|
211
|
+
// foreignField: "_id",
|
|
212
|
+
// justOne: false,
|
|
213
|
+
// }) as VirtualWithDescription;
|
|
214
|
+
// virtualProposedTenants.description =
|
|
215
|
+
// "Populated lookup values for proposed tenants of the property";
|
|
216
|
+
// const virtualLeaseType = mortgageSchema.virtual("leaseType", {
|
|
217
|
+
// ref: "Lookup",
|
|
218
|
+
// localField: "leaseTypeLid",
|
|
219
|
+
// foreignField: "_id",
|
|
220
|
+
// justOne: true,
|
|
221
|
+
// }) as VirtualWithDescription;
|
|
222
|
+
// virtualLeaseType.description = "Populated lookup value for lease type";
|
|
223
|
+
// virtual property 'applicationType'
|
|
224
|
+
mortgageSchema.virtual("applicationType").get(function () {
|
|
225
|
+
return this.applicationId?.applicationTypeLid instanceof
|
|
226
|
+
mongoose.Types.ObjectId
|
|
227
|
+
? null
|
|
228
|
+
: this.applicationId?.applicationTypeLid?.text || null;
|
|
229
|
+
});
|
|
230
|
+
// virtual property 'lendingType'
|
|
231
|
+
mortgageSchema.virtual("lendingType").get(function () {
|
|
232
|
+
return this.applicationId?.lendingTypeLid instanceof
|
|
233
|
+
mongoose.Types.ObjectId
|
|
234
|
+
? null
|
|
235
|
+
: this.applicationId?.lendingTypeLid?.text || null;
|
|
236
|
+
});
|
|
237
|
+
// virtual property 'purchaseType'
|
|
238
|
+
mortgageSchema.virtual("purchaseType").get(function () {
|
|
239
|
+
return this.applicationId?.purchaseTypeLid instanceof
|
|
240
|
+
mongoose.Types.ObjectId
|
|
241
|
+
? null
|
|
242
|
+
: this.applicationId?.purchaseTypeLid?.text || null;
|
|
243
|
+
});
|
|
244
|
+
// virtual property 'lendingType'
|
|
245
|
+
mortgageSchema.virtual("sourceOfWealth").get(function () {
|
|
246
|
+
const sourceOfWealthLids = this.applicationId?.sourceOfWealthLids;
|
|
247
|
+
if (!Array.isArray(sourceOfWealthLids)) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
return sourceOfWealthLids
|
|
251
|
+
.filter((lid) => !(lid instanceof mongoose.Types.ObjectId))
|
|
252
|
+
.map((lid) => lid?.text || null)
|
|
253
|
+
.filter((text) => text !== null);
|
|
254
|
+
});
|
|
255
|
+
const MortgageModel = mongoose.model("Mortgage", mortgageSchema);
|
|
256
|
+
export default MortgageModel;
|