gemcap-be-common 1.5.129 → 1.5.131
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/db/brokers.db.d.ts +10 -166
- package/db/brokers.db.js +5 -5
- package/db/brokers.db.ts +15 -15
- package/models/LoanBroker.model.d.ts +23 -49
- package/models/LoanBroker.model.js +17 -4
- package/models/LoanBroker.model.ts +40 -10
- package/models/ProductBroker.model.d.ts +19 -19
- package/models/ProductBroker.model.js +9 -3
- package/models/ProductBroker.model.ts +13 -10
- package/package.json +1 -1
- package/services/borrowers.service.d.ts +2 -2
- package/services/brokers.service.d.ts +12 -166
- package/services/brokers.service.js +12 -18
- package/services/brokers.service.ts +23 -25
- package/services/compliance-borrowers.service.d.ts +1 -1
- package/services/quickbooks.service.js +13 -13
- package/services/quickbooks.service.ts +18 -18
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ProductBroker = exports.ProductBrokerSchema = exports.ProductBrokerValidationSchema = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const joi_1 = __importDefault(require("joi"));
|
|
9
9
|
const _models_1 = require("./_models");
|
|
10
10
|
exports.ProductBrokerValidationSchema = joi_1.default.object({
|
|
11
|
-
_id: joi_1.default.string()
|
|
11
|
+
_id: joi_1.default.string(),
|
|
12
|
+
uiId: joi_1.default.string().required(),
|
|
12
13
|
order: joi_1.default.number(),
|
|
13
14
|
borrowerId: joi_1.default.string().required(),
|
|
14
15
|
active: joi_1.default.boolean().required(),
|
|
@@ -21,6 +22,11 @@ exports.ProductBrokerValidationSchema = joi_1.default.object({
|
|
|
21
22
|
otherShare: joi_1.default.number().required(),
|
|
22
23
|
});
|
|
23
24
|
exports.ProductBrokerSchema = new mongoose_1.default.Schema({
|
|
25
|
+
uiId: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
trim: true,
|
|
29
|
+
},
|
|
24
30
|
borrowerId: {
|
|
25
31
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
26
32
|
ref: _models_1.MODEL_NAMES.borrowers,
|
|
@@ -68,4 +74,4 @@ exports.ProductBrokerSchema = new mongoose_1.default.Schema({
|
|
|
68
74
|
},
|
|
69
75
|
__v: { type: Number, select: false },
|
|
70
76
|
}, { timestamps: true });
|
|
71
|
-
exports.
|
|
77
|
+
exports.ProductBroker = mongoose_1.default.model(_models_1.MODEL_NAMES.productBrokers, exports.ProductBrokerSchema);
|
|
@@ -2,10 +2,11 @@ import mongoose from 'mongoose';
|
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
|
|
4
4
|
import { MODEL_NAMES } from './_models';
|
|
5
|
-
import {
|
|
5
|
+
import { ILoanBrokerLean } from './LoanBroker.model';
|
|
6
6
|
|
|
7
7
|
export const ProductBrokerValidationSchema = Joi.object({
|
|
8
|
-
_id: Joi.string()
|
|
8
|
+
_id: Joi.string(),
|
|
9
|
+
uiId: Joi.string().required(),
|
|
9
10
|
order: Joi.number(),
|
|
10
11
|
borrowerId: Joi.string().required(),
|
|
11
12
|
active: Joi.boolean().required(),
|
|
@@ -19,6 +20,7 @@ export const ProductBrokerValidationSchema = Joi.object({
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
export interface IProductBroker {
|
|
23
|
+
uiId: string;
|
|
22
24
|
order: number;
|
|
23
25
|
borrowerId: mongoose.Types.ObjectId;
|
|
24
26
|
active: boolean;
|
|
@@ -31,11 +33,7 @@ export interface IProductBroker {
|
|
|
31
33
|
otherShare: number;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
export
|
|
35
|
-
_id: mongoose.Types.ObjectId;
|
|
36
|
-
createdAt: Date;
|
|
37
|
-
updatedAt: Date;
|
|
38
|
-
}
|
|
36
|
+
export type TProductBrokerDoc = mongoose.HydratedDocument<IProductBroker>;
|
|
39
37
|
|
|
40
38
|
export interface IProductBrokerLean extends IProductBroker {
|
|
41
39
|
_id: mongoose.Types.ObjectId;
|
|
@@ -50,8 +48,8 @@ export interface IProductBrokerPlain extends Omit<IProductBroker, 'borrowerId' |
|
|
|
50
48
|
productId: string;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
export interface
|
|
54
|
-
loanBroker:
|
|
51
|
+
export interface IProductBrokerDocWithLoanBroker extends TProductBrokerDoc {
|
|
52
|
+
loanBroker: ILoanBrokerLean;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
export type IProductBrokerView = Omit<IProductBrokerLean, 'borrowerId' | 'order'>
|
|
@@ -60,6 +58,11 @@ export type TProductBrokerModel = mongoose.Model<IProductBroker>;
|
|
|
60
58
|
|
|
61
59
|
export const ProductBrokerSchema = new mongoose.Schema(
|
|
62
60
|
{
|
|
61
|
+
uiId: {
|
|
62
|
+
type: String,
|
|
63
|
+
required: true,
|
|
64
|
+
trim: true,
|
|
65
|
+
},
|
|
63
66
|
borrowerId: {
|
|
64
67
|
type: mongoose.Schema.Types.ObjectId,
|
|
65
68
|
ref: MODEL_NAMES.borrowers,
|
|
@@ -110,4 +113,4 @@ export const ProductBrokerSchema = new mongoose.Schema(
|
|
|
110
113
|
{ timestamps: true },
|
|
111
114
|
);
|
|
112
115
|
|
|
113
|
-
export const
|
|
116
|
+
export const ProductBroker = mongoose.model<IProductBroker, TProductBrokerModel>(MODEL_NAMES.productBrokers, ProductBrokerSchema);
|
package/package.json
CHANGED
|
@@ -86,10 +86,10 @@ export declare class BorrowerService {
|
|
|
86
86
|
getBorrowerCodesMap(): Promise<Map<string, string>>;
|
|
87
87
|
getBorrowerStatementDetails(borrowers: IBorrowerDoc[]): Promise<{
|
|
88
88
|
[x: string]: {
|
|
89
|
-
SELECTED_PERIOD?: boolean;
|
|
90
|
-
ENTIRE_LOAN?: boolean;
|
|
91
89
|
LAST_MONTH?: boolean;
|
|
92
90
|
CURRENT_MONTH?: boolean;
|
|
91
|
+
ENTIRE_LOAN?: boolean;
|
|
92
|
+
SELECTED_PERIOD?: boolean;
|
|
93
93
|
TERM_LOAN?: boolean;
|
|
94
94
|
};
|
|
95
95
|
}>;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
/// <reference types="mongoose/types/types" />
|
|
2
|
-
/// <reference types="mongoose/types/document" />
|
|
3
|
-
/// <reference types="mongoose/types/models" />
|
|
4
|
-
/// <reference types="mongoose/types/collection" />
|
|
5
|
-
/// <reference types="mongoose/types/connection" />
|
|
6
|
-
/// <reference types="mongoose/types/query" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/populate" />
|
|
9
|
-
/// <reference types="mongoose/types/utility" />
|
|
10
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
11
2
|
/// <reference types="mongoose/types/aggregate" />
|
|
12
3
|
/// <reference types="mongoose/types/callback" />
|
|
13
4
|
/// <reference types="mongoose/types/collection" />
|
|
@@ -34,7 +25,7 @@
|
|
|
34
25
|
/// <reference types="mongoose" />
|
|
35
26
|
/// <reference types="mongoose/types/inferschematype" />
|
|
36
27
|
import { IProductBrokerView } from '../models/ProductBroker.model';
|
|
37
|
-
import {
|
|
28
|
+
import { ILoanBrokerPlain, ILoanBrokerEmailPlain } from '../models/LoanBroker.model';
|
|
38
29
|
import { LoanChargesService } from './loan-charges.service';
|
|
39
30
|
type BrokerView = Omit<IProductBrokerView, '_id'> & {
|
|
40
31
|
_id: string;
|
|
@@ -53,170 +44,25 @@ export declare class BrokersService {
|
|
|
53
44
|
private readonly loanChargesService;
|
|
54
45
|
constructor(loanChargesService: LoanChargesService);
|
|
55
46
|
normalizeObjects(): Promise<void>;
|
|
56
|
-
getAllProductBrokers(): Promise<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
|
|
60
|
-
_id: import("mongoose").Types.ObjectId;
|
|
61
|
-
}>)[]>;
|
|
62
|
-
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithBroker[]>;
|
|
47
|
+
getAllProductBrokers(): Promise<import("../models/ProductBroker.model").IProductBrokerLean[]>;
|
|
48
|
+
getBorrowerBrokers(borrowerId: string): Promise<import("../models/ProductBroker.model").IProductBrokerLean[] | BrokerView[]>;
|
|
49
|
+
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithLoanBroker[]>;
|
|
63
50
|
getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
|
|
64
51
|
getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
|
|
65
52
|
checkTotalShares(borrowerId: string, brokers: IProductBrokerView[]): Promise<boolean>;
|
|
66
53
|
saveProductBrokers(borrowerId: string, brokers: IProductBrokerView[]): Promise<import("mongodb").BulkWriteResult>;
|
|
67
54
|
getAllLoanBrokers(): Promise<{
|
|
68
|
-
emails: import("
|
|
55
|
+
emails: import("../models/LoanBroker.model").ILoanBrokerEmail[];
|
|
56
|
+
_id: import("mongoose").Types.ObjectId;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
uiId: string;
|
|
69
60
|
order: number;
|
|
70
61
|
active: boolean;
|
|
71
62
|
name: string;
|
|
72
|
-
_id: any;
|
|
73
|
-
__v?: any;
|
|
74
|
-
$assertPopulated: <Paths = {}>(path: string | string[], values?: Partial<Paths>) => Omit<import("../models/LoanBroker.model").ILoanBrokerDoc, keyof Paths> & Paths;
|
|
75
|
-
$clone: () => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
76
|
-
$getAllSubdocs: () => import("mongoose").Document<any, any, any>[];
|
|
77
|
-
$ignore: (path: string) => void;
|
|
78
|
-
$isDefault: (path: string) => boolean;
|
|
79
|
-
$isDeleted: (val?: boolean) => boolean;
|
|
80
|
-
$getPopulatedDocs: () => import("mongoose").Document<any, any, any>[];
|
|
81
|
-
$inc: (path: string | string[], val?: number) => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
82
|
-
$isEmpty: (path: string) => boolean;
|
|
83
|
-
$isValid: (path: string) => boolean;
|
|
84
|
-
$locals: import("mongoose").FlattenMaps<Record<string, unknown>>;
|
|
85
|
-
$markValid: (path: string) => void;
|
|
86
|
-
$model: {
|
|
87
|
-
<ModelType = import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown> & Required<{
|
|
88
|
-
_id: unknown;
|
|
89
|
-
}>, any>>(name: string): ModelType;
|
|
90
|
-
<ModelType_1 = import("mongoose").Model<any, {}, {}, {}, any, any>>(): ModelType_1;
|
|
91
|
-
};
|
|
92
|
-
$op: "save" | "validate" | "remove";
|
|
93
|
-
$session: (session?: import("mongodb").ClientSession) => import("mongodb").ClientSession;
|
|
94
|
-
$set: {
|
|
95
|
-
(path: string | Record<string, any>, val: any, type: any, options?: import("mongoose").DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
96
|
-
(path: string | Record<string, any>, val: any, options?: import("mongoose").DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
97
|
-
(value: string | Record<string, any>): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
98
|
-
};
|
|
99
|
-
$where: import("mongoose").FlattenMaps<Record<string, unknown>>;
|
|
100
|
-
baseModelName?: string;
|
|
101
|
-
collection: import("mongoose").Collection<import("bson").Document>;
|
|
102
|
-
db: import("mongoose").FlattenMaps<import("mongoose").Connection>;
|
|
103
|
-
deleteOne: (options?: import("mongoose").QueryOptions<unknown>) => any;
|
|
104
|
-
depopulate: (path?: string | string[]) => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
105
|
-
directModifiedPaths: () => string[];
|
|
106
|
-
equals: (doc: import("mongoose").Document<any, any, any>) => boolean;
|
|
107
|
-
errors?: import("mongoose").Error.ValidationError;
|
|
108
|
-
get: {
|
|
109
|
-
<T extends string | number | symbol>(path: T, type?: any, options?: any): any;
|
|
110
|
-
(path: string, type?: any, options?: any): any;
|
|
111
|
-
};
|
|
112
|
-
getChanges: () => import("mongoose").UpdateQuery<import("../models/LoanBroker.model").ILoanBrokerDoc>;
|
|
113
|
-
id?: any;
|
|
114
|
-
increment: () => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
115
|
-
init: (obj: import("mongoose").AnyObject, opts?: import("mongoose").AnyObject) => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
116
|
-
invalidate: {
|
|
117
|
-
<T_1 extends string | number | symbol>(path: T_1, errorMsg: string | NativeError, value?: any, kind?: string): NativeError;
|
|
118
|
-
(path: string, errorMsg: string | NativeError, value?: any, kind?: string): NativeError;
|
|
119
|
-
};
|
|
120
|
-
isDirectModified: {
|
|
121
|
-
<T_2 extends string | number | symbol>(path: T_2 | T_2[]): boolean;
|
|
122
|
-
(path: string | string[]): boolean;
|
|
123
|
-
};
|
|
124
|
-
isDirectSelected: {
|
|
125
|
-
<T_3 extends string | number | symbol>(path: T_3): boolean;
|
|
126
|
-
(path: string): boolean;
|
|
127
|
-
};
|
|
128
|
-
isInit: {
|
|
129
|
-
<T_4 extends string | number | symbol>(path: T_4): boolean;
|
|
130
|
-
(path: string): boolean;
|
|
131
|
-
};
|
|
132
|
-
isModified: {
|
|
133
|
-
<T_5 extends string | number | symbol>(path?: T_5 | T_5[], options?: {
|
|
134
|
-
ignoreAtomics?: boolean;
|
|
135
|
-
}): boolean;
|
|
136
|
-
(path?: string | string[], options?: {
|
|
137
|
-
ignoreAtomics?: boolean;
|
|
138
|
-
}): boolean;
|
|
139
|
-
};
|
|
140
|
-
isNew: boolean;
|
|
141
|
-
isSelected: {
|
|
142
|
-
<T_6 extends string | number | symbol>(path: T_6): boolean;
|
|
143
|
-
(path: string): boolean;
|
|
144
|
-
};
|
|
145
|
-
markModified: {
|
|
146
|
-
<T_7 extends string | number | symbol>(path: T_7, scope?: any): void;
|
|
147
|
-
(path: string, scope?: any): void;
|
|
148
|
-
};
|
|
149
|
-
model: {
|
|
150
|
-
<ModelType_2 = import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown> & Required<{
|
|
151
|
-
_id: unknown;
|
|
152
|
-
}>, any>>(name: string): ModelType_2;
|
|
153
|
-
<ModelType_3 = import("mongoose").Model<any, {}, {}, {}, any, any>>(): ModelType_3;
|
|
154
|
-
};
|
|
155
|
-
modifiedPaths: (options?: {
|
|
156
|
-
includeChildren?: boolean;
|
|
157
|
-
}) => string[];
|
|
158
|
-
overwrite: (obj: import("mongoose").AnyObject) => import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
159
|
-
$parent: () => import("mongoose").Document<any, any, any>;
|
|
160
|
-
populate: {
|
|
161
|
-
<Paths_1 = {}>(path: string | import("mongoose").PopulateOptions | (string | import("mongoose").PopulateOptions)[]): Promise<import("mongoose").MergeType<import("../models/LoanBroker.model").ILoanBrokerDoc, Paths_1>>;
|
|
162
|
-
<Paths_2 = {}>(path: string, select?: string | import("mongoose").AnyObject, model?: import("mongoose").Model<any, {}, {}, {}, any, any>, match?: import("mongoose").AnyObject, options?: import("mongoose").PopulateOptions): Promise<import("mongoose").MergeType<import("../models/LoanBroker.model").ILoanBrokerDoc, Paths_2>>;
|
|
163
|
-
};
|
|
164
|
-
populated: (path: string) => any;
|
|
165
|
-
replaceOne: (replacement?: import("mongoose").AnyObject, options?: import("mongoose").QueryOptions<unknown>) => import("mongoose").Query<any, import("../models/LoanBroker.model").ILoanBrokerDoc, {}, import("../models/LoanBroker.model").ILoanBrokerDoc, "find">;
|
|
166
|
-
save: (options?: import("mongoose").SaveOptions) => Promise<import("../models/LoanBroker.model").ILoanBrokerDoc>;
|
|
167
|
-
schema: import("mongoose").FlattenMaps<import("mongoose").Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
|
|
168
|
-
[x: string]: unknown;
|
|
169
|
-
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
170
|
-
[x: string]: unknown;
|
|
171
|
-
}>> & import("mongoose").FlatRecord<{
|
|
172
|
-
[x: string]: unknown;
|
|
173
|
-
}> & Required<{
|
|
174
|
-
_id: unknown;
|
|
175
|
-
}>>>;
|
|
176
|
-
set: {
|
|
177
|
-
<T_8 extends string | number | symbol>(path: T_8, val: any, type: any, options?: import("mongoose").DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
178
|
-
(path: string | Record<string, any>, val: any, type: any, options?: import("mongoose").DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
179
|
-
(path: string | Record<string, any>, val: any, options?: import("mongoose").DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
180
|
-
(value: string | Record<string, any>): import("../models/LoanBroker.model").ILoanBrokerDoc;
|
|
181
|
-
};
|
|
182
|
-
toJSON: {
|
|
183
|
-
<T_9 = any>(options?: import("mongoose").ToObjectOptions<import("mongoose").Document<unknown, {}, unknown> & Required<{
|
|
184
|
-
_id: unknown;
|
|
185
|
-
}>> & {
|
|
186
|
-
flattenMaps?: true;
|
|
187
|
-
}): import("mongoose").FlattenMaps<T_9>;
|
|
188
|
-
<T_10 = any>(options: import("mongoose").ToObjectOptions<import("mongoose").Document<unknown, {}, unknown> & Required<{
|
|
189
|
-
_id: unknown;
|
|
190
|
-
}>> & {
|
|
191
|
-
flattenMaps: false;
|
|
192
|
-
}): T_10;
|
|
193
|
-
};
|
|
194
|
-
toObject: <T_11 = any>(options?: import("mongoose").ToObjectOptions<import("mongoose").Document<unknown, {}, unknown> & Required<{
|
|
195
|
-
_id: unknown;
|
|
196
|
-
}>>) => import("mongoose").Require_id<T_11>;
|
|
197
|
-
unmarkModified: {
|
|
198
|
-
<T_12 extends string | number | symbol>(path: T_12): void;
|
|
199
|
-
(path: string): void;
|
|
200
|
-
};
|
|
201
|
-
updateOne: (update?: import("mongoose").UpdateWithAggregationPipeline | import("mongoose").UpdateQuery<import("../models/LoanBroker.model").ILoanBrokerDoc>, options?: import("mongoose").QueryOptions<unknown>) => import("mongoose").Query<any, import("../models/LoanBroker.model").ILoanBrokerDoc, {}, import("../models/LoanBroker.model").ILoanBrokerDoc, "find">;
|
|
202
|
-
validate: {
|
|
203
|
-
<T_13 extends string | number | symbol>(pathsToValidate?: T_13 | T_13[], options?: import("mongoose").AnyObject): Promise<void>;
|
|
204
|
-
(pathsToValidate?: import("mongoose").PathsToValidate, options?: import("mongoose").AnyObject): Promise<void>;
|
|
205
|
-
(options: {
|
|
206
|
-
pathsToSkip?: import("mongoose").pathsToSkip;
|
|
207
|
-
}): Promise<void>;
|
|
208
|
-
};
|
|
209
|
-
validateSync: {
|
|
210
|
-
(options: {
|
|
211
|
-
[k: string]: any;
|
|
212
|
-
pathsToSkip?: import("mongoose").pathsToSkip;
|
|
213
|
-
}): import("mongoose").Error.ValidationError;
|
|
214
|
-
<T_14 extends string | number | symbol>(pathsToValidate?: T_14 | T_14[], options?: import("mongoose").AnyObject): import("mongoose").Error.ValidationError;
|
|
215
|
-
(pathsToValidate?: import("mongoose").PathsToValidate, options?: import("mongoose").AnyObject): import("mongoose").Error.ValidationError;
|
|
216
|
-
};
|
|
217
63
|
}[]>;
|
|
218
|
-
saveLoanBrokers(brokers:
|
|
219
|
-
saveLoanBroker(broker: Partial<
|
|
220
|
-
saveLoanBrokerEmails(loanBrokerId: string, emails:
|
|
64
|
+
saveLoanBrokers(brokers: ILoanBrokerPlain[]): Promise<void>;
|
|
65
|
+
saveLoanBroker(broker: Partial<ILoanBrokerPlain>, order: number): Promise<void>;
|
|
66
|
+
saveLoanBrokerEmails(loanBrokerId: string, emails: ILoanBrokerEmailPlain[]): Promise<void>;
|
|
221
67
|
}
|
|
222
68
|
export {};
|
|
@@ -12,7 +12,8 @@ const brokers_db_2 = require("../db/brokers.db");
|
|
|
12
12
|
const main_helper_1 = require("../helpers/main.helper");
|
|
13
13
|
const defaultBrokerList = [
|
|
14
14
|
{
|
|
15
|
-
_id:
|
|
15
|
+
_id: (0, main_helper_1.getUUID)(),
|
|
16
|
+
uiId: (0, main_helper_1.getUUID)(),
|
|
16
17
|
active: true,
|
|
17
18
|
BSCode: '',
|
|
18
19
|
PLCode: '',
|
|
@@ -32,7 +33,7 @@ class BrokersService {
|
|
|
32
33
|
}
|
|
33
34
|
async normalizeObjects() {
|
|
34
35
|
try {
|
|
35
|
-
await LoanBroker_model_1.
|
|
36
|
+
await LoanBroker_model_1.LoanBroker.updateMany({}, { emails: [] });
|
|
36
37
|
}
|
|
37
38
|
catch (e) {
|
|
38
39
|
console.error(e);
|
|
@@ -77,7 +78,7 @@ class BrokersService {
|
|
|
77
78
|
return productShares;
|
|
78
79
|
}
|
|
79
80
|
async getTotals(borrowerId) {
|
|
80
|
-
const brokers = await ProductBroker_model_1.
|
|
81
|
+
const brokers = await ProductBroker_model_1.ProductBroker.find({ borrowerId });
|
|
81
82
|
const shortTotals = await this.getTotalShares(borrowerId, brokers, true);
|
|
82
83
|
return Object.entries(shortTotals).map(([product, shares]) => {
|
|
83
84
|
return {
|
|
@@ -100,9 +101,9 @@ class BrokersService {
|
|
|
100
101
|
const existingBrokers = await (0, brokers_db_2.getBorrowerBrokers)(borrowerId);
|
|
101
102
|
const existingBrokerIds = existingBrokers.map((broker) => broker._id.toString());
|
|
102
103
|
const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
|
|
103
|
-
await ProductBroker_model_1.
|
|
104
|
+
await ProductBroker_model_1.ProductBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
104
105
|
const brokersToSave = brokers.map((broker) => {
|
|
105
|
-
if (broker._id
|
|
106
|
+
if (!broker._id) {
|
|
106
107
|
let { _id, ...brokerWithoutId } = broker;
|
|
107
108
|
return { ...brokerWithoutId, borrowerId: borrowerId };
|
|
108
109
|
}
|
|
@@ -112,7 +113,7 @@ class BrokersService {
|
|
|
112
113
|
return broker.hasOwnProperty('_id') ? { _id: broker._id } : { createdAt: Math.random() };
|
|
113
114
|
};
|
|
114
115
|
try {
|
|
115
|
-
return ProductBroker_model_1.
|
|
116
|
+
return ProductBroker_model_1.ProductBroker.bulkWrite(brokersToSave.map((broker, order) => ({
|
|
116
117
|
updateOne: {
|
|
117
118
|
filter: getFilters(broker),
|
|
118
119
|
update: { $set: { ...broker, order } },
|
|
@@ -131,15 +132,8 @@ class BrokersService {
|
|
|
131
132
|
const existingBrokers = await (0, brokers_db_2.getAllLoanBrokers)();
|
|
132
133
|
const existingBrokerIds = existingBrokers.map((broker) => broker._id.toString());
|
|
133
134
|
const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
|
|
134
|
-
await LoanBroker_model_1.
|
|
135
|
-
|
|
136
|
-
if (broker._id.toString().startsWith('new_')) {
|
|
137
|
-
let { _id, ...brokerWithoutId } = broker;
|
|
138
|
-
return brokerWithoutId;
|
|
139
|
-
}
|
|
140
|
-
return broker;
|
|
141
|
-
});
|
|
142
|
-
await Promise.all(brokersToSave.map(async (brokerToSave, order) => {
|
|
135
|
+
await LoanBroker_model_1.LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
136
|
+
await Promise.all(brokers.map(async (brokerToSave, order) => {
|
|
143
137
|
await this.saveLoanBroker(brokerToSave, order);
|
|
144
138
|
}));
|
|
145
139
|
}
|
|
@@ -148,15 +142,15 @@ class BrokersService {
|
|
|
148
142
|
return broker.hasOwnProperty('_id') ? { _id: broker._id } : { createdAt: Math.random() };
|
|
149
143
|
};
|
|
150
144
|
const { emails, ...update } = broker;
|
|
151
|
-
const updatedBroker = await LoanBroker_model_1.
|
|
145
|
+
const updatedBroker = await LoanBroker_model_1.LoanBroker.findOneAndUpdate(getFilters(broker), { ...update, order }, { upsert: true, new: true });
|
|
152
146
|
await this.saveLoanBrokerEmails(updatedBroker._id.toString(), emails);
|
|
153
147
|
}
|
|
154
148
|
async saveLoanBrokerEmails(loanBrokerId, emails) {
|
|
155
149
|
const emailsWithoutId = emails.map((email) => {
|
|
156
150
|
const { _id, ...rest } = email;
|
|
157
|
-
return
|
|
151
|
+
return rest;
|
|
158
152
|
});
|
|
159
|
-
await LoanBroker_model_1.
|
|
153
|
+
await LoanBroker_model_1.LoanBroker.findByIdAndUpdate(loanBrokerId, { emails: emailsWithoutId });
|
|
160
154
|
}
|
|
161
155
|
}
|
|
162
156
|
exports.BrokersService = BrokersService;
|
|
@@ -2,9 +2,13 @@ import Decimal from 'decimal.js';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
IProductBrokerView,
|
|
5
|
-
|
|
5
|
+
ProductBroker,
|
|
6
6
|
} from '../models/ProductBroker.model';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ILoanBrokerPlain,
|
|
9
|
+
ILoanBrokerEmailPlain,
|
|
10
|
+
LoanBroker,
|
|
11
|
+
} from '../models/LoanBroker.model';
|
|
8
12
|
import { getProductBrokers } from '../db/brokers.db';
|
|
9
13
|
|
|
10
14
|
import { getAllLoanBrokers, getAllProductBrokers, getBorrowerBrokers } from '../db/brokers.db';
|
|
@@ -16,7 +20,8 @@ type BrokerTotalView = Omit<IProductBrokerView, 'productId'> & { productId: stri
|
|
|
16
20
|
|
|
17
21
|
const defaultBrokerList: BrokerView[] = [
|
|
18
22
|
{
|
|
19
|
-
_id:
|
|
23
|
+
_id: getUUID(),
|
|
24
|
+
uiId: getUUID(),
|
|
20
25
|
active: true,
|
|
21
26
|
BSCode: '',
|
|
22
27
|
PLCode: '',
|
|
@@ -49,7 +54,7 @@ export class BrokersService {
|
|
|
49
54
|
|
|
50
55
|
async normalizeObjects() {
|
|
51
56
|
try {
|
|
52
|
-
await
|
|
57
|
+
await LoanBroker.updateMany({}, { emails: [] });
|
|
53
58
|
} catch (e) {
|
|
54
59
|
console.error(e);
|
|
55
60
|
}
|
|
@@ -100,7 +105,7 @@ export class BrokersService {
|
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
async getTotals(borrowerId: string) {
|
|
103
|
-
const brokers = await
|
|
108
|
+
const brokers = await ProductBroker.find({ borrowerId }) as IProductBrokerView[];
|
|
104
109
|
const shortTotals = await this.getTotalShares(borrowerId, brokers, true);
|
|
105
110
|
return Object.entries(shortTotals).map(([product, shares]) => {
|
|
106
111
|
return <BrokerTotalView>{
|
|
@@ -126,10 +131,10 @@ export class BrokersService {
|
|
|
126
131
|
|
|
127
132
|
const existingBrokerIds = existingBrokers.map((broker) => broker._id.toString());
|
|
128
133
|
const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
|
|
129
|
-
await
|
|
134
|
+
await ProductBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
130
135
|
|
|
131
136
|
const brokersToSave = brokers.map((broker) => {
|
|
132
|
-
if (broker._id
|
|
137
|
+
if (!broker._id) {
|
|
133
138
|
let { _id, ...brokerWithoutId } = broker;
|
|
134
139
|
return { ...brokerWithoutId, borrowerId: borrowerId };
|
|
135
140
|
}
|
|
@@ -141,7 +146,7 @@ export class BrokersService {
|
|
|
141
146
|
};
|
|
142
147
|
|
|
143
148
|
try {
|
|
144
|
-
return
|
|
149
|
+
return ProductBroker.bulkWrite(
|
|
145
150
|
brokersToSave.map((broker, order) => ({
|
|
146
151
|
updateOne: {
|
|
147
152
|
filter: getFilters(broker),
|
|
@@ -159,32 +164,25 @@ export class BrokersService {
|
|
|
159
164
|
return getAllLoanBrokers();
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
async saveLoanBrokers(brokers:
|
|
167
|
+
async saveLoanBrokers(brokers: ILoanBrokerPlain[]) {
|
|
163
168
|
const existingBrokers = await getAllLoanBrokers();
|
|
164
169
|
|
|
165
170
|
const existingBrokerIds = existingBrokers.map((broker) => broker._id.toString());
|
|
166
171
|
const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
|
|
167
|
-
await
|
|
168
|
-
|
|
169
|
-
const brokersToSave = brokers.map((broker) => {
|
|
170
|
-
if (broker._id.toString().startsWith('new_')) {
|
|
171
|
-
let { _id, ...brokerWithoutId } = broker;
|
|
172
|
-
return brokerWithoutId;
|
|
173
|
-
}
|
|
174
|
-
return broker;
|
|
175
|
-
});
|
|
172
|
+
await LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
176
173
|
|
|
177
|
-
await Promise.all(
|
|
174
|
+
await Promise.all(brokers.map(async (brokerToSave, order) => {
|
|
178
175
|
await this.saveLoanBroker(brokerToSave, order);
|
|
179
176
|
}));
|
|
180
177
|
}
|
|
181
178
|
|
|
182
|
-
async saveLoanBroker(broker: Partial<
|
|
183
|
-
const getFilters = (broker: Partial<
|
|
179
|
+
async saveLoanBroker(broker: Partial<ILoanBrokerPlain>, order: number) {
|
|
180
|
+
const getFilters = (broker: Partial<ILoanBrokerPlain>) => {
|
|
184
181
|
return broker.hasOwnProperty('_id') ? { _id: broker._id } : { createdAt: Math.random() };
|
|
185
182
|
};
|
|
183
|
+
|
|
186
184
|
const { emails, ...update } = broker;
|
|
187
|
-
const updatedBroker = await
|
|
185
|
+
const updatedBroker = await LoanBroker.findOneAndUpdate(
|
|
188
186
|
getFilters(broker),
|
|
189
187
|
{ ...update, order },
|
|
190
188
|
{ upsert: true, new: true },
|
|
@@ -192,11 +190,11 @@ export class BrokersService {
|
|
|
192
190
|
await this.saveLoanBrokerEmails(updatedBroker._id.toString(), emails);
|
|
193
191
|
}
|
|
194
192
|
|
|
195
|
-
async saveLoanBrokerEmails(loanBrokerId: string, emails:
|
|
193
|
+
async saveLoanBrokerEmails(loanBrokerId: string, emails: ILoanBrokerEmailPlain[]) {
|
|
196
194
|
const emailsWithoutId = emails.map((email) => {
|
|
197
195
|
const { _id, ...rest } = email;
|
|
198
|
-
return
|
|
196
|
+
return rest;
|
|
199
197
|
});
|
|
200
|
-
await
|
|
198
|
+
await LoanBroker.findByIdAndUpdate(loanBrokerId, { emails: emailsWithoutId });
|
|
201
199
|
}
|
|
202
200
|
}
|
|
@@ -60,7 +60,7 @@ export declare class ComplianceBorrowersService {
|
|
|
60
60
|
isComplianceBorrowerAllowed(userAccess: IUserAccess, requestedBorrowerId: string): boolean;
|
|
61
61
|
calculateInstanceStatuses(instance: IBorrowerItemInstance, item: IBorrowerItemLean): IInstanceStatus;
|
|
62
62
|
getFullComplianceBorrowerById(complianceBorrowerId: string): Promise<IComplianceBorrowerDocumentFullWithStatuses>;
|
|
63
|
-
getAllBorrowersShortened(userAccess: IUserAccess): Promise<Pick<IComplianceBorrowerWithBorrower, "borrower" | "
|
|
63
|
+
getAllBorrowersShortened(userAccess: IUserAccess): Promise<Pick<IComplianceBorrowerWithBorrower, "borrower" | "items" | "fundingStatus">[]>;
|
|
64
64
|
generateInstances(complianceBorrowerId: any): Promise<IComplianceBorrowerDocumentFullWithStatuses>;
|
|
65
65
|
calculateAndUpdateFundingStatus(complianceBorrowerId: string): Promise<void>;
|
|
66
66
|
calculateFundingStatus(complianceBorrower: IComplianceBorrowerDocumentFull): string;
|
|
@@ -261,14 +261,14 @@ class QuickbooksService {
|
|
|
261
261
|
}
|
|
262
262
|
const transactionsFilter = {
|
|
263
263
|
productIds: productIds,
|
|
264
|
-
start:
|
|
265
|
-
end:
|
|
264
|
+
start: dayjs_1.default.utc(reportDate).startOf('month').toDate(),
|
|
265
|
+
end: dayjs_1.default.utc(reportDate).endOf('month').toDate(),
|
|
266
266
|
};
|
|
267
267
|
return await this.loanChargesService.getLoanStatementsForProduct(transactionsFilter);
|
|
268
268
|
}
|
|
269
269
|
async getChargeTransactionsForPayments(productIds, reportDate) {
|
|
270
|
-
const start =
|
|
271
|
-
const end =
|
|
270
|
+
const start = dayjs_1.default.utc(reportDate).startOf('day').toDate();
|
|
271
|
+
const end = dayjs_1.default.utc(reportDate).endOf('day').toDate();
|
|
272
272
|
const payments = await this.loanPaymentsService.getPaymentsForPeriod(productIds, start, end);
|
|
273
273
|
if (!payments.length) {
|
|
274
274
|
return [];
|
|
@@ -278,8 +278,8 @@ class QuickbooksService {
|
|
|
278
278
|
return await this.loanChargesService.getLoanStatementsForIdsAndCharge(transactionsFilter);
|
|
279
279
|
}
|
|
280
280
|
async getPrincipalTransactionsForPayments(productId, reportDate) {
|
|
281
|
-
const start =
|
|
282
|
-
const end =
|
|
281
|
+
const start = dayjs_1.default.utc(reportDate).startOf('day').toDate();
|
|
282
|
+
const end = dayjs_1.default.utc(reportDate).endOf('day').toDate();
|
|
283
283
|
const payments = await this.loanPaymentsService.getPaymentsForPeriod([productId], start, end);
|
|
284
284
|
if (!payments.length) {
|
|
285
285
|
return {};
|
|
@@ -309,9 +309,9 @@ class QuickbooksService {
|
|
|
309
309
|
}
|
|
310
310
|
const companyFilter = { companyId: { $in: params.companyIds.map((id) => new mongoose_1.default.Types.ObjectId(id)) } };
|
|
311
311
|
const { reportType, productIds, chargeTypes, reportDate } = params;
|
|
312
|
-
const reportDateFormatted =
|
|
313
|
-
const reportDateTrFormatted =
|
|
314
|
-
const currentDateTrFormatted =
|
|
312
|
+
const reportDateFormatted = dayjs_1.default.utc(reportDate).format('MM/DD/YYYY').toUpperCase();
|
|
313
|
+
const reportDateTrFormatted = dayjs_1.default.utc(reportDate).format(transactionsDateFormat).toUpperCase();
|
|
314
|
+
const currentDateTrFormatted = dayjs_1.default.utc(new Date).format(transactionsDateFormat).toUpperCase();
|
|
315
315
|
const isAccrual = reportType === 'accrual';
|
|
316
316
|
const mainData = [];
|
|
317
317
|
const trTemplate = {
|
|
@@ -483,10 +483,10 @@ class QuickbooksService {
|
|
|
483
483
|
async getQuickbooksCashReport(params) {
|
|
484
484
|
const reportErrorsSet = new Set();
|
|
485
485
|
const { reportType, productIds, chargeTypes, reportDate } = params;
|
|
486
|
-
const reportDateFormatted =
|
|
487
|
-
const reportDateTrFormatted =
|
|
488
|
-
const startDate =
|
|
489
|
-
const endDate =
|
|
486
|
+
const reportDateFormatted = dayjs_1.default.utc(reportDate).format('MM/DD/YYYY').toUpperCase();
|
|
487
|
+
const reportDateTrFormatted = dayjs_1.default.utc(reportDate).format(transactionsDateFormat).toUpperCase();
|
|
488
|
+
const startDate = dayjs_1.default.utc(reportDate).startOf('day').toDate();
|
|
489
|
+
const endDate = dayjs_1.default.utc(reportDate).endOf('day').toDate();
|
|
490
490
|
const transactions = await this.bankUploadedTransactionsService.getUploadedBankTransactions(startDate, endDate);
|
|
491
491
|
const { references, products } = await this.cashAllocationService.getAllCashAllocations();
|
|
492
492
|
const allAccounts = await this.getAllAccounts();
|