@dynamatix/gb-schemas 1.2.44 → 1.2.46
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.d.ts +3 -3
- package/dist/applicants/applicant-employment.model.js +1 -1
- package/dist/applicants/applicant.model.d.ts +3 -3
- package/dist/applications/application-company-model.d.ts.map +1 -1
- package/dist/applications/application-company-model.js +34 -80
- package/dist/properties/security.model.d.ts.map +1 -1
- package/dist/properties/security.model.js +29 -63
- package/package.json +1 -1
|
@@ -60,7 +60,7 @@ declare const applicantEmploymentSchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
60
60
|
maternityIncome: Pound;
|
|
61
61
|
pensionIncome: Pound;
|
|
62
62
|
previousAddressCity: string;
|
|
63
|
-
|
|
63
|
+
previousAddressCountryLid: mongoose.Types.ObjectId;
|
|
64
64
|
previousAddressLine1: string;
|
|
65
65
|
previousAddressLine2: string;
|
|
66
66
|
previousAddressLine3: string;
|
|
@@ -106,7 +106,7 @@ declare const applicantEmploymentSchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
106
106
|
maternityIncome: Pound;
|
|
107
107
|
pensionIncome: Pound;
|
|
108
108
|
previousAddressCity: string;
|
|
109
|
-
|
|
109
|
+
previousAddressCountryLid: mongoose.Types.ObjectId;
|
|
110
110
|
previousAddressLine1: string;
|
|
111
111
|
previousAddressLine2: string;
|
|
112
112
|
previousAddressLine3: string;
|
|
@@ -152,7 +152,7 @@ declare const applicantEmploymentSchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
152
152
|
maternityIncome: Pound;
|
|
153
153
|
pensionIncome: Pound;
|
|
154
154
|
previousAddressCity: string;
|
|
155
|
-
|
|
155
|
+
previousAddressCountryLid: mongoose.Types.ObjectId;
|
|
156
156
|
previousAddressLine1: string;
|
|
157
157
|
previousAddressLine2: string;
|
|
158
158
|
previousAddressLine3: string;
|
|
@@ -33,7 +33,7 @@ const applicantEmploymentSchema = new mongoose.Schema({
|
|
|
33
33
|
natureOfBusiness: { type: String, required: true },
|
|
34
34
|
pensionIncome: { type: Pound, default: '£0.00' },
|
|
35
35
|
previousAddressCity: { type: String, default: null },
|
|
36
|
-
|
|
36
|
+
previousAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
|
|
37
37
|
previousAddressLine1: { type: String, required: true },
|
|
38
38
|
previousAddressLine2: { type: String, default: null },
|
|
39
39
|
previousAddressLine3: { type: String, default: null },
|
|
@@ -2527,7 +2527,7 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
2527
2527
|
defaultOptions?: unknown;
|
|
2528
2528
|
} | null | undefined;
|
|
2529
2529
|
previousAddressCity?: unknown;
|
|
2530
|
-
|
|
2530
|
+
previousAddressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
2531
2531
|
previousAddressLine1?: unknown;
|
|
2532
2532
|
previousAddressLine2?: unknown;
|
|
2533
2533
|
previousAddressLine3?: unknown;
|
|
@@ -7820,7 +7820,7 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
7820
7820
|
defaultOptions?: unknown;
|
|
7821
7821
|
} | null | undefined;
|
|
7822
7822
|
previousAddressCity?: unknown;
|
|
7823
|
-
|
|
7823
|
+
previousAddressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
7824
7824
|
previousAddressLine1?: unknown;
|
|
7825
7825
|
previousAddressLine2?: unknown;
|
|
7826
7826
|
previousAddressLine3?: unknown;
|
|
@@ -13113,7 +13113,7 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
13113
13113
|
defaultOptions?: unknown;
|
|
13114
13114
|
} | null | undefined;
|
|
13115
13115
|
previousAddressCity?: unknown;
|
|
13116
|
-
|
|
13116
|
+
previousAddressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
13117
13117
|
previousAddressLine1?: unknown;
|
|
13118
13118
|
previousAddressLine2?: unknown;
|
|
13119
13119
|
previousAddressLine3?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-company-model.d.ts","sourceRoot":"","sources":["../../applications/application-company-model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"application-company-model.d.ts","sourceRoot":"","sources":["../../applications/application-company-model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AA2IhD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAsD,CAAC;AACpF,eAAe,uBAAuB,CAAC"}
|
|
@@ -4,10 +4,7 @@ const companySchema = new mongoose.Schema({
|
|
|
4
4
|
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true,
|
|
5
5
|
description: "Unique identifier for the application"
|
|
6
6
|
},
|
|
7
|
-
pageValidFlag: { type: Boolean, default: true,
|
|
8
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
9
|
-
set: (value) => value.toLowerCase() === 'yes', // form - hidden
|
|
10
|
-
},
|
|
7
|
+
pageValidFlag: { type: Boolean, default: true, },
|
|
11
8
|
registeredName: { type: String, required: true, maxlength: 70, default: '' }, // form
|
|
12
9
|
businessTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }, // form
|
|
13
10
|
registeredNumber: { type: Number, max: 99999999, default: 0 }, // form
|
|
@@ -45,83 +42,16 @@ const companySchema = new mongoose.Schema({
|
|
|
45
42
|
companySecuredArrears: { type: String, required: true, default: '' }, // form
|
|
46
43
|
companyUnsecuredArrears: { type: String, required: true, default: '' }, // form
|
|
47
44
|
companyBankruptcy: { type: String, required: true, default: '' }, // form
|
|
48
|
-
companyBankruptcyYes: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
companyBankruptcyNo: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: true,
|
|
60
|
-
get: function () { return this.companyBankruptcyYes ? "No" : "Yes"; },
|
|
61
|
-
set: function (value) {
|
|
62
|
-
this.companyBankruptcyYes = !(value.toString().toLowerCase() === 'yes');
|
|
63
|
-
return !this.companyBankruptcyYes;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
companyCCJInLastThreeYearYes: {
|
|
67
|
-
type: Boolean,
|
|
68
|
-
default: false,
|
|
69
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
70
|
-
set: function (value) {
|
|
71
|
-
this.companyCCJInLastThreeYearNo = !(value.toString().toLowerCase() === 'yes');
|
|
72
|
-
return value.toString().toLowerCase() === 'yes';
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
companyCCJInLastThreeYearNo: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: true,
|
|
78
|
-
get: function () { return this.companyCCJInLastThreeYearYes ? "No" : "Yes"; },
|
|
79
|
-
set: function (value) {
|
|
80
|
-
this.companyCCJInLastThreeYearYes = !(value.toString().toLowerCase() === 'yes');
|
|
81
|
-
return !this.companyCCJInLastThreeYearYes;
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
companyDefaultsInLastYearYes: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
default: false,
|
|
87
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
88
|
-
set: function (value) {
|
|
89
|
-
this.companyDefaultsInLastYearNo = !(value.toString().toLowerCase() === 'yes');
|
|
90
|
-
return value.toString().toLowerCase() === 'yes';
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
companyDefaultsInLastYearNo: {
|
|
94
|
-
type: Boolean,
|
|
95
|
-
default: true,
|
|
96
|
-
get: function () { return this.companyDefaultsInLastYearYes ? "No" : "Yes"; },
|
|
97
|
-
set: function (value) {
|
|
98
|
-
this.companyDefaultsInLastYearYes = !(value.toString().toLowerCase() === 'yes');
|
|
99
|
-
return !this.companyDefaultsInLastYearYes;
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
companyAnyVoluntaryEnforcedPossessionYes: {
|
|
103
|
-
type: Boolean,
|
|
104
|
-
default: false,
|
|
105
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
106
|
-
set: function (value) {
|
|
107
|
-
this.companyAnyVoluntaryEnforcedPossessionNo = !(value.toString().toLowerCase() === 'yes');
|
|
108
|
-
return value.toString().toLowerCase() === 'yes';
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
companyAnyVoluntaryEnforcedPossessionNo: {
|
|
112
|
-
type: Boolean,
|
|
113
|
-
default: true,
|
|
114
|
-
get: function () { return this.companyAnyVoluntaryEnforcedPossessionYes ? "No" : "Yes"; },
|
|
115
|
-
set: function (value) {
|
|
116
|
-
this.companyAnyVoluntaryEnforcedPossessionYes = !(value.toString().toLowerCase() === 'yes');
|
|
117
|
-
return !this.companyAnyVoluntaryEnforcedPossessionYes;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
45
|
+
companyBankruptcyYes: { type: Boolean, default: false, },
|
|
46
|
+
companyBankruptcyNo: { type: Boolean, default: true, },
|
|
47
|
+
companyCCJInLastThreeYearYes: { type: Boolean, default: false, },
|
|
48
|
+
companyCCJInLastThreeYearNo: { type: Boolean, default: true, },
|
|
49
|
+
companyDefaultsInLastYearYes: { type: Boolean, default: false, },
|
|
50
|
+
companyDefaultsInLastYearNo: { type: Boolean, default: true, },
|
|
51
|
+
companyAnyVoluntaryEnforcedPossessionYes: { type: Boolean, default: false, },
|
|
52
|
+
companyAnyVoluntaryEnforcedPossessionNo: { type: Boolean, default: true, },
|
|
120
53
|
// Not in form Fields
|
|
121
|
-
doYouKnowRegisteredNumber: { type: Boolean, default: true,
|
|
122
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
123
|
-
set: (value) => value.toLowerCase() === 'yes', // form
|
|
124
|
-
},
|
|
54
|
+
doYouKnowRegisteredNumber: { type: Boolean, default: true, },
|
|
125
55
|
sicCodes: [{ type: String, default: "" }],
|
|
126
56
|
epc: { type: String, default: "" },
|
|
127
57
|
remainingLease: { type: String, default: "" },
|
|
@@ -131,6 +61,30 @@ const companySchema = new mongoose.Schema({
|
|
|
131
61
|
toJSON: { virtuals: true, getters: true },
|
|
132
62
|
toObject: { virtuals: true, getters: true }
|
|
133
63
|
});
|
|
64
|
+
///////////////// HOOKS //////////////////
|
|
65
|
+
const yesNoPairs = [
|
|
66
|
+
["companyBankruptcyYes", "companyBankruptcyNo"],
|
|
67
|
+
["companyCCJInLastThreeYearYes", "companyCCJInLastThreeYearNo"],
|
|
68
|
+
["companyDefaultsInLastYearYes", "companyDefaultsInLastYearNo"],
|
|
69
|
+
["companyAnyVoluntaryEnforcedPossessionYes", "companyAnyVoluntaryEnforcedPossessionNo"],
|
|
70
|
+
];
|
|
71
|
+
function handleYesNoLogic(update) {
|
|
72
|
+
const $set = update?.$set ?? update; // Handles both direct update and $set syntax
|
|
73
|
+
yesNoPairs.forEach(([yesKey, noKey]) => {
|
|
74
|
+
if (yesKey in $set) {
|
|
75
|
+
$set[noKey] = !$set[yesKey]; // Set No field to opposite of Yes field
|
|
76
|
+
}
|
|
77
|
+
// Prevent direct updates to No fields
|
|
78
|
+
if (noKey in $set) {
|
|
79
|
+
delete $set[noKey];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Apply to various update operations - handle both cases
|
|
84
|
+
companySchema.pre("updateOne", function (next) {
|
|
85
|
+
handleYesNoLogic(this.getUpdate());
|
|
86
|
+
next();
|
|
87
|
+
});
|
|
134
88
|
const virtualBusinessType = companySchema.virtual('businessType', {
|
|
135
89
|
ref: 'Lookup',
|
|
136
90
|
localField: 'businessTypeLid',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.model.d.ts","sourceRoot":"","sources":["../../properties/security.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"security.model.d.ts","sourceRoot":"","sources":["../../properties/security.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA0JhC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6C,CAAC;AACjE,eAAe,aAAa,CAAC"}
|
|
@@ -54,71 +54,35 @@ const securitySchema = new mongoose.Schema({
|
|
|
54
54
|
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true,
|
|
55
55
|
description: "Unique identifier for the application"
|
|
56
56
|
}, // not-form securityData
|
|
57
|
-
pageValidFlag: { type: Boolean, default: true,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, //form
|
|
61
|
-
haveAnyBuyToLetProperties: { type: Boolean, required: true,
|
|
62
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
63
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
64
|
-
}, // not-form propertyData - not in Property form
|
|
65
|
-
isPropertyInEnglandOrWales: { type: Boolean, required: true,
|
|
66
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
67
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
68
|
-
}, // not-form propertyData - not in Property form
|
|
57
|
+
pageValidFlag: { type: Boolean, default: true, }, //form
|
|
58
|
+
haveAnyBuyToLetProperties: { type: Boolean, required: true, default: false }, // not-form propertyData - not in Property form
|
|
59
|
+
isPropertyInEnglandOrWales: { type: Boolean, required: true, default: false }, // not-form propertyData - not in Property form
|
|
69
60
|
// price: { type: Pound, required: true, default: '£0.00'} as any, // *already in Purchase Form -> not-form mortgateData - pounds
|
|
70
61
|
noOfBuyToLetProperties: { type: Number, default: 0 }, // not-form propertyData - not in Property form
|
|
71
62
|
totalMonthlyRentalIncome: { type: Pound, required: true, default: '£0.00' }, // not-form pound propertyData - not in Property form
|
|
72
63
|
totalMonthlyRepayment: { type: Pound, required: true, default: '£0.00' }, // not-form pound propertyData - not in Property form
|
|
73
64
|
totalOutstandingBalance: { type: Pound, required: true, default: '£0.00' }, // not-form pound propertyData - not in Property form
|
|
74
|
-
areAllBedRoomsOver10sqm: { type: Boolean, required: true,
|
|
75
|
-
|
|
76
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
77
|
-
}, // form
|
|
78
|
-
isBrickTileConstruction: { type: Boolean, required: true,
|
|
79
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
80
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
81
|
-
}, // form
|
|
65
|
+
areAllBedRoomsOver10sqm: { type: Boolean, required: true, default: false }, // form
|
|
66
|
+
isBrickTileConstruction: { type: Boolean, required: true, default: false }, // form
|
|
82
67
|
constructionDetails: { type: String, required: true, default: '' }, // form
|
|
83
|
-
isExLAExclusion: { type: Boolean, required: true,
|
|
84
|
-
|
|
85
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
86
|
-
}, // form
|
|
87
|
-
isFlatLift: { type: Boolean, required: true,
|
|
88
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
89
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
90
|
-
}, // form
|
|
68
|
+
isExLAExclusion: { type: Boolean, required: true, default: false }, // form
|
|
69
|
+
isFlatLift: { type: Boolean, required: true, default: false }, // form
|
|
91
70
|
flatNumberOfBedrooms: { type: Number, required: true, default: 0 }, // form
|
|
92
|
-
isGreenEPC: { type: Boolean,
|
|
93
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
94
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
95
|
-
}, // form
|
|
71
|
+
isGreenEPC: { type: Boolean, default: false }, // form
|
|
96
72
|
isGroundRent: {
|
|
97
73
|
type: Pound,
|
|
98
74
|
required: true,
|
|
99
75
|
default: '£0.00' // Default value in correct format
|
|
100
76
|
}, // form - pounds
|
|
101
|
-
isHouseLicensed: { type: Boolean, required: true,
|
|
102
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
103
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
104
|
-
}, // form
|
|
77
|
+
isHouseLicensed: { type: Boolean, required: true, default: false }, // form
|
|
105
78
|
houseNumberOfFloors: { type: Number, required: true, default: 0 }, // form
|
|
106
79
|
houseNumberOfKitchens: { type: Number, required: true, default: 0 }, // form
|
|
107
80
|
houseNumberOfLivingRooms: { type: Number, required: true, default: 0 }, // form
|
|
108
81
|
houseNumberOfBathrooms: { type: Number, required: true, default: 0 }, // form
|
|
109
82
|
houseNumberOfTenancies: { type: Number, required: true, default: 0 }, // form
|
|
110
|
-
hasHousePlanningPermission: { type: Boolean, required: true,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, // not-form securityData
|
|
114
|
-
isGarage: { type: Boolean,
|
|
115
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
116
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
117
|
-
}, // form
|
|
118
|
-
isNewBuild: { type: Boolean, required: true,
|
|
119
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
120
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
121
|
-
}, // form
|
|
83
|
+
hasHousePlanningPermission: { type: Boolean, required: true, default: false }, // not-form securityData
|
|
84
|
+
isGarage: { type: Boolean, default: false }, // form
|
|
85
|
+
isNewBuild: { type: Boolean, required: true, default: false }, // form
|
|
122
86
|
propertyAddressCity: { type: String, default: '', maxlength: 30 }, // form
|
|
123
87
|
propertyAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }, // form
|
|
124
88
|
propertyAddressLine1: { type: String, required: true, maxlength: 35, default: '' }, // form
|
|
@@ -128,10 +92,7 @@ const securitySchema = new mongoose.Schema({
|
|
|
128
92
|
propertyTenureLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }, // form
|
|
129
93
|
propertyTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup" }, // form
|
|
130
94
|
propertyYearBuilt: { type: Number, required: true, max: 9999, default: 0 }, // form
|
|
131
|
-
receiptOfAnyDiscount: { type: Boolean, required: true,
|
|
132
|
-
get: (value) => (value ? "Yes" : "No"),
|
|
133
|
-
set: (value) => value.toLowerCase() === "yes"
|
|
134
|
-
}, // form
|
|
95
|
+
receiptOfAnyDiscount: { type: Boolean, required: true, default: false }, // form
|
|
135
96
|
receiptOfDiscountDetails: { type: String, required: true, default: '', maxlength: 100 }, // form
|
|
136
97
|
sectorExperience: { type: String, required: true, default: '' }, // form
|
|
137
98
|
serviceCharge: {
|
|
@@ -148,19 +109,24 @@ const securitySchema = new mongoose.Schema({
|
|
|
148
109
|
toJSON: { getters: true, virtuals: true },
|
|
149
110
|
toObject: { getters: true, virtuals: true }
|
|
150
111
|
});
|
|
151
|
-
//
|
|
152
|
-
securitySchema.virtual('tenure'
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
112
|
+
// Virtual for 'tenure'
|
|
113
|
+
const virtualTenure = securitySchema.virtual('tenure', {
|
|
114
|
+
ref: 'Lookup',
|
|
115
|
+
localField: 'propertyTenureLid',
|
|
116
|
+
foreignField: '_id',
|
|
117
|
+
justOne: true,
|
|
118
|
+
options: { select: 'label' },
|
|
157
119
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
120
|
+
virtualTenure.description = 'Populated lookup value for the property tenure';
|
|
121
|
+
// Virtual for 'type'
|
|
122
|
+
const virtualType = securitySchema.virtual('type', {
|
|
123
|
+
ref: 'Lookup',
|
|
124
|
+
localField: 'propertyTypeLid',
|
|
125
|
+
foreignField: '_id',
|
|
126
|
+
justOne: true,
|
|
127
|
+
options: { select: 'label' },
|
|
163
128
|
});
|
|
129
|
+
virtualType.description = 'Populated lookup value for the property type';
|
|
164
130
|
// virtual property 'applicationType'
|
|
165
131
|
securitySchema.virtual('applicationType').get(function () {
|
|
166
132
|
return this.applicationId?.applicationTypeLid instanceof mongoose.Types.ObjectId
|