gemcap-be-common 1.4.257 → 1.4.259
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.
|
@@ -22,12 +22,22 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import mongoose, { Model } from 'mongoose';
|
|
25
|
+
import mongoose, { Document, Model } from 'mongoose';
|
|
26
26
|
export interface ICRMProspectIndustry {
|
|
27
27
|
code: string;
|
|
28
28
|
name: string;
|
|
29
29
|
order: number;
|
|
30
30
|
}
|
|
31
|
+
export interface ICRMProspectIndustryDoc extends ICRMProspectIndustry, Document {
|
|
32
|
+
_id: mongoose.Types.ObjectId;
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
}
|
|
36
|
+
export interface ICRMProspectIndustryLean extends ICRMProspectIndustry {
|
|
37
|
+
_id: mongoose.Types.ObjectId;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updatedAt: Date;
|
|
40
|
+
}
|
|
31
41
|
export interface ICRMProspectIndustryWithId extends ICRMProspectIndustry {
|
|
32
42
|
_id: string;
|
|
33
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import mongoose, { Model } from 'mongoose';
|
|
1
|
+
import mongoose, { Document, Model } from 'mongoose';
|
|
2
2
|
|
|
3
3
|
import { MODEL_NAMES } from './_models';
|
|
4
4
|
|
|
@@ -8,6 +8,18 @@ export interface ICRMProspectIndustry {
|
|
|
8
8
|
order: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export interface ICRMProspectIndustryDoc extends ICRMProspectIndustry, Document {
|
|
12
|
+
_id: mongoose.Types.ObjectId;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ICRMProspectIndustryLean extends ICRMProspectIndustry {
|
|
18
|
+
_id: mongoose.Types.ObjectId;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
export interface ICRMProspectIndustryWithId extends ICRMProspectIndustry {
|
|
12
24
|
_id: string;
|
|
13
25
|
}
|
package/models/_index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare const allSchemas: {
|
|
|
31
31
|
createdAt: NativeDate;
|
|
32
32
|
updatedAt: NativeDate;
|
|
33
33
|
} & {
|
|
34
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
35
34
|
order: number;
|
|
35
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
36
36
|
apDate: Date;
|
|
37
37
|
amount: number;
|
|
38
38
|
__v?: number;
|
|
@@ -45,8 +45,8 @@ export declare const allSchemas: {
|
|
|
45
45
|
createdAt: NativeDate;
|
|
46
46
|
updatedAt: NativeDate;
|
|
47
47
|
} & {
|
|
48
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
49
48
|
order: number;
|
|
49
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
50
50
|
apDate: Date;
|
|
51
51
|
amount: number;
|
|
52
52
|
__v?: number;
|
|
@@ -59,8 +59,8 @@ export declare const allSchemas: {
|
|
|
59
59
|
createdAt: NativeDate;
|
|
60
60
|
updatedAt: NativeDate;
|
|
61
61
|
} & {
|
|
62
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
63
62
|
order: number;
|
|
63
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
64
64
|
apDate: Date;
|
|
65
65
|
amount: number;
|
|
66
66
|
__v?: number;
|
package/package.json
CHANGED
|
@@ -144,14 +144,15 @@ class BorrowerService {
|
|
|
144
144
|
.populate('data.insurance')
|
|
145
145
|
.lean();
|
|
146
146
|
const options = await BorrowerData_model_1.BorrowerDataOptionModel.find({ isActive: true }).lean();
|
|
147
|
+
const optionsMap = new Map(options.map((opt) => [opt._id.toString(), opt]));
|
|
147
148
|
if (borrowerSettings?.data?.options) {
|
|
148
149
|
borrowerSettings.data.options = borrowerSettings.data.options
|
|
150
|
+
.filter((item) => optionsMap.has(item.dataOption.toString()))
|
|
149
151
|
.sort((a, b) => {
|
|
150
|
-
const foundA =
|
|
151
|
-
const foundB =
|
|
152
|
-
if (!foundA || !foundB)
|
|
152
|
+
const foundA = optionsMap.get(a.dataOption.toString());
|
|
153
|
+
const foundB = optionsMap.get(b.dataOption.toString());
|
|
154
|
+
if (!foundA || !foundB)
|
|
153
155
|
return 0;
|
|
154
|
-
}
|
|
155
156
|
return foundA.order - foundB.order;
|
|
156
157
|
});
|
|
157
158
|
}
|
|
@@ -162,17 +162,19 @@ export class BorrowerService {
|
|
|
162
162
|
.populate('data.banks')
|
|
163
163
|
.populate('data.insurance')
|
|
164
164
|
.lean() as unknown as IBorrowerSettingsDocPopulated;
|
|
165
|
+
|
|
165
166
|
const options = await BorrowerDataOptionModel.find({ isActive: true }).lean();
|
|
167
|
+
const optionsMap = new Map(options.map((opt) => [opt._id.toString(), opt]));
|
|
166
168
|
if (borrowerSettings?.data?.options) {
|
|
167
169
|
borrowerSettings.data.options = borrowerSettings.data.options
|
|
170
|
+
.filter((item) => optionsMap.has(item.dataOption.toString()))
|
|
168
171
|
.sort((a, b) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return 0;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
172
|
+
const foundA = optionsMap.get(a.dataOption.toString());
|
|
173
|
+
const foundB = optionsMap.get(b.dataOption.toString());
|
|
174
|
+
|
|
175
|
+
if (!foundA || !foundB) return 0;
|
|
176
|
+
return foundA.order - foundB.order;
|
|
177
|
+
});
|
|
176
178
|
}
|
|
177
179
|
const unmappedSettings = borrowerSettings ? borrowerSettings : await this.getDefaultSettings(borrowerId);
|
|
178
180
|
return await this.addOptionNames(unmappedSettings as IBorrowerSettingsDocPopulated);
|