From c42304ffa6e63dbab2356999d1c44fa129ccd82d Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Wed, 11 Jun 2025 23:40:09 -0500 Subject: [PATCH] Loan account Contract Termination undo --- .../transactions-tab.component.ts | 7 +- .../view-transaction.component.ts | 94 ++++++++++++++----- .../models/loan-transaction-type.model.ts | 1 + 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts index 35f61184e..75a91d7d6 100644 --- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts +++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts @@ -196,7 +196,7 @@ export class TransactionsTabComponent implements OnInit { * INTEREST REFUND:33 * CAPITALIZED INCOME:35 * CAPITALIZED INCOME ADJUSTMENT:37 - * CONTRACT_TERMINATION:90 + * CONTRACT_TERMINATION:38 */ showTransaction(transactionsData: LoanTransaction): boolean { return [ @@ -216,7 +216,7 @@ export class TransactionsTabComponent implements OnInit { 33, 35, 37, - 90 + 38 ].includes(transactionsData.type.id); } @@ -228,7 +228,8 @@ export class TransactionsTabComponent implements OnInit { transaction.type.disbursement || transaction.type.chargeoff || this.isReAgoeOrReAmortize(transaction.type) || - transaction.type.interestRefund + transaction.type.interestRefund || + transaction.type.contractTermination ); } diff --git a/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts b/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts index 06a0ee188..de227ff8e 100644 --- a/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts +++ b/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts @@ -163,35 +163,77 @@ export class ViewTransactionComponent implements OnInit { * Undo the loans transaction */ undoTransaction() { + console.log(this.transactionData); const accountId = this.route.snapshot.params['loanId']; - const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, { - data: { - heading: this.translateService.instant('labels.heading.Undo Transaction'), - dialogContext: - this.translateService.instant('labels.dialogContext.Are you sure you want undo the transaction') + - `${this.transactionData.id}` - } - }); - undoTransactionAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => { - if (response.confirm) { - const locale = this.settingsService.language.code; - const dateFormat = this.settingsService.dateFormat; - const data = { - transactionDate: this.dateUtils.formatDate( - this.transactionData.date && new Date(this.transactionData.date), - dateFormat - ), - transactionAmount: 0, - dateFormat, - locale - }; - this.loansService - .executeLoansAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id) - .subscribe(() => { + + if (this.transactionType.contractTermination) { + const formfields: FormfieldBase[] = [ + new InputBase({ + controlName: 'note', + label: 'Note', + value: '', + type: 'text', + required: false, + order: 1 + }), + new InputBase({ + controlName: 'reversalExternalId', + label: 'externalId', + value: '', + type: 'text', + required: false, + order: 2 + }) + + ]; + const data = { + title: this.translateService.instant('labels.heading.Undo Transaction'), + layout: { addButtonText: 'Undo' }, + formfields: formfields + }; + const undoTransactionAccountDialogRef = this.dialog.open(FormDialogComponent, { data, width: '50rem' }); + undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + const payload = { + note: response.data.value.note, + reversalExternalId: response.data.value.reversalExternalId + }; + + this.loansService.loanActionButtons(accountId, 'undoContractTermination', payload).subscribe(() => { this.router.navigate(['../'], { relativeTo: this.route }); }); - } - }); + } + }); + } else { + const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, { + data: { + heading: this.translateService.instant('labels.heading.Undo Transaction'), + dialogContext: + this.translateService.instant('labels.dialogContext.Are you sure you want undo the transaction') + + `${this.transactionData.id}` + } + }); + undoTransactionAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => { + if (response.confirm) { + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const data = { + transactionDate: this.dateUtils.formatDate( + this.transactionData.date && new Date(this.transactionData.date), + dateFormat + ), + transactionAmount: 0, + dateFormat, + locale + }; + this.loansService + .executeLoansAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id) + .subscribe(() => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + }); + } } chargebackTransaction() { diff --git a/src/app/loans/models/loan-transaction-type.model.ts b/src/app/loans/models/loan-transaction-type.model.ts index 96cf2f243..8e2b1fbfb 100644 --- a/src/app/loans/models/loan-transaction-type.model.ts +++ b/src/app/loans/models/loan-transaction-type.model.ts @@ -36,4 +36,5 @@ export interface LoanTransactionType { capitalizedIncomeAdjustment: boolean; capitalizedIncomeAmortization: boolean; capitalizedIncomeAmortizationAdjustment: boolean; + contractTermination: boolean; }