gemcap-be-common 1.5.144 → 1.5.145
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.
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
26
|
export interface IBorrowerAssumption {
|
|
27
|
-
borrowerId
|
|
27
|
+
borrowerId?: mongoose.Types.ObjectId;
|
|
28
|
+
prospectId?: mongoose.Types.ObjectId;
|
|
28
29
|
assumptionFileId: mongoose.Types.ObjectId;
|
|
29
30
|
version: number;
|
|
30
31
|
uploadedAt: Date;
|
|
@@ -34,9 +35,10 @@ export type TCreateBorrowerAssumption = Omit<IBorrowerAssumptionPlain, '_id'>;
|
|
|
34
35
|
export interface IBorrowerAssumptionLean extends IBorrowerAssumption {
|
|
35
36
|
_id: mongoose.Types.ObjectId;
|
|
36
37
|
}
|
|
37
|
-
export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId' | 'assumptionFileId'> {
|
|
38
|
+
export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId' | 'prospectId' | 'assumptionFileId'> {
|
|
38
39
|
_id: string;
|
|
39
|
-
borrowerId
|
|
40
|
+
borrowerId?: string;
|
|
41
|
+
prospectId?: string;
|
|
40
42
|
assumptionFileId: string;
|
|
41
43
|
}
|
|
42
44
|
export type TBorrowerAssumptionDoc = mongoose.HydratedDocument<IBorrowerAssumption>;
|
|
@@ -10,7 +10,14 @@ exports.BorrowerAssumptionSchema = new mongoose_1.default.Schema({
|
|
|
10
10
|
borrowerId: {
|
|
11
11
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
12
12
|
ref: _models_1.MODEL_NAMES.borrowers,
|
|
13
|
-
required:
|
|
13
|
+
required: false,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
prospectId: {
|
|
17
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
18
|
+
ref: _models_1.MODEL_NAMES.CRMProspects,
|
|
19
|
+
required: false,
|
|
20
|
+
index: true,
|
|
14
21
|
},
|
|
15
22
|
assumptionFileId: {
|
|
16
23
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
@@ -33,4 +40,9 @@ exports.BorrowerAssumptionSchema = new mongoose_1.default.Schema({
|
|
|
33
40
|
timestamps: { createdAt: true, updatedAt: true },
|
|
34
41
|
versionKey: false,
|
|
35
42
|
});
|
|
43
|
+
exports.BorrowerAssumptionSchema.pre('validate', function () {
|
|
44
|
+
if (!this.borrowerId && !this.prospectId) {
|
|
45
|
+
this.invalidate('borrowerId', 'Either borrowerId or prospectId is required');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
36
48
|
exports.BorrowerAssumption = mongoose_1.default.model(_models_1.MODEL_NAMES.borrowerAssumption, exports.BorrowerAssumptionSchema);
|
|
@@ -3,7 +3,8 @@ import mongoose from 'mongoose';
|
|
|
3
3
|
import { MODEL_NAMES } from './_models';
|
|
4
4
|
|
|
5
5
|
export interface IBorrowerAssumption {
|
|
6
|
-
borrowerId
|
|
6
|
+
borrowerId?: mongoose.Types.ObjectId;
|
|
7
|
+
prospectId?: mongoose.Types.ObjectId;
|
|
7
8
|
assumptionFileId: mongoose.Types.ObjectId;
|
|
8
9
|
version: number;
|
|
9
10
|
uploadedAt: Date;
|
|
@@ -16,9 +17,10 @@ export interface IBorrowerAssumptionLean extends IBorrowerAssumption {
|
|
|
16
17
|
_id: mongoose.Types.ObjectId;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId' | 'assumptionFileId'> {
|
|
20
|
+
export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId' | 'prospectId' | 'assumptionFileId'> {
|
|
20
21
|
_id: string;
|
|
21
|
-
borrowerId
|
|
22
|
+
borrowerId?: string;
|
|
23
|
+
prospectId?: string;
|
|
22
24
|
assumptionFileId: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -31,7 +33,14 @@ export const BorrowerAssumptionSchema = new mongoose.Schema<IBorrowerAssumption,
|
|
|
31
33
|
borrowerId: {
|
|
32
34
|
type: mongoose.Schema.Types.ObjectId,
|
|
33
35
|
ref: MODEL_NAMES.borrowers,
|
|
34
|
-
required:
|
|
36
|
+
required: false,
|
|
37
|
+
index: true,
|
|
38
|
+
},
|
|
39
|
+
prospectId: {
|
|
40
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
41
|
+
ref: MODEL_NAMES.CRMProspects,
|
|
42
|
+
required: false,
|
|
43
|
+
index: true,
|
|
35
44
|
},
|
|
36
45
|
assumptionFileId: {
|
|
37
46
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -57,4 +66,12 @@ export const BorrowerAssumptionSchema = new mongoose.Schema<IBorrowerAssumption,
|
|
|
57
66
|
},
|
|
58
67
|
);
|
|
59
68
|
|
|
69
|
+
BorrowerAssumptionSchema.pre('validate', function () {
|
|
70
|
+
if (!this.borrowerId && !this.prospectId) {
|
|
71
|
+
this.invalidate('borrowerId', 'Either borrowerId or prospectId is required');
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
60
77
|
export const BorrowerAssumption = mongoose.model<IBorrowerAssumption, TBorrowerAssumptionModel>(MODEL_NAMES.borrowerAssumption, BorrowerAssumptionSchema);
|