gemcap-be-common 1.4.70 → 1.4.71
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/loan-products.db.d.ts +1 -1
- package/db/loan-products.db.js +5 -5
- package/db/loan-products.db.ts +5 -5
- package/package.json +1 -1
- package/services/loan-statement.service.js +2 -1
- package/services/loan-statement.service.ts +2 -1
- package/services/loan-transactions.service.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/db/loan-products.db.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const fieldsToUnset: string[];
|
|
|
30
30
|
export declare const getLoanProductById: (productId: string) => Promise<mongoose.FlattenMaps<import("../models/LoanProducts.model").ILoanProductDoc> & {
|
|
31
31
|
_id: mongoose.Types.ObjectId;
|
|
32
32
|
}>;
|
|
33
|
-
export declare const getLoanProductBalance: (productId: string,
|
|
33
|
+
export declare const getLoanProductBalance: (productId: string, asOfDate?: Date) => Promise<{
|
|
34
34
|
balance: number;
|
|
35
35
|
floatedBalance: number;
|
|
36
36
|
}>;
|
package/db/loan-products.db.js
CHANGED
|
@@ -21,12 +21,12 @@ const getLoanProductById = async (productId) => {
|
|
|
21
21
|
return LoanProducts_model_1.LoanProduct.findById(productId).lean();
|
|
22
22
|
};
|
|
23
23
|
exports.getLoanProductById = getLoanProductById;
|
|
24
|
-
const getLoanProductBalance = async (productId,
|
|
24
|
+
const getLoanProductBalance = async (productId, asOfDate = new Date()) => {
|
|
25
25
|
const simpleTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
|
|
26
26
|
{
|
|
27
27
|
$match: {
|
|
28
28
|
'productId': new mongoose_1.default.Types.ObjectId(productId),
|
|
29
|
-
'date': { $lte:
|
|
29
|
+
'date': { $lte: asOfDate },
|
|
30
30
|
},
|
|
31
31
|
}, {
|
|
32
32
|
$sort: {
|
|
@@ -42,7 +42,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
|
|
|
42
42
|
{
|
|
43
43
|
$match: {
|
|
44
44
|
'productId': new mongoose_1.default.Types.ObjectId(productId),
|
|
45
|
-
'effectiveDate': { $lte:
|
|
45
|
+
'effectiveDate': { $lte: asOfDate },
|
|
46
46
|
$expr: { $ne: ['$date', '$effectiveDate'] },
|
|
47
47
|
},
|
|
48
48
|
}, {
|
|
@@ -59,7 +59,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
|
|
|
59
59
|
{
|
|
60
60
|
$match: {
|
|
61
61
|
'productId': new mongoose_1.default.Types.ObjectId(productId),
|
|
62
|
-
'effectiveDate': { $lte:
|
|
62
|
+
'effectiveDate': { $lte: asOfDate },
|
|
63
63
|
$expr: { $eq: ['$date', '$effectiveDate'] },
|
|
64
64
|
},
|
|
65
65
|
}, {
|
|
@@ -97,7 +97,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
|
|
|
97
97
|
if (normalTransaction && !collectionsTransaction) {
|
|
98
98
|
floatedBalance = normalTransaction.floatedBalance;
|
|
99
99
|
}
|
|
100
|
-
const totalPostponed = await (0, exports.getPostponedTransactions)(
|
|
100
|
+
const totalPostponed = await (0, exports.getPostponedTransactions)(asOfDate, productId);
|
|
101
101
|
if (transactions.length === 0) {
|
|
102
102
|
return { balance: 0, floatedBalance: totalPostponed };
|
|
103
103
|
}
|
package/db/loan-products.db.ts
CHANGED
|
@@ -21,13 +21,13 @@ export const getLoanProductById = async (productId: string) => {
|
|
|
21
21
|
return LoanProduct.findById(productId).lean();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const getLoanProductBalance = async (productId: string,
|
|
24
|
+
export const getLoanProductBalance = async (productId: string, asOfDate = new Date()) => {
|
|
25
25
|
|
|
26
26
|
const simpleTransactions = await LoanTransaction.aggregate<ILoanTransactionDoc>([
|
|
27
27
|
{
|
|
28
28
|
$match: {
|
|
29
29
|
'productId': new mongoose.Types.ObjectId(productId),
|
|
30
|
-
'date': { $lte:
|
|
30
|
+
'date': { $lte: asOfDate },
|
|
31
31
|
},
|
|
32
32
|
}, {
|
|
33
33
|
$sort: {
|
|
@@ -44,7 +44,7 @@ export const getLoanProductBalance = async (productId: string, forDate = new Dat
|
|
|
44
44
|
{
|
|
45
45
|
$match: {
|
|
46
46
|
'productId': new mongoose.Types.ObjectId(productId),
|
|
47
|
-
'effectiveDate': { $lte:
|
|
47
|
+
'effectiveDate': { $lte: asOfDate },
|
|
48
48
|
$expr: { $ne: ['$date', '$effectiveDate'] },
|
|
49
49
|
},
|
|
50
50
|
}, {
|
|
@@ -62,7 +62,7 @@ export const getLoanProductBalance = async (productId: string, forDate = new Dat
|
|
|
62
62
|
{
|
|
63
63
|
$match: {
|
|
64
64
|
'productId': new mongoose.Types.ObjectId(productId),
|
|
65
|
-
'effectiveDate': { $lte:
|
|
65
|
+
'effectiveDate': { $lte: asOfDate },
|
|
66
66
|
$expr: { $eq: ['$date', '$effectiveDate'] },
|
|
67
67
|
},
|
|
68
68
|
}, {
|
|
@@ -103,7 +103,7 @@ export const getLoanProductBalance = async (productId: string, forDate = new Dat
|
|
|
103
103
|
if (normalTransaction && !collectionsTransaction) {
|
|
104
104
|
floatedBalance = normalTransaction.floatedBalance;
|
|
105
105
|
}
|
|
106
|
-
const totalPostponed = await getPostponedTransactions(
|
|
106
|
+
const totalPostponed = await getPostponedTransactions(asOfDate, productId);
|
|
107
107
|
if (transactions.length === 0) {
|
|
108
108
|
return { balance: 0, floatedBalance: totalPostponed };
|
|
109
109
|
}
|
package/package.json
CHANGED
|
@@ -173,7 +173,8 @@ class LoanStatementService {
|
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
await this.cleanProductStatement(productId, statementDate);
|
|
176
|
-
const
|
|
176
|
+
const balanceDate = dayjs_1.default.utc(statementDate).add(1, 'day').subtract(1, 'second').toDate();
|
|
177
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, balanceDate);
|
|
177
178
|
const loanStatementEffectsService = this.getLoanStatementEffectsService();
|
|
178
179
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
179
180
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
@@ -208,7 +208,8 @@ export class LoanStatementService {
|
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
await this.cleanProductStatement(productId, statementDate);
|
|
211
|
-
const
|
|
211
|
+
const balanceDate = dayjs.utc(statementDate).add(1, 'day').subtract(1, 'second').toDate();
|
|
212
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, balanceDate);
|
|
212
213
|
|
|
213
214
|
const loanStatementEffectsService = this.getLoanStatementEffectsService();
|
|
214
215
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
@@ -155,7 +155,7 @@ export declare class LoanTransactionsService {
|
|
|
155
155
|
getTransactionReport(transactionIds: string[], borrowerId: string, effectiveDate: Date): Promise<{
|
|
156
156
|
transactionIdsToMark: any[];
|
|
157
157
|
transactions: {
|
|
158
|
-
[x: string]: (string | number |
|
|
158
|
+
[x: string]: (string | number | string[] | Date)[];
|
|
159
159
|
}[];
|
|
160
160
|
}>;
|
|
161
161
|
getBorrowerIdsForFile(transactionFileId: string): Promise<{
|