Savings account status and substatus management (#1606)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2022-12-26 23:38:53 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent d0dc2aabb2
commit e2fbfc9c2f
23 changed files with 215 additions and 125 deletions
@@ -4,7 +4,6 @@
<h2 mat-title *ngIf="transactionType.holdamount">Hold Amount</h2>
<h2 mat-title *ngIf="transactionType.blockaccount">Block Savings Account</h2>
<h2 mat-title *ngIf="transactionType.unblockaccount">Unblock Savings Account</h2>
<form [formGroup]="manageSavingsAccountForm" (ngSubmit)="submit()">
@@ -27,10 +27,10 @@ export class ManageSavingsAccountComponent implements OnInit {
transactionType: {
holdamount: boolean,
blockaccount: boolean,
unblockaccount: boolean
blockaccount: boolean
} = {
holdamount: false, blockaccount: false, unblockaccount: false };
holdamount: false, blockaccount: false
};
/**
* @param {FormBuilder} formBuilder Form Builder
@@ -41,12 +41,12 @@ export class ManageSavingsAccountComponent implements OnInit {
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private systemService: SystemService,
private settingsService: SettingsService) {
private savingsService: SavingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private systemService: SystemService,
private settingsService: SettingsService) {
this.transactionCommand = this.route.snapshot.params['name'].toLowerCase().replaceAll(' ', '');
this.transactionType[this.transactionCommand] = true;
this.savingAccountId = this.route.parent.snapshot.params['savingAccountId'];
@@ -83,15 +83,15 @@ export class ManageSavingsAccountComponent implements OnInit {
}
/**
* Creates the post interest savings account form.
* Creates the manage savings account form.
*/
createManageSavingsAccountForm() {
if (this.transactionType.holdamount) {
this.manageSavingsAccountForm = this.formBuilder.group({
'reasonForBlock': ['', Validators.required],
'transactionDate': ['', Validators.required],
'transactionAmount': [0.0, Validators.required]
});
this.manageSavingsAccountForm = this.formBuilder.group({
'reasonForBlock': ['', Validators.required],
'transactionDate': ['', Validators.required],
'transactionAmount': [0.0, Validators.required]
});
} else {
this.manageSavingsAccountForm = this.formBuilder.group({
'reasonForBlock': ['', Validators.required]
@@ -101,7 +101,7 @@ export class ManageSavingsAccountComponent implements OnInit {
submit() {
let command = '';
let payload = { };
let payload = {};
if (this.transactionType.holdamount) {
const manageSavingsAccountFormData = this.manageSavingsAccountForm.value;
@@ -119,7 +119,6 @@ export class ManageSavingsAccountComponent implements OnInit {
command = 'holdAmount';
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, command, payload).subscribe((response: any) => {
console.log(response);
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});
} else {
@@ -131,7 +130,6 @@ export class ManageSavingsAccountComponent implements OnInit {
}
this.savingsService.executeSavingsAccountCommand(this.savingAccountId, command, payload).subscribe((response: any) => {
console.log(response);
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});
}
@@ -10,4 +10,4 @@
<mifosx-savings-transactions *ngIf="actions['Withdrawal'] || actions['Deposit']"></mifosx-savings-transactions>
<mifosx-close-savings-account *ngIf="actions['Close']"></mifosx-close-savings-account>
<mifosx-apply-annual-fees-savings-account *ngIf="actions['Apply Annual Fees']"></mifosx-apply-annual-fees-savings-account>
<mifosx-manage-savings-account *ngIf="actions['Hold Amount']"></mifosx-manage-savings-account>
<mifosx-manage-savings-account *ngIf="actions['Hold Amount'] || actions['Block Account']"></mifosx-manage-savings-account>
@@ -15,7 +15,9 @@
<mat-card-title fxLayout="row" fxLayout.lt-md="column">
<h3 fxFlex="95%">
<i class="fa fa-stop" [ngClass]="savingsAccountData.status.code | statusLookup"
[matTooltip]="savingsAccountData.status.value"></i>
[matTooltip]="savingsAccountData.status.value" *ngIf="!savingsAccountData.subStatus.block"></i>
<i class="fa fa-stop" [ngClass]="savingsAccountData.subStatus.value | statusLookup"
[matTooltip]="savingsAccountData.subStatus.value" *ngIf="savingsAccountData.subStatus.block"></i>
Savings Product : {{savingsAccountData.savingsProductName}}<span class="m-l-10">({{savingsAccountData.accountNo}})</span>
</h3>
<div fxFlex="5%">
@@ -53,7 +55,7 @@
</button>
</ng-container>
<ng-container *ngIf="buttonConfig.options">
<ng-container *ngIf="buttonConfig.options && !savingsAccountData.subStatus.block">
<button mat-menu-item [matMenuTriggerFor]="More">More</button>
<mat-menu #More="matMenu">
<span *ngFor="let option of buttonConfig.options">
@@ -12,6 +12,7 @@ import { ToggleWithholdTaxDialogComponent } from './custom-dialogs/toggle-withho
/** Custom Buttons Configuration */
import { SavingsButtonsConfiguration } from './savings-buttons.config';
import { SavingsService } from '../savings.service';
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
/**
* Savings Account View Component
@@ -64,7 +65,8 @@ export class SavingsAccountViewComponent implements OnInit {
*/
setConditionalButtons() {
const status = this.savingsAccountData.status.value;
this.buttonConfig = new SavingsButtonsConfiguration(status);
const subStatus = this.savingsAccountData.subStatus;
this.buttonConfig = new SavingsButtonsConfiguration(status, subStatus);
if (this.savingsAccountData.clientId) {
this.buttonConfig.addOption({
name: 'Transfer Funds',
@@ -108,7 +110,6 @@ export class SavingsAccountViewComponent implements OnInit {
}
}
/**
* Refetches data foe the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
@@ -137,7 +138,6 @@ export class SavingsAccountViewComponent implements OnInit {
case 'Add Charge':
case 'Hold Amount':
case 'Block Account':
case 'Unblock Account':
case 'Unassign Staff':
case 'Withdraw By Client':
case 'Apply Annual Fees':
@@ -168,6 +168,9 @@ export class SavingsAccountViewComponent implements OnInit {
const queryParams: any = { savingsId: this.savingsAccountData.id, accountType: 'fromsavings' };
this.router.navigate(['transfer-funds/make-account-transfer'], { relativeTo: this.route, queryParams: queryParams });
break;
case 'Unblock Account':
this.unblockSavingsAccount();
break;
}
}
@@ -249,4 +252,20 @@ export class SavingsAccountViewComponent implements OnInit {
});
}
/**
* Unblock Savings Account.
*/
private unblockSavingsAccount() {
const unblockSavingsAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { heading: 'Unblock Savings Account', dialogContext: 'Are you sure you want Unblock this Savings Account' }
});
unblockSavingsAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
if (response.confirm) {
this.savingsService.executeSavingsAccountCommand(this.savingsAccountData.id, 'unblock', { })
.subscribe(() => {
this.reload();
});
}
});
}
}
@@ -12,9 +12,9 @@ export class SavingsButtonsConfiguration {
taskPermissionName: string,
}[];
constructor(status: string) {
constructor(status: string, substatus: any) {
this.setOptions(status);
this.setButtons(status);
this.setButtons(status, substatus);
}
get singleButtons() {
@@ -25,36 +25,60 @@ export class SavingsButtonsConfiguration {
return this.optionArray;
}
setButtons(status: string) {
setButtons(status: string, substatus: any) {
switch (status) {
case 'Active':
this.buttonsArray = [
this.buttonsArray = [];
if (!substatus.block) {
if (!substatus.blockCredit) {
this.buttonsArray.push(
{
name: 'Deposit',
icon: 'arrow-up',
taskPermissionName: 'DEPOSIT_SAVINGSACCOUNT'
}
);
}
if (!substatus.blockDebit) {
this.buttonsArray.push(
{
name: 'Withdrawal',
icon: 'arrow-down',
taskPermissionName: 'WITHDRAWAL_SAVINGSACCOUNT'
}
);
}
this.buttonsArray = this.buttonsArray.concat([
{
name: 'Block Account',
icon: 'lock',
taskPermissionName: 'BLOCK_SAVINGSACCOUNT'
},
{
name: 'Hold Amount',
icon: 'lock',
taskPermissionName: 'HOLDAMOUNT_SAVINGSACCOUNT'
},
{
name: 'Calculate Interest',
icon: 'table',
taskPermissionName: 'CALCULATEINTEREST_SAVINGSACCOUNT'
},
{
name: 'Post Interest As On',
icon: 'arrow-right',
taskPermissionName: 'POSTINTEREST_SAVINGSACCOUNT',
},
]);
} else {
this.buttonsArray = [
{
name: 'Deposit',
icon: 'arrow-up',
taskPermissionName: 'DEPOSIT_SAVINGSACCOUNT'
},
{
name: 'Withdraw',
icon: 'arrow-down',
taskPermissionName: 'WITHDRAW_SAVINGSACCOUNT'
},
{
name: 'Hold Amount',
icon: 'lock',
taskPermissionName: 'HOLDAMOUNT_SAVINGSACCOUNT'
},
{
name: 'Calculate Interest',
icon: 'table',
taskPermissionName: 'CALCULATEINTEREST_SAVINGSACCOUNT'
},
{
name: 'Post Interest As On',
icon: 'arrow-right',
taskPermissionName: 'POSTINTEREST_SAVINGSACCOUNT',
},
];
name: 'Unblock Account',
icon: 'lock-open',
taskPermissionName: 'UNBLOCK_SAVINGSACCOUNT'
}
];
}
break;
case 'Submitted and pending approval':
this.buttonsArray = [
@@ -50,20 +50,20 @@
{{ transactionData.date | dateFormat }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Currency
</div>
<div fxFlex="50%">
{{ transactionData.currency.displayLabel }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Amount
</div>
<div fxFlex="50%">
{{ transactionData.amount }}
{{ transactionData.currency.displaySymbol }} {{ transactionData.amount | number }} ({{ transactionData.currency.code }})
</div>
<div fxFlex="50%" class="mat-body-strong">
Currency
</div>
<div fxFlex="50%">
{{ transactionData.currency.name }}
</div>
<div fxFlex="50%" class="mat-body-strong">
+1 -1
View File
@@ -178,7 +178,7 @@ const routes: Routes = [
},
{
path: 'actions/:name',
data: { title: extract('Savings Account Actions'), routeParamBreadcrumb: 'name' },
data: { title: extract('Savings Account Actions'), breadcrumb: 'name', routeParamBreadcrumb: false },
component: SavingAccountActionsComponent,
resolve: {
savingsAccountActionData: SavingsAccountActionsResolver