gemcap-be-common 1.5.53 → 1.5.56

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.
@@ -23,7 +23,6 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document, Model } from 'mongoose';
26
- import { IOrganization } from './Organization.model';
27
26
  interface ISchemaItem {
28
27
  column: string;
29
28
  databaseTitle: string;
@@ -39,7 +38,7 @@ export interface IBorrower {
39
38
  title: string;
40
39
  active: boolean;
41
40
  accrualStatus: boolean;
42
- organizationId: IOrganization;
41
+ organizationId: mongoose.Types.ObjectId;
43
42
  schemas: IMapSchema[];
44
43
  }
45
44
  export interface IBorrowerDoc extends IBorrower, Document {
@@ -52,7 +51,7 @@ export interface IBorrowerLean extends IBorrower {
52
51
  createdAt: Date;
53
52
  updatedAt: Date;
54
53
  }
55
- export interface IBorrowerPlain extends IBorrower {
54
+ export interface IBorrowerPlain extends Omit<IBorrower, 'organizationId'> {
56
55
  _id: string;
57
56
  createdAt: Date;
58
57
  updatedAt: Date;
@@ -64,59 +63,59 @@ export declare const BorrowerSchema: mongoose.Schema<any, mongoose.Model<any, an
64
63
  createdAt: NativeDate;
65
64
  updatedAt: NativeDate;
66
65
  } & {
67
- name: string;
68
- active: boolean;
69
66
  code: string;
67
+ name: string;
70
68
  title: string;
69
+ active: boolean;
71
70
  accrualStatus: boolean;
72
- __v?: number;
73
71
  organizationId?: mongoose.Types.ObjectId;
74
72
  schemas?: mongoose.Types.DocumentArray<{
75
- type: string;
76
73
  name: string;
74
+ type: string;
77
75
  data: mongoose.Types.DocumentArray<{
78
76
  column: string;
79
77
  databaseTitle: string;
80
78
  }>;
81
79
  }>;
80
+ __v?: number;
82
81
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
83
82
  createdAt: NativeDate;
84
83
  updatedAt: NativeDate;
85
84
  } & {
86
- name: string;
87
- active: boolean;
88
85
  code: string;
86
+ name: string;
89
87
  title: string;
88
+ active: boolean;
90
89
  accrualStatus: boolean;
91
- __v?: number;
92
90
  organizationId?: mongoose.Types.ObjectId;
93
91
  schemas?: mongoose.Types.DocumentArray<{
94
- type: string;
95
92
  name: string;
93
+ type: string;
96
94
  data: mongoose.Types.DocumentArray<{
97
95
  column: string;
98
96
  databaseTitle: string;
99
97
  }>;
100
98
  }>;
99
+ __v?: number;
101
100
  }>> & mongoose.FlatRecord<{
102
101
  createdAt: NativeDate;
103
102
  updatedAt: NativeDate;
104
103
  } & {
105
- name: string;
106
- active: boolean;
107
104
  code: string;
105
+ name: string;
108
106
  title: string;
107
+ active: boolean;
109
108
  accrualStatus: boolean;
110
- __v?: number;
111
109
  organizationId?: mongoose.Types.ObjectId;
112
110
  schemas?: mongoose.Types.DocumentArray<{
113
- type: string;
114
111
  name: string;
112
+ type: string;
115
113
  data: mongoose.Types.DocumentArray<{
116
114
  column: string;
117
115
  databaseTitle: string;
118
116
  }>;
119
117
  }>;
118
+ __v?: number;
120
119
  }> & {
121
120
  _id: mongoose.Types.ObjectId;
122
121
  }>;
@@ -21,7 +21,7 @@ export interface IBorrower {
21
21
  title: string;
22
22
  active: boolean;
23
23
  accrualStatus: boolean;
24
- organizationId: IOrganization;
24
+ organizationId: mongoose.Types.ObjectId;
25
25
  schemas: IMapSchema[];
26
26
  }
27
27
 
@@ -37,7 +37,7 @@ export interface IBorrowerLean extends IBorrower {
37
37
  updatedAt: Date;
38
38
  }
39
39
 
40
- export interface IBorrowerPlain extends IBorrower {
40
+ export interface IBorrowerPlain extends Omit<IBorrower, 'organizationId'> {
41
41
  _id: string;
42
42
  createdAt: Date;
43
43
  updatedAt: Date;
@@ -91,13 +91,13 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
91
91
  user?: string;
92
92
  }>;
93
93
  mainEmails: mongoose.Types.DocumentArray<{
94
- email?: string;
95
94
  title?: string;
95
+ email?: string;
96
96
  isActive?: boolean;
97
97
  }>;
98
98
  financialEmails: mongoose.Types.DocumentArray<{
99
- email?: string;
100
99
  title?: string;
100
+ email?: string;
101
101
  isActive?: boolean;
102
102
  }>;
103
103
  items: mongoose.Types.DocumentArray<{
@@ -105,8 +105,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
105
105
  updatedAt: NativeDate;
106
106
  } & {
107
107
  emailAddresses: mongoose.Types.DocumentArray<{
108
- email?: string;
109
108
  title?: string;
109
+ email?: string;
110
110
  isActive?: boolean;
111
111
  }>;
112
112
  instances: mongoose.Types.DocumentArray<{
@@ -124,8 +124,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
124
124
  submittedDate?: Date;
125
125
  status?: string;
126
126
  }>;
127
- startDate?: Date;
128
127
  item?: mongoose.Types.ObjectId;
128
+ startDate?: Date;
129
129
  frequency?: string;
130
130
  }>;
131
131
  __v?: number;
@@ -152,13 +152,13 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
152
152
  user?: string;
153
153
  }>;
154
154
  mainEmails: mongoose.Types.DocumentArray<{
155
- email?: string;
156
155
  title?: string;
156
+ email?: string;
157
157
  isActive?: boolean;
158
158
  }>;
159
159
  financialEmails: mongoose.Types.DocumentArray<{
160
- email?: string;
161
160
  title?: string;
161
+ email?: string;
162
162
  isActive?: boolean;
163
163
  }>;
164
164
  items: mongoose.Types.DocumentArray<{
@@ -166,8 +166,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
166
166
  updatedAt: NativeDate;
167
167
  } & {
168
168
  emailAddresses: mongoose.Types.DocumentArray<{
169
- email?: string;
170
169
  title?: string;
170
+ email?: string;
171
171
  isActive?: boolean;
172
172
  }>;
173
173
  instances: mongoose.Types.DocumentArray<{
@@ -185,8 +185,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
185
185
  submittedDate?: Date;
186
186
  status?: string;
187
187
  }>;
188
- startDate?: Date;
189
188
  item?: mongoose.Types.ObjectId;
189
+ startDate?: Date;
190
190
  frequency?: string;
191
191
  }>;
192
192
  __v?: number;
@@ -213,13 +213,13 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
213
213
  user?: string;
214
214
  }>;
215
215
  mainEmails: mongoose.Types.DocumentArray<{
216
- email?: string;
217
216
  title?: string;
217
+ email?: string;
218
218
  isActive?: boolean;
219
219
  }>;
220
220
  financialEmails: mongoose.Types.DocumentArray<{
221
- email?: string;
222
221
  title?: string;
222
+ email?: string;
223
223
  isActive?: boolean;
224
224
  }>;
225
225
  items: mongoose.Types.DocumentArray<{
@@ -227,8 +227,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
227
227
  updatedAt: NativeDate;
228
228
  } & {
229
229
  emailAddresses: mongoose.Types.DocumentArray<{
230
- email?: string;
231
230
  title?: string;
231
+ email?: string;
232
232
  isActive?: boolean;
233
233
  }>;
234
234
  instances: mongoose.Types.DocumentArray<{
@@ -246,8 +246,8 @@ export declare const BorrowerComplianceSchema: mongoose.Schema<any, mongoose.Mod
246
246
  submittedDate?: Date;
247
247
  status?: string;
248
248
  }>;
249
- startDate?: Date;
250
249
  item?: mongoose.Types.ObjectId;
250
+ startDate?: Date;
251
251
  frequency?: string;
252
252
  }>;
253
253
  __v?: number;
@@ -53,11 +53,11 @@ export interface IFinancialComplianceBorrowerDocumentWithMails extends IFinancia
53
53
  financialEmails: IEmailRecipient[];
54
54
  }
55
55
  export declare const FinancialComplianceBorrowerSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
56
- borrower: mongoose.Types.ObjectId;
57
56
  isDeleted: boolean;
57
+ borrower: mongoose.Types.ObjectId;
58
58
  __v?: number;
59
- dueDate?: Date;
60
59
  invoiceSentDate?: Date;
60
+ dueDate?: Date;
61
61
  stopFundingDate?: Date;
62
62
  lastReminderSentAt?: Date;
63
63
  accountClearedDate?: Date;
@@ -69,11 +69,11 @@ export declare const FinancialComplianceBorrowerSchema: mongoose.Schema<any, mon
69
69
  balanceOutstanding?: number;
70
70
  reminderCounter?: number;
71
71
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
72
- borrower: mongoose.Types.ObjectId;
73
72
  isDeleted: boolean;
73
+ borrower: mongoose.Types.ObjectId;
74
74
  __v?: number;
75
- dueDate?: Date;
76
75
  invoiceSentDate?: Date;
76
+ dueDate?: Date;
77
77
  stopFundingDate?: Date;
78
78
  lastReminderSentAt?: Date;
79
79
  accountClearedDate?: Date;
@@ -85,11 +85,11 @@ export declare const FinancialComplianceBorrowerSchema: mongoose.Schema<any, mon
85
85
  balanceOutstanding?: number;
86
86
  reminderCounter?: number;
87
87
  }>> & mongoose.FlatRecord<{
88
- borrower: mongoose.Types.ObjectId;
89
88
  isDeleted: boolean;
89
+ borrower: mongoose.Types.ObjectId;
90
90
  __v?: number;
91
- dueDate?: Date;
92
91
  invoiceSentDate?: Date;
92
+ dueDate?: Date;
93
93
  stopFundingDate?: Date;
94
94
  lastReminderSentAt?: Date;
95
95
  accountClearedDate?: Date;
@@ -81,12 +81,12 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
81
81
  createdAt: NativeDate;
82
82
  updatedAt: NativeDate;
83
83
  } & {
84
- borrowerId: mongoose.Types.ObjectId;
85
- type: string;
84
+ code: string;
86
85
  name: string;
87
- order: number;
88
86
  active: boolean;
89
- code: string;
87
+ type: string;
88
+ order: number;
89
+ borrowerId: mongoose.Types.ObjectId;
90
90
  startDate: Date;
91
91
  maturityDate: Date;
92
92
  commitment: number;
@@ -95,24 +95,24 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
95
95
  isParticipant: boolean;
96
96
  isDefaultPaymentOrder: boolean;
97
97
  __v?: number;
98
+ settlementCode?: string;
98
99
  masterCode?: string;
99
100
  payoffDate?: Date;
100
101
  minPercent?: number;
101
102
  maxPercent?: number;
102
103
  prepaymentDate?: Date;
103
104
  prepaymentTerms?: string;
104
- settlementCode?: string;
105
105
  deactivationDate?: Date;
106
106
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
107
107
  createdAt: NativeDate;
108
108
  updatedAt: NativeDate;
109
109
  } & {
110
- borrowerId: mongoose.Types.ObjectId;
111
- type: string;
110
+ code: string;
112
111
  name: string;
113
- order: number;
114
112
  active: boolean;
115
- code: string;
113
+ type: string;
114
+ order: number;
115
+ borrowerId: mongoose.Types.ObjectId;
116
116
  startDate: Date;
117
117
  maturityDate: Date;
118
118
  commitment: number;
@@ -121,24 +121,24 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
121
121
  isParticipant: boolean;
122
122
  isDefaultPaymentOrder: boolean;
123
123
  __v?: number;
124
+ settlementCode?: string;
124
125
  masterCode?: string;
125
126
  payoffDate?: Date;
126
127
  minPercent?: number;
127
128
  maxPercent?: number;
128
129
  prepaymentDate?: Date;
129
130
  prepaymentTerms?: string;
130
- settlementCode?: string;
131
131
  deactivationDate?: Date;
132
132
  }>> & mongoose.FlatRecord<{
133
133
  createdAt: NativeDate;
134
134
  updatedAt: NativeDate;
135
135
  } & {
136
- borrowerId: mongoose.Types.ObjectId;
137
- type: string;
136
+ code: string;
138
137
  name: string;
139
- order: number;
140
138
  active: boolean;
141
- code: string;
139
+ type: string;
140
+ order: number;
141
+ borrowerId: mongoose.Types.ObjectId;
142
142
  startDate: Date;
143
143
  maturityDate: Date;
144
144
  commitment: number;
@@ -147,13 +147,13 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
147
147
  isParticipant: boolean;
148
148
  isDefaultPaymentOrder: boolean;
149
149
  __v?: number;
150
+ settlementCode?: string;
150
151
  masterCode?: string;
151
152
  payoffDate?: Date;
152
153
  minPercent?: number;
153
154
  maxPercent?: number;
154
155
  prepaymentDate?: Date;
155
156
  prepaymentTerms?: string;
156
- settlementCode?: string;
157
157
  deactivationDate?: Date;
158
158
  }> & {
159
159
  _id: mongoose.Types.ObjectId;
@@ -24,7 +24,6 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Model } from 'mongoose';
26
26
  export interface IOrganization {
27
- _id?: mongoose.Types.ObjectId;
28
27
  name: string;
29
28
  subfolder: string;
30
29
  isDefault?: boolean;
@@ -32,9 +31,19 @@ export interface IOrganization {
32
31
  export type IOrganizationStringified = {
33
32
  [K in keyof IOrganization]: K extends '_id' | 'productId' ? string : IOrganization[K];
34
33
  };
35
- type OrganizationModel = Model<IOrganization>;
36
- export declare const OrganizationSchema: mongoose.Schema<IOrganization, OrganizationModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IOrganization, mongoose.Document<unknown, {}, mongoose.FlatRecord<IOrganization>> & mongoose.FlatRecord<IOrganization> & Required<{
34
+ export type TOrganizationModel = Model<IOrganization>;
35
+ export type TOrganizationDoc = mongoose.HydratedDocument<IOrganization>;
36
+ export interface IOrganizationLean extends IOrganization {
37
37
  _id: mongoose.Types.ObjectId;
38
- }>>;
39
- export declare const Organization: OrganizationModel;
40
- export {};
38
+ createdAt: Date;
39
+ updatedAt: Date;
40
+ }
41
+ export interface IOrganizationPlain extends IOrganization {
42
+ _id: string;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ }
46
+ export declare const OrganizationSchema: mongoose.Schema<IOrganization, TOrganizationModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IOrganization, mongoose.Document<unknown, {}, mongoose.FlatRecord<IOrganization>> & mongoose.FlatRecord<IOrganization> & {
47
+ _id: mongoose.Types.ObjectId;
48
+ }>;
49
+ export declare const Organization: TOrganizationModel;
@@ -19,7 +19,7 @@ exports.OrganizationSchema = new mongoose_1.default.Schema({
19
19
  },
20
20
  isDefault: {
21
21
  type: Boolean,
22
- }
22
+ },
23
23
  }, {
24
24
  timestamps: { createdAt: true, updatedAt: false },
25
25
  });
@@ -3,7 +3,6 @@ import mongoose, { Model } from 'mongoose';
3
3
  import { MODEL_NAMES } from './_models';
4
4
 
5
5
  export interface IOrganization {
6
- _id?: mongoose.Types.ObjectId;
7
6
  name: string;
8
7
  subfolder: string;
9
8
  isDefault?: boolean;
@@ -13,9 +12,23 @@ export type IOrganizationStringified = {
13
12
  [K in keyof IOrganization]: K extends '_id' | 'productId' ? string : IOrganization[K];
14
13
  };
15
14
 
16
- type OrganizationModel = Model<IOrganization>;
15
+ export type TOrganizationModel = Model<IOrganization>;
17
16
 
18
- export const OrganizationSchema = new mongoose.Schema<IOrganization, OrganizationModel>(
17
+ export type TOrganizationDoc = mongoose.HydratedDocument<IOrganization>
18
+
19
+ export interface IOrganizationLean extends IOrganization {
20
+ _id: mongoose.Types.ObjectId;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ }
24
+
25
+ export interface IOrganizationPlain extends IOrganization {
26
+ _id: string;
27
+ createdAt: Date;
28
+ updatedAt: Date;
29
+ }
30
+
31
+ export const OrganizationSchema = new mongoose.Schema<IOrganization, TOrganizationModel>(
19
32
  {
20
33
  name: {
21
34
  type: String,
@@ -29,11 +42,11 @@ export const OrganizationSchema = new mongoose.Schema<IOrganization, Organizatio
29
42
  },
30
43
  isDefault: {
31
44
  type: Boolean,
32
- }
45
+ },
33
46
  },
34
47
  {
35
48
  timestamps: { createdAt: true, updatedAt: false },
36
49
  },
37
50
  );
38
51
 
39
- export const Organization = mongoose.model<IOrganization, OrganizationModel>(MODEL_NAMES.organizations, OrganizationSchema);
52
+ export const Organization = mongoose.model<IOrganization, TOrganizationModel>(MODEL_NAMES.organizations, OrganizationSchema);
@@ -52,18 +52,18 @@ export declare const PostponedTransactionSchema: mongoose.Schema<any, mongoose.M
52
52
  timestamps: false;
53
53
  }, {
54
54
  productId: mongoose.Types.ObjectId;
55
- postponedToDate: string;
56
55
  transactionId: mongoose.Types.ObjectId;
56
+ postponedToDate: string;
57
57
  __v?: number;
58
58
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
59
59
  productId: mongoose.Types.ObjectId;
60
- postponedToDate: string;
61
60
  transactionId: mongoose.Types.ObjectId;
61
+ postponedToDate: string;
62
62
  __v?: number;
63
63
  }>> & mongoose.FlatRecord<{
64
64
  productId: mongoose.Types.ObjectId;
65
- postponedToDate: string;
66
65
  transactionId: mongoose.Types.ObjectId;
66
+ postponedToDate: string;
67
67
  __v?: number;
68
68
  }> & {
69
69
  _id: mongoose.Types.ObjectId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.53",
3
+ "version": "1.5.56",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -46,9 +46,9 @@ export declare class BrokersService {
46
46
  getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
47
47
  _id: import("mongoose").Types.ObjectId;
48
48
  }>)[]>;
49
- getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
49
+ getBorrowerBrokers(borrowerId: string): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
50
50
  _id: import("mongoose").Types.ObjectId;
51
- }>)[]>;
51
+ }>)[] | BrokerView[]>;
52
52
  getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithBroker[]>;
53
53
  getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
54
54
  getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
@@ -1,34 +1,7 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose" />
25
- /// <reference types="mongoose/types/inferschematype" />
26
- import { IOrganization } from '../models/Organization.model';
1
+ import { IOrganization, IOrganizationLean } from '../models/Organization.model';
27
2
  export declare class OrganizationsService {
28
3
  getOrganizations(): Promise<IOrganization[]>;
29
4
  createInitialOrganizations(): Promise<void>;
30
- getDefaultOrganization(): Promise<import("mongoose").FlattenMaps<IOrganization> & Required<{
31
- _id: import("mongoose").Types.ObjectId;
32
- }>>;
33
- getOrganizationForBorrower(borrowerId: string): Promise<IOrganization>;
5
+ getDefaultOrganization(): Promise<IOrganizationLean>;
6
+ getOrganizationForBorrower(borrowerId: string): Promise<IOrganizationLean>;
34
7
  }
@@ -56,15 +56,15 @@ class OrganizationsService {
56
56
  }));
57
57
  }
58
58
  async getDefaultOrganization() {
59
- return Organization_model_1.Organization.findOne({ isDefault: true }).lean();
59
+ return Organization_model_1.Organization.findOne({ isDefault: true }).lean().exec();
60
60
  }
61
61
  async getOrganizationForBorrower(borrowerId) {
62
- const borrower = await Borrower_model_1.BorrowerModel.findById(borrowerId).lean();
62
+ const borrower = await Borrower_model_1.BorrowerModel.findById(borrowerId).lean().exec();
63
63
  const defaultOrganization = await this.getDefaultOrganization();
64
64
  if (!borrower) {
65
65
  return defaultOrganization;
66
66
  }
67
- const organization = await Organization_model_1.Organization.findById(borrower.organizationId).lean();
67
+ const organization = await Organization_model_1.Organization.findById(borrower.organizationId).lean().exec();
68
68
  if (!organization) {
69
69
  return defaultOrganization;
70
70
  }
@@ -1,5 +1,5 @@
1
- import { IOrganization, Organization } from '../models/Organization.model';
2
- import { BorrowerModel } from '../models/Borrower.model';
1
+ import { IOrganization, IOrganizationLean, Organization } from '../models/Organization.model';
2
+ import { BorrowerModel, IBorrowerLean } from '../models/Borrower.model';
3
3
 
4
4
  import { fieldsToUnset, removeFields } from '../helpers/main.helper';
5
5
  import { IOrganizationEmail, OrganizationEmail, OrganizationEmailsType } from '../models/OrganizationEmails.model';
@@ -66,16 +66,16 @@ export class OrganizationsService {
66
66
  }
67
67
 
68
68
  async getDefaultOrganization() {
69
- return Organization.findOne({ isDefault: true }).lean();
69
+ return Organization.findOne({ isDefault: true }).lean<IOrganizationLean>().exec();
70
70
  }
71
71
 
72
- async getOrganizationForBorrower(borrowerId: string): Promise<IOrganization> {
73
- const borrower = await BorrowerModel.findById(borrowerId).lean();
72
+ async getOrganizationForBorrower(borrowerId: string) {
73
+ const borrower = await BorrowerModel.findById(borrowerId).lean<IBorrowerLean>().exec();
74
74
  const defaultOrganization = await this.getDefaultOrganization();
75
75
  if (!borrower) {
76
76
  return defaultOrganization;
77
77
  }
78
- const organization = await Organization.findById(borrower.organizationId).lean();
78
+ const organization = await Organization.findById(borrower.organizationId).lean<IOrganizationLean>().exec();
79
79
  if (!organization) {
80
80
  return defaultOrganization;
81
81
  }