gemcap-be-common 1.3.94 → 1.3.95

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.
@@ -164,7 +164,7 @@ export interface IProspectFilesLegacy {
164
164
  auditorSharedFiles: IProspectFile[];
165
165
  acceptedFiles: string[];
166
166
  }
167
- export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFilesLegacy {
167
+ export interface IProspect extends IProspectBase, IProspectExternalNew {
168
168
  probability: number;
169
169
  businessDescription: string;
170
170
  comments: string;
@@ -493,18 +493,6 @@ exports.ProspectSchema = new mongoose_1.default.Schema({
493
493
  },
494
494
  contacts: [contactSchema],
495
495
  ...ProspectInfoSchema,
496
- files: ProspectFilesSchema,
497
- auditorSharedFiles: [fileDetailsSchema],
498
- auditorFiles: {
499
- type: Map,
500
- of: [fileDetailsSchema],
501
- default: {},
502
- required: false,
503
- },
504
- acceptedFiles: [{
505
- type: String,
506
- required: false,
507
- }],
508
496
  underwriterIds: [{
509
497
  type: mongoose_1.default.Schema.Types.ObjectId,
510
498
  ref: _models_1.MODEL_NAMES.underwriters,
@@ -350,7 +350,7 @@ export interface IProspectFilesLegacy {
350
350
  acceptedFiles: string[];
351
351
  }
352
352
 
353
- export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFilesLegacy {
353
+ export interface IProspect extends IProspectBase, IProspectExternalNew {
354
354
  probability: number;
355
355
  businessDescription: string;
356
356
  comments: string;
@@ -652,18 +652,6 @@ export const ProspectSchema = new mongoose.Schema<IProspect, ProspectModel>(
652
652
  },
653
653
  contacts: [contactSchema],
654
654
  ...ProspectInfoSchema,
655
- files: ProspectFilesSchema,
656
- auditorSharedFiles: [fileDetailsSchema],
657
- auditorFiles: {
658
- type: Map,
659
- of: [fileDetailsSchema],
660
- default: {},
661
- required: false,
662
- },
663
- acceptedFiles: [{
664
- type: String,
665
- required: false,
666
- }],
667
655
  underwriterIds: [{
668
656
  type: mongoose.Schema.Types.ObjectId,
669
657
  ref: MODEL_NAMES.underwriters,
@@ -41,6 +41,7 @@ export interface IProspectFile {
41
41
  sharepointFolderId?: string;
42
42
  sharepointDriveId?: string;
43
43
  sharepointWebUrl?: string;
44
+ isAccepted?: boolean;
44
45
  }
45
46
  export interface IProspectFileDoc extends IProspectFile, mongoose.Document {
46
47
  }
@@ -21,6 +21,7 @@ export interface IProspectFile {
21
21
  sharepointFolderId?: string;
22
22
  sharepointDriveId?: string;
23
23
  sharepointWebUrl?: string;
24
+ isAccepted?: boolean;
24
25
  }
25
26
 
26
27
  export interface IProspectFileDoc extends IProspectFile, mongoose.Document {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.3.94",
3
+ "version": "1.3.95",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,7 +21,7 @@ class CrmProspectsService {
21
21
  for (const file of fileArray) {
22
22
  const newFile = {
23
23
  type: ProspectFile_model_1.EProspectFileType.FILE,
24
- prospectId,
24
+ prospectId: new mongoose_1.default.Types.ObjectId(prospectId),
25
25
  group,
26
26
  rowId,
27
27
  fileId: file.fileId,
@@ -37,7 +37,7 @@ class CrmProspectsService {
37
37
  for (const file of auditorSharedFiles) {
38
38
  const newFile = {
39
39
  type: ProspectFile_model_1.EProspectFileType.AUDITOR_SHARED_FILE,
40
- prospectId,
40
+ prospectId: new mongoose_1.default.Types.ObjectId(prospectId),
41
41
  fileId: file.fileId,
42
42
  filename: file.filename,
43
43
  uploadedAt: file.uploadedAt,
@@ -50,7 +50,7 @@ class CrmProspectsService {
50
50
  for (const file of fileArray) {
51
51
  const newFile = {
52
52
  type: ProspectFile_model_1.EProspectFileType.AUDITOR_FILE,
53
- prospectId,
53
+ prospectId: new mongoose_1.default.Types.ObjectId(prospectId),
54
54
  auditorId: new mongoose_1.default.Types.ObjectId(auditorId),
55
55
  fileId: file.fileId,
56
56
  filename: file.filename,
@@ -1,8 +1,20 @@
1
1
  import mongoose from 'mongoose';
2
2
 
3
- import { Prospect } from '../models/Prospect.model';
3
+ import {
4
+ IProspectWithId,
5
+ Prospect,
6
+ TProspectAuditorFiles,
7
+ TProspectFiles,
8
+ } from '../models/Prospect.model';
4
9
  import { EProspectFileType, IProspectFile, ProspectFile } from '../models/ProspectFile.model';
5
10
 
11
+ interface IProspectLegacy extends IProspectWithId {
12
+ files: TProspectFiles;
13
+ auditorFiles: TProspectAuditorFiles;
14
+ auditorSharedFiles: IProspectFile[];
15
+ acceptedFiles: string[];
16
+ }
17
+
6
18
  export class CrmProspectsService {
7
19
  async resetFiles() {
8
20
  await ProspectFile.deleteMany({});
@@ -13,14 +25,14 @@ export class CrmProspectsService {
13
25
  const prospects = await Prospect.find().lean();
14
26
 
15
27
  for (const prospect of prospects) {
16
- const { _id: prospectId, files, auditorFiles, auditorSharedFiles } = prospect;
28
+ const { _id: prospectId, files, auditorFiles, auditorSharedFiles } = prospect as unknown as IProspectLegacy;
17
29
 
18
30
  for (const [group, rowMap] of Object.entries(files || {})) {
19
31
  for (const [rowId, fileArray] of Object.entries(rowMap)) {
20
32
  for (const file of fileArray) {
21
33
  const newFile: IProspectFile = {
22
34
  type: EProspectFileType.FILE,
23
- prospectId,
35
+ prospectId: new mongoose.Types.ObjectId(prospectId),
24
36
  group,
25
37
  rowId,
26
38
  fileId: file.fileId,
@@ -37,7 +49,7 @@ export class CrmProspectsService {
37
49
  for (const file of auditorSharedFiles) {
38
50
  const newFile: IProspectFile = {
39
51
  type: EProspectFileType.AUDITOR_SHARED_FILE,
40
- prospectId,
52
+ prospectId: new mongoose.Types.ObjectId(prospectId),
41
53
  fileId: file.fileId,
42
54
  filename: file.filename,
43
55
  uploadedAt: file.uploadedAt,
@@ -51,7 +63,7 @@ export class CrmProspectsService {
51
63
  for (const file of fileArray) {
52
64
  const newFile: IProspectFile = {
53
65
  type: EProspectFileType.AUDITOR_FILE,
54
- prospectId,
66
+ prospectId: new mongoose.Types.ObjectId(prospectId),
55
67
  auditorId: new mongoose.Types.ObjectId(auditorId),
56
68
  fileId: file.fileId,
57
69
  filename: file.filename,