Merge pull request #2515 from alberto-art3ch/enhancement/loan_account_undo_contract_termination

Loan account Contract Termination undo
This commit is contained in:
Jose Alberto Hernandez
2025-06-11 23:41:48 -05:00
committed by GitHub
3 changed files with 73 additions and 29 deletions
@@ -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
);
}
@@ -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() {
@@ -36,4 +36,5 @@ export interface LoanTransactionType {
capitalizedIncomeAdjustment: boolean;
capitalizedIncomeAmortization: boolean;
capitalizedIncomeAmortizationAdjustment: boolean;
contractTermination: boolean;
}