gemcap-be-common 1.3.13 → 1.3.15

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.
Files changed (37) hide show
  1. package/classes/bank-transaction-item.d.ts +3 -3
  2. package/classes/bank-transaction-item.js +4 -4
  3. package/classes/bank-transaction-item.ts +3 -3
  4. package/package.json +1 -1
  5. package/services/borrower-summary.service.d.ts +3 -1
  6. package/services/borrower-summary.service.js +4 -2
  7. package/services/borrower-summary.service.ts +3 -1
  8. package/services/borrowers.db.d.ts +37 -0
  9. package/services/borrowers.db.js +20 -0
  10. package/services/borrowers.db.ts +20 -0
  11. package/services/borrowers.service.d.ts +2 -12
  12. package/services/borrowers.service.js +0 -13
  13. package/services/borrowers.service.ts +0 -17
  14. package/services/brokers.service.d.ts +2 -2
  15. package/services/compliance-borrowers.service.d.ts +1 -1
  16. package/services/loan-charges.service.d.ts +3 -3
  17. package/services/loan-charges.service.js +4 -4
  18. package/services/loan-charges.service.ts +3 -3
  19. package/services/loan-payments.service.d.ts +3 -3
  20. package/services/loan-payments.service.js +5 -5
  21. package/services/loan-payments.service.ts +4 -4
  22. package/services/loan-products.service.d.ts +18 -2
  23. package/services/loan-products.service.js +103 -1
  24. package/services/loan-products.service.ts +125 -2
  25. package/services/loan-transactions.service.d.ts +3 -3
  26. package/services/loan-transactions.service.js +4 -4
  27. package/services/loan-transactions.service.ts +3 -3
  28. package/services/quickbooks.service.d.ts +3 -3
  29. package/services/quickbooks.service.js +4 -4
  30. package/services/quickbooks.service.ts +3 -3
  31. package/services/uploads.service.d.ts +3 -3
  32. package/services/uploads.service.js +4 -4
  33. package/services/uploads.service.ts +3 -3
  34. package/services/user-logs.service.d.ts +3 -3
  35. package/services/user-logs.service.js +4 -4
  36. package/services/user-logs.service.ts +3 -3
  37. package/tsconfig.tsbuildinfo +1 -1
@@ -1,13 +1,25 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.LoanProductsService = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const decimal_js_1 = __importDefault(require("decimal.js"));
4
10
  const LoanProducts_model_1 = require("../models/LoanProducts.model");
5
11
  const LoanCharges_model_1 = require("../models/LoanCharges.model");
6
12
  const loan_payments_service_1 = require("./loan-payments.service");
13
+ const _models_1 = require("../models/_models");
14
+ const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
15
+ const loan_statement_db_1 = require("../db/loan-statement.db");
16
+ const loan_products_db_1 = require("../db/loan-products.db");
7
17
  class LoanProductsService {
8
18
  loanChargesService;
9
- constructor(loanChargesService) {
19
+ borrowersDB;
20
+ constructor(loanChargesService, borrowersDB) {
10
21
  this.loanChargesService = loanChargesService;
22
+ this.borrowersDB = borrowersDB;
11
23
  }
12
24
  async getLinkedLoanProducts(codes) {
13
25
  const loanProducts = await LoanProducts_model_1.LoanProduct
@@ -51,5 +63,95 @@ class LoanProductsService {
51
63
  }));
52
64
  }
53
65
  }
66
+ async getAllLoanProducts(borrowerIds) {
67
+ if (!borrowerIds) {
68
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
69
+ borrowerIds = borrowers.map((borrower) => borrower._id.toString());
70
+ }
71
+ return LoanProducts_model_1.LoanProduct.aggregate([
72
+ { $match: { borrowerId: { $in: borrowerIds.map((borrowerId) => new mongoose_1.default.Types.ObjectId(borrowerId)) } } },
73
+ {
74
+ $lookup: {
75
+ from: _models_1.MODEL_NAMES.borrowers,
76
+ localField: 'borrowerId',
77
+ foreignField: '_id',
78
+ as: 'borrower',
79
+ },
80
+ },
81
+ { $unwind: '$borrower' },
82
+ { $sort: { 'borrower.name': 1 } },
83
+ { $project: { borrower: 0 } },
84
+ ]);
85
+ }
86
+ ;
87
+ async getLoanProductBalance(productId, forDate = new Date()) {
88
+ const simpleTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
89
+ {
90
+ $match: {
91
+ productId: new mongoose_1.default.Types.ObjectId(productId),
92
+ date: { $lte: (0, dayjs_1.default)(forDate).startOf('day').subtract(1, 'seconds').toDate() },
93
+ },
94
+ },
95
+ { $sort: { date: -1, order: -1, createdAt: -1 } },
96
+ { $limit: 1 },
97
+ ]);
98
+ const collectionsTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
99
+ {
100
+ $match: {
101
+ productId: new mongoose_1.default.Types.ObjectId(productId),
102
+ effectiveDate: { $lte: forDate },
103
+ $expr: { $ne: ['$date', '$effectiveDate'] },
104
+ },
105
+ },
106
+ { $sort: { effectiveDate: -1, order: -1, createdAt: -1 } },
107
+ { $limit: 1 },
108
+ ]);
109
+ const normalTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
110
+ {
111
+ $match: {
112
+ productId: new mongoose_1.default.Types.ObjectId(productId),
113
+ effectiveDate: { $lte: forDate },
114
+ $expr: { $eq: ['$date', '$effectiveDate'] },
115
+ },
116
+ },
117
+ { $sort: { effectiveDate: -1, order: -1, createdAt: -1 } },
118
+ { $limit: 1 },
119
+ ]);
120
+ return this.calculateBalanceFromTransactions(simpleTransactions.length > 0 ? simpleTransactions[0] : null, normalTransactions.length > 0 ? normalTransactions[0] : null, collectionsTransactions.length > 0 ? collectionsTransactions[0] : null, productId, forDate);
121
+ }
122
+ ;
123
+ async calculateBalanceFromTransactions(simpleTransaction, normalTransaction, collectionsTransaction, productId, forDate) {
124
+ const balance = simpleTransaction?.balance || 0;
125
+ let floatedBalance = 0;
126
+ if (normalTransaction && collectionsTransaction) {
127
+ const totalCollections = await (0, loan_statement_db_1.getTotalForDate)(productId, collectionsTransaction.effectiveDate);
128
+ if ((0, dayjs_1.default)(normalTransaction.date).isSame(collectionsTransaction.date)) {
129
+ floatedBalance = new decimal_js_1.default(normalTransaction.floatedBalance).add(totalCollections).toNumber();
130
+ }
131
+ else if ((0, dayjs_1.default)(normalTransaction.date).isAfter(collectionsTransaction.date)) {
132
+ floatedBalance = normalTransaction.floatedBalance;
133
+ }
134
+ else {
135
+ floatedBalance = collectionsTransaction.balance;
136
+ }
137
+ }
138
+ else if (normalTransaction) {
139
+ floatedBalance = normalTransaction.floatedBalance;
140
+ }
141
+ else if (!normalTransaction && !collectionsTransaction) {
142
+ const totalPostponed = await (0, loan_products_db_1.getPostponedTransactions)(forDate, productId);
143
+ return { balance: 0, floatedBalance: totalPostponed };
144
+ }
145
+ return { balance, floatedBalance };
146
+ }
147
+ ;
148
+ async getLoanProductBalances(productIds, forDate) {
149
+ const results = {};
150
+ await Promise.all(productIds.map(async (productId) => {
151
+ results[productId] = await this.getLoanProductBalance(productId, forDate);
152
+ }));
153
+ return results;
154
+ }
155
+ ;
54
156
  }
55
157
  exports.LoanProductsService = LoanProductsService;
@@ -1,13 +1,27 @@
1
- import { ILoanProductView, ILoanProductViewWithBalances, LoanProduct } from '../models/LoanProducts.model';
2
- import { LoanCharge } from '../models/LoanCharges.model';
1
+ import mongoose from 'mongoose';
2
+ import dayjs from 'dayjs';
3
+ import Decimal from 'decimal.js';
3
4
 
5
+ import {
6
+ ILoanProductDoc,
7
+ ILoanProductView,
8
+ ILoanProductViewWithBalances,
9
+ LoanProduct,
10
+ } from '../models/LoanProducts.model';
11
+ import { LoanCharge } from '../models/LoanCharges.model';
4
12
  import { paymentOrder } from './loan-payments.service';
5
13
  import { LoanChargesService } from './loan-charges.service';
14
+ import { BorrowersDB } from './borrowers.db';
15
+ import { MODEL_NAMES } from '../models/_models';
16
+ import { ILoanTransactionDoc, LoanTransaction } from '../models/LoanTransaction.model';
17
+ import { getTotalForDate } from '../db/loan-statement.db';
18
+ import { getPostponedTransactions } from '../db/loan-products.db';
6
19
 
7
20
  export class LoanProductsService {
8
21
 
9
22
  constructor(
10
23
  private readonly loanChargesService: LoanChargesService,
24
+ private readonly borrowersDB: BorrowersDB,
11
25
  ) {
12
26
  }
13
27
 
@@ -55,4 +69,113 @@ export class LoanProductsService {
55
69
  }));
56
70
  }
57
71
  }
72
+
73
+ async getAllLoanProducts(borrowerIds?: string[]) {
74
+ if (!borrowerIds) {
75
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
76
+ borrowerIds = borrowers.map((borrower) => borrower._id.toString());
77
+ }
78
+ return LoanProduct.aggregate<ILoanProductDoc>([
79
+ { $match: { borrowerId: { $in: borrowerIds.map((borrowerId) => new mongoose.Types.ObjectId(borrowerId)) } } },
80
+ {
81
+ $lookup: {
82
+ from: MODEL_NAMES.borrowers,
83
+ localField: 'borrowerId',
84
+ foreignField: '_id',
85
+ as: 'borrower',
86
+ },
87
+ },
88
+ { $unwind: '$borrower' },
89
+ { $sort: { 'borrower.name': 1 } },
90
+ { $project: { borrower: 0 } },
91
+ ]);
92
+ };
93
+
94
+ async getLoanProductBalance(productId: string, forDate = new Date()) {
95
+ const simpleTransactions = await LoanTransaction.aggregate<ILoanTransactionDoc>([
96
+ {
97
+ $match: {
98
+ productId: new mongoose.Types.ObjectId(productId),
99
+ date: { $lte: dayjs(forDate).startOf('day').subtract(1, 'seconds').toDate() },
100
+ },
101
+ },
102
+ { $sort: { date: -1, order: -1, createdAt: -1 } },
103
+ { $limit: 1 },
104
+ ]);
105
+
106
+ const collectionsTransactions = await LoanTransaction.aggregate<ILoanTransactionDoc>([
107
+ {
108
+ $match: {
109
+ productId: new mongoose.Types.ObjectId(productId),
110
+ effectiveDate: { $lte: forDate },
111
+ $expr: { $ne: ['$date', '$effectiveDate'] },
112
+ },
113
+ },
114
+ { $sort: { effectiveDate: -1, order: -1, createdAt: -1 } },
115
+ { $limit: 1 },
116
+ ]);
117
+
118
+ const normalTransactions = await LoanTransaction.aggregate<ILoanTransactionDoc>([
119
+ {
120
+ $match: {
121
+ productId: new mongoose.Types.ObjectId(productId),
122
+ effectiveDate: { $lte: forDate },
123
+ $expr: { $eq: ['$date', '$effectiveDate'] },
124
+ },
125
+ },
126
+ { $sort: { effectiveDate: -1, order: -1, createdAt: -1 } },
127
+ { $limit: 1 },
128
+ ]);
129
+
130
+ return this.calculateBalanceFromTransactions(
131
+ simpleTransactions.length > 0 ? simpleTransactions[0] : null,
132
+ normalTransactions.length > 0 ? normalTransactions[0] : null,
133
+ collectionsTransactions.length > 0 ? collectionsTransactions[0] : null,
134
+ productId,
135
+ forDate,
136
+ );
137
+ };
138
+
139
+ async calculateBalanceFromTransactions(
140
+ simpleTransaction: ILoanTransactionDoc | null,
141
+ normalTransaction: ILoanTransactionDoc | null,
142
+ collectionsTransaction: ILoanTransactionDoc | null,
143
+ productId: string,
144
+ forDate: Date,
145
+ ): Promise<{ balance: number; floatedBalance: number }> {
146
+ const balance = simpleTransaction?.balance || 0;
147
+ let floatedBalance = 0;
148
+
149
+ if (normalTransaction && collectionsTransaction) {
150
+ const totalCollections = await getTotalForDate(productId, collectionsTransaction.effectiveDate);
151
+ if (dayjs(normalTransaction.date).isSame(collectionsTransaction.date)) {
152
+ floatedBalance = new Decimal(normalTransaction.floatedBalance).add(totalCollections).toNumber();
153
+ } else if (dayjs(normalTransaction.date).isAfter(collectionsTransaction.date)) {
154
+ floatedBalance = normalTransaction.floatedBalance;
155
+ } else {
156
+ floatedBalance = collectionsTransaction.balance;
157
+ }
158
+ } else if (normalTransaction) {
159
+ floatedBalance = normalTransaction.floatedBalance;
160
+ } else if (!normalTransaction && !collectionsTransaction) {
161
+ const totalPostponed = await getPostponedTransactions(forDate, productId);
162
+ return { balance: 0, floatedBalance: totalPostponed };
163
+ }
164
+
165
+ return { balance, floatedBalance };
166
+ };
167
+
168
+ async getLoanProductBalances(
169
+ productIds: string[],
170
+ forDate: Date,
171
+ ): Promise<Record<string, { balance: number, floatedBalance: number }>> {
172
+ const results: Record<string, { balance: number, floatedBalance: number }> = {};
173
+ await Promise.all(
174
+ productIds.map(async (productId) => {
175
+ results[productId] = await this.getLoanProductBalance(productId, forDate);
176
+ }),
177
+ );
178
+ return results;
179
+ };
180
+
58
181
  }
@@ -30,7 +30,7 @@ import { ILoanProductDoc } from '../models/LoanProducts.model';
30
30
  import { IUploadOption, UploadsService } from './uploads.service';
31
31
  import { AttachedFilesService } from './attached-files.service';
32
32
  import { BanksService } from './banks.service';
33
- import { BorrowerService } from './borrowers.service';
33
+ import { BorrowersDB } from './borrowers.db';
34
34
  import { CalendarService } from './calendar.service';
35
35
  import { LoanChargesService } from './loan-charges.service';
36
36
  import { LoanPaymentsService } from './loan-payments.service';
@@ -53,7 +53,7 @@ export interface ITransactionsFilter {
53
53
  export declare class LoanTransactionsService {
54
54
  private readonly attachedFilesService;
55
55
  private readonly banksService;
56
- private readonly borrowerService;
56
+ private readonly borrowersDB;
57
57
  private readonly calendarService;
58
58
  private readonly loanChargesService;
59
59
  private readonly getLoanPaymentsService;
@@ -64,7 +64,7 @@ export declare class LoanTransactionsService {
64
64
  private readonly termLoanService;
65
65
  private readonly uploadsService;
66
66
  private readonly config;
67
- constructor(config: ILoanTransactionsServiceConfig, attachedFilesService: AttachedFilesService, banksService: BanksService, borrowerService: BorrowerService, calendarService: CalendarService, loanChargesService: LoanChargesService, getLoanPaymentsService: () => LoanPaymentsService, getLoanStatementService: () => LoanStatementService, loanStatementStatusService: LoanStatementStatusService, getNodemailerService: () => NodemailerService, lockService: LockService, termLoanService: TermLoanService, uploadsService: UploadsService);
67
+ constructor(config: ILoanTransactionsServiceConfig, attachedFilesService: AttachedFilesService, banksService: BanksService, borrowersDB: BorrowersDB, calendarService: CalendarService, loanChargesService: LoanChargesService, getLoanPaymentsService: () => LoanPaymentsService, getLoanStatementService: () => LoanStatementService, loanStatementStatusService: LoanStatementStatusService, getNodemailerService: () => NodemailerService, lockService: LockService, termLoanService: TermLoanService, uploadsService: UploadsService);
68
68
  getTransactionsById(transactionId: string): Promise<mongoose.FlattenMaps<ILoanTransaction> & {
69
69
  _id: mongoose.Types.ObjectId;
70
70
  }>;
@@ -27,7 +27,7 @@ const LoanTransactionFile_model_1 = require("../models/LoanTransactionFile.model
27
27
  class LoanTransactionsService {
28
28
  attachedFilesService;
29
29
  banksService;
30
- borrowerService;
30
+ borrowersDB;
31
31
  calendarService;
32
32
  loanChargesService;
33
33
  getLoanPaymentsService;
@@ -38,10 +38,10 @@ class LoanTransactionsService {
38
38
  termLoanService;
39
39
  uploadsService;
40
40
  config;
41
- constructor(config, attachedFilesService, banksService, borrowerService, calendarService, loanChargesService, getLoanPaymentsService, getLoanStatementService, loanStatementStatusService, getNodemailerService, lockService, termLoanService, uploadsService) {
41
+ constructor(config, attachedFilesService, banksService, borrowersDB, calendarService, loanChargesService, getLoanPaymentsService, getLoanStatementService, loanStatementStatusService, getNodemailerService, lockService, termLoanService, uploadsService) {
42
42
  this.attachedFilesService = attachedFilesService;
43
43
  this.banksService = banksService;
44
- this.borrowerService = borrowerService;
44
+ this.borrowersDB = borrowersDB;
45
45
  this.calendarService = calendarService;
46
46
  this.loanChargesService = loanChargesService;
47
47
  this.getLoanPaymentsService = getLoanPaymentsService;
@@ -878,7 +878,7 @@ class LoanTransactionsService {
878
878
  }));
879
879
  }
880
880
  async sendAllReport(effectiveDate) {
881
- const borrowers = await this.borrowerService.getActiveBorrowers();
881
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
882
882
  await Promise.all(borrowers.map(async (borrower) => {
883
883
  if (!borrower.active) {
884
884
  return;
@@ -43,7 +43,7 @@ import { IUploadOption, UploadsService } from './uploads.service';
43
43
  import { ILoanTransactionFileDoc, LoanTransactionFileModel } from '../models/LoanTransactionFile.model';
44
44
  import { AttachedFilesService } from './attached-files.service';
45
45
  import { BanksService } from './banks.service';
46
- import { BorrowerService } from './borrowers.service';
46
+ import { BorrowersDB } from './borrowers.db';
47
47
  import { CalendarService } from './calendar.service';
48
48
  import { LoanChargesService } from './loan-charges.service';
49
49
  import { LoanPaymentsService } from './loan-payments.service';
@@ -74,7 +74,7 @@ export class LoanTransactionsService {
74
74
  config: ILoanTransactionsServiceConfig,
75
75
  private readonly attachedFilesService: AttachedFilesService,
76
76
  private readonly banksService: BanksService,
77
- private readonly borrowerService: BorrowerService,
77
+ private readonly borrowersDB: BorrowersDB,
78
78
  private readonly calendarService: CalendarService,
79
79
  private readonly loanChargesService: LoanChargesService,
80
80
  private readonly getLoanPaymentsService: () => LoanPaymentsService,
@@ -976,7 +976,7 @@ export class LoanTransactionsService {
976
976
  }
977
977
 
978
978
  async sendAllReport(effectiveDate: Date) {
979
- const borrowers = await this.borrowerService.getActiveBorrowers();
979
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
980
980
  await Promise.all(borrowers.map(async (borrower) => {
981
981
  if (!borrower.active) {
982
982
  return;
@@ -27,7 +27,7 @@ import { IQuickbooksAccount } from '../models/QuickbooksAccount.model';
27
27
  import { IQuickbooksUploadItem } from '../classes/quickbook-item';
28
28
  import { BanksService } from './banks.service';
29
29
  import { BankUploadedTransactionsService } from './bank-uploaded-transactions.service';
30
- import { BorrowerService } from './borrowers.service';
30
+ import { BorrowersDB } from './borrowers.db';
31
31
  import { BrokersService } from './brokers.service';
32
32
  import { CashAllocationService } from './cash-allocation.service';
33
33
  import { CompaniesService } from './companies.service';
@@ -50,13 +50,13 @@ interface IQBReportTransaction {
50
50
  export declare class QuickbooksService {
51
51
  private readonly banksService;
52
52
  private readonly bankUploadedTransactionsService;
53
- private readonly borrowerService;
53
+ private readonly borrowersDB;
54
54
  private readonly brokersService;
55
55
  private readonly cashAllocationService;
56
56
  private readonly companiesService;
57
57
  private readonly loanChargesService;
58
58
  private readonly loanPaymentsService;
59
- constructor(banksService: BanksService, bankUploadedTransactionsService: BankUploadedTransactionsService, borrowerService: BorrowerService, brokersService: BrokersService, cashAllocationService: CashAllocationService, companiesService: CompaniesService, loanChargesService: LoanChargesService, loanPaymentsService: LoanPaymentsService);
59
+ constructor(banksService: BanksService, bankUploadedTransactionsService: BankUploadedTransactionsService, borrowersDB: BorrowersDB, brokersService: BrokersService, cashAllocationService: CashAllocationService, companiesService: CompaniesService, loanChargesService: LoanChargesService, loanPaymentsService: LoanPaymentsService);
60
60
  uploadAccounts(accounts: IQuickbooksUploadItem[], deleteOld: boolean): Promise<void>;
61
61
  getAllAccounts(): Promise<(mongoose.FlattenMaps<IQuickbooksAccount> & {
62
62
  _id: mongoose.Types.ObjectId;
@@ -81,16 +81,16 @@ const IIFDateFormat = 'M/D/YYYY';
81
81
  class QuickbooksService {
82
82
  banksService;
83
83
  bankUploadedTransactionsService;
84
- borrowerService;
84
+ borrowersDB;
85
85
  brokersService;
86
86
  cashAllocationService;
87
87
  companiesService;
88
88
  loanChargesService;
89
89
  loanPaymentsService;
90
- constructor(banksService, bankUploadedTransactionsService, borrowerService, brokersService, cashAllocationService, companiesService, loanChargesService, loanPaymentsService) {
90
+ constructor(banksService, bankUploadedTransactionsService, borrowersDB, brokersService, cashAllocationService, companiesService, loanChargesService, loanPaymentsService) {
91
91
  this.banksService = banksService;
92
92
  this.bankUploadedTransactionsService = bankUploadedTransactionsService;
93
- this.borrowerService = borrowerService;
93
+ this.borrowersDB = borrowersDB;
94
94
  this.brokersService = brokersService;
95
95
  this.cashAllocationService = cashAllocationService;
96
96
  this.companiesService = companiesService;
@@ -132,7 +132,7 @@ class QuickbooksService {
132
132
  return Promise.all(accountSavePromises);
133
133
  }
134
134
  async getAllProducts() {
135
- const borrowers = await this.borrowerService.getActiveBorrowers();
135
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
136
136
  const borrowerIds = borrowers.map((borrower) => borrower._id);
137
137
  return LoanProducts_model_1.LoanProduct.aggregate([
138
138
  {
@@ -17,7 +17,7 @@ import { IQuickbooksUploadItem } from '../classes/quickbook-item';
17
17
  import { IUploadedBankTransaction } from '../models/UploadedBankTransaction.model';
18
18
  import { BanksService } from './banks.service';
19
19
  import { BankUploadedTransactionsService } from './bank-uploaded-transactions.service';
20
- import { BorrowerService } from './borrowers.service';
20
+ import { BorrowersDB } from './borrowers.db';
21
21
  import { BrokersService } from './brokers.service';
22
22
  import { CashAllocationService } from './cash-allocation.service';
23
23
  import { CompaniesService } from './companies.service';
@@ -129,7 +129,7 @@ export class QuickbooksService {
129
129
  constructor(
130
130
  private readonly banksService: BanksService,
131
131
  private readonly bankUploadedTransactionsService: BankUploadedTransactionsService,
132
- private readonly borrowerService: BorrowerService,
132
+ private readonly borrowersDB: BorrowersDB,
133
133
  private readonly brokersService: BrokersService,
134
134
  private readonly cashAllocationService: CashAllocationService,
135
135
  private readonly companiesService: CompaniesService,
@@ -176,7 +176,7 @@ export class QuickbooksService {
176
176
  }
177
177
 
178
178
  async getAllProducts() {
179
- const borrowers = await this.borrowerService.getActiveBorrowers();
179
+ const borrowers = await this.borrowersDB.getActiveBorrowers();
180
180
  const borrowerIds = borrowers.map((borrower) => borrower._id);
181
181
  return LoanProduct.aggregate([
182
182
  {
@@ -36,7 +36,7 @@ import { LoanTransactionsService } from './loan-transactions.service';
36
36
  import { QuickbooksService } from './quickbooks.service';
37
37
  import { UserLogsService } from './user-logs.service';
38
38
  import { LockService } from './lock.service';
39
- import { BorrowerService } from './borrowers.service';
39
+ import { BorrowersDB } from './borrowers.db';
40
40
  interface IMappedColumns {
41
41
  [columnName: string]: number;
42
42
  }
@@ -72,8 +72,8 @@ export declare class UploadsService {
72
72
  private readonly getQuickbooksService;
73
73
  private readonly getLockService;
74
74
  private readonly userLogsService;
75
- private readonly borrowerService;
76
- constructor(rootDir: string, bankUploadedTransactionsService: BankUploadedTransactionsService, getCollateralsService: () => CollateralsService, getLoanTransactionsService: () => LoanTransactionsService, getQuickbooksService: () => QuickbooksService, getLockService: () => LockService, userLogsService: UserLogsService, borrowerService: BorrowerService);
75
+ private readonly borrowersDB;
76
+ constructor(rootDir: string, bankUploadedTransactionsService: BankUploadedTransactionsService, getCollateralsService: () => CollateralsService, getLoanTransactionsService: () => LoanTransactionsService, getQuickbooksService: () => QuickbooksService, getLockService: () => LockService, userLogsService: UserLogsService, borrowersDB: BorrowersDB);
77
77
  createUploadFile(file: IMulterFile, borrowerId: string, userId: string, uploadType: EUploadTypes): Promise<mongoose.Document<unknown, {}, IUploadedFileDoc> & IUploadedFileDoc & {
78
78
  _id: mongoose.Types.ObjectId;
79
79
  }>;
@@ -100,8 +100,8 @@ class UploadsService {
100
100
  getQuickbooksService;
101
101
  getLockService;
102
102
  userLogsService;
103
- borrowerService;
104
- constructor(rootDir, bankUploadedTransactionsService, getCollateralsService, getLoanTransactionsService, getQuickbooksService, getLockService, userLogsService, borrowerService) {
103
+ borrowersDB;
104
+ constructor(rootDir, bankUploadedTransactionsService, getCollateralsService, getLoanTransactionsService, getQuickbooksService, getLockService, userLogsService, borrowersDB) {
105
105
  this.rootDir = rootDir;
106
106
  this.bankUploadedTransactionsService = bankUploadedTransactionsService;
107
107
  this.getCollateralsService = getCollateralsService;
@@ -109,7 +109,7 @@ class UploadsService {
109
109
  this.getQuickbooksService = getQuickbooksService;
110
110
  this.getLockService = getLockService;
111
111
  this.userLogsService = userLogsService;
112
- this.borrowerService = borrowerService;
112
+ this.borrowersDB = borrowersDB;
113
113
  }
114
114
  async createUploadFile(file, borrowerId, userId, uploadType) {
115
115
  const borrowerIdToWrite = new mongoose_1.default.Types.ObjectId(borrowerId);
@@ -456,7 +456,7 @@ class UploadsService {
456
456
  [collaterals_enum_1.ECollaterals.RECEIVABLE]: () => new receivable_item_1.ReceivableItem(row, bbcDate),
457
457
  [collaterals_enum_1.ECollaterals.ACCOUNT_PAYABLE]: () => new payable_account_item_1.PayableAccountItem(row, bbcDate),
458
458
  [collaterals_enum_1.ECollaterals.LOAN_TRANSACTIONS]: async () => {
459
- const newItem = new bank_transaction_item_1.LoanTransactionItem(row, this.borrowerService);
459
+ const newItem = new bank_transaction_item_1.LoanTransactionItem(row, this.borrowersDB);
460
460
  const classErrors = await newItem.initialize();
461
461
  if (classErrors.length) {
462
462
  classErrors.forEach((error) => extraErrors.push(error));
@@ -52,7 +52,7 @@ import { LoanTransactionsService } from './loan-transactions.service';
52
52
  import { QuickbooksService } from './quickbooks.service';
53
53
  import { UserLogsService } from './user-logs.service';
54
54
  import { LockService } from './lock.service';
55
- import { BorrowerService } from './borrowers.service';
55
+ import { BorrowersDB } from './borrowers.db';
56
56
 
57
57
  interface IMappedColumns {
58
58
  [columnName: string]: number;
@@ -128,7 +128,7 @@ export class UploadsService {
128
128
  private readonly getQuickbooksService: () => QuickbooksService,
129
129
  private readonly getLockService: () => LockService,
130
130
  private readonly userLogsService: UserLogsService,
131
- private readonly borrowerService: BorrowerService,
131
+ private readonly borrowersDB: BorrowersDB,
132
132
  ) {
133
133
  }
134
134
 
@@ -513,7 +513,7 @@ export class UploadsService {
513
513
  [ECollaterals.RECEIVABLE]: () => new ReceivableItem(row, bbcDate),
514
514
  [ECollaterals.ACCOUNT_PAYABLE]: () => new PayableAccountItem(row, bbcDate),
515
515
  [ECollaterals.LOAN_TRANSACTIONS]: async () => {
516
- const newItem = new LoanTransactionItem(row, this.borrowerService);
516
+ const newItem = new LoanTransactionItem(row, this.borrowersDB);
517
517
  const classErrors = await newItem.initialize();
518
518
  if (classErrors.length) {
519
519
  classErrors.forEach((error) => extraErrors.push(error));
@@ -1,7 +1,7 @@
1
1
  import { ICreateLogParams } from '../db/user-logs.db';
2
2
  import { IUserLog, IUserLogWithLookup } from '../models/UserLog.model';
3
3
  import { BanksService } from './banks.service';
4
- import { BorrowerService } from './borrowers.service';
4
+ import { BorrowersDB } from './borrowers.db';
5
5
  import { LoanChargesService } from './loan-charges.service';
6
6
  export interface IUserLogFilter {
7
7
  userId: string;
@@ -11,9 +11,9 @@ export interface IUserLogFilter {
11
11
  }
12
12
  export declare class UserLogsService {
13
13
  private readonly banksService;
14
- private readonly borrowerService;
14
+ private readonly borrowerDB;
15
15
  private readonly loanChargesService;
16
- constructor(banksService: BanksService, borrowerService: BorrowerService, loanChargesService: LoanChargesService);
16
+ constructor(banksService: BanksService, borrowerDB: BorrowersDB, loanChargesService: LoanChargesService);
17
17
  createUserLog(params: ICreateLogParams): Promise<void>;
18
18
  filterByBorrower(logs: IUserLogWithLookup[], borrowerId: string): Promise<IUserLogWithLookup[]>;
19
19
  replaceBorrowers(logs: IUserLogWithLookup[]): Promise<void[]>;
@@ -11,11 +11,11 @@ const DeletedRecords_model_1 = require("../models/DeletedRecords.model");
11
11
  const createLogs = true;
12
12
  class UserLogsService {
13
13
  banksService;
14
- borrowerService;
14
+ borrowerDB;
15
15
  loanChargesService;
16
- constructor(banksService, borrowerService, loanChargesService) {
16
+ constructor(banksService, borrowerDB, loanChargesService) {
17
17
  this.banksService = banksService;
18
- this.borrowerService = borrowerService;
18
+ this.borrowerDB = borrowerDB;
19
19
  this.loanChargesService = loanChargesService;
20
20
  }
21
21
  async createUserLog(params) {
@@ -45,7 +45,7 @@ class UserLogsService {
45
45
  return acc;
46
46
  }, new Map());
47
47
  };
48
- const borrowers = await this.borrowerService.getAllBorrowers();
48
+ const borrowers = await this.borrowerDB.getAllBorrowers();
49
49
  const borrowersMap = convertToMap(borrowers);
50
50
  const products = await this.loanChargesService.getAllLoanProducts();
51
51
  const productsMap = convertToMap(products);
@@ -5,7 +5,7 @@ import { ELogType, IUserLog, IUserLogWithLookup, UserLog } from '../models/UserL
5
5
  import { DeletedRecord } from '../models/DeletedRecords.model';
6
6
 
7
7
  import { BanksService } from './banks.service';
8
- import { BorrowerService } from './borrowers.service';
8
+ import { BorrowersDB } from './borrowers.db';
9
9
  import { LoanChargesService } from './loan-charges.service';
10
10
 
11
11
  export interface IUserLogFilter {
@@ -21,7 +21,7 @@ export class UserLogsService {
21
21
 
22
22
  constructor(
23
23
  private readonly banksService: BanksService,
24
- private readonly borrowerService: BorrowerService,
24
+ private readonly borrowerDB: BorrowersDB,
25
25
  private readonly loanChargesService: LoanChargesService,
26
26
  ) {
27
27
  }
@@ -55,7 +55,7 @@ export class UserLogsService {
55
55
  return acc;
56
56
  }, new Map<string, string>());
57
57
  };
58
- const borrowers = await this.borrowerService.getAllBorrowers();
58
+ const borrowers = await this.borrowerDB.getAllBorrowers();
59
59
  const borrowersMap = convertToMap(borrowers);
60
60
 
61
61
  const products = await this.loanChargesService.getAllLoanProducts();