pristine-member-nest-api-database 1.0.91 → 1.0.93
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/models/Member.model.ts
CHANGED
|
@@ -1,17 +1,627 @@
|
|
|
1
|
+
// import mongoose, { Document, Schema } from "mongoose";
|
|
2
|
+
// import { Audit } from "../interface/Audit.interface";
|
|
3
|
+
// import IFile from "../interface/IFile.interface";
|
|
4
|
+
|
|
5
|
+
// type barcodeBranchMemberhipdetails = {
|
|
6
|
+
// isRegisteredMembership: boolean; //field is used to check whether membership is created on first time registering
|
|
7
|
+
// isMembershipRequested: boolean; //means membership request is waiting for approval
|
|
8
|
+
// membershipType: mongoose.Types.ObjectId;
|
|
9
|
+
// membershipStatus: mongoose.Types.ObjectId;
|
|
10
|
+
// remarks: String;
|
|
11
|
+
// requestedDate: Date;
|
|
12
|
+
// isMembershipSynced: boolean; //used to check whether SAP sync done or not
|
|
13
|
+
// noOfSubscriptionMonths: number;
|
|
14
|
+
// isIssued: boolean; //means subscription is issued or not
|
|
15
|
+
// electedDate: Date;
|
|
16
|
+
// barcodeBranchMemberCode: string;
|
|
17
|
+
// barCode: number;
|
|
18
|
+
// validFrom: Date;
|
|
19
|
+
// validTo: Date;
|
|
20
|
+
// countryCode: number;
|
|
21
|
+
// changeDate: Date;
|
|
22
|
+
// isTerminationRequested: boolean;
|
|
23
|
+
// isTerminationSynced: boolean; //used to check whether SAP sync done or not
|
|
24
|
+
// terminationDate: Date;
|
|
25
|
+
// terminationReason: string;
|
|
26
|
+
// };
|
|
27
|
+
|
|
28
|
+
// type noneGs1MembershipDetails = {
|
|
29
|
+
// associationMemberCode: string;
|
|
30
|
+
// membershipStatus: mongoose.Types.ObjectId;
|
|
31
|
+
// membershipType: mongoose.Types.ObjectId;
|
|
32
|
+
// isTerminated: boolean;
|
|
33
|
+
// terminatedDate: Date;
|
|
34
|
+
// reasonForTermination: string;
|
|
35
|
+
// isTerminationRequested: boolean;
|
|
36
|
+
// terminationRequestedDate: Date;
|
|
37
|
+
// terminationRequestedBy: string;
|
|
38
|
+
// terminationRequestRemarks: string;
|
|
39
|
+
// onOfSubscriptionMonths: number;
|
|
40
|
+
// isMembershipSynced: boolean;
|
|
41
|
+
// SyncOn: Date;
|
|
42
|
+
// electedDate: Date;
|
|
43
|
+
// };
|
|
44
|
+
|
|
45
|
+
// interface MemberDocument extends Document {
|
|
46
|
+
// memberId: number;
|
|
47
|
+
// memberCode: string;
|
|
48
|
+
// memberName: string;
|
|
49
|
+
// isMemberOfMasterBranch: boolean;
|
|
50
|
+
|
|
51
|
+
// pureStaticMemberLevelFieldValues: [
|
|
52
|
+
// {
|
|
53
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
54
|
+
// value: string;
|
|
55
|
+
// },
|
|
56
|
+
// ];
|
|
57
|
+
// //Member Level Sync
|
|
58
|
+
// isCreatedInSAP: boolean;
|
|
59
|
+
// isMemberSyncedWithSAP: boolean;
|
|
60
|
+
// memberSyncedOn: Date;
|
|
61
|
+
// isActive: boolean;
|
|
62
|
+
|
|
63
|
+
// //new
|
|
64
|
+
// memberAssociation: [
|
|
65
|
+
// {
|
|
66
|
+
// applicationId: mongoose.Types.ObjectId;
|
|
67
|
+
// branchId: mongoose.Types.ObjectId;
|
|
68
|
+
|
|
69
|
+
// categoryData: [
|
|
70
|
+
// {
|
|
71
|
+
// categoryId: mongoose.Types.ObjectId;
|
|
72
|
+
// fieldValues: [
|
|
73
|
+
// {
|
|
74
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
75
|
+
// value: string | number | any;
|
|
76
|
+
// },
|
|
77
|
+
// ];
|
|
78
|
+
// },
|
|
79
|
+
// ];
|
|
80
|
+
// membershipData: {
|
|
81
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
82
|
+
// value: barcodeBranchMemberhipdetails[] | noneGs1MembershipDetails;
|
|
83
|
+
// };
|
|
84
|
+
|
|
85
|
+
// isCreatedInSAP: boolean;
|
|
86
|
+
// isMemberSyncedWithSAP: boolean;
|
|
87
|
+
// memberSyncedOn: Date;
|
|
88
|
+
// dynamicDetails: JSON;
|
|
89
|
+
|
|
90
|
+
// applicationStatus: string;
|
|
91
|
+
// isEnrolmentCreatedInSAP: boolean;
|
|
92
|
+
// isEnrolmentSyncedWithSAP: boolean;
|
|
93
|
+
// enrolmentSyncedOn: Date;
|
|
94
|
+
// salesOrderDocEntry: string; // SAP sales order doc entry when creating BP in SAP
|
|
95
|
+
// salesOrderStatus: string; // SAP sales order status when creating BP in SAP
|
|
96
|
+
// isActive: boolean;
|
|
97
|
+
// createdDate: Date;
|
|
98
|
+
// approverOneData: {
|
|
99
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
100
|
+
// remarks: string;
|
|
101
|
+
// userId: string;
|
|
102
|
+
// attachment: IFile[];
|
|
103
|
+
// };
|
|
104
|
+
// approverTwoData: {
|
|
105
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
106
|
+
// remarks: string;
|
|
107
|
+
// userId: string;
|
|
108
|
+
// attachment: IFile[];
|
|
109
|
+
// };
|
|
110
|
+
// },
|
|
111
|
+
// ];
|
|
112
|
+
// audit: Audit[];
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// mongoose.set("strictPopulate", false);
|
|
116
|
+
|
|
117
|
+
// /* ------------------------------------------------ */
|
|
118
|
+
// /* File Schema */
|
|
119
|
+
// /* ------------------------------------------------ */
|
|
120
|
+
|
|
121
|
+
// const fileSchema = new Schema<IFile>({
|
|
122
|
+
// baseURL: { type: String },
|
|
123
|
+
// fileName: { type: String },
|
|
124
|
+
// fileExtension: { type: String },
|
|
125
|
+
// });
|
|
126
|
+
|
|
127
|
+
// /* ------------------------------------------------ */
|
|
128
|
+
// /* Barcode Membership Schema */
|
|
129
|
+
// /* ------------------------------------------------ */
|
|
130
|
+
|
|
131
|
+
// const barcodeMembershipSchema = new Schema({
|
|
132
|
+
// isRegisteredMembership: { type: Boolean, required: true },
|
|
133
|
+
// isMembershipRequested: { type: Boolean, default: true },
|
|
134
|
+
// membershipType: {
|
|
135
|
+
// type: Schema.Types.ObjectId,
|
|
136
|
+
// ref: "Membership.Types",
|
|
137
|
+
// required: true,
|
|
138
|
+
// },
|
|
139
|
+
// membershipStatus: {
|
|
140
|
+
// type: Schema.Types.ObjectId,
|
|
141
|
+
// ref: "Membership.Statuses",
|
|
142
|
+
// required: true,
|
|
143
|
+
// },
|
|
144
|
+
// remarks: { type: String },
|
|
145
|
+
// requestedDate: { type: Date, default: Date.now },
|
|
146
|
+
// isMembershipSynced: { type: Boolean, default: false },
|
|
147
|
+
// noOfSubscriptionMonths: { type: Number },
|
|
148
|
+
// isIssued: { type: Boolean },
|
|
149
|
+
// electedDate: { type: Date },
|
|
150
|
+
// barcodeBranchMemberCode: { type: String },
|
|
151
|
+
// barCode: { type: Number },
|
|
152
|
+
// validFrom: { type: Date },
|
|
153
|
+
// validTo: { type: Date },
|
|
154
|
+
// countryCode: { type: Number },
|
|
155
|
+
// changeDate: { type: Date },
|
|
156
|
+
// isTerminationRequested: { type: Boolean, default: false },
|
|
157
|
+
// isTerminationSynced: { type: Boolean, default: false },
|
|
158
|
+
// terminationDate: { type: Date },
|
|
159
|
+
// terminationReason: { type: String },
|
|
160
|
+
// });
|
|
161
|
+
|
|
162
|
+
// /* ------------------------------------------------ */
|
|
163
|
+
// /* None GS1 Membership Schema */
|
|
164
|
+
// /* ------------------------------------------------ */
|
|
165
|
+
|
|
166
|
+
// const noneGs1MembershipSchema = new Schema({
|
|
167
|
+
// associationMemberCode: { type: String },
|
|
168
|
+
// membershipStatus: {
|
|
169
|
+
// type: Schema.Types.ObjectId,
|
|
170
|
+
// ref: "Membership.Statuses",
|
|
171
|
+
// },
|
|
172
|
+
// membershipType: {
|
|
173
|
+
// type: Schema.Types.ObjectId,
|
|
174
|
+
// ref: "Membership.Types",
|
|
175
|
+
// },
|
|
176
|
+
// isTerminated: { type: Boolean },
|
|
177
|
+
// terminatedDate: { type: Date },
|
|
178
|
+
// reasonForTermination: { type: String },
|
|
179
|
+
// isTerminationRequested: { type: Boolean },
|
|
180
|
+
// terminationRequestedDate: { type: Date },
|
|
181
|
+
// terminationRequestedBy: { type: String },
|
|
182
|
+
// terminationRequestRemarks: { type: String },
|
|
183
|
+
// onOfSubscriptionMonths: { type: Number },
|
|
184
|
+
// isMembershipSynced: { type: Boolean },
|
|
185
|
+
// SyncOn: { type: Date },
|
|
186
|
+
// electedDate: { type: Date },
|
|
187
|
+
// });
|
|
188
|
+
|
|
189
|
+
// /* ------------------------------------------------ */
|
|
190
|
+
// /* Category Field Value */
|
|
191
|
+
// /* ------------------------------------------------ */
|
|
192
|
+
|
|
193
|
+
// const fieldValueSchema = new Schema({
|
|
194
|
+
// fieldId: {
|
|
195
|
+
// type: Schema.Types.ObjectId,
|
|
196
|
+
// ref: "Editor.Fields.Master",
|
|
197
|
+
// },
|
|
198
|
+
// value: { type: Schema.Types.Mixed },
|
|
199
|
+
// });
|
|
200
|
+
|
|
201
|
+
// /* ------------------------------------------------ */
|
|
202
|
+
// /* Category Schema */
|
|
203
|
+
// /* ------------------------------------------------ */
|
|
204
|
+
|
|
205
|
+
// const categorySchema = new Schema({
|
|
206
|
+
// categoryId: {
|
|
207
|
+
// type: Schema.Types.ObjectId,
|
|
208
|
+
// ref: "Field.Categories",
|
|
209
|
+
// },
|
|
210
|
+
// fieldValues: [fieldValueSchema],
|
|
211
|
+
// });
|
|
212
|
+
|
|
213
|
+
// /* ------------------------------------------------ */
|
|
214
|
+
// /* Membership Data */
|
|
215
|
+
// /* ------------------------------------------------ */
|
|
216
|
+
|
|
217
|
+
// const membershipDataSchema = new Schema({
|
|
218
|
+
// fieldId: {
|
|
219
|
+
// type: Schema.Types.ObjectId,
|
|
220
|
+
// },
|
|
221
|
+
// barcodeBranchMembership: [barcodeMembershipSchema],
|
|
222
|
+
// noneGs1Membership: noneGs1MembershipSchema,
|
|
223
|
+
// });
|
|
224
|
+
|
|
225
|
+
// /* ------------------------------------------------ */
|
|
226
|
+
// /* Approver Schema */
|
|
227
|
+
// /* ------------------------------------------------ */
|
|
228
|
+
|
|
229
|
+
// const approverSchema = new Schema({
|
|
230
|
+
// fieldId: { type: Schema.Types.ObjectId },
|
|
231
|
+
// remarks: { type: String },
|
|
232
|
+
// userId: { type: String },
|
|
233
|
+
// attachment: [fileSchema],
|
|
234
|
+
// });
|
|
235
|
+
|
|
236
|
+
// /* ------------------------------------------------ */
|
|
237
|
+
// /* Member Association */
|
|
238
|
+
// /* ------------------------------------------------ */
|
|
239
|
+
|
|
240
|
+
// const memberAssociationSchema = new Schema({
|
|
241
|
+
// applicationId: {
|
|
242
|
+
// type: Schema.Types.ObjectId,
|
|
243
|
+
// },
|
|
244
|
+
// branchId: {
|
|
245
|
+
// type: Schema.Types.ObjectId,
|
|
246
|
+
// ref: "Branches",
|
|
247
|
+
// },
|
|
248
|
+
// categoryData: [categorySchema],
|
|
249
|
+
// membershipData: membershipDataSchema,
|
|
250
|
+
// isCreatedInSAP: { type: Boolean, default: false },
|
|
251
|
+
// isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
252
|
+
// memberSyncedOn: { type: Date },
|
|
253
|
+
// dynamicDetails: { type: JSON, default: null },
|
|
254
|
+
// applicationStatus: { type: String },
|
|
255
|
+
// isEnrolmentCreatedInSAP: { type: Boolean, default: false },
|
|
256
|
+
// isEnrolmentSyncedWithSAP: { type: Boolean, default: false },
|
|
257
|
+
// enrolmentSyncedOn: { type: Date },
|
|
258
|
+
// salesOrderDocEntry: { type: String },
|
|
259
|
+
// salesOrderStatus: { type: String },
|
|
260
|
+
// isActive: { type: Boolean, default: true },
|
|
261
|
+
// createdDate: {
|
|
262
|
+
// type: Date,
|
|
263
|
+
// default: Date.now,
|
|
264
|
+
// },
|
|
265
|
+
// approverOneData: approverSchema,
|
|
266
|
+
// approverTwoData: approverSchema,
|
|
267
|
+
// });
|
|
268
|
+
|
|
269
|
+
// /* ------------------------------------------------ */
|
|
270
|
+
// /* Member Schema */
|
|
271
|
+
// /* ------------------------------------------------ */
|
|
272
|
+
|
|
273
|
+
// const memberSchema = new Schema<MemberDocument>({
|
|
274
|
+
// memberId: { type: Number },
|
|
275
|
+
// memberCode: { type: String, default: "" },
|
|
276
|
+
// memberName: { type: String },
|
|
277
|
+
// isMemberOfMasterBranch: { type: Boolean, default: false },
|
|
278
|
+
// pureStaticMemberLevelFieldValues: [
|
|
279
|
+
// {
|
|
280
|
+
// fieldId: {
|
|
281
|
+
// type: Schema.Types.ObjectId,
|
|
282
|
+
// ref: "Editor.Fields.Master",
|
|
283
|
+
// },
|
|
284
|
+
// value: { type: String },
|
|
285
|
+
// },
|
|
286
|
+
// ],
|
|
287
|
+
|
|
288
|
+
// isCreatedInSAP: { type: Boolean, default: false },
|
|
289
|
+
// isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
290
|
+
// memberSyncedOn: { type: Date },
|
|
291
|
+
// isActive: { type: Boolean },
|
|
292
|
+
// memberAssociation: [memberAssociationSchema],
|
|
293
|
+
// audit: [
|
|
294
|
+
// {
|
|
295
|
+
// userId: { type: String },
|
|
296
|
+
// auditedOn: { type: Date },
|
|
297
|
+
// actionType: { type: String },
|
|
298
|
+
// },
|
|
299
|
+
// ],
|
|
300
|
+
// });
|
|
301
|
+
|
|
302
|
+
// const mongoMember = mongoose.model<MemberDocument>("Members", memberSchema);
|
|
303
|
+
|
|
304
|
+
// export { mongoMember };
|
|
305
|
+
|
|
306
|
+
// import mongoose, { Document, Schema } from "mongoose";
|
|
307
|
+
// import { Audit } from "../interface/Audit.interface";
|
|
308
|
+
// import IFile from "../interface/IFile.interface";
|
|
309
|
+
|
|
310
|
+
// type barcodeBranchMemberhipdetails = {
|
|
311
|
+
// isRegisteredMembership: boolean; //field is used to check whether membership is created on first time registering
|
|
312
|
+
// isMembershipRequested: boolean; //means membership request is waiting for approval
|
|
313
|
+
// membershipType: mongoose.Types.ObjectId;
|
|
314
|
+
// membershipStatus: mongoose.Types.ObjectId;
|
|
315
|
+
// remarks: String;
|
|
316
|
+
// requestedDate: Date;
|
|
317
|
+
// isMembershipSynced: boolean; //used to check whether SAP sync done or not
|
|
318
|
+
// noOfSubscriptionMonths: number;
|
|
319
|
+
// isIssued: boolean; //means subscription is issued or not
|
|
320
|
+
// electedDate: Date;
|
|
321
|
+
// barcodeBranchMemberCode: string;
|
|
322
|
+
// barCode: number;
|
|
323
|
+
// validFrom: Date;
|
|
324
|
+
// validTo: Date;
|
|
325
|
+
// countryCode: number;
|
|
326
|
+
// changeDate: Date;
|
|
327
|
+
// isTerminationRequested: boolean;
|
|
328
|
+
// isTerminationSynced: boolean; //used to check whether SAP sync done or not
|
|
329
|
+
// terminationDate: Date;
|
|
330
|
+
// terminationReason: string;
|
|
331
|
+
// };
|
|
332
|
+
|
|
333
|
+
// type noneGs1MembershipDetails = {
|
|
334
|
+
// associationMemberCode: string;
|
|
335
|
+
// membershipStatus: mongoose.Types.ObjectId;
|
|
336
|
+
// membershipType: mongoose.Types.ObjectId;
|
|
337
|
+
// isTerminated: boolean;
|
|
338
|
+
// terminatedDate: Date;
|
|
339
|
+
// reasonForTermination: string;
|
|
340
|
+
// isTerminationRequested: boolean;
|
|
341
|
+
// terminationRequestedDate: Date;
|
|
342
|
+
// terminationRequestedBy: string;
|
|
343
|
+
// terminationRequestRemarks: string;
|
|
344
|
+
// onOfSubscriptionMonths: number;
|
|
345
|
+
// isMembershipSynced: boolean;
|
|
346
|
+
// SyncOn: Date;
|
|
347
|
+
// electedDate: Date;
|
|
348
|
+
// };
|
|
349
|
+
|
|
350
|
+
// interface MemberDocument extends Document {
|
|
351
|
+
// memberId: number;
|
|
352
|
+
// memberCode: string;
|
|
353
|
+
// memberName: string;
|
|
354
|
+
// isMemberOfMasterBranch: boolean;
|
|
355
|
+
|
|
356
|
+
// pureStaticMemberLevelFieldValues: [
|
|
357
|
+
// {
|
|
358
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
359
|
+
// value: string;
|
|
360
|
+
// },
|
|
361
|
+
// ];
|
|
362
|
+
// //Member Level Sync
|
|
363
|
+
// isCreatedInSAP: boolean;
|
|
364
|
+
// isMemberSyncedWithSAP: boolean;
|
|
365
|
+
// memberSyncedOn: Date;
|
|
366
|
+
// isActive: boolean;
|
|
367
|
+
|
|
368
|
+
// //new
|
|
369
|
+
// memberAssociation: [
|
|
370
|
+
// {
|
|
371
|
+
// applicationId: mongoose.Types.ObjectId;
|
|
372
|
+
// branchId: mongoose.Types.ObjectId;
|
|
373
|
+
|
|
374
|
+
// categoryData: [
|
|
375
|
+
// {
|
|
376
|
+
// categoryId: mongoose.Types.ObjectId;
|
|
377
|
+
// fieldValues: [
|
|
378
|
+
// {
|
|
379
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
380
|
+
// value: string | number | any;
|
|
381
|
+
// },
|
|
382
|
+
// ];
|
|
383
|
+
// },
|
|
384
|
+
// ];
|
|
385
|
+
// membershipData: {
|
|
386
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
387
|
+
// value: barcodeBranchMemberhipdetails[] | noneGs1MembershipDetails;
|
|
388
|
+
// };
|
|
389
|
+
|
|
390
|
+
// isCreatedInSAP: boolean;
|
|
391
|
+
// isMemberSyncedWithSAP: boolean;
|
|
392
|
+
// memberSyncedOn: Date;
|
|
393
|
+
// dynamicDetails: JSON;
|
|
394
|
+
|
|
395
|
+
// applicationStatus: string;
|
|
396
|
+
// isEnrolmentCreatedInSAP: boolean;
|
|
397
|
+
// isEnrolmentSyncedWithSAP: boolean;
|
|
398
|
+
// enrolmentSyncedOn: Date;
|
|
399
|
+
// salesOrderDocEntry: string; // SAP sales order doc entry when creating BP in SAP
|
|
400
|
+
// salesOrderStatus: string; // SAP sales order status when creating BP in SAP
|
|
401
|
+
// isActive: boolean;
|
|
402
|
+
// createdDate: Date;
|
|
403
|
+
// approverOneData: {
|
|
404
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
405
|
+
// remarks: string;
|
|
406
|
+
// userId: string;
|
|
407
|
+
// attachment: IFile[];
|
|
408
|
+
// };
|
|
409
|
+
// approverTwoData: {
|
|
410
|
+
// fieldId: mongoose.Types.ObjectId;
|
|
411
|
+
// remarks: string;
|
|
412
|
+
// userId: string;
|
|
413
|
+
// attachment: IFile[];
|
|
414
|
+
// };
|
|
415
|
+
// },
|
|
416
|
+
// ];
|
|
417
|
+
// audit: Audit[];
|
|
418
|
+
// }
|
|
419
|
+
|
|
420
|
+
// mongoose.set("strictPopulate", false);
|
|
421
|
+
|
|
422
|
+
// /* ------------------------------------------------ */
|
|
423
|
+
// /* File Schema */
|
|
424
|
+
// /* ------------------------------------------------ */
|
|
425
|
+
|
|
426
|
+
// const fileSchema = new Schema<IFile>({
|
|
427
|
+
// baseURL: { type: String },
|
|
428
|
+
// fileName: { type: String },
|
|
429
|
+
// fileExtension: { type: String },
|
|
430
|
+
// });
|
|
431
|
+
|
|
432
|
+
// /* ------------------------------------------------ */
|
|
433
|
+
// /* Barcode Membership Schema */
|
|
434
|
+
// /* ------------------------------------------------ */
|
|
435
|
+
|
|
436
|
+
// const barcodeMembershipSchema = new Schema({
|
|
437
|
+
// isRegisteredMembership: { type: Boolean, required: true },
|
|
438
|
+
// isMembershipRequested: { type: Boolean, default: true },
|
|
439
|
+
// membershipType: {
|
|
440
|
+
// type: Schema.Types.ObjectId,
|
|
441
|
+
// ref: "Membership.Types",
|
|
442
|
+
// required: true,
|
|
443
|
+
// },
|
|
444
|
+
// membershipStatus: {
|
|
445
|
+
// type: Schema.Types.ObjectId,
|
|
446
|
+
// ref: "Membership.Statuses",
|
|
447
|
+
// required: true,
|
|
448
|
+
// },
|
|
449
|
+
// remarks: { type: String },
|
|
450
|
+
// requestedDate: { type: Date, default: Date.now },
|
|
451
|
+
// isMembershipSynced: { type: Boolean, default: false },
|
|
452
|
+
// noOfSubscriptionMonths: { type: Number },
|
|
453
|
+
// isIssued: { type: Boolean },
|
|
454
|
+
// electedDate: { type: Date },
|
|
455
|
+
// barcodeBranchMemberCode: { type: String },
|
|
456
|
+
// barCode: { type: Number },
|
|
457
|
+
// validFrom: { type: Date },
|
|
458
|
+
// validTo: { type: Date },
|
|
459
|
+
// countryCode: { type: Number },
|
|
460
|
+
// changeDate: { type: Date },
|
|
461
|
+
// isTerminationRequested: { type: Boolean, default: false },
|
|
462
|
+
// isTerminationSynced: { type: Boolean, default: false },
|
|
463
|
+
// terminationDate: { type: Date },
|
|
464
|
+
// terminationReason: { type: String },
|
|
465
|
+
// });
|
|
466
|
+
|
|
467
|
+
// /* ------------------------------------------------ */
|
|
468
|
+
// /* None GS1 Membership Schema */
|
|
469
|
+
// /* ------------------------------------------------ */
|
|
470
|
+
|
|
471
|
+
// const noneGs1MembershipSchema = new Schema({
|
|
472
|
+
// associationMemberCode: { type: String },
|
|
473
|
+
// membershipStatus: {
|
|
474
|
+
// type: Schema.Types.ObjectId,
|
|
475
|
+
// ref: "Membership.Statuses",
|
|
476
|
+
// },
|
|
477
|
+
// membershipType: {
|
|
478
|
+
// type: Schema.Types.ObjectId,
|
|
479
|
+
// ref: "Membership.Types",
|
|
480
|
+
// },
|
|
481
|
+
// isTerminated: { type: Boolean },
|
|
482
|
+
// terminatedDate: { type: Date },
|
|
483
|
+
// reasonForTermination: { type: String },
|
|
484
|
+
// isTerminationRequested: { type: Boolean },
|
|
485
|
+
// terminationRequestedDate: { type: Date },
|
|
486
|
+
// terminationRequestedBy: { type: String },
|
|
487
|
+
// terminationRequestRemarks: { type: String },
|
|
488
|
+
// onOfSubscriptionMonths: { type: Number },
|
|
489
|
+
// isMembershipSynced: { type: Boolean },
|
|
490
|
+
// SyncOn: { type: Date },
|
|
491
|
+
// electedDate: { type: Date },
|
|
492
|
+
// });
|
|
493
|
+
|
|
494
|
+
// /* ------------------------------------------------ */
|
|
495
|
+
// /* Category Field Value */
|
|
496
|
+
// /* ------------------------------------------------ */
|
|
497
|
+
|
|
498
|
+
// const fieldValueSchema = new Schema({
|
|
499
|
+
// fieldId: {
|
|
500
|
+
// type: Schema.Types.ObjectId,
|
|
501
|
+
// ref: "Editor.Fields.Master",
|
|
502
|
+
// },
|
|
503
|
+
// value: { type: Schema.Types.Mixed },
|
|
504
|
+
// });
|
|
505
|
+
|
|
506
|
+
// /* ------------------------------------------------ */
|
|
507
|
+
// /* Category Schema */
|
|
508
|
+
// /* ------------------------------------------------ */
|
|
509
|
+
|
|
510
|
+
// const categorySchema = new Schema({
|
|
511
|
+
// categoryId: {
|
|
512
|
+
// type: Schema.Types.ObjectId,
|
|
513
|
+
// ref: "Field.Categories",
|
|
514
|
+
// },
|
|
515
|
+
// fieldValues: [fieldValueSchema],
|
|
516
|
+
// });
|
|
517
|
+
|
|
518
|
+
// /* ------------------------------------------------ */
|
|
519
|
+
// /* Membership Data */
|
|
520
|
+
// /* ------------------------------------------------ */
|
|
521
|
+
|
|
522
|
+
// const membershipDataSchema = new Schema({
|
|
523
|
+
// fieldId: {
|
|
524
|
+
// type: Schema.Types.ObjectId,
|
|
525
|
+
// },
|
|
526
|
+
// barcodeBranchMembership: [barcodeMembershipSchema],
|
|
527
|
+
// noneGs1Membership: noneGs1MembershipSchema,
|
|
528
|
+
// });
|
|
529
|
+
|
|
530
|
+
// /* ------------------------------------------------ */
|
|
531
|
+
// /* Approver Schema */
|
|
532
|
+
// /* ------------------------------------------------ */
|
|
533
|
+
|
|
534
|
+
// const approverSchema = new Schema({
|
|
535
|
+
// fieldId: { type: Schema.Types.ObjectId },
|
|
536
|
+
// remarks: { type: String },
|
|
537
|
+
// userId: { type: String },
|
|
538
|
+
// attachment: [fileSchema],
|
|
539
|
+
// });
|
|
540
|
+
|
|
541
|
+
// /* ------------------------------------------------ */
|
|
542
|
+
// /* Member Association */
|
|
543
|
+
// /* ------------------------------------------------ */
|
|
544
|
+
|
|
545
|
+
// const memberAssociationSchema = new Schema({
|
|
546
|
+
// applicationId: {
|
|
547
|
+
// type: Schema.Types.ObjectId,
|
|
548
|
+
// },
|
|
549
|
+
// branchId: {
|
|
550
|
+
// type: Schema.Types.ObjectId,
|
|
551
|
+
// ref: "Branches",
|
|
552
|
+
// },
|
|
553
|
+
// categoryData: [categorySchema],
|
|
554
|
+
// membershipData: membershipDataSchema,
|
|
555
|
+
// isCreatedInSAP: { type: Boolean, default: false },
|
|
556
|
+
// isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
557
|
+
// memberSyncedOn: { type: Date },
|
|
558
|
+
// dynamicDetails: { type: JSON, default: null },
|
|
559
|
+
// applicationStatus: { type: String },
|
|
560
|
+
// isEnrolmentCreatedInSAP: { type: Boolean, default: false },
|
|
561
|
+
// isEnrolmentSyncedWithSAP: { type: Boolean, default: false },
|
|
562
|
+
// enrolmentSyncedOn: { type: Date },
|
|
563
|
+
// salesOrderDocEntry: { type: String },
|
|
564
|
+
// salesOrderStatus: { type: String },
|
|
565
|
+
// isActive: { type: Boolean, default: true },
|
|
566
|
+
// createdDate: {
|
|
567
|
+
// type: Date,
|
|
568
|
+
// default: Date.now,
|
|
569
|
+
// },
|
|
570
|
+
// approverOneData: approverSchema,
|
|
571
|
+
// approverTwoData: approverSchema,
|
|
572
|
+
// });
|
|
573
|
+
|
|
574
|
+
// /* ------------------------------------------------ */
|
|
575
|
+
// /* Member Schema */
|
|
576
|
+
// /* ------------------------------------------------ */
|
|
577
|
+
|
|
578
|
+
// const memberSchema = new Schema<MemberDocument>({
|
|
579
|
+
// memberId: { type: Number },
|
|
580
|
+
// memberCode: { type: String, default: "" },
|
|
581
|
+
// memberName: { type: String },
|
|
582
|
+
// isMemberOfMasterBranch: { type: Boolean, default: false },
|
|
583
|
+
// pureStaticMemberLevelFieldValues: [
|
|
584
|
+
// {
|
|
585
|
+
// fieldId: {
|
|
586
|
+
// type: Schema.Types.ObjectId,
|
|
587
|
+
// ref: "Editor.Fields.Master",
|
|
588
|
+
// },
|
|
589
|
+
// value: { type: String },
|
|
590
|
+
// },
|
|
591
|
+
// ],
|
|
592
|
+
|
|
593
|
+
// isCreatedInSAP: { type: Boolean, default: false },
|
|
594
|
+
// isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
595
|
+
// memberSyncedOn: { type: Date },
|
|
596
|
+
// isActive: { type: Boolean },
|
|
597
|
+
// memberAssociation: [memberAssociationSchema],
|
|
598
|
+
// audit: [
|
|
599
|
+
// {
|
|
600
|
+
// userId: { type: String },
|
|
601
|
+
// auditedOn: { type: Date },
|
|
602
|
+
// actionType: { type: String },
|
|
603
|
+
// },
|
|
604
|
+
// ],
|
|
605
|
+
// });
|
|
606
|
+
|
|
607
|
+
// const mongoMember = mongoose.model<MemberDocument>("Members", memberSchema);
|
|
608
|
+
|
|
609
|
+
// export { mongoMember };
|
|
610
|
+
|
|
1
611
|
import mongoose, { Document, Schema } from "mongoose";
|
|
2
612
|
import { Audit } from "../interface/Audit.interface";
|
|
3
613
|
import IFile from "../interface/IFile.interface";
|
|
4
614
|
|
|
5
615
|
type barcodeBranchMemberhipdetails = {
|
|
6
|
-
isRegisteredMembership: boolean;
|
|
7
|
-
isMembershipRequested: boolean;
|
|
616
|
+
isRegisteredMembership: boolean;
|
|
617
|
+
isMembershipRequested: boolean;
|
|
8
618
|
membershipType: mongoose.Types.ObjectId;
|
|
9
619
|
membershipStatus: mongoose.Types.ObjectId;
|
|
10
620
|
remarks: String;
|
|
11
621
|
requestedDate: Date;
|
|
12
|
-
isMembershipSynced: boolean;
|
|
622
|
+
isMembershipSynced: boolean;
|
|
13
623
|
noOfSubscriptionMonths: number;
|
|
14
|
-
isIssued: boolean;
|
|
624
|
+
isIssued: boolean;
|
|
15
625
|
electedDate: Date;
|
|
16
626
|
barcodeBranchMemberCode: string;
|
|
17
627
|
barCode: number;
|
|
@@ -20,7 +630,7 @@ type barcodeBranchMemberhipdetails = {
|
|
|
20
630
|
countryCode: number;
|
|
21
631
|
changeDate: Date;
|
|
22
632
|
isTerminationRequested: boolean;
|
|
23
|
-
isTerminationSynced: boolean;
|
|
633
|
+
isTerminationSynced: boolean;
|
|
24
634
|
terminationDate: Date;
|
|
25
635
|
terminationReason: string;
|
|
26
636
|
};
|
|
@@ -50,22 +660,25 @@ interface MemberDocument extends Document {
|
|
|
50
660
|
|
|
51
661
|
pureStaticMemberLevelFieldValues: [
|
|
52
662
|
{
|
|
53
|
-
|
|
54
|
-
|
|
663
|
+
categoryId: mongoose.Types.ObjectId;
|
|
664
|
+
fieldValues: [
|
|
665
|
+
{
|
|
666
|
+
fieldId: mongoose.Types.ObjectId;
|
|
667
|
+
value: string | number | any;
|
|
668
|
+
},
|
|
669
|
+
];
|
|
55
670
|
},
|
|
56
671
|
];
|
|
57
|
-
|
|
672
|
+
|
|
58
673
|
isCreatedInSAP: boolean;
|
|
59
674
|
isMemberSyncedWithSAP: boolean;
|
|
60
675
|
memberSyncedOn: Date;
|
|
61
676
|
isActive: boolean;
|
|
62
677
|
|
|
63
|
-
//new
|
|
64
678
|
memberAssociation: [
|
|
65
679
|
{
|
|
66
680
|
applicationId: mongoose.Types.ObjectId;
|
|
67
681
|
branchId: mongoose.Types.ObjectId;
|
|
68
|
-
|
|
69
682
|
categoryData: [
|
|
70
683
|
{
|
|
71
684
|
categoryId: mongoose.Types.ObjectId;
|
|
@@ -81,18 +694,16 @@ interface MemberDocument extends Document {
|
|
|
81
694
|
fieldId: mongoose.Types.ObjectId;
|
|
82
695
|
value: barcodeBranchMemberhipdetails[] | noneGs1MembershipDetails;
|
|
83
696
|
};
|
|
84
|
-
|
|
85
697
|
isCreatedInSAP: boolean;
|
|
86
698
|
isMemberSyncedWithSAP: boolean;
|
|
87
699
|
memberSyncedOn: Date;
|
|
88
700
|
dynamicDetails: JSON;
|
|
89
|
-
|
|
90
701
|
applicationStatus: string;
|
|
91
702
|
isEnrolmentCreatedInSAP: boolean;
|
|
92
703
|
isEnrolmentSyncedWithSAP: boolean;
|
|
93
704
|
enrolmentSyncedOn: Date;
|
|
94
|
-
salesOrderDocEntry: string;
|
|
95
|
-
salesOrderStatus: string;
|
|
705
|
+
salesOrderDocEntry: string;
|
|
706
|
+
salesOrderStatus: string;
|
|
96
707
|
isActive: boolean;
|
|
97
708
|
createdDate: Date;
|
|
98
709
|
approverOneData: {
|
|
@@ -114,20 +725,14 @@ interface MemberDocument extends Document {
|
|
|
114
725
|
|
|
115
726
|
mongoose.set("strictPopulate", false);
|
|
116
727
|
|
|
117
|
-
|
|
118
|
-
/* File Schema */
|
|
119
|
-
/* ------------------------------------------------ */
|
|
120
|
-
|
|
728
|
+
// ------------------ File ------------------
|
|
121
729
|
const fileSchema = new Schema<IFile>({
|
|
122
|
-
baseURL:
|
|
123
|
-
fileName:
|
|
124
|
-
fileExtension:
|
|
730
|
+
baseURL: String,
|
|
731
|
+
fileName: String,
|
|
732
|
+
fileExtension: String,
|
|
125
733
|
});
|
|
126
734
|
|
|
127
|
-
|
|
128
|
-
/* Barcode Membership Schema */
|
|
129
|
-
/* ------------------------------------------------ */
|
|
130
|
-
|
|
735
|
+
// ------------------ Barcode Membership ------------------
|
|
131
736
|
const barcodeMembershipSchema = new Schema({
|
|
132
737
|
isRegisteredMembership: { type: Boolean, required: true },
|
|
133
738
|
isMembershipRequested: { type: Boolean, default: true },
|
|
@@ -141,164 +746,123 @@ const barcodeMembershipSchema = new Schema({
|
|
|
141
746
|
ref: "Membership.Statuses",
|
|
142
747
|
required: true,
|
|
143
748
|
},
|
|
144
|
-
remarks:
|
|
749
|
+
remarks: String,
|
|
145
750
|
requestedDate: { type: Date, default: Date.now },
|
|
146
751
|
isMembershipSynced: { type: Boolean, default: false },
|
|
147
|
-
noOfSubscriptionMonths:
|
|
148
|
-
isIssued:
|
|
149
|
-
electedDate:
|
|
150
|
-
barcodeBranchMemberCode:
|
|
151
|
-
barCode:
|
|
152
|
-
validFrom:
|
|
153
|
-
validTo:
|
|
154
|
-
countryCode:
|
|
155
|
-
changeDate:
|
|
752
|
+
noOfSubscriptionMonths: Number,
|
|
753
|
+
isIssued: Boolean,
|
|
754
|
+
electedDate: Date,
|
|
755
|
+
barcodeBranchMemberCode: String,
|
|
756
|
+
barCode: Number,
|
|
757
|
+
validFrom: Date,
|
|
758
|
+
validTo: Date,
|
|
759
|
+
countryCode: Number,
|
|
760
|
+
changeDate: Date,
|
|
156
761
|
isTerminationRequested: { type: Boolean, default: false },
|
|
157
762
|
isTerminationSynced: { type: Boolean, default: false },
|
|
158
|
-
terminationDate:
|
|
159
|
-
terminationReason:
|
|
763
|
+
terminationDate: Date,
|
|
764
|
+
terminationReason: String,
|
|
160
765
|
});
|
|
161
766
|
|
|
162
|
-
|
|
163
|
-
/* None GS1 Membership Schema */
|
|
164
|
-
/* ------------------------------------------------ */
|
|
165
|
-
|
|
767
|
+
// ------------------ None GS1 Membership ------------------
|
|
166
768
|
const noneGs1MembershipSchema = new Schema({
|
|
167
|
-
associationMemberCode:
|
|
168
|
-
membershipStatus: {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
terminationRequestedBy: { type: String },
|
|
182
|
-
terminationRequestRemarks: { type: String },
|
|
183
|
-
onOfSubscriptionMonths: { type: Number },
|
|
184
|
-
isMembershipSynced: { type: Boolean },
|
|
185
|
-
SyncOn: { type: Date },
|
|
186
|
-
electedDate: { type: Date },
|
|
769
|
+
associationMemberCode: String,
|
|
770
|
+
membershipStatus: { type: Schema.Types.ObjectId, ref: "Membership.Statuses" },
|
|
771
|
+
membershipType: { type: Schema.Types.ObjectId, ref: "Membership.Types" },
|
|
772
|
+
isTerminated: Boolean,
|
|
773
|
+
terminatedDate: Date,
|
|
774
|
+
reasonForTermination: String,
|
|
775
|
+
isTerminationRequested: Boolean,
|
|
776
|
+
terminationRequestedDate: Date,
|
|
777
|
+
terminationRequestedBy: String,
|
|
778
|
+
terminationRequestRemarks: String,
|
|
779
|
+
onOfSubscriptionMonths: Number,
|
|
780
|
+
isMembershipSynced: Boolean,
|
|
781
|
+
SyncOn: Date,
|
|
782
|
+
electedDate: Date,
|
|
187
783
|
});
|
|
188
784
|
|
|
189
|
-
|
|
190
|
-
/* Category Field Value */
|
|
191
|
-
/* ------------------------------------------------ */
|
|
192
|
-
|
|
785
|
+
// ------------------ Field Values ------------------
|
|
193
786
|
const fieldValueSchema = new Schema({
|
|
194
|
-
fieldId: {
|
|
195
|
-
|
|
196
|
-
ref: "Editor.Fields.Master",
|
|
197
|
-
},
|
|
198
|
-
value: { type: Schema.Types.Mixed },
|
|
787
|
+
fieldId: { type: Schema.Types.ObjectId, ref: "Editor.Fields.Master" },
|
|
788
|
+
value: Schema.Types.Mixed,
|
|
199
789
|
});
|
|
200
790
|
|
|
201
|
-
|
|
202
|
-
/* Category Schema */
|
|
203
|
-
/* ------------------------------------------------ */
|
|
204
|
-
|
|
791
|
+
// ------------------ Category ------------------
|
|
205
792
|
const categorySchema = new Schema({
|
|
206
|
-
categoryId: {
|
|
207
|
-
type: Schema.Types.ObjectId,
|
|
208
|
-
ref: "Field.Categories",
|
|
209
|
-
},
|
|
793
|
+
categoryId: { type: Schema.Types.ObjectId, ref: "Field.Categories" },
|
|
210
794
|
fieldValues: [fieldValueSchema],
|
|
211
795
|
});
|
|
212
796
|
|
|
213
|
-
|
|
214
|
-
/* Membership Data */
|
|
215
|
-
/* ------------------------------------------------ */
|
|
216
|
-
|
|
797
|
+
// ------------------ Membership Data ------------------
|
|
217
798
|
const membershipDataSchema = new Schema({
|
|
218
|
-
fieldId:
|
|
219
|
-
type: Schema.Types.ObjectId,
|
|
220
|
-
},
|
|
799
|
+
fieldId: Schema.Types.ObjectId,
|
|
221
800
|
barcodeBranchMembership: [barcodeMembershipSchema],
|
|
222
801
|
noneGs1Membership: noneGs1MembershipSchema,
|
|
223
802
|
});
|
|
224
803
|
|
|
225
|
-
|
|
226
|
-
/* Approver Schema */
|
|
227
|
-
/* ------------------------------------------------ */
|
|
228
|
-
|
|
804
|
+
// ------------------ Approver ------------------
|
|
229
805
|
const approverSchema = new Schema({
|
|
230
|
-
fieldId:
|
|
231
|
-
remarks:
|
|
232
|
-
userId:
|
|
806
|
+
fieldId: Schema.Types.ObjectId,
|
|
807
|
+
remarks: String,
|
|
808
|
+
userId: String,
|
|
233
809
|
attachment: [fileSchema],
|
|
234
810
|
});
|
|
235
811
|
|
|
236
|
-
|
|
237
|
-
/* Member Association */
|
|
238
|
-
/* ------------------------------------------------ */
|
|
239
|
-
|
|
812
|
+
// ------------------ Member Association ------------------
|
|
240
813
|
const memberAssociationSchema = new Schema({
|
|
241
|
-
applicationId:
|
|
242
|
-
|
|
243
|
-
},
|
|
244
|
-
branchId: {
|
|
245
|
-
type: Schema.Types.ObjectId,
|
|
246
|
-
ref: "Branches",
|
|
247
|
-
},
|
|
814
|
+
applicationId: Schema.Types.ObjectId,
|
|
815
|
+
branchId: { type: Schema.Types.ObjectId, ref: "Branches" },
|
|
248
816
|
categoryData: [categorySchema],
|
|
249
817
|
membershipData: membershipDataSchema,
|
|
250
818
|
isCreatedInSAP: { type: Boolean, default: false },
|
|
251
819
|
isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
252
|
-
memberSyncedOn:
|
|
820
|
+
memberSyncedOn: Date,
|
|
253
821
|
dynamicDetails: { type: JSON, default: null },
|
|
254
|
-
applicationStatus:
|
|
822
|
+
applicationStatus: String,
|
|
255
823
|
isEnrolmentCreatedInSAP: { type: Boolean, default: false },
|
|
256
824
|
isEnrolmentSyncedWithSAP: { type: Boolean, default: false },
|
|
257
|
-
enrolmentSyncedOn:
|
|
258
|
-
salesOrderDocEntry:
|
|
259
|
-
salesOrderStatus:
|
|
825
|
+
enrolmentSyncedOn: Date,
|
|
826
|
+
salesOrderDocEntry: String,
|
|
827
|
+
salesOrderStatus: String,
|
|
260
828
|
isActive: { type: Boolean, default: true },
|
|
261
|
-
createdDate: {
|
|
262
|
-
type: Date,
|
|
263
|
-
default: Date.now,
|
|
264
|
-
},
|
|
829
|
+
createdDate: { type: Date, default: Date.now },
|
|
265
830
|
approverOneData: approverSchema,
|
|
266
831
|
approverTwoData: approverSchema,
|
|
267
832
|
});
|
|
268
833
|
|
|
269
|
-
|
|
270
|
-
/* Member Schema */
|
|
271
|
-
/* ------------------------------------------------ */
|
|
272
|
-
|
|
834
|
+
// ------------------ Member ------------------
|
|
273
835
|
const memberSchema = new Schema<MemberDocument>({
|
|
274
|
-
memberId:
|
|
836
|
+
memberId: Number,
|
|
275
837
|
memberCode: { type: String, default: "" },
|
|
276
|
-
memberName:
|
|
838
|
+
memberName: String,
|
|
277
839
|
isMemberOfMasterBranch: { type: Boolean, default: false },
|
|
840
|
+
|
|
278
841
|
pureStaticMemberLevelFieldValues: [
|
|
279
842
|
{
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
843
|
+
categoryId: { type: Schema.Types.ObjectId, ref: "Field.Categories" },
|
|
844
|
+
fieldValues: [
|
|
845
|
+
{
|
|
846
|
+
fieldId: { type: Schema.Types.ObjectId, ref: "Editor.Fields.Master" },
|
|
847
|
+
value: Schema.Types.Mixed,
|
|
848
|
+
},
|
|
849
|
+
],
|
|
285
850
|
},
|
|
286
851
|
],
|
|
287
852
|
|
|
288
853
|
isCreatedInSAP: { type: Boolean, default: false },
|
|
289
854
|
isMemberSyncedWithSAP: { type: Boolean, default: false },
|
|
290
|
-
memberSyncedOn:
|
|
291
|
-
isActive:
|
|
855
|
+
memberSyncedOn: Date,
|
|
856
|
+
isActive: Boolean,
|
|
292
857
|
memberAssociation: [memberAssociationSchema],
|
|
293
858
|
audit: [
|
|
294
859
|
{
|
|
295
|
-
userId:
|
|
296
|
-
auditedOn:
|
|
297
|
-
actionType:
|
|
860
|
+
userId: String,
|
|
861
|
+
auditedOn: Date,
|
|
862
|
+
actionType: String,
|
|
298
863
|
},
|
|
299
864
|
],
|
|
300
865
|
});
|
|
301
866
|
|
|
302
867
|
const mongoMember = mongoose.model<MemberDocument>("Members", memberSchema);
|
|
303
|
-
|
|
304
868
|
export { mongoMember };
|