Undo Loan Charge-off transaction

This commit is contained in:
Jose Alberto Hernandez
2025-01-02 01:40:30 -05:00
committed by Jose Alberto Hernandez
parent 54ac7b4612
commit 5e5c7ed47d
15 changed files with 33 additions and 6 deletions
@@ -54,7 +54,6 @@
<mifosx-add-loan-charge *ngIf="actions['Add Loan Charge']"></mifosx-add-loan-charge>
<mifosx-edit-repayment-schedule *ngIf="actions['Edit Repayment Schedule']"></mifosx-edit-repayment-schedule>
<mifosx-charge-off [dataObject]="actionButtonData" *ngIf="actions['Charge-Off']"></mifosx-charge-off>
<mifosx-undo-command [actionName]="actionName" *ngIf="actions['Undo Charge-Off']"></mifosx-undo-command>
<mifosx-asset-transfer-loan *ngIf="actions['Sell Loan'] || actions['Buy Back Loan']"></mifosx-asset-transfer-loan>
<mifosx-loan-reaging [dataObject]="actionButtonData" *ngIf="actions['Re-Age']"></mifosx-loan-reaging>
<mifosx-loan-reamortize [dataObject]="actionButtonData" *ngIf="actions['Re-Amortize']"></mifosx-loan-reamortize>
@@ -42,7 +42,6 @@ export class LoanAccountActionsComponent {
'Credit Balance Refund': boolean,
'Edit Repayment Schedule': boolean,
'Charge-Off': boolean,
'Undo Charge-Off': boolean,
'Sell Loan': boolean,
'Buy Back Loan': boolean,
'Re-Age': boolean
@@ -76,7 +75,6 @@ export class LoanAccountActionsComponent {
'Credit Balance Refund': false,
'Edit Repayment Schedule': false,
'Charge-Off': false,
'Undo Charge-Off': false,
'Sell Loan': false,
'Buy Back Loan': false,
'Re-Age': false
@@ -176,6 +176,12 @@ export class LoansViewComponent implements OnInit {
icon: 'coins',
taskPermissionName: 'CHARGEOFF_LOAN'
});
} else {
this.buttonConfig.addButton({
name: 'Undo Charge-Off',
icon: 'undo',
taskPermissionName: 'UNDOCHARGEOFF_LOAN'
});
}
// Allow Re-Ageing only when there is not any Re-Age transaction
@@ -226,7 +232,8 @@ export class LoansViewComponent implements OnInit {
break;
case 'Undo Re-Age':
case 'Undo Re-Amortize':
this.undoReAgeOrReAmortize(actionName);
case 'Undo Charge-Off':
this.undoLoanAction(actionName);
break;
default:
this.router.navigate(['actions', actionName], { relativeTo: this.route });
@@ -261,7 +268,7 @@ export class LoansViewComponent implements OnInit {
}
}
undoReAgeOrReAmortize(actionName: string): void {
undoLoanAction(actionName: string): void {
actionName = actionName.replace('Undo ', '');
const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
@@ -271,7 +278,18 @@ export class LoansViewComponent implements OnInit {
});
undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
const undoCommand = actionName === 'Re-Age' ? 'undoReAge' : 'undoReAmortize';
let undoCommand: string = '';
switch (actionName) {
case 'Re-Age':
undoCommand = 'undoReAge';
break;
case 'Re-Amortize':
undoCommand = 'undoReAmortize';
break;
case 'Charge-Off':
undoCommand = 'undo-charge-off';
break;
}
this.loansService.executeLoansAccountTransactionsCommand(String(this.loanId), undoCommand, {}).subscribe(() => {
this.reload();
});