Support for Recurring Deposits undo Activation

This commit is contained in:
Jose Alberto Hernandez
2024-01-15 10:23:41 +01:00
committed by Adam Saghy
parent ff491250e4
commit 3e589894ce
18 changed files with 65 additions and 9 deletions
@@ -1,5 +1,5 @@
<mifosx-activate-recurring-deposits-account *ngIf="actions['Activate']"></mifosx-activate-recurring-deposits-account>
<mifosx-undo-approval-recurring-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-recurring-deposits-account>
<mifosx-undo-approval-recurring-deposits-account *ngIf="actions['Undo Approval'] || actions['Undo Activation']"></mifosx-undo-approval-recurring-deposits-account>
<mifosx-approve-recurring-deposits-account *ngIf="actions['Approve']"></mifosx-approve-recurring-deposits-account>
<mifosx-reject-recurring-deposits-account *ngIf="actions['Reject']"></mifosx-reject-recurring-deposits-account>
<mifosx-withdraw-by-client-recurring-deposits-account *ngIf="actions['Withdrawn by client']"></mifosx-withdraw-by-client-recurring-deposits-account>
@@ -12,6 +12,7 @@ export class RecurringDepositsAccountActionsComponent {
/** Flag object to store possible actions and render appropriate UI to the user */
actions: {
'Activate': boolean
'Undo Activation': boolean
'Undo Approval': boolean
'Approve': boolean
'Reject': boolean
@@ -23,6 +24,7 @@ export class RecurringDepositsAccountActionsComponent {
'Withdrawal': boolean
} = {
'Activate': false,
'Undo Activation': false,
'Undo Approval': false,
'Approve': false,
'Reject': false,
@@ -20,6 +20,9 @@ export class UndoApprovalRecurringDepositsAccountComponent implements OnInit {
undoApprovalRecurringDepositsAccountForm: UntypedFormGroup;
/** Recurring Deposits Account Id */
accountId: any;
/** Action to be Undo */
undoAction: string;
undoCommand: string;
/**
* @param {FormBuilder} formBuilder Form Builder
@@ -31,6 +34,11 @@ export class UndoApprovalRecurringDepositsAccountComponent implements OnInit {
private recurringDepositsService: RecurringDepositsService,
private route: ActivatedRoute,
private router: Router) {
this.undoCommand = 'undoapproval'; // Default command
this.undoAction = this.route.snapshot.params['name'];
if (this.undoAction === 'Undo Activation') {
this.undoCommand = 'undoactivate';
}
this.accountId = this.route.parent.snapshot.params['recurringDepositAccountId'];
}
@@ -58,9 +66,15 @@ export class UndoApprovalRecurringDepositsAccountComponent implements OnInit {
const data = {
...this.undoApprovalRecurringDepositsAccountForm.value,
};
this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, 'undoapproval', data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
if (this.undoAction === 'Undo Activation') {
this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, this.undoCommand, data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
} else {
this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, 'undoapproval', data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
}
@@ -71,10 +71,7 @@
<mat-menu #accountMenu="matMenu">
<ng-container *ngFor="let item of buttonConfig.singleButtons">
<button mat-menu-item *mifosxHasPermission="item.taskPermissionName" (click)="doAction(item.name)">
<mat-icon matListIcon>
<fa-icon icon="{{item.icon}}" size="sm"></fa-icon>
</mat-icon>
<span> {{'labels.menus.' + item.name | translate}} </span>
<i ngClass="{{item.icon}}"></i> {{'labels.menus.' + item.name | translate}}
</button>
</ng-container>
@@ -105,7 +102,7 @@
[active]="IRC.isActive">
{{"labels.inputs.Interest Rate Chart" | translate }}
</a>
<ng-container *ngIf="recurringDepositsAccountData.transactions">
<ng-container *ngIf="showTransactions">
<a mat-tab-link [routerLink]="['./transactions']" routerLinkActive #transactions="routerLinkActive"
[active]="transactions.isActive">
{{"labels.inputs.Transactions" | translate }}
@@ -39,6 +39,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
isprematureAllowed: any;
entityType: string;
currency: Currency;
showTransactions = false;
/**
* Fetches recurringDeposits account data from `resolve`
* @param {ActivatedRoute} route Activated Route
@@ -64,6 +65,8 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
} else if (this.router.url.includes('centers')) {
this.entityType = 'Center';
}
const status: any = data.recurringDepositsAccountData.status;
this.showTransactions = (status.id >= 300);
});
}
@@ -156,6 +159,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
doAction(name: string) {
switch (name) {
case 'Activate':
case 'Undo Activation':
case 'Approve':
case 'Reject':
case 'Undo Approval':
@@ -44,6 +44,11 @@ export class RecurringDepositsButtonsConfiguration {
name: 'Calculate Interest',
icon: 'calculator',
taskPermissionName: 'CALCULATEINTEREST_RECURRINGDEPOSITACCOUNT'
},
{
name: 'Undo Activation',
icon: 'fa fa-undo',
taskPermissionName: 'UNDO_ACTIVATE_RECURRINGDEPOSITACCOUNT'
}
];
break;