gemcap-be-common 1.5.20 → 1.5.22
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/package.json +1 -1
- package/services/loan-payments.service.js +5 -1
- package/services/loan-payments.service.ts +4 -1
- package/services/loan-statement.service.js +1 -1
- package/services/loan-statement.service.ts +1 -1
- package/services/loan-transactions.service.js +3 -1
- package/services/loan-transactions.service.ts +3 -1
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -248,6 +248,7 @@ class LoanPaymentsService {
|
|
|
248
248
|
}
|
|
249
249
|
async recalculateProduct(productId, userId) {
|
|
250
250
|
const loanCharges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
251
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
251
252
|
const chargesIds = loanCharges.map((charge) => charge._id);
|
|
252
253
|
await LoanStatementTransaction_model_1.LoanStatementTransactionModel.updateMany({ 'chargeId': { $in: chargesIds } }, { amountPaid: 0 });
|
|
253
254
|
const firstStatements = await LoanStatementTransaction_model_1.LoanStatementTransactionModel.aggregate([
|
|
@@ -281,7 +282,7 @@ class LoanPaymentsService {
|
|
|
281
282
|
]);
|
|
282
283
|
for (const [index, payment] of payments.entries()) {
|
|
283
284
|
try {
|
|
284
|
-
console.log(`updating payment ${index + 1}/${payments.length}`, (0, dayjs_1.default)(payment.date).format('DD-MM-YYYY'), payment.amount);
|
|
285
|
+
console.log(`updating payment (for ${product.name}) ${index + 1}/${payments.length}`, (0, dayjs_1.default)(payment.date).format('DD-MM-YYYY'), payment.amount);
|
|
285
286
|
for (const loanTransaction of payment.loanTransactions) {
|
|
286
287
|
await LoanTransaction_model_1.LoanTransaction.findByIdAndDelete(loanTransaction.transactionId);
|
|
287
288
|
}
|
|
@@ -292,6 +293,9 @@ class LoanPaymentsService {
|
|
|
292
293
|
console.error({ productId, payments });
|
|
293
294
|
console.error(e);
|
|
294
295
|
}
|
|
296
|
+
finally {
|
|
297
|
+
console.log(`finished updating payment (for ${product.name}) ${index + 1}/${payments.length}`);
|
|
298
|
+
}
|
|
295
299
|
}
|
|
296
300
|
}
|
|
297
301
|
async getPaymentsForPeriod(productIds, startDate, endDate) {
|
|
@@ -285,6 +285,7 @@ export class LoanPaymentsService {
|
|
|
285
285
|
|
|
286
286
|
async recalculateProduct(productId: string, userId: string) {
|
|
287
287
|
const loanCharges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
288
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
288
289
|
const chargesIds = loanCharges.map((charge) => charge._id);
|
|
289
290
|
await LoanStatementTransactionModel.updateMany({ 'chargeId': { $in: chargesIds } }, { amountPaid: 0 });
|
|
290
291
|
|
|
@@ -321,7 +322,7 @@ export class LoanPaymentsService {
|
|
|
321
322
|
]);
|
|
322
323
|
for (const [index, payment] of payments.entries()) {
|
|
323
324
|
try {
|
|
324
|
-
console.log(`updating payment ${index + 1}/${payments.length}`, dayjs(payment.date).format('DD-MM-YYYY'), payment.amount);
|
|
325
|
+
console.log(`updating payment (for ${product.name}) ${index + 1}/${payments.length}`, dayjs(payment.date).format('DD-MM-YYYY'), payment.amount);
|
|
325
326
|
for (const loanTransaction of payment.loanTransactions) {
|
|
326
327
|
await LoanTransaction.findByIdAndDelete(loanTransaction.transactionId);
|
|
327
328
|
}
|
|
@@ -330,6 +331,8 @@ export class LoanPaymentsService {
|
|
|
330
331
|
} catch (e) {
|
|
331
332
|
console.error({ productId, payments });
|
|
332
333
|
console.error(e);
|
|
334
|
+
} finally {
|
|
335
|
+
console.log(`finished updating payment (for ${product.name}) ${index + 1}/${payments.length}`);
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
338
|
}
|
|
@@ -166,7 +166,7 @@ class LoanStatementService {
|
|
|
166
166
|
}
|
|
167
167
|
async calculateStatement(productId, period, statementDate) {
|
|
168
168
|
if (!statementDate) {
|
|
169
|
-
statementDate =
|
|
169
|
+
statementDate = dayjs_1.default.utc().startOf('day').toDate();
|
|
170
170
|
}
|
|
171
171
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(financial_indexes_service_1.EFinancialIndex.PRIME_RATE, statementDate);
|
|
172
172
|
if (!primeRate) {
|
|
@@ -201,7 +201,7 @@ export class LoanStatementService {
|
|
|
201
201
|
|
|
202
202
|
async calculateStatement(productId: string, period: IStatementPeriod, statementDate?: Date) {
|
|
203
203
|
if (!statementDate) {
|
|
204
|
-
statementDate = dayjs
|
|
204
|
+
statementDate = dayjs.utc().startOf('day').toDate();
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(EFinancialIndex.PRIME_RATE, statementDate);
|
|
@@ -176,8 +176,10 @@ class LoanTransactionsService {
|
|
|
176
176
|
}));
|
|
177
177
|
}
|
|
178
178
|
async getDisbursementTransactions(productId, date) {
|
|
179
|
+
const startOfDay = dayjs_1.default.utc(date).startOf('day').toDate();
|
|
180
|
+
const endOfDay = dayjs_1.default.utc(date).endOf('day').toDate();
|
|
179
181
|
return LoanTransaction_model_1.LoanTransaction.countDocuments({
|
|
180
|
-
date:
|
|
182
|
+
date: { $gte: startOfDay, $lte: endOfDay },
|
|
181
183
|
productId: new mongoose_1.default.Types.ObjectId(productId),
|
|
182
184
|
transactionType: LoanTransaction_model_1.ELoanTransactionTypes.DISBURSEMENT,
|
|
183
185
|
bankId: { $ne: null },
|
|
@@ -218,9 +218,11 @@ export class LoanTransactionsService {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
async getDisbursementTransactions(productId: string, date: Date) {
|
|
221
|
+
const startOfDay = dayjs.utc(date).startOf('day').toDate();
|
|
222
|
+
const endOfDay = dayjs.utc(date).endOf('day').toDate();
|
|
221
223
|
return LoanTransaction.countDocuments(
|
|
222
224
|
{
|
|
223
|
-
date:
|
|
225
|
+
date: { $gte: startOfDay, $lte: endOfDay },
|
|
224
226
|
productId: new mongoose.Types.ObjectId(productId),
|
|
225
227
|
transactionType: ELoanTransactionTypes.DISBURSEMENT,
|
|
226
228
|
bankId: { $ne: null },
|