gemcap-be-common 1.5.128 → 1.5.130
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 -162
- package/db/brokers.db.js +5 -5
- package/db/brokers.db.ts +11 -11
- package/models/AiJob.model.d.ts +3 -0
- package/models/AiJob.model.js +17 -1
- package/models/AiJob.model.ts +22 -0
- 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 -164
- package/services/brokers.service.js +11 -10
- package/services/brokers.service.ts +22 -16
- package/services/loan-transactions.service.d.ts +1 -1
- package/services/quickbooks.service.js +13 -13
- package/services/quickbooks.service.ts +18 -18
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="mongoose/types/types" />
|
|
2
|
-
/// <reference types="mongoose/types/document" />
|
|
3
2
|
/// <reference types="mongoose/types/models" />
|
|
4
3
|
/// <reference types="mongoose/types/utility" />
|
|
4
|
+
/// <reference types="mongoose/types/document" />
|
|
5
5
|
/// <reference types="mongoose/types/aggregate" />
|
|
6
6
|
/// <reference types="mongoose/types/callback" />
|
|
7
7
|
/// <reference types="mongoose/types/collection" />
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
/// <reference types="mongoose/types/inferschematype" />
|
|
29
29
|
import mongoose from 'mongoose';
|
|
30
30
|
import Joi from 'joi';
|
|
31
|
-
import {
|
|
31
|
+
import { ILoanBrokerLean } from './LoanBroker.model';
|
|
32
32
|
export declare const ProductBrokerValidationSchema: Joi.ObjectSchema<any>;
|
|
33
33
|
export interface IProductBroker {
|
|
34
|
+
uiId: string;
|
|
34
35
|
order: number;
|
|
35
36
|
borrowerId: mongoose.Types.ObjectId;
|
|
36
37
|
active: boolean;
|
|
@@ -42,11 +43,7 @@ export interface IProductBroker {
|
|
|
42
43
|
adminShare: number;
|
|
43
44
|
otherShare: number;
|
|
44
45
|
}
|
|
45
|
-
export
|
|
46
|
-
_id: mongoose.Types.ObjectId;
|
|
47
|
-
createdAt: Date;
|
|
48
|
-
updatedAt: Date;
|
|
49
|
-
}
|
|
46
|
+
export type TProductBrokerDoc = mongoose.HydratedDocument<IProductBroker>;
|
|
50
47
|
export interface IProductBrokerLean extends IProductBroker {
|
|
51
48
|
_id: mongoose.Types.ObjectId;
|
|
52
49
|
createdAt: Date;
|
|
@@ -58,8 +55,8 @@ export interface IProductBrokerPlain extends Omit<IProductBroker, 'borrowerId' |
|
|
|
58
55
|
loanBrokerId: string;
|
|
59
56
|
productId: string;
|
|
60
57
|
}
|
|
61
|
-
export interface
|
|
62
|
-
loanBroker:
|
|
58
|
+
export interface IProductBrokerDocWithLoanBroker extends TProductBrokerDoc {
|
|
59
|
+
loanBroker: ILoanBrokerLean;
|
|
63
60
|
}
|
|
64
61
|
export type IProductBrokerView = Omit<IProductBrokerLean, 'borrowerId' | 'order'>;
|
|
65
62
|
export type TProductBrokerModel = mongoose.Model<IProductBroker>;
|
|
@@ -69,13 +66,14 @@ export declare const ProductBrokerSchema: mongoose.Schema<any, mongoose.Model<an
|
|
|
69
66
|
createdAt: NativeDate;
|
|
70
67
|
updatedAt: NativeDate;
|
|
71
68
|
} & {
|
|
72
|
-
|
|
73
|
-
productId: mongoose.Types.ObjectId;
|
|
69
|
+
uiId: string;
|
|
74
70
|
order: number;
|
|
71
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
75
72
|
active: boolean;
|
|
76
|
-
PLCode: string;
|
|
77
73
|
loanBrokerId: mongoose.Types.ObjectId;
|
|
78
74
|
BSCode: string;
|
|
75
|
+
PLCode: string;
|
|
76
|
+
productId: mongoose.Types.ObjectId;
|
|
79
77
|
interestShare: number;
|
|
80
78
|
adminShare: number;
|
|
81
79
|
otherShare: number;
|
|
@@ -84,13 +82,14 @@ export declare const ProductBrokerSchema: mongoose.Schema<any, mongoose.Model<an
|
|
|
84
82
|
createdAt: NativeDate;
|
|
85
83
|
updatedAt: NativeDate;
|
|
86
84
|
} & {
|
|
87
|
-
|
|
88
|
-
productId: mongoose.Types.ObjectId;
|
|
85
|
+
uiId: string;
|
|
89
86
|
order: number;
|
|
87
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
90
88
|
active: boolean;
|
|
91
|
-
PLCode: string;
|
|
92
89
|
loanBrokerId: mongoose.Types.ObjectId;
|
|
93
90
|
BSCode: string;
|
|
91
|
+
PLCode: string;
|
|
92
|
+
productId: mongoose.Types.ObjectId;
|
|
94
93
|
interestShare: number;
|
|
95
94
|
adminShare: number;
|
|
96
95
|
otherShare: number;
|
|
@@ -99,13 +98,14 @@ export declare const ProductBrokerSchema: mongoose.Schema<any, mongoose.Model<an
|
|
|
99
98
|
createdAt: NativeDate;
|
|
100
99
|
updatedAt: NativeDate;
|
|
101
100
|
} & {
|
|
102
|
-
|
|
103
|
-
productId: mongoose.Types.ObjectId;
|
|
101
|
+
uiId: string;
|
|
104
102
|
order: number;
|
|
103
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
105
104
|
active: boolean;
|
|
106
|
-
PLCode: string;
|
|
107
105
|
loanBrokerId: mongoose.Types.ObjectId;
|
|
108
106
|
BSCode: string;
|
|
107
|
+
PLCode: string;
|
|
108
|
+
productId: mongoose.Types.ObjectId;
|
|
109
109
|
interestShare: number;
|
|
110
110
|
adminShare: number;
|
|
111
111
|
otherShare: number;
|
|
@@ -113,4 +113,4 @@ export declare const ProductBrokerSchema: mongoose.Schema<any, mongoose.Model<an
|
|
|
113
113
|
}> & {
|
|
114
114
|
_id: mongoose.Types.ObjectId;
|
|
115
115
|
}>;
|
|
116
|
-
export declare const
|
|
116
|
+
export declare const ProductBroker: TProductBrokerModel;
|
|
@@ -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
89
|
ENTIRE_LOAN?: boolean;
|
|
91
|
-
|
|
90
|
+
SELECTED_PERIOD?: boolean;
|
|
92
91
|
CURRENT_MONTH?: boolean;
|
|
92
|
+
LAST_MONTH?: 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,27 @@ export declare class BrokersService {
|
|
|
53
44
|
private readonly loanChargesService;
|
|
54
45
|
constructor(loanChargesService: LoanChargesService);
|
|
55
46
|
normalizeObjects(): Promise<void>;
|
|
56
|
-
getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").
|
|
47
|
+
getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
|
|
57
48
|
_id: import("mongoose").Types.ObjectId;
|
|
58
|
-
}
|
|
59
|
-
getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").
|
|
49
|
+
})[]>;
|
|
50
|
+
getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
|
|
60
51
|
_id: import("mongoose").Types.ObjectId;
|
|
61
|
-
}
|
|
62
|
-
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").
|
|
52
|
+
})[]>;
|
|
53
|
+
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithLoanBroker[]>;
|
|
63
54
|
getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
|
|
64
55
|
getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
|
|
65
56
|
checkTotalShares(borrowerId: string, brokers: IProductBrokerView[]): Promise<boolean>;
|
|
66
57
|
saveProductBrokers(borrowerId: string, brokers: IProductBrokerView[]): Promise<import("mongodb").BulkWriteResult>;
|
|
67
58
|
getAllLoanBrokers(): Promise<{
|
|
68
|
-
emails: import("mongoose").FlattenMaps<ILoanBrokerEmail>[];
|
|
59
|
+
emails: import("mongoose").FlattenMaps<import("../models/LoanBroker.model").ILoanBrokerEmail>[];
|
|
60
|
+
uiId: string;
|
|
69
61
|
order: number;
|
|
70
62
|
active: boolean;
|
|
71
63
|
name: string;
|
|
72
|
-
_id:
|
|
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
|
-
};
|
|
64
|
+
_id: import("mongoose").Types.ObjectId;
|
|
217
65
|
}[]>;
|
|
218
|
-
saveLoanBrokers(brokers:
|
|
219
|
-
saveLoanBroker(broker: Partial<
|
|
220
|
-
saveLoanBrokerEmails(loanBrokerId: string, emails:
|
|
66
|
+
saveLoanBrokers(brokers: ILoanBrokerPlain[]): Promise<void>;
|
|
67
|
+
saveLoanBroker(broker: Partial<ILoanBrokerPlain>, order: number): Promise<void>;
|
|
68
|
+
saveLoanBrokerEmails(loanBrokerId: string, emails: ILoanBrokerEmailPlain[]): Promise<void>;
|
|
221
69
|
}
|
|
222
70
|
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,7 +132,7 @@ 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
|
+
await LoanBroker_model_1.LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
135
136
|
const brokersToSave = brokers.map((broker) => {
|
|
136
137
|
if (broker._id.toString().startsWith('new_')) {
|
|
137
138
|
let { _id, ...brokerWithoutId } = broker;
|
|
@@ -148,15 +149,15 @@ class BrokersService {
|
|
|
148
149
|
return broker.hasOwnProperty('_id') ? { _id: broker._id } : { createdAt: Math.random() };
|
|
149
150
|
};
|
|
150
151
|
const { emails, ...update } = broker;
|
|
151
|
-
const updatedBroker = await LoanBroker_model_1.
|
|
152
|
+
const updatedBroker = await LoanBroker_model_1.LoanBroker.findOneAndUpdate(getFilters(broker), { ...update, order }, { upsert: true, new: true });
|
|
152
153
|
await this.saveLoanBrokerEmails(updatedBroker._id.toString(), emails);
|
|
153
154
|
}
|
|
154
155
|
async saveLoanBrokerEmails(loanBrokerId, emails) {
|
|
155
156
|
const emailsWithoutId = emails.map((email) => {
|
|
156
157
|
const { _id, ...rest } = email;
|
|
157
|
-
return
|
|
158
|
+
return rest;
|
|
158
159
|
});
|
|
159
|
-
await LoanBroker_model_1.
|
|
160
|
+
await LoanBroker_model_1.LoanBroker.findByIdAndUpdate(loanBrokerId, { emails: emailsWithoutId });
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
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,12 +164,12 @@ 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
|
|
172
|
+
await LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
|
|
168
173
|
|
|
169
174
|
const brokersToSave = brokers.map((broker) => {
|
|
170
175
|
if (broker._id.toString().startsWith('new_')) {
|
|
@@ -179,12 +184,13 @@ export class BrokersService {
|
|
|
179
184
|
}));
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
async saveLoanBroker(broker: Partial<
|
|
183
|
-
const getFilters = (broker: Partial<
|
|
187
|
+
async saveLoanBroker(broker: Partial<ILoanBrokerPlain>, order: number) {
|
|
188
|
+
const getFilters = (broker: Partial<ILoanBrokerPlain>) => {
|
|
184
189
|
return broker.hasOwnProperty('_id') ? { _id: broker._id } : { createdAt: Math.random() };
|
|
185
190
|
};
|
|
191
|
+
|
|
186
192
|
const { emails, ...update } = broker;
|
|
187
|
-
const updatedBroker = await
|
|
193
|
+
const updatedBroker = await LoanBroker.findOneAndUpdate(
|
|
188
194
|
getFilters(broker),
|
|
189
195
|
{ ...update, order },
|
|
190
196
|
{ upsert: true, new: true },
|
|
@@ -192,11 +198,11 @@ export class BrokersService {
|
|
|
192
198
|
await this.saveLoanBrokerEmails(updatedBroker._id.toString(), emails);
|
|
193
199
|
}
|
|
194
200
|
|
|
195
|
-
async saveLoanBrokerEmails(loanBrokerId: string, emails:
|
|
201
|
+
async saveLoanBrokerEmails(loanBrokerId: string, emails: ILoanBrokerEmailPlain[]) {
|
|
196
202
|
const emailsWithoutId = emails.map((email) => {
|
|
197
203
|
const { _id, ...rest } = email;
|
|
198
|
-
return
|
|
204
|
+
return rest;
|
|
199
205
|
});
|
|
200
|
-
await
|
|
206
|
+
await LoanBroker.findByIdAndUpdate(loanBrokerId, { emails: emailsWithoutId });
|
|
201
207
|
}
|
|
202
208
|
}
|
|
@@ -172,7 +172,7 @@ export declare class LoanTransactionsService {
|
|
|
172
172
|
getTransactionReport(transactionIds: string[], borrowerId: string, effectiveDate: Date): Promise<{
|
|
173
173
|
transactionIdsToMark: string[];
|
|
174
174
|
transactions: {
|
|
175
|
-
[x: string]: (string | number |
|
|
175
|
+
[x: string]: (string | number | string[] | Date)[];
|
|
176
176
|
}[];
|
|
177
177
|
}>;
|
|
178
178
|
getBorrowerIdsForFile(transactionFileId: string): Promise<{
|