gemcap-be-common 1.3.13 → 1.3.14
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/classes/bank-transaction-item.d.ts +3 -3
- package/classes/bank-transaction-item.js +4 -4
- package/classes/bank-transaction-item.ts +3 -3
- package/package.json +1 -1
- package/services/borrower-summary.service.d.ts +3 -1
- package/services/borrower-summary.service.js +4 -2
- package/services/borrower-summary.service.ts +3 -1
- package/services/borrowers.db.d.ts +37 -0
- package/services/borrowers.db.js +20 -0
- package/services/borrowers.db.ts +20 -0
- package/services/borrowers.service.d.ts +2 -12
- package/services/borrowers.service.js +0 -13
- package/services/borrowers.service.ts +0 -17
- package/services/brokers.service.d.ts +2 -2
- package/services/compliance-borrowers.service.d.ts +1 -1
- package/services/loan-charges.service.d.ts +3 -3
- package/services/loan-charges.service.js +4 -4
- package/services/loan-charges.service.ts +3 -3
- package/services/loan-payments.service.d.ts +3 -3
- package/services/loan-payments.service.js +5 -5
- package/services/loan-payments.service.ts +4 -4
- package/services/loan-products.service.d.ts +18 -2
- package/services/loan-products.service.js +103 -1
- package/services/loan-products.service.ts +125 -2
- package/services/loan-transactions.service.d.ts +3 -3
- package/services/loan-transactions.service.js +4 -4
- package/services/loan-transactions.service.ts +3 -3
- package/services/quickbooks.service.d.ts +3 -3
- package/services/quickbooks.service.js +4 -4
- package/services/quickbooks.service.ts +3 -3
- package/services/uploads.service.d.ts +3 -3
- package/services/uploads.service.js +4 -4
- package/services/uploads.service.ts +3 -3
- package/services/user-logs.service.d.ts +3 -3
- package/services/user-logs.service.js +4 -4
- package/services/user-logs.service.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ELoanTransactionTypes, ILoanTransactionUpload } from '../models/LoanTransaction.model';
|
|
2
|
-
import {
|
|
2
|
+
import { BorrowersDB } from '../services/borrowers.db';
|
|
3
3
|
export declare class LoanTransactionItem implements ILoanTransactionUpload {
|
|
4
|
-
private readonly
|
|
4
|
+
private readonly borrowersDB;
|
|
5
5
|
amount: number;
|
|
6
6
|
customerId: string;
|
|
7
7
|
date: Date;
|
|
@@ -11,7 +11,7 @@ export declare class LoanTransactionItem implements ILoanTransactionUpload {
|
|
|
11
11
|
bankAccountNumber: string;
|
|
12
12
|
transactionType: ELoanTransactionTypes;
|
|
13
13
|
isStatement: boolean;
|
|
14
|
-
constructor(item: Partial<ILoanTransactionUpload>,
|
|
14
|
+
constructor(item: Partial<ILoanTransactionUpload>, borrowersDB: BorrowersDB);
|
|
15
15
|
initialize(): Promise<any[]>;
|
|
16
16
|
validateData(): Promise<any[]>;
|
|
17
17
|
}
|
|
@@ -13,7 +13,7 @@ const Borrower_model_1 = require("../models/Borrower.model");
|
|
|
13
13
|
const banks_service_1 = require("../services/banks.service");
|
|
14
14
|
const loan_charges_service_1 = require("../services/loan-charges.service");
|
|
15
15
|
class LoanTransactionItem {
|
|
16
|
-
|
|
16
|
+
borrowersDB;
|
|
17
17
|
amount = 0;
|
|
18
18
|
customerId = '';
|
|
19
19
|
date = new Date();
|
|
@@ -23,8 +23,8 @@ class LoanTransactionItem {
|
|
|
23
23
|
bankAccountNumber = '';
|
|
24
24
|
transactionType = null;
|
|
25
25
|
isStatement = false;
|
|
26
|
-
constructor(item,
|
|
27
|
-
this.
|
|
26
|
+
constructor(item, borrowersDB) {
|
|
27
|
+
this.borrowersDB = borrowersDB;
|
|
28
28
|
const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.LOAN_TRANSACTIONS);
|
|
29
29
|
const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
|
|
30
30
|
this.transactionType = item.amount < 0 ? LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION : LoanTransaction_model_1.ELoanTransactionTypes.DISBURSEMENT;
|
|
@@ -37,7 +37,7 @@ class LoanTransactionItem {
|
|
|
37
37
|
const errors = [];
|
|
38
38
|
const banksService = new banks_service_1.BanksService();
|
|
39
39
|
const foundBank = await banksService.findBankByNumber(this.bankAccountNumber);
|
|
40
|
-
const loanChargesService = new loan_charges_service_1.LoanChargesService(this.
|
|
40
|
+
const loanChargesService = new loan_charges_service_1.LoanChargesService(this.borrowersDB);
|
|
41
41
|
const foundProductId = await loanChargesService.getLoanProductIdByCode(this.ledgerAccountCode);
|
|
42
42
|
const foundChargeId = await loanChargesService.getLoanChargeIdByCode(this.ledgerAccountCode);
|
|
43
43
|
if (foundChargeId) {
|
|
@@ -7,7 +7,7 @@ import { LoanProduct } from '../models/LoanProducts.model';
|
|
|
7
7
|
import { BorrowerModel } from '../models/Borrower.model';
|
|
8
8
|
import { BanksService } from '../services/banks.service';
|
|
9
9
|
import { LoanChargesService } from '../services/loan-charges.service';
|
|
10
|
-
import {
|
|
10
|
+
import { BorrowersDB } from '../services/borrowers.db';
|
|
11
11
|
|
|
12
12
|
export class LoanTransactionItem implements ILoanTransactionUpload {
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@ export class LoanTransactionItem implements ILoanTransactionUpload {
|
|
|
23
23
|
|
|
24
24
|
constructor(
|
|
25
25
|
item: Partial<ILoanTransactionUpload>,
|
|
26
|
-
private readonly
|
|
26
|
+
private readonly borrowersDB: BorrowersDB,
|
|
27
27
|
) {
|
|
28
28
|
const itemWithDates = convertIntoDates(item, ECollaterals.LOAN_TRANSACTIONS);
|
|
29
29
|
const itemWithoutNulls = _.omitBy(itemWithDates, (value) => value === null);
|
|
@@ -39,7 +39,7 @@ export class LoanTransactionItem implements ILoanTransactionUpload {
|
|
|
39
39
|
const errors = [];
|
|
40
40
|
const banksService: BanksService = new BanksService();
|
|
41
41
|
const foundBank = await banksService.findBankByNumber(this.bankAccountNumber);
|
|
42
|
-
const loanChargesService: LoanChargesService = new LoanChargesService(this.
|
|
42
|
+
const loanChargesService: LoanChargesService = new LoanChargesService(this.borrowersDB);
|
|
43
43
|
const foundProductId = await loanChargesService.getLoanProductIdByCode(this.ledgerAccountCode);
|
|
44
44
|
const foundChargeId = await loanChargesService.getLoanChargeIdByCode(this.ledgerAccountCode);
|
|
45
45
|
if (foundChargeId) {
|
package/package.json
CHANGED
|
@@ -5,14 +5,16 @@ import { InventoryService } from './inventory.service';
|
|
|
5
5
|
import { LoanChargesService } from './loan-charges.service';
|
|
6
6
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
7
7
|
import { ReportsService } from './reports.service';
|
|
8
|
+
import { BorrowersDB } from './borrowers.db';
|
|
8
9
|
export declare class BorrowerSummaryService {
|
|
9
10
|
private readonly availabilityService;
|
|
11
|
+
private readonly borrowersDB;
|
|
10
12
|
private readonly borrowerService;
|
|
11
13
|
private readonly inventoryService;
|
|
12
14
|
private readonly loanChargesService;
|
|
13
15
|
private readonly loanTransactionsService;
|
|
14
16
|
private readonly reportsService;
|
|
15
|
-
constructor(availabilityService: AvailabilityService, borrowerService: BorrowerService, inventoryService: InventoryService, loanChargesService: LoanChargesService, loanTransactionsService: LoanTransactionsService, reportsService: ReportsService);
|
|
17
|
+
constructor(availabilityService: AvailabilityService, borrowersDB: BorrowersDB, borrowerService: BorrowerService, inventoryService: InventoryService, loanChargesService: LoanChargesService, loanTransactionsService: LoanTransactionsService, reportsService: ReportsService);
|
|
16
18
|
getBorrowerSummary(borrowerId: string): Promise<IBorrowerSummaryDoc>;
|
|
17
19
|
private getHighLevelTable;
|
|
18
20
|
private getComplianceItemsTable;
|
|
@@ -21,13 +21,15 @@ const BorrowerSummary_model_1 = require("../models/BorrowerSummary.model");
|
|
|
21
21
|
const inventories_1 = require("../db/inventories");
|
|
22
22
|
class BorrowerSummaryService {
|
|
23
23
|
availabilityService;
|
|
24
|
+
borrowersDB;
|
|
24
25
|
borrowerService;
|
|
25
26
|
inventoryService;
|
|
26
27
|
loanChargesService;
|
|
27
28
|
loanTransactionsService;
|
|
28
29
|
reportsService;
|
|
29
|
-
constructor(availabilityService, borrowerService, inventoryService, loanChargesService, loanTransactionsService, reportsService) {
|
|
30
|
+
constructor(availabilityService, borrowersDB, borrowerService, inventoryService, loanChargesService, loanTransactionsService, reportsService) {
|
|
30
31
|
this.availabilityService = availabilityService;
|
|
32
|
+
this.borrowersDB = borrowersDB;
|
|
31
33
|
this.borrowerService = borrowerService;
|
|
32
34
|
this.inventoryService = inventoryService;
|
|
33
35
|
this.loanChargesService = loanChargesService;
|
|
@@ -294,7 +296,7 @@ class BorrowerSummaryService {
|
|
|
294
296
|
console.log(`calculation finished - ${borrowerId}`);
|
|
295
297
|
}
|
|
296
298
|
async recalculateAllActive() {
|
|
297
|
-
const borrowers = await this.
|
|
299
|
+
const borrowers = await this.borrowersDB.getActiveBorrowers();
|
|
298
300
|
let i = 1;
|
|
299
301
|
for (const borrower of borrowers) {
|
|
300
302
|
try {
|
|
@@ -31,11 +31,13 @@ import { InventoryService } from './inventory.service';
|
|
|
31
31
|
import { LoanChargesService } from './loan-charges.service';
|
|
32
32
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
33
33
|
import { ReportsService } from './reports.service';
|
|
34
|
+
import { BorrowersDB } from './borrowers.db';
|
|
34
35
|
|
|
35
36
|
export class BorrowerSummaryService {
|
|
36
37
|
|
|
37
38
|
constructor(
|
|
38
39
|
private readonly availabilityService: AvailabilityService,
|
|
40
|
+
private readonly borrowersDB: BorrowersDB,
|
|
39
41
|
private readonly borrowerService: BorrowerService,
|
|
40
42
|
private readonly inventoryService: InventoryService,
|
|
41
43
|
private readonly loanChargesService: LoanChargesService,
|
|
@@ -320,7 +322,7 @@ export class BorrowerSummaryService {
|
|
|
320
322
|
}
|
|
321
323
|
|
|
322
324
|
async recalculateAllActive() {
|
|
323
|
-
const borrowers = await this.
|
|
325
|
+
const borrowers = await this.borrowersDB.getActiveBorrowers();
|
|
324
326
|
let i = 1;
|
|
325
327
|
for (const borrower of borrowers) {
|
|
326
328
|
try {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose" />
|
|
25
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
+
import { IUser } from '../models/User.model';
|
|
27
|
+
export declare class BorrowersDB {
|
|
28
|
+
getAllBorrowers(): Promise<(import("mongoose").FlattenMaps<import("../models/Borrower.model").IBorrowerDocument> & {
|
|
29
|
+
_id: import("mongoose").Types.ObjectId;
|
|
30
|
+
})[]>;
|
|
31
|
+
getActiveBorrowers(): Promise<(import("mongoose").FlattenMaps<import("../models/Borrower.model").IBorrowerDocument> & {
|
|
32
|
+
_id: import("mongoose").Types.ObjectId;
|
|
33
|
+
})[]>;
|
|
34
|
+
getAllowedBorrowers(user: IUser): Promise<(import("mongoose").FlattenMaps<import("../models/Borrower.model").IBorrowerDocument> & {
|
|
35
|
+
_id: import("mongoose").Types.ObjectId;
|
|
36
|
+
})[]>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BorrowersDB = void 0;
|
|
4
|
+
const Borrower_model_1 = require("../models/Borrower.model");
|
|
5
|
+
class BorrowersDB {
|
|
6
|
+
async getAllBorrowers() {
|
|
7
|
+
return Borrower_model_1.BorrowerModel.find().sort({ name: 1 }).lean();
|
|
8
|
+
}
|
|
9
|
+
async getActiveBorrowers() {
|
|
10
|
+
return Borrower_model_1.BorrowerModel.find({ active: true }).sort({ name: 1 }).lean();
|
|
11
|
+
}
|
|
12
|
+
async getAllowedBorrowers(user) {
|
|
13
|
+
return Borrower_model_1.BorrowerModel
|
|
14
|
+
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess.map((b) => b.borrower) } })
|
|
15
|
+
.collation({ locale: 'en' })
|
|
16
|
+
.sort({ code: 1 })
|
|
17
|
+
.lean();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BorrowersDB = BorrowersDB;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BorrowerModel } from '../models/Borrower.model';
|
|
2
|
+
import { IUser } from '../models/User.model';
|
|
3
|
+
|
|
4
|
+
export class BorrowersDB {
|
|
5
|
+
async getAllBorrowers() {
|
|
6
|
+
return BorrowerModel.find().sort({ name: 1 }).lean();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getActiveBorrowers() {
|
|
10
|
+
return BorrowerModel.find({ active: true }).sort({ name: 1 }).lean();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getAllowedBorrowers(user: IUser) {
|
|
14
|
+
return BorrowerModel
|
|
15
|
+
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess.map((b) => b.borrower) } })
|
|
16
|
+
.collation({ locale: 'en' })
|
|
17
|
+
.sort({ code: 1 })
|
|
18
|
+
.lean();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -26,7 +26,6 @@ import mongoose from 'mongoose';
|
|
|
26
26
|
import { IBorrowerSettingsDocPopulated } from '../models/BorrowerSettings.model';
|
|
27
27
|
import { IBorrowerDocument } from '../models/Borrower.model';
|
|
28
28
|
import { IBorrowerDataDocWithName } from '../models/BorrowerData.model';
|
|
29
|
-
import { IUser } from '../models/User.model';
|
|
30
29
|
import { CollateralsService } from './collaterals.service';
|
|
31
30
|
import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
32
31
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
@@ -82,21 +81,12 @@ export declare class BorrowerService {
|
|
|
82
81
|
}>;
|
|
83
82
|
updateBorrowerSettings(borrowerId: string, borrowerSettings: IBorrowerSettingsDocPopulated): Promise<void>;
|
|
84
83
|
getBorrowerCodesMap(): Promise<Map<string, string>>;
|
|
85
|
-
getAllBorrowers(): Promise<(mongoose.FlattenMaps<IBorrowerDocument> & {
|
|
86
|
-
_id: mongoose.Types.ObjectId;
|
|
87
|
-
})[]>;
|
|
88
|
-
getActiveBorrowers(): Promise<(mongoose.FlattenMaps<IBorrowerDocument> & {
|
|
89
|
-
_id: mongoose.Types.ObjectId;
|
|
90
|
-
})[]>;
|
|
91
|
-
getAllowedBorrowers(user: IUser): Promise<(mongoose.FlattenMaps<IBorrowerDocument> & {
|
|
92
|
-
_id: mongoose.Types.ObjectId;
|
|
93
|
-
})[]>;
|
|
94
84
|
getBorrowerStatementDetails(borrowers: IBorrowerDocument[]): Promise<{
|
|
95
85
|
[x: number]: {
|
|
86
|
+
SELECTED_PERIOD?: boolean;
|
|
87
|
+
ENTIRE_LOAN?: boolean;
|
|
96
88
|
LAST_MONTH?: boolean;
|
|
97
89
|
CURRENT_MONTH?: boolean;
|
|
98
|
-
ENTIRE_LOAN?: boolean;
|
|
99
|
-
SELECTED_PERIOD?: boolean;
|
|
100
90
|
TERM_LOAN?: boolean;
|
|
101
91
|
};
|
|
102
92
|
}>;
|
|
@@ -240,19 +240,6 @@ class BorrowerService {
|
|
|
240
240
|
});
|
|
241
241
|
return codesMap;
|
|
242
242
|
}
|
|
243
|
-
async getAllBorrowers() {
|
|
244
|
-
return Borrower_model_1.BorrowerModel.find().sort({ name: 1 }).lean();
|
|
245
|
-
}
|
|
246
|
-
async getActiveBorrowers() {
|
|
247
|
-
return Borrower_model_1.BorrowerModel.find({ active: true }).sort({ name: 1 }).lean();
|
|
248
|
-
}
|
|
249
|
-
async getAllowedBorrowers(user) {
|
|
250
|
-
return Borrower_model_1.BorrowerModel
|
|
251
|
-
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess.map((b) => b.borrower) } })
|
|
252
|
-
.collation({ locale: 'en' })
|
|
253
|
-
.sort({ code: 1 })
|
|
254
|
-
.lean();
|
|
255
|
-
}
|
|
256
243
|
async getBorrowerStatementDetails(borrowers) {
|
|
257
244
|
const allBorrowersWithExtraInfo = await Promise.all(borrowers.map(async (borrower) => {
|
|
258
245
|
const borrowerId = borrower._id.toString();
|
|
@@ -20,7 +20,6 @@ import { BorrowerDataReceivableModel } from '../models/BorrowerDataReceivable.mo
|
|
|
20
20
|
import { BorrowerDataInventoryModel } from '../models/BorrowerDataInventory.model';
|
|
21
21
|
import { BorrowerDataTermModel } from '../models/BorrowerDataTerm.model';
|
|
22
22
|
import { BorrowerDataBootCollateralModel } from '../models/BorrowerDataBootCollateral.model';
|
|
23
|
-
import { IUser } from '../models/User.model';
|
|
24
23
|
import { CollateralsService } from './collaterals.service';
|
|
25
24
|
import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
26
25
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
@@ -271,22 +270,6 @@ export class BorrowerService {
|
|
|
271
270
|
return codesMap;
|
|
272
271
|
}
|
|
273
272
|
|
|
274
|
-
async getAllBorrowers() {
|
|
275
|
-
return BorrowerModel.find().sort({ name: 1 }).lean();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
async getActiveBorrowers() {
|
|
279
|
-
return BorrowerModel.find({ active: true }).sort({ name: 1 }).lean();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async getAllowedBorrowers(user: IUser) {
|
|
283
|
-
return BorrowerModel
|
|
284
|
-
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess.map((b) => b.borrower) } })
|
|
285
|
-
.collation({ locale: 'en' })
|
|
286
|
-
.sort({ code: 1 })
|
|
287
|
-
.lean();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
273
|
async getBorrowerStatementDetails(borrowers: IBorrowerDocument[]) {
|
|
291
274
|
const allBorrowersWithExtraInfo = await Promise.all(borrowers.map(async (borrower) => {
|
|
292
275
|
const borrowerId = borrower._id.toString();
|
|
@@ -46,9 +46,9 @@ export declare class BrokersService {
|
|
|
46
46
|
getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & {
|
|
47
47
|
_id: import("mongoose").Types.ObjectId;
|
|
48
48
|
})[]>;
|
|
49
|
-
getBorrowerBrokers(borrowerId: string): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & {
|
|
49
|
+
getBorrowerBrokers(borrowerId: string): Promise<BrokerView[] | (import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & {
|
|
50
50
|
_id: import("mongoose").Types.ObjectId;
|
|
51
|
-
})[]
|
|
51
|
+
})[]>;
|
|
52
52
|
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithBroker[]>;
|
|
53
53
|
getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
|
|
54
54
|
getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
|
|
@@ -45,7 +45,7 @@ export declare class ComplianceBorrowersService {
|
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
getFullComplianceBorrowerById(complianceBorrowerId: any): Promise<any>;
|
|
48
|
-
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "
|
|
48
|
+
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "items" | "borrower" | "fundingStatus"> | {
|
|
49
49
|
items: {
|
|
50
50
|
instances: any[];
|
|
51
51
|
item: import("../models/ComplianceItem.model").IComplianceItemDocument;
|
|
@@ -28,10 +28,10 @@ import { ELoanChargeType } from '../enums/loan-charge-type.enum';
|
|
|
28
28
|
import { ILoanProductDoc, ILoanProductView } from '../models/LoanProducts.model';
|
|
29
29
|
import { ILoanChargeView } from '../models/LoanCharges.model';
|
|
30
30
|
import { ILoanStatementTransactionDoc, ILoanStatementTransactionDocWithCharge } from '../models/LoanStatementTransaction.model';
|
|
31
|
-
import {
|
|
31
|
+
import { BorrowersDB } from './borrowers.db';
|
|
32
32
|
export declare class LoanChargesService {
|
|
33
|
-
private readonly
|
|
34
|
-
constructor(
|
|
33
|
+
private readonly borrowersDB;
|
|
34
|
+
constructor(borrowersDB: BorrowersDB);
|
|
35
35
|
private validateCharge;
|
|
36
36
|
getProductByChargeId(chargeId: string): Promise<mongoose.FlattenMaps<ILoanProductDoc> & {
|
|
37
37
|
_id: mongoose.Types.ObjectId;
|
|
@@ -17,9 +17,9 @@ const LoanStatementTransaction_model_1 = require("../models/LoanStatementTransac
|
|
|
17
17
|
const collaterals_db_1 = require("../db/collaterals.db");
|
|
18
18
|
const updateChargesForProduct = false;
|
|
19
19
|
class LoanChargesService {
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
this.
|
|
20
|
+
borrowersDB;
|
|
21
|
+
constructor(borrowersDB) {
|
|
22
|
+
this.borrowersDB = borrowersDB;
|
|
23
23
|
}
|
|
24
24
|
validateCharge = (charge) => {
|
|
25
25
|
const chargePLCode = charge.PLCode ? charge.PLCode.trim() : '';
|
|
@@ -37,7 +37,7 @@ class LoanChargesService {
|
|
|
37
37
|
return LoanProducts_model_1.LoanProduct.find({ borrowerId }).lean();
|
|
38
38
|
}
|
|
39
39
|
async getAllLoanProducts() {
|
|
40
|
-
const borrowers = await this.
|
|
40
|
+
const borrowers = await this.borrowersDB.getActiveBorrowers();
|
|
41
41
|
const borrowerIds = borrowers.map((borrower) => borrower._id);
|
|
42
42
|
return LoanProducts_model_1.LoanProduct.aggregate([
|
|
43
43
|
{ $match: { borrowerId: { $in: borrowerIds } } },
|
|
@@ -30,14 +30,14 @@ import {
|
|
|
30
30
|
LoanStatementTransactionModel,
|
|
31
31
|
} from '../models/LoanStatementTransaction.model';
|
|
32
32
|
import { ITEMS_PAGINATION } from '../db/collaterals.db';
|
|
33
|
-
import {
|
|
33
|
+
import { BorrowersDB } from './borrowers.db';
|
|
34
34
|
|
|
35
35
|
const updateChargesForProduct = false;
|
|
36
36
|
|
|
37
37
|
export class LoanChargesService {
|
|
38
38
|
|
|
39
39
|
constructor(
|
|
40
|
-
private readonly
|
|
40
|
+
private readonly borrowersDB: BorrowersDB,
|
|
41
41
|
) {
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -60,7 +60,7 @@ export class LoanChargesService {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async getAllLoanProducts() {
|
|
63
|
-
const borrowers = await this.
|
|
63
|
+
const borrowers = await this.borrowersDB.getActiveBorrowers();
|
|
64
64
|
const borrowerIds = borrowers.map((borrower) => borrower._id);
|
|
65
65
|
return LoanProduct.aggregate<ILoanProductDoc>([
|
|
66
66
|
{ $match: { borrowerId: { $in: borrowerIds } } },
|
|
@@ -27,7 +27,7 @@ import { RedisClientType } from 'redis';
|
|
|
27
27
|
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
28
28
|
import { ELoanChargeType } from '../enums/loan-charge-type.enum';
|
|
29
29
|
import { ICombinedPayment, ILoanPaymentDoc, ILoanPaymentWithId } from '../models/LoanPayment.model';
|
|
30
|
-
import {
|
|
30
|
+
import { BorrowersDB } from './borrowers.db';
|
|
31
31
|
import { LoanStatementBalanceService } from './loan-statement-balance.service';
|
|
32
32
|
import { LoanProductsService } from './loan-products.service';
|
|
33
33
|
import { LoanChargesService } from './loan-charges.service';
|
|
@@ -40,7 +40,7 @@ import { LockService } from './lock.service';
|
|
|
40
40
|
export declare const paymentOrder: ELoanChargeType[];
|
|
41
41
|
export declare class LoanPaymentsService {
|
|
42
42
|
private readonly redisClient;
|
|
43
|
-
private readonly
|
|
43
|
+
private readonly borrowersDB;
|
|
44
44
|
private readonly financialComplianceService;
|
|
45
45
|
private readonly loanChargesService;
|
|
46
46
|
private readonly loanProductsService;
|
|
@@ -50,7 +50,7 @@ export declare class LoanPaymentsService {
|
|
|
50
50
|
private readonly loanTransactionsService;
|
|
51
51
|
private readonly lockService;
|
|
52
52
|
private readonly termLoanService;
|
|
53
|
-
constructor(redisClient: RedisClientType,
|
|
53
|
+
constructor(redisClient: RedisClientType, borrowersDB: BorrowersDB, financialComplianceService: FinancialComplianceService, loanChargesService: LoanChargesService, loanProductsService: LoanProductsService, loanStatementBalanceService: LoanStatementBalanceService, getLoanStatementService: () => LoanStatementService, loanStatementStatusService: LoanStatementStatusService, loanTransactionsService: LoanTransactionsService, lockService: LockService, termLoanService: TermLoanService);
|
|
54
54
|
getLoanPayment(paymentId: string): Promise<mongoose.FlattenMaps<ILoanPaymentDoc> & {
|
|
55
55
|
_id: mongoose.Types.ObjectId;
|
|
56
56
|
}>;
|
|
@@ -30,7 +30,7 @@ exports.paymentOrder = [
|
|
|
30
30
|
const CALCULATION_VAR = 'BULK_PAYMENT';
|
|
31
31
|
class LoanPaymentsService {
|
|
32
32
|
redisClient;
|
|
33
|
-
|
|
33
|
+
borrowersDB;
|
|
34
34
|
financialComplianceService;
|
|
35
35
|
loanChargesService;
|
|
36
36
|
loanProductsService;
|
|
@@ -40,9 +40,9 @@ class LoanPaymentsService {
|
|
|
40
40
|
loanTransactionsService;
|
|
41
41
|
lockService;
|
|
42
42
|
termLoanService;
|
|
43
|
-
constructor(redisClient,
|
|
43
|
+
constructor(redisClient, borrowersDB, financialComplianceService, loanChargesService, loanProductsService, loanStatementBalanceService, getLoanStatementService, loanStatementStatusService, loanTransactionsService, lockService, termLoanService) {
|
|
44
44
|
this.redisClient = redisClient;
|
|
45
|
-
this.
|
|
45
|
+
this.borrowersDB = borrowersDB;
|
|
46
46
|
this.financialComplianceService = financialComplianceService;
|
|
47
47
|
this.loanChargesService = loanChargesService;
|
|
48
48
|
this.loanProductsService = loanProductsService;
|
|
@@ -403,7 +403,7 @@ class LoanPaymentsService {
|
|
|
403
403
|
if (!user) {
|
|
404
404
|
return [];
|
|
405
405
|
}
|
|
406
|
-
const borrowers = await this.
|
|
406
|
+
const borrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
407
407
|
const isCalculated = await this.redisClient.get(CALCULATION_VAR);
|
|
408
408
|
const borrowersData = await Promise.all(borrowers
|
|
409
409
|
.filter((borrower) => borrower.active)
|
|
@@ -431,7 +431,7 @@ class LoanPaymentsService {
|
|
|
431
431
|
if (!user) {
|
|
432
432
|
return { message: 'Cannot find user with this id' };
|
|
433
433
|
}
|
|
434
|
-
const borrowers = await this.
|
|
434
|
+
const borrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
435
435
|
const paymentPromises = borrowers.map(async (borrower) => {
|
|
436
436
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
437
437
|
try {
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
LoanPaymentModel,
|
|
31
31
|
} from '../models/LoanPayment.model';
|
|
32
32
|
|
|
33
|
-
import {
|
|
33
|
+
import { BorrowersDB } from './borrowers.db';
|
|
34
34
|
import { LoanStatementBalanceService } from './loan-statement-balance.service';
|
|
35
35
|
import { LoanProductsService } from './loan-products.service';
|
|
36
36
|
import { LoanChargesService } from './loan-charges.service';
|
|
@@ -56,7 +56,7 @@ const CALCULATION_VAR = 'BULK_PAYMENT';
|
|
|
56
56
|
export class LoanPaymentsService {
|
|
57
57
|
constructor(
|
|
58
58
|
private readonly redisClient: RedisClientType,
|
|
59
|
-
private readonly
|
|
59
|
+
private readonly borrowersDB: BorrowersDB,
|
|
60
60
|
private readonly financialComplianceService: FinancialComplianceService,
|
|
61
61
|
private readonly loanChargesService: LoanChargesService,
|
|
62
62
|
private readonly loanProductsService: LoanProductsService,
|
|
@@ -450,7 +450,7 @@ export class LoanPaymentsService {
|
|
|
450
450
|
if (!user) {
|
|
451
451
|
return [];
|
|
452
452
|
}
|
|
453
|
-
const borrowers = await this.
|
|
453
|
+
const borrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
454
454
|
const isCalculated = await this.redisClient.get(CALCULATION_VAR);
|
|
455
455
|
const borrowersData = await Promise.all(borrowers
|
|
456
456
|
.filter((borrower) => borrower.active)
|
|
@@ -483,7 +483,7 @@ export class LoanPaymentsService {
|
|
|
483
483
|
if (!user) {
|
|
484
484
|
return { message: 'Cannot find user with this id' };
|
|
485
485
|
}
|
|
486
|
-
const borrowers = await this.
|
|
486
|
+
const borrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
487
487
|
const paymentPromises = borrowers.map(async (borrower) => {
|
|
488
488
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
489
489
|
try {
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import { ILoanProductView } from '../models/LoanProducts.model';
|
|
1
|
+
import { ILoanProductDoc, ILoanProductView } from '../models/LoanProducts.model';
|
|
2
2
|
import { LoanChargesService } from './loan-charges.service';
|
|
3
|
+
import { BorrowersDB } from './borrowers.db';
|
|
4
|
+
import { ILoanTransactionDoc } from '../models/LoanTransaction.model';
|
|
3
5
|
export declare class LoanProductsService {
|
|
4
6
|
private readonly loanChargesService;
|
|
5
|
-
|
|
7
|
+
private readonly borrowersDB;
|
|
8
|
+
constructor(loanChargesService: LoanChargesService, borrowersDB: BorrowersDB);
|
|
6
9
|
getLinkedLoanProducts(codes: string[]): Promise<{
|
|
7
10
|
[code: string]: string;
|
|
8
11
|
}>;
|
|
9
12
|
getProductsWithBalances(products: ILoanProductView[], showFloatedBalance: boolean): Promise<ILoanProductView[]>;
|
|
10
13
|
getProductPaymentOrder(productId: string): Promise<any[]>;
|
|
11
14
|
savePaymentOrder(productId: string, paymentOrder: string[]): Promise<void>;
|
|
15
|
+
getAllLoanProducts(borrowerIds?: string[]): Promise<ILoanProductDoc[]>;
|
|
16
|
+
getLoanProductBalance(productId: string, forDate?: Date): Promise<{
|
|
17
|
+
balance: number;
|
|
18
|
+
floatedBalance: number;
|
|
19
|
+
}>;
|
|
20
|
+
calculateBalanceFromTransactions(simpleTransaction: ILoanTransactionDoc | null, normalTransaction: ILoanTransactionDoc | null, collectionsTransaction: ILoanTransactionDoc | null, productId: string, forDate: Date): Promise<{
|
|
21
|
+
balance: number;
|
|
22
|
+
floatedBalance: number;
|
|
23
|
+
}>;
|
|
24
|
+
getLoanProductBalances(productIds: string[], forDate: Date): Promise<Record<string, {
|
|
25
|
+
balance: number;
|
|
26
|
+
floatedBalance: number;
|
|
27
|
+
}>>;
|
|
12
28
|
}
|