pending account terminate feature develop
This commit is contained in:
@@ -24,6 +24,9 @@ import { ClientsService } from 'app/clients/clients.service';
|
||||
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
|
||||
import { Currency } from 'app/shared/models/general.model';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { AccountsService } from 'app/accounts/accounts.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/** Environment Configuration */
|
||||
import { environment } from '../../../environments/environment';
|
||||
@@ -83,6 +86,9 @@ export class CurrentAccountViewComponent implements OnInit {
|
||||
private currentAccountsService = inject(CurrentAccountsService);
|
||||
private clientsService = inject(ClientsService);
|
||||
private translateService = inject(TranslateService);
|
||||
private accountsService = inject(AccountsService);
|
||||
private settingsService = inject(SettingsService);
|
||||
private dateUtils = inject(Dates);
|
||||
dialog = inject(MatDialog);
|
||||
|
||||
/** Current Account Data */
|
||||
@@ -126,7 +132,8 @@ export class CurrentAccountViewComponent implements OnInit {
|
||||
Close: 'danger',
|
||||
Reject: 'danger',
|
||||
Delete: 'danger',
|
||||
'Withdrawn by Client': 'danger'
|
||||
'Withdrawn by Client': 'danger',
|
||||
Terminate: 'danger'
|
||||
};
|
||||
|
||||
private readonly ACTION_ICON: Record<string, string> = {
|
||||
@@ -157,7 +164,8 @@ export class CurrentAccountViewComponent implements OnInit {
|
||||
Close: 'times-circle',
|
||||
Reject: 'ban',
|
||||
Delete: 'trash',
|
||||
'Withdrawn by Client': 'user-slash'
|
||||
'Withdrawn by Client': 'user-slash',
|
||||
Terminate: 'times-circle'
|
||||
};
|
||||
|
||||
kindOf(name: string): 'transact' | 'block' | 'interest' | 'admin' | 'danger' {
|
||||
@@ -309,6 +317,9 @@ export class CurrentAccountViewComponent implements OnInit {
|
||||
case 'Delete':
|
||||
this.deleteCurrentAccount();
|
||||
break;
|
||||
case 'Terminate':
|
||||
this.terminateCurrentAccount();
|
||||
break;
|
||||
case 'Calculate Interest':
|
||||
this.calculateInterest();
|
||||
break;
|
||||
@@ -370,6 +381,32 @@ export class CurrentAccountViewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private terminateCurrentAccount() {
|
||||
const terminateCurrentAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
heading: 'Terminate Account',
|
||||
dialogContext: 'Are you sure you want to terminate this account?',
|
||||
type: 'Strong'
|
||||
}
|
||||
});
|
||||
terminateCurrentAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response && response.confirm) {
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const terminatedOnDate = this.dateUtils.formatDate(new Date(), dateFormat);
|
||||
const data = {
|
||||
accountType: 'CURRENT',
|
||||
terminatedOnDate,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.accountsService.terminateAccount(this.currentAccountData.id, data).subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates current account's interest
|
||||
*/
|
||||
|
||||
@@ -194,6 +194,10 @@ export class CurrentAccountButtonsConfiguration {
|
||||
{
|
||||
name: 'Delete',
|
||||
taskPermissionName: 'DELETE_CURRENTACCOUNT'
|
||||
},
|
||||
{
|
||||
name: 'Terminate',
|
||||
taskPermissionName: 'DELETE_CURRENTACCOUNT'
|
||||
}
|
||||
];
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user