pending account terminate feature develop

This commit is contained in:
keshav898966
2026-07-01 17:19:38 +05:30
parent 9afb177c69
commit d00eac0aa1
19 changed files with 471 additions and 17 deletions
@@ -24,6 +24,9 @@ import { SavingsService } from '../savings.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';
@@ -75,6 +78,9 @@ export class SavingsAccountViewComponent implements OnInit {
private router = inject(Router);
private savingsService = inject(SavingsService);
private translateService = inject(TranslateService);
private accountsService = inject(AccountsService);
private settingsService = inject(SettingsService);
private dateUtils = inject(Dates);
dialog = inject(MatDialog);
/** Savings Account Data */
@@ -124,7 +130,8 @@ export class SavingsAccountViewComponent implements OnInit {
Close: 'danger',
Reject: 'danger',
Delete: 'danger',
'Withdrawn by Client': 'danger'
'Withdrawn by Client': 'danger',
Terminate: 'danger'
};
/** Lightweight icon fallback for actions whose buttonConfig doesn't
@@ -157,7 +164,8 @@ export class SavingsAccountViewComponent implements OnInit {
Close: 'times-circle',
Reject: 'ban',
Delete: 'trash',
'Withdrawn by Client': 'user-slash'
'Withdrawn by Client': 'user-slash',
Terminate: 'times-circle'
};
/** Returns the colour kind for a given action name (used to tint the
@@ -306,6 +314,9 @@ export class SavingsAccountViewComponent implements OnInit {
case 'Delete':
this.deleteSavingsAccount();
break;
case 'Terminate':
this.terminateSavingsAccount();
break;
case 'Calculate Interest':
this.calculateInterest();
break;
@@ -363,6 +374,35 @@ export class SavingsAccountViewComponent implements OnInit {
});
}
/**
* Terminates Savings Account.
*/
private terminateSavingsAccount() {
const terminateSavingsAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
heading: 'Terminate Account',
dialogContext: 'Are you sure you want to terminate this account?',
type: 'Strong'
}
});
terminateSavingsAccountDialogRef.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: 'SAVINGS',
terminatedOnDate,
dateFormat,
locale
};
this.accountsService.terminateAccount(this.savingsAccountData.id, data).subscribe(() => {
this.reload();
});
}
});
}
/**
* Calculates savings account's interest
*/
@@ -192,6 +192,10 @@ export class SavingsButtonsConfiguration {
{
name: 'Delete',
taskPermissionName: 'DELETE_SAVINGSACCOUNT'
},
{
name: 'Terminate',
taskPermissionName: 'DELETE_SAVINGSACCOUNT'
}
];
break;