gemcap-be-common 1.5.131 → 1.5.133
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.js
CHANGED
|
@@ -10,6 +10,7 @@ const _models_1 = require("../models/_models");
|
|
|
10
10
|
const reports_db_1 = require("./reports.db");
|
|
11
11
|
const ProductBroker_model_1 = require("../models/ProductBroker.model");
|
|
12
12
|
const LoanBroker_model_1 = require("../models/LoanBroker.model");
|
|
13
|
+
const main_helper_1 = require("../helpers/main.helper");
|
|
13
14
|
const getProductBrokers = async (productId) => {
|
|
14
15
|
return ProductBroker_model_1.ProductBroker.aggregate([
|
|
15
16
|
{
|
|
@@ -63,10 +64,11 @@ const enrichWithBrokers = async (transactions, product) => {
|
|
|
63
64
|
};
|
|
64
65
|
exports.enrichWithBrokers = enrichWithBrokers;
|
|
65
66
|
const getBorrowerBrokers = async (borrowerId) => {
|
|
66
|
-
|
|
67
|
+
const brokers = await ProductBroker_model_1.ProductBroker
|
|
67
68
|
.find({ borrowerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
|
|
68
69
|
.sort({ order: 1 })
|
|
69
70
|
.lean();
|
|
71
|
+
return brokers.map((broker) => (0, main_helper_1.sanitizePlainObject)(broker, main_helper_1.fieldsToUnset));
|
|
70
72
|
};
|
|
71
73
|
exports.getBorrowerBrokers = getBorrowerBrokers;
|
|
72
74
|
const getAllProductBrokers = async () => {
|
package/db/brokers.db.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { EChargeType, ILedgerDataRow } from './reports.db';
|
|
|
6
6
|
import { ILoanProductDoc } from '../models/LoanProducts.model';
|
|
7
7
|
import { IProductBrokerDocWithLoanBroker, IProductBrokerLean, ProductBroker } from '../models/ProductBroker.model';
|
|
8
8
|
import { ILoanBrokerLean, LoanBroker } from '../models/LoanBroker.model';
|
|
9
|
+
import { fieldsToUnset, sanitizePlainObject } from '../helpers/main.helper';
|
|
9
10
|
|
|
10
11
|
export const getProductBrokers = async (productId: string) => {
|
|
11
12
|
return ProductBroker.aggregate<IProductBrokerDocWithLoanBroker>([
|
|
@@ -62,10 +63,11 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
|
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
export const getBorrowerBrokers = async (borrowerId: string) => {
|
|
65
|
-
|
|
66
|
+
const brokers = await ProductBroker
|
|
66
67
|
.find({ borrowerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
|
|
67
68
|
.sort({ order: 1 })
|
|
68
69
|
.lean<IProductBrokerLean[]>();
|
|
70
|
+
return brokers.map((broker) => sanitizePlainObject(broker, fieldsToUnset));
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
export const getAllProductBrokers = async () => {
|
package/package.json
CHANGED
|
@@ -27,9 +27,7 @@
|
|
|
27
27
|
import { IProductBrokerView } from '../models/ProductBroker.model';
|
|
28
28
|
import { ILoanBrokerPlain, ILoanBrokerEmailPlain } from '../models/LoanBroker.model';
|
|
29
29
|
import { LoanChargesService } from './loan-charges.service';
|
|
30
|
-
type BrokerView = Omit<IProductBrokerView, '_id'
|
|
31
|
-
_id: string;
|
|
32
|
-
};
|
|
30
|
+
type BrokerView = Omit<IProductBrokerView, '_id' | 'createdAt' | 'updatedAt'>;
|
|
33
31
|
type BrokerTotalView = Omit<IProductBrokerView, 'productId'> & {
|
|
34
32
|
productId: string;
|
|
35
33
|
};
|
|
@@ -45,7 +43,7 @@ export declare class BrokersService {
|
|
|
45
43
|
constructor(loanChargesService: LoanChargesService);
|
|
46
44
|
normalizeObjects(): Promise<void>;
|
|
47
45
|
getAllProductBrokers(): Promise<import("../models/ProductBroker.model").IProductBrokerLean[]>;
|
|
48
|
-
getBorrowerBrokers(borrowerId: string): Promise<
|
|
46
|
+
getBorrowerBrokers(borrowerId: string): Promise<BrokerView[]>;
|
|
49
47
|
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithLoanBroker[]>;
|
|
50
48
|
getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
|
|
51
49
|
getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
|
|
@@ -12,7 +12,6 @@ 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: (0, main_helper_1.getUUID)(),
|
|
16
15
|
uiId: (0, main_helper_1.getUUID)(),
|
|
17
16
|
active: true,
|
|
18
17
|
BSCode: '',
|
|
@@ -22,8 +21,6 @@ const defaultBrokerList = [
|
|
|
22
21
|
adminShare: 0,
|
|
23
22
|
interestShare: 0,
|
|
24
23
|
otherShare: 0,
|
|
25
|
-
createdAt: null,
|
|
26
|
-
updatedAt: null,
|
|
27
24
|
},
|
|
28
25
|
];
|
|
29
26
|
class BrokersService {
|
|
@@ -15,12 +15,11 @@ import { getAllLoanBrokers, getAllProductBrokers, getBorrowerBrokers } from '../
|
|
|
15
15
|
import { LoanChargesService } from './loan-charges.service';
|
|
16
16
|
import { getUUID } from '../helpers/main.helper';
|
|
17
17
|
|
|
18
|
-
type BrokerView = Omit<IProductBrokerView, '_id'
|
|
18
|
+
type BrokerView = Omit<IProductBrokerView, '_id' | 'createdAt' | 'updatedAt'>;
|
|
19
19
|
type BrokerTotalView = Omit<IProductBrokerView, 'productId'> & { productId: string };
|
|
20
20
|
|
|
21
21
|
const defaultBrokerList: BrokerView[] = [
|
|
22
22
|
{
|
|
23
|
-
_id: getUUID(),
|
|
24
23
|
uiId: getUUID(),
|
|
25
24
|
active: true,
|
|
26
25
|
BSCode: '',
|
|
@@ -30,8 +29,6 @@ const defaultBrokerList: BrokerView[] = [
|
|
|
30
29
|
adminShare: 0,
|
|
31
30
|
interestShare: 0,
|
|
32
31
|
otherShare: 0,
|
|
33
|
-
createdAt: null,
|
|
34
|
-
updatedAt: null,
|
|
35
32
|
},
|
|
36
33
|
];
|
|
37
34
|
|