gemcap-be-common 1.3.105 → 1.3.107
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
CHANGED
|
@@ -270,7 +270,7 @@ class LoanTransactionsService {
|
|
|
270
270
|
.from(earliestTransactionIds.values())
|
|
271
271
|
.map((entry) => entry.transactionId);
|
|
272
272
|
await Promise.all(earliestTransactionIdsList.map(async (transactionId) => {
|
|
273
|
-
setTimeout(async () => await this.
|
|
273
|
+
setTimeout(async () => await this.recalculateBalanceQueued(null, transactionId));
|
|
274
274
|
}));
|
|
275
275
|
}
|
|
276
276
|
async normalizeLoanTransaction(transaction, userId) {
|
|
@@ -318,7 +318,6 @@ class LoanTransactionsService {
|
|
|
318
318
|
}
|
|
319
319
|
if (startId) {
|
|
320
320
|
this.recalculateBalanceQueued(transaction.productId.toString(), startId).catch(console.error);
|
|
321
|
-
// this.recalculateBalance(startId).catch(console.error);
|
|
322
321
|
}
|
|
323
322
|
const statementDate = this.loanStatementStatusService.getStatementDateForDate(new Date(transaction.date));
|
|
324
323
|
this.loanStatementStatusService.updateStatementStatus(transaction.productId.toString(), statementDate, false).catch(console.error);
|
|
@@ -340,7 +339,7 @@ class LoanTransactionsService {
|
|
|
340
339
|
},
|
|
341
340
|
]);
|
|
342
341
|
if (firstTransactions.length > 0) {
|
|
343
|
-
await this.
|
|
342
|
+
await this.recalculateBalanceQueued(firstTransactions[0].productId.toString(), firstTransactions[0]._id.toString());
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
async recalculateBalanceLegacy(transactionId) {
|
|
@@ -469,7 +468,7 @@ class LoanTransactionsService {
|
|
|
469
468
|
await recalcFloatedBalance();
|
|
470
469
|
}
|
|
471
470
|
async recalculateBalanceQueued(productId, transactionId) {
|
|
472
|
-
await this.mainQueueService.sendTaskToQueue({ productId, transactionId }, 'recalc#BALANCES');
|
|
471
|
+
await this.mainQueueService.sendTaskToQueue({ data: { productId, transactionId }, pattern: 'recalc#BALANCES' }, 'goat_legacy_queue');
|
|
473
472
|
}
|
|
474
473
|
async recalculateBalance(transactionId) {
|
|
475
474
|
const startTransaction = await LoanTransaction_model_1.LoanTransaction.findById(transactionId).lean();
|
|
@@ -568,7 +567,7 @@ class LoanTransactionsService {
|
|
|
568
567
|
}
|
|
569
568
|
}
|
|
570
569
|
if (nextTransaction.length) {
|
|
571
|
-
this.
|
|
570
|
+
this.recalculateBalanceQueued(nextTransaction[0].productId.toString(), nextTransaction[0]._id.toString()).catch(console.error);
|
|
572
571
|
}
|
|
573
572
|
const statementDate = this.loanStatementStatusService.getStatementDateForDate(new Date(currentTransaction.date));
|
|
574
573
|
this.loanStatementStatusService.updateStatementStatus(currentTransaction.productId.toString(), statementDate, false).catch(console.error);
|
|
@@ -324,7 +324,7 @@ export class LoanTransactionsService {
|
|
|
324
324
|
.map((entry) => entry.transactionId);
|
|
325
325
|
|
|
326
326
|
await Promise.all(earliestTransactionIdsList.map(async (transactionId) => {
|
|
327
|
-
setTimeout(async () => await this.
|
|
327
|
+
setTimeout(async () => await this.recalculateBalanceQueued(null, transactionId));
|
|
328
328
|
}));
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -375,7 +375,6 @@ export class LoanTransactionsService {
|
|
|
375
375
|
}
|
|
376
376
|
if (startId) {
|
|
377
377
|
this.recalculateBalanceQueued(transaction.productId.toString(), startId).catch(console.error);
|
|
378
|
-
// this.recalculateBalance(startId).catch(console.error);
|
|
379
378
|
}
|
|
380
379
|
const statementDate = this.loanStatementStatusService.getStatementDateForDate(new Date(transaction.date));
|
|
381
380
|
this.loanStatementStatusService.updateStatementStatus(transaction.productId.toString(), statementDate, false).catch(console.error);
|
|
@@ -399,7 +398,7 @@ export class LoanTransactionsService {
|
|
|
399
398
|
]);
|
|
400
399
|
|
|
401
400
|
if (firstTransactions.length > 0) {
|
|
402
|
-
await this.
|
|
401
|
+
await this.recalculateBalanceQueued(firstTransactions[0].productId.toString(), firstTransactions[0]._id.toString());
|
|
403
402
|
}
|
|
404
403
|
}
|
|
405
404
|
|
|
@@ -535,7 +534,7 @@ export class LoanTransactionsService {
|
|
|
535
534
|
}
|
|
536
535
|
|
|
537
536
|
async recalculateBalanceQueued(productId: string, transactionId: string) {
|
|
538
|
-
await this.mainQueueService.sendTaskToQueue({ productId, transactionId }, 'recalc#BALANCES');
|
|
537
|
+
await this.mainQueueService.sendTaskToQueue({ data: { productId, transactionId }, pattern: 'recalc#BALANCES' }, 'goat_legacy_queue');
|
|
539
538
|
}
|
|
540
539
|
|
|
541
540
|
async recalculateBalance(transactionId: string) {
|
|
@@ -652,7 +651,7 @@ export class LoanTransactionsService {
|
|
|
652
651
|
}
|
|
653
652
|
}
|
|
654
653
|
if (nextTransaction.length) {
|
|
655
|
-
this.
|
|
654
|
+
this.recalculateBalanceQueued(nextTransaction[0].productId.toString(), nextTransaction[0]._id.toString()).catch(console.error);
|
|
656
655
|
}
|
|
657
656
|
const statementDate = this.loanStatementStatusService.getStatementDateForDate(new Date(currentTransaction.date));
|
|
658
657
|
this.loanStatementStatusService.updateStatementStatus(currentTransaction.productId.toString(), statementDate, false).catch(console.error);
|
|
@@ -12,9 +12,8 @@ class MainQueueService {
|
|
|
12
12
|
const rabbitMQApi = NODE_ENV === 'development' ? 'localhost' : 'rabbitmq';
|
|
13
13
|
const connection = await amqplib_1.default.connect(`amqp://${rabbitMQApi}`, { heartbeat: 10 });
|
|
14
14
|
const channel = await connection.createChannel();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
channel.sendToQueue(queue, Buffer.from(JSON.stringify(task)));
|
|
15
|
+
await channel.assertQueue(queueName);
|
|
16
|
+
channel.sendToQueue(queueName, Buffer.from(JSON.stringify(task)));
|
|
18
17
|
await channel.close();
|
|
19
18
|
await connection.close();
|
|
20
19
|
console.log('new task is sent');
|
|
@@ -9,10 +9,9 @@ export class MainQueueService {
|
|
|
9
9
|
const rabbitMQApi = NODE_ENV === 'development' ? 'localhost' : 'rabbitmq';
|
|
10
10
|
const connection = await amqp.connect(`amqp://${rabbitMQApi}`, { heartbeat: 10 });
|
|
11
11
|
const channel = await connection.createChannel();
|
|
12
|
-
const queue = queueName;
|
|
13
12
|
|
|
14
|
-
await channel.assertQueue(
|
|
15
|
-
channel.sendToQueue(
|
|
13
|
+
await channel.assertQueue(queueName);
|
|
14
|
+
channel.sendToQueue(queueName, Buffer.from(JSON.stringify(task)));
|
|
16
15
|
|
|
17
16
|
await channel.close();
|
|
18
17
|
await connection.close();
|