gemcap-be-common 1.5.130 → 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.
@@ -26,23 +26,19 @@
26
26
  import mongoose from 'mongoose';
27
27
  import { ILedgerDataRow } from './reports.db';
28
28
  import { ILoanProductDoc } from '../models/LoanProducts.model';
29
- import { IProductBrokerDocWithLoanBroker } from '../models/ProductBroker.model';
29
+ import { IProductBrokerDocWithLoanBroker, IProductBrokerLean } from '../models/ProductBroker.model';
30
30
  export declare const getProductBrokers: (productId: string) => Promise<IProductBrokerDocWithLoanBroker[]>;
31
31
  export declare const enrichWithBrokers: (transactions: ILedgerDataRow[], product: ILoanProductDoc) => Promise<ILedgerDataRow[]>;
32
- export declare const getBorrowerBrokers: (borrowerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
33
- _id: mongoose.Types.ObjectId;
34
- })[]>;
35
- export declare const getAllProductBrokers: () => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
36
- _id: mongoose.Types.ObjectId;
37
- })[]>;
32
+ export declare const getBorrowerBrokers: (borrowerId: string) => Promise<IProductBrokerLean[]>;
33
+ export declare const getAllProductBrokers: () => Promise<IProductBrokerLean[]>;
38
34
  export declare const getAllLoanBrokers: () => Promise<{
39
- emails: mongoose.FlattenMaps<import("../models/LoanBroker.model").ILoanBrokerEmail>[];
35
+ emails: import("../models/LoanBroker.model").ILoanBrokerEmail[];
36
+ _id: mongoose.Types.ObjectId;
37
+ createdAt: Date;
38
+ updatedAt: Date;
40
39
  uiId: string;
41
40
  order: number;
42
41
  active: boolean;
43
42
  name: string;
44
- _id: mongoose.Types.ObjectId;
45
43
  }[]>;
46
- export declare const getBrokerProducts: (loanBrokerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
47
- _id: mongoose.Types.ObjectId;
48
- })[]>;
44
+ export declare const getBrokerProducts: (loanBrokerId: string) => Promise<IProductBrokerLean[]>;
package/db/brokers.db.ts CHANGED
@@ -4,8 +4,8 @@ import mongoose from 'mongoose';
4
4
  import { MODEL_NAMES } from '../models/_models';
5
5
  import { EChargeType, ILedgerDataRow } from './reports.db';
6
6
  import { ILoanProductDoc } from '../models/LoanProducts.model';
7
- import { IProductBrokerDocWithLoanBroker, ProductBroker } from '../models/ProductBroker.model';
8
- import { LoanBroker } from '../models/LoanBroker.model';
7
+ import { IProductBrokerDocWithLoanBroker, IProductBrokerLean, ProductBroker } from '../models/ProductBroker.model';
8
+ import { ILoanBrokerLean, LoanBroker } from '../models/LoanBroker.model';
9
9
 
10
10
  export const getProductBrokers = async (productId: string) => {
11
11
  return ProductBroker.aggregate<IProductBrokerDocWithLoanBroker>([
@@ -65,21 +65,21 @@ export const getBorrowerBrokers = async (borrowerId: string) => {
65
65
  return ProductBroker
66
66
  .find({ borrowerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
67
67
  .sort({ order: 1 })
68
- .lean();
68
+ .lean<IProductBrokerLean[]>();
69
69
  };
70
70
 
71
71
  export const getAllProductBrokers = async () => {
72
72
  return ProductBroker
73
73
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
74
74
  .sort({ order: 1 })
75
- .lean();
75
+ .lean<IProductBrokerLean[]>();
76
76
  };
77
77
 
78
78
  export const getAllLoanBrokers = async () => {
79
79
  const results = await LoanBroker
80
80
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
81
81
  .sort({ order: 1 })
82
- .lean();
82
+ .lean<ILoanBrokerLean[]>();
83
83
  return results.map((result) => ({
84
84
  ...result,
85
85
  emails: result.emails ?? [],
@@ -90,5 +90,5 @@ export const getBrokerProducts = async (loanBrokerId: string) => {
90
90
  return ProductBroker
91
91
  .find({ loanBrokerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
92
92
  .sort({ order: 1, BSCode: 1, PLCode: 1 })
93
- .lean();
93
+ .lean<IProductBrokerLean[]>();
94
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.130",
3
+ "version": "1.5.131",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
+ LAST_MONTH?: boolean;
90
+ CURRENT_MONTH?: boolean;
89
91
  ENTIRE_LOAN?: boolean;
90
92
  SELECTED_PERIOD?: boolean;
91
- CURRENT_MONTH?: boolean;
92
- LAST_MONTH?: boolean;
93
93
  TERM_LOAN?: boolean;
94
94
  };
95
95
  }>;
@@ -44,24 +44,22 @@ export declare class BrokersService {
44
44
  private readonly loanChargesService;
45
45
  constructor(loanChargesService: LoanChargesService);
46
46
  normalizeObjects(): Promise<void>;
47
- getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
48
- _id: import("mongoose").Types.ObjectId;
49
- })[]>;
50
- getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
51
- _id: import("mongoose").Types.ObjectId;
52
- })[]>;
47
+ getAllProductBrokers(): Promise<import("../models/ProductBroker.model").IProductBrokerLean[]>;
48
+ getBorrowerBrokers(borrowerId: string): Promise<import("../models/ProductBroker.model").IProductBrokerLean[] | BrokerView[]>;
53
49
  getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithLoanBroker[]>;
54
50
  getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
55
51
  getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
56
52
  checkTotalShares(borrowerId: string, brokers: IProductBrokerView[]): Promise<boolean>;
57
53
  saveProductBrokers(borrowerId: string, brokers: IProductBrokerView[]): Promise<import("mongodb").BulkWriteResult>;
58
54
  getAllLoanBrokers(): Promise<{
59
- emails: import("mongoose").FlattenMaps<import("../models/LoanBroker.model").ILoanBrokerEmail>[];
55
+ emails: import("../models/LoanBroker.model").ILoanBrokerEmail[];
56
+ _id: import("mongoose").Types.ObjectId;
57
+ createdAt: Date;
58
+ updatedAt: Date;
60
59
  uiId: string;
61
60
  order: number;
62
61
  active: boolean;
63
62
  name: string;
64
- _id: import("mongoose").Types.ObjectId;
65
63
  }[]>;
66
64
  saveLoanBrokers(brokers: ILoanBrokerPlain[]): Promise<void>;
67
65
  saveLoanBroker(broker: Partial<ILoanBrokerPlain>, order: number): Promise<void>;
@@ -133,14 +133,7 @@ class BrokersService {
133
133
  const existingBrokerIds = existingBrokers.map((broker) => broker._id.toString());
134
134
  const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
135
135
  await LoanBroker_model_1.LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
136
- const brokersToSave = brokers.map((broker) => {
137
- if (broker._id.toString().startsWith('new_')) {
138
- let { _id, ...brokerWithoutId } = broker;
139
- return brokerWithoutId;
140
- }
141
- return broker;
142
- });
143
- await Promise.all(brokersToSave.map(async (brokerToSave, order) => {
136
+ await Promise.all(brokers.map(async (brokerToSave, order) => {
144
137
  await this.saveLoanBroker(brokerToSave, order);
145
138
  }));
146
139
  }
@@ -171,15 +171,7 @@ export class BrokersService {
171
171
  const brokersToDelete = existingBrokerIds.filter((id) => !brokers.some((broker) => String(broker._id) === id));
172
172
  await LoanBroker.deleteMany({ _id: { $in: brokersToDelete } });
173
173
 
174
- const brokersToSave = brokers.map((broker) => {
175
- if (broker._id.toString().startsWith('new_')) {
176
- let { _id, ...brokerWithoutId } = broker;
177
- return brokerWithoutId;
178
- }
179
- return broker;
180
- });
181
-
182
- await Promise.all(brokersToSave.map(async (brokerToSave, order) => {
174
+ await Promise.all(brokers.map(async (brokerToSave, order) => {
183
175
  await this.saveLoanBroker(brokerToSave, order);
184
176
  }));
185
177
  }
@@ -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" | "fundingStatus" | "items">[]>;
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;
@@ -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 | string[] | Date)[];
175
+ [x: string]: (string | number | Date | string[])[];
176
176
  }[];
177
177
  }>;
178
178
  getBorrowerIdsForFile(transactionFileId: string): Promise<{