gemcap-be-common 1.5.65 → 1.5.66
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/reports.db.ts +1 -1
- package/models/LoanProducts.model.ts +4 -4
- package/package.json +1 -1
- package/services/loan-charges.service.ts +1 -1
- package/services/loan-products.service.ts +1 -1
- package/services/quickbooks.service.ts +4 -4
- package/services/reports/investor-summary.service.ts +1 -1
- package/services/reports.service.ts +1 -1
package/db/reports.db.ts
CHANGED
|
@@ -285,7 +285,7 @@ const getLedgerData = async (params: ReportLedgerParams, options = defaultReport
|
|
|
285
285
|
}))
|
|
286
286
|
: statementTransactions.slice();
|
|
287
287
|
|
|
288
|
-
const isParticipant = group.product.
|
|
288
|
+
const isParticipant = group.product.masteredLoanProductId != null;
|
|
289
289
|
const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
|
|
290
290
|
|
|
291
291
|
const transactions = [];
|
|
@@ -19,7 +19,7 @@ export interface ILoanProduct {
|
|
|
19
19
|
isBalanceActual: boolean;
|
|
20
20
|
isFloatedBalanceActual: boolean;
|
|
21
21
|
isParticipant?: boolean;
|
|
22
|
-
|
|
22
|
+
masteredLoanProductId: mongoose.Types.ObjectId;
|
|
23
23
|
minPercent: number;
|
|
24
24
|
maxPercent: number;
|
|
25
25
|
prepaymentDate?: Date;
|
|
@@ -42,10 +42,10 @@ export interface ILoanProductLean extends ILoanProduct {
|
|
|
42
42
|
updatedAt: Date;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | '
|
|
45
|
+
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | 'masteredLoanProductId'> {
|
|
46
46
|
_id: string;
|
|
47
47
|
borrowerId: string;
|
|
48
|
-
|
|
48
|
+
masteredLoanProductId: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface ILoanProductWithId extends ILoanProduct {
|
|
@@ -128,7 +128,7 @@ export const LoanProductSchema = new mongoose.Schema(
|
|
|
128
128
|
type: Boolean,
|
|
129
129
|
required: false,
|
|
130
130
|
},
|
|
131
|
-
|
|
131
|
+
masteredLoanProductId: {
|
|
132
132
|
type: mongoose.Schema.Types.ObjectId,
|
|
133
133
|
ref: MODEL_NAMES.loanProducts,
|
|
134
134
|
default: null,
|
package/package.json
CHANGED
|
@@ -112,7 +112,7 @@ export class LoanChargesService {
|
|
|
112
112
|
if (!masterProduct) {
|
|
113
113
|
return 0;
|
|
114
114
|
}
|
|
115
|
-
const participationProduct = await LoanProduct.findOne({
|
|
115
|
+
const participationProduct = await LoanProduct.findOne({ masteredLoanProductId: masterProduct._id }).lean();
|
|
116
116
|
if (!participationProduct) {
|
|
117
117
|
return 0;
|
|
118
118
|
}
|
|
@@ -29,7 +29,7 @@ export class LoanProductsService {
|
|
|
29
29
|
const masterProducts = await LoanProduct.find({ code: { $in: codes } });
|
|
30
30
|
const masterProductIds = masterProducts.map((product) => product._id);
|
|
31
31
|
const loanProducts = await LoanProduct
|
|
32
|
-
.find({
|
|
32
|
+
.find({ masteredLoanProductId: { $in: masterProductIds } })
|
|
33
33
|
.sort({ code: 1 })
|
|
34
34
|
.lean();
|
|
35
35
|
return loanProducts.reduce((acc, loanProduct) => ({ ...acc, [loanProduct.code]: loanProduct._id.toString() }), {});
|
|
@@ -416,7 +416,7 @@ export class QuickbooksService {
|
|
|
416
416
|
if (totalAmountValue === 0) {
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
let totalAmount = product.
|
|
419
|
+
let totalAmount = product.masteredLoanProductId != null ? -totalAmountValue : totalAmountValue;
|
|
420
420
|
totalAmount = isAccrual ? totalAmount : -totalAmount;
|
|
421
421
|
const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
|
|
422
422
|
const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
|
|
@@ -433,7 +433,7 @@ export class QuickbooksService {
|
|
|
433
433
|
...trTemplate,
|
|
434
434
|
productId,
|
|
435
435
|
class: borrower.code,
|
|
436
|
-
memo: `${borrower.code} ${product.
|
|
436
|
+
memo: `${borrower.code} ${product.masteredLoanProductId != null ? 'PARTICIPANT' : ''} ${EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
437
437
|
};
|
|
438
438
|
|
|
439
439
|
tr.account = quickbooksAccountBS.fullName;
|
|
@@ -500,8 +500,8 @@ export class QuickbooksService {
|
|
|
500
500
|
...trTemplate,
|
|
501
501
|
productId,
|
|
502
502
|
class: borrower.code,
|
|
503
|
-
amount: product.
|
|
504
|
-
memo: `${borrower.code} ${product.
|
|
503
|
+
amount: product.masteredLoanProductId != null ? +amount : -+amount,
|
|
504
|
+
memo: `${borrower.code} ${product.masteredLoanProductId != null ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
505
505
|
};
|
|
506
506
|
|
|
507
507
|
if (settlementCode === 'null') {
|
|
@@ -100,7 +100,7 @@ export class InvestorSummaryService {
|
|
|
100
100
|
await Promise.all(borrowerIds.map(async (borrowerId) => {
|
|
101
101
|
const borrower = await BorrowerModel.findById(borrowerId).lean();
|
|
102
102
|
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
|
|
103
|
-
await Promise.all(borrowerProducts.filter((product) => product.
|
|
103
|
+
await Promise.all(borrowerProducts.filter((product) => product.masteredLoanProductId == null).map(async (product) => {
|
|
104
104
|
const productId = product._id.toString();
|
|
105
105
|
const isRevolver = product.type === ELoanTypes.REVOLVER;
|
|
106
106
|
const { balance: balanceEnd } = await this.loanChargesService.getLoanProductBalance(productId, end);
|
|
@@ -426,7 +426,7 @@ export class ReportsService {
|
|
|
426
426
|
const manyTermProduct = products.filter((product) => product.type === ELoanTypes.TERM).length > 1;
|
|
427
427
|
|
|
428
428
|
return await Promise.all(products.map(async (product) => {
|
|
429
|
-
if (product.
|
|
429
|
+
if (product.masteredLoanProductId != null) {
|
|
430
430
|
return null as IBankReportData;
|
|
431
431
|
}
|
|
432
432
|
if (dayjs(product.deactivationDate).isBefore(dayjs(date))) {
|