@dynamatix/gb-schemas 1.3.207 → 1.3.208
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/applications/application.model.d.ts +24 -0
- package/dist/applications/application.model.d.ts.map +1 -1
- package/dist/applications/applications-task.model.d.ts +100 -0
- package/dist/applications/applications-task.model.d.ts.map +1 -0
- package/dist/applications/applications-task.model.js +41 -0
- package/dist/applications/index.d.ts +1 -0
- package/dist/applications/index.d.ts.map +1 -1
- package/dist/value-objects/pound.d.ts +1 -1
- package/dist/value-objects/pound.d.ts.map +1 -1
- package/dist/value-objects/pound.js +37 -16
- package/package.json +1 -1
|
@@ -67,6 +67,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
67
67
|
isUkResident: string;
|
|
68
68
|
newAuditRecordsCount: number;
|
|
69
69
|
propertyIds: mongoose.Types.ObjectId[];
|
|
70
|
+
documentTasksCount: number;
|
|
71
|
+
informationTasksCount: number;
|
|
72
|
+
feePaymentTasksCount: number;
|
|
73
|
+
applicationFormSignedDate: NativeDate;
|
|
70
74
|
selectedProduct?: string | null | undefined;
|
|
71
75
|
riskRating?: string | null | undefined;
|
|
72
76
|
creditProfile?: {
|
|
@@ -129,6 +133,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
129
133
|
isUkResident: string;
|
|
130
134
|
newAuditRecordsCount: number;
|
|
131
135
|
propertyIds: mongoose.Types.ObjectId[];
|
|
136
|
+
documentTasksCount: number;
|
|
137
|
+
informationTasksCount: number;
|
|
138
|
+
feePaymentTasksCount: number;
|
|
139
|
+
applicationFormSignedDate: NativeDate;
|
|
132
140
|
selectedProduct?: string | null | undefined;
|
|
133
141
|
riskRating?: string | null | undefined;
|
|
134
142
|
creditProfile?: {
|
|
@@ -191,6 +199,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
191
199
|
isUkResident: string;
|
|
192
200
|
newAuditRecordsCount: number;
|
|
193
201
|
propertyIds: mongoose.Types.ObjectId[];
|
|
202
|
+
documentTasksCount: number;
|
|
203
|
+
informationTasksCount: number;
|
|
204
|
+
feePaymentTasksCount: number;
|
|
205
|
+
applicationFormSignedDate: NativeDate;
|
|
194
206
|
selectedProduct?: string | null | undefined;
|
|
195
207
|
riskRating?: string | null | undefined;
|
|
196
208
|
creditProfile?: {
|
|
@@ -265,6 +277,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
265
277
|
isUkResident: string;
|
|
266
278
|
newAuditRecordsCount: number;
|
|
267
279
|
propertyIds: mongoose.Types.ObjectId[];
|
|
280
|
+
documentTasksCount: number;
|
|
281
|
+
informationTasksCount: number;
|
|
282
|
+
feePaymentTasksCount: number;
|
|
283
|
+
applicationFormSignedDate: NativeDate;
|
|
268
284
|
selectedProduct?: string | null | undefined;
|
|
269
285
|
riskRating?: string | null | undefined;
|
|
270
286
|
creditProfile?: {
|
|
@@ -327,6 +343,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
327
343
|
isUkResident: string;
|
|
328
344
|
newAuditRecordsCount: number;
|
|
329
345
|
propertyIds: mongoose.Types.ObjectId[];
|
|
346
|
+
documentTasksCount: number;
|
|
347
|
+
informationTasksCount: number;
|
|
348
|
+
feePaymentTasksCount: number;
|
|
349
|
+
applicationFormSignedDate: NativeDate;
|
|
330
350
|
selectedProduct?: string | null | undefined;
|
|
331
351
|
riskRating?: string | null | undefined;
|
|
332
352
|
creditProfile?: {
|
|
@@ -389,6 +409,10 @@ declare const ApplicationModel: mongoose.Model<{
|
|
|
389
409
|
isUkResident: string;
|
|
390
410
|
newAuditRecordsCount: number;
|
|
391
411
|
propertyIds: mongoose.Types.ObjectId[];
|
|
412
|
+
documentTasksCount: number;
|
|
413
|
+
informationTasksCount: number;
|
|
414
|
+
feePaymentTasksCount: number;
|
|
415
|
+
applicationFormSignedDate: NativeDate;
|
|
392
416
|
selectedProduct?: string | null | undefined;
|
|
393
417
|
riskRating?: string | null | undefined;
|
|
394
418
|
creditProfile?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.model.d.ts","sourceRoot":"","sources":["../../applications/application.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"application.model.d.ts","sourceRoot":"","sources":["../../applications/application.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA2LhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAC;AAC1E,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/// <reference path="../value-objects/pound.d.ts" />
|
|
2
|
+
/// <reference path="../value-objects/account-number.d.ts" />
|
|
3
|
+
/// <reference path="../value-objects/sort-code.d.ts" />
|
|
4
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
5
|
+
/// <reference types="mongoose/types/callback" />
|
|
6
|
+
/// <reference types="mongoose/types/collection" />
|
|
7
|
+
/// <reference types="mongoose/types/connection" />
|
|
8
|
+
/// <reference types="mongoose/types/cursor" />
|
|
9
|
+
/// <reference types="mongoose/types/document" />
|
|
10
|
+
/// <reference types="mongoose/types/error" />
|
|
11
|
+
/// <reference types="mongoose/types/expressions" />
|
|
12
|
+
/// <reference types="mongoose/types/helpers" />
|
|
13
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
14
|
+
/// <reference types="mongoose/types/indexes" />
|
|
15
|
+
/// <reference types="mongoose/types/models" />
|
|
16
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
17
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
18
|
+
/// <reference types="mongoose/types/populate" />
|
|
19
|
+
/// <reference types="mongoose/types/query" />
|
|
20
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
21
|
+
/// <reference types="mongoose/types/session" />
|
|
22
|
+
/// <reference types="mongoose/types/types" />
|
|
23
|
+
/// <reference types="mongoose/types/utility" />
|
|
24
|
+
/// <reference types="mongoose/types/validation" />
|
|
25
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
26
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
27
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
28
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
29
|
+
import mongoose from "mongoose";
|
|
30
|
+
declare const ApplicationsTaskModel: mongoose.Model<{
|
|
31
|
+
applicationId: string;
|
|
32
|
+
description: string;
|
|
33
|
+
status: string;
|
|
34
|
+
feeType: string;
|
|
35
|
+
applicationNumber: string;
|
|
36
|
+
activityName: string;
|
|
37
|
+
instanceId: string;
|
|
38
|
+
checkFlowId: string;
|
|
39
|
+
hasAttachment: string;
|
|
40
|
+
}, {}, {}, {}, mongoose.Document<unknown, {}, {
|
|
41
|
+
applicationId: string;
|
|
42
|
+
description: string;
|
|
43
|
+
status: string;
|
|
44
|
+
feeType: string;
|
|
45
|
+
applicationNumber: string;
|
|
46
|
+
activityName: string;
|
|
47
|
+
instanceId: string;
|
|
48
|
+
checkFlowId: string;
|
|
49
|
+
hasAttachment: string;
|
|
50
|
+
}, {}> & {
|
|
51
|
+
applicationId: string;
|
|
52
|
+
description: string;
|
|
53
|
+
status: string;
|
|
54
|
+
feeType: string;
|
|
55
|
+
applicationNumber: string;
|
|
56
|
+
activityName: string;
|
|
57
|
+
instanceId: string;
|
|
58
|
+
checkFlowId: string;
|
|
59
|
+
hasAttachment: string;
|
|
60
|
+
} & {
|
|
61
|
+
_id: mongoose.Types.ObjectId;
|
|
62
|
+
} & {
|
|
63
|
+
__v: number;
|
|
64
|
+
}, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
65
|
+
applicationId: string;
|
|
66
|
+
description: string;
|
|
67
|
+
status: string;
|
|
68
|
+
feeType: string;
|
|
69
|
+
applicationNumber: string;
|
|
70
|
+
activityName: string;
|
|
71
|
+
instanceId: string;
|
|
72
|
+
checkFlowId: string;
|
|
73
|
+
hasAttachment: string;
|
|
74
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
75
|
+
applicationId: string;
|
|
76
|
+
description: string;
|
|
77
|
+
status: string;
|
|
78
|
+
feeType: string;
|
|
79
|
+
applicationNumber: string;
|
|
80
|
+
activityName: string;
|
|
81
|
+
instanceId: string;
|
|
82
|
+
checkFlowId: string;
|
|
83
|
+
hasAttachment: string;
|
|
84
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
85
|
+
applicationId: string;
|
|
86
|
+
description: string;
|
|
87
|
+
status: string;
|
|
88
|
+
feeType: string;
|
|
89
|
+
applicationNumber: string;
|
|
90
|
+
activityName: string;
|
|
91
|
+
instanceId: string;
|
|
92
|
+
checkFlowId: string;
|
|
93
|
+
hasAttachment: string;
|
|
94
|
+
}> & {
|
|
95
|
+
_id: mongoose.Types.ObjectId;
|
|
96
|
+
} & {
|
|
97
|
+
__v: number;
|
|
98
|
+
}>>;
|
|
99
|
+
export default ApplicationsTaskModel;
|
|
100
|
+
//# sourceMappingURL=applications-task.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applications-task.model.d.ts","sourceRoot":"","sources":["../../applications/applications-task.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAyChC,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6D,CAAC;AACzF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
const applicationsTaskSchema = new mongoose.Schema({
|
|
3
|
+
applicationId: {
|
|
4
|
+
type: String,
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
applicationNumber: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
activityName: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: ""
|
|
14
|
+
},
|
|
15
|
+
description: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
},
|
|
19
|
+
instanceId: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
checkFlowId: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ""
|
|
26
|
+
},
|
|
27
|
+
status: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ""
|
|
30
|
+
},
|
|
31
|
+
hasAttachment: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: ""
|
|
34
|
+
},
|
|
35
|
+
feeType: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: ""
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const ApplicationsTaskModel = mongoose.model("ApplicationsTask", applicationsTaskSchema);
|
|
41
|
+
export default ApplicationsTaskModel;
|
|
@@ -19,4 +19,5 @@ export { default as DocumentModel } from './document.model';
|
|
|
19
19
|
export { default as MortgageModel } from './application-mortgage.model';
|
|
20
20
|
export { default as ApplicationProductFeaturesModel } from './application-productfeatures.model';
|
|
21
21
|
export { default as ApplicationEucModel } from './application-euc.model';
|
|
22
|
+
export { default as ApplicationsTaskModel } from './applications-task.model';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../applications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAC,MAAM,kCAAkC,CAAA;AACxF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../applications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAC,MAAM,kCAAkC,CAAA;AACxF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -36,8 +36,8 @@ declare module 'mongoose' {
|
|
|
36
36
|
}
|
|
37
37
|
declare class Pound extends mongoose.SchemaType {
|
|
38
38
|
constructor(key: string, options: mongoose.AnyObject | undefined);
|
|
39
|
-
static formatUK(value: number): string;
|
|
40
39
|
cast(val: any): any;
|
|
40
|
+
get(val: any): any;
|
|
41
41
|
}
|
|
42
42
|
export { Pound };
|
|
43
43
|
//# sourceMappingURL=pound.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pound.d.ts","sourceRoot":"","sources":["../../value-objects/pound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,QAAQ,UAAU,CAAC;IACtB,UAAU,MAAM,CAAC;QACb,UAAU,KAAK,CAAC;YACZ,MAAM,KAAM,SAAQ,UAAU;aAAI;SACrC;KACJ;CACJ;AAED,cAAM,KAAM,SAAQ,QAAQ,CAAC,UAAU;gBACvB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"pound.d.ts","sourceRoot":"","sources":["../../value-objects/pound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,QAAQ,UAAU,CAAC;IACtB,UAAU,MAAM,CAAC;QACb,UAAU,KAAK,CAAC;YACZ,MAAM,KAAM,SAAQ,UAAU;aAAI;SACrC;KACJ;CACJ;AAED,cAAM,KAAM,SAAQ,QAAQ,CAAC,UAAU;gBACvB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,SAAS;IAKhE,IAAI,CAAC,GAAG,EAAE,GAAG;IA+Cb,GAAG,CAAC,GAAG,EAAE,GAAG;CAoBf;AAKD,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -4,28 +4,49 @@ class Pound extends mongoose.SchemaType {
|
|
|
4
4
|
constructor(key, options) {
|
|
5
5
|
super(key, options, 'Pound');
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
// Format with commas and 2 decimals, no pound sign
|
|
9
|
-
return value.toLocaleString('en-GB', {
|
|
10
|
-
minimumFractionDigits: 2,
|
|
11
|
-
maximumFractionDigits: 2
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
// Casting method that validates and formats the value
|
|
7
|
+
// Casting method that validates and formats the value when saving
|
|
15
8
|
cast(val) {
|
|
16
9
|
if (val == null) {
|
|
17
10
|
return val; // Allow null or undefined values
|
|
18
11
|
}
|
|
19
|
-
//
|
|
20
|
-
if (typeof val
|
|
21
|
-
|
|
12
|
+
// If it's already a number, validate and return
|
|
13
|
+
if (typeof val === 'number') {
|
|
14
|
+
if (isNaN(val)) {
|
|
15
|
+
throw new mongoose.Error.CastError('Pound', val, this.path, new Error(`${val} is not a valid currency value`));
|
|
16
|
+
}
|
|
17
|
+
return parseFloat(val.toFixed(2));
|
|
22
18
|
}
|
|
23
|
-
//
|
|
24
|
-
if (
|
|
25
|
-
|
|
19
|
+
// If it's a string, try to parse it
|
|
20
|
+
if (typeof val === 'string') {
|
|
21
|
+
// Remove pound sign, commas, and spaces
|
|
22
|
+
const cleanedValue = val.replace(/[£,\s]/g, '');
|
|
23
|
+
// Check if the cleaned value is a valid number
|
|
24
|
+
const numValue = parseFloat(cleanedValue);
|
|
25
|
+
if (isNaN(numValue)) {
|
|
26
|
+
throw new mongoose.Error.CastError('Pound', val, this.path, new Error(`${val} is not a valid currency value`));
|
|
27
|
+
}
|
|
28
|
+
// Return as number with 2 decimal places
|
|
29
|
+
return parseFloat(numValue.toFixed(2));
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
throw new mongoose.Error.CastError('Pound', val, this.path, new Error('Pound value must be a string or number'));
|
|
32
|
+
}
|
|
33
|
+
// Custom getter to format the value when retrieving
|
|
34
|
+
get(val) {
|
|
35
|
+
if (val == null) {
|
|
36
|
+
return val;
|
|
37
|
+
}
|
|
38
|
+
// Ensure we have a number
|
|
39
|
+
const numValue = typeof val === 'number' ? val : parseFloat(val);
|
|
40
|
+
if (isNaN(numValue)) {
|
|
41
|
+
return val; // Return original value if parsing fails
|
|
42
|
+
}
|
|
43
|
+
// Format as UK currency with pound sign, commas, and 2 decimal places
|
|
44
|
+
return new Intl.NumberFormat('en-GB', {
|
|
45
|
+
style: 'currency',
|
|
46
|
+
currency: 'GBP',
|
|
47
|
+
minimumFractionDigits: 2,
|
|
48
|
+
maximumFractionDigits: 2
|
|
49
|
+
}).format(numValue);
|
|
29
50
|
}
|
|
30
51
|
}
|
|
31
52
|
// Register custom type
|