feat; savings account actions (enable/disable-withhold-tax) (#945)

Fixes: #944
This commit is contained in:
Karan Takalkar
2020-06-29 01:09:36 +05:30
committed by GitHub
parent d800f05ae3
commit be0e7032a7
7 changed files with 120 additions and 9 deletions
@@ -7,6 +7,7 @@ import { MatDialog } from '@angular/material';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { CalculateInterestDialogComponent } from './custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component';
import { PostInterestDialogComponent } from './custom-dialogs/post-interest-dialog/post-interest-dialog.component';
import { ToggleWithholdTaxDialogComponent } from './custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component';
/** Custom Buttons Configuration */
import { SavingsButtonsConfiguration } from './savings-buttons.config';
@@ -98,6 +99,18 @@ export class SavingsAccountViewComponent implements OnInit {
}
}
/**
* Refetches data fot the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
reload() {
const clientId = this.savingsAccountData.clientId;
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}
/**
* Performs action button/option action.
* @param {string} name action name.
@@ -132,6 +145,12 @@ export class SavingsAccountViewComponent implements OnInit {
case 'Post Interest':
this.postInterest();
break;
case 'Enable Withhold Tax':
this.enableWithHoldTax();
break;
case 'Disable Withhold Tax':
this.disableWithHoldTax();
break;
}
}
@@ -180,14 +199,37 @@ export class SavingsAccountViewComponent implements OnInit {
}
/**
* Refetches data fot the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
* Enables withhold tax for savings account.
*/
private reload() {
const clientId = this.savingsAccountData.clientId;
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
private enableWithHoldTax() {
const deleteSavingsAccountDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
data: { isEnable: true }
});
deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
this.savingsService.executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: true})
.subscribe(() => {
this.reload();
});
}
});
}
/**
* Disables withhold tac for savings account
*/
private disableWithHoldTax() {
const disableWithHoldTaxDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
data: { isEnable: false }
});
disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
this.savingsService.executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: false})
.subscribe(() => {
this.reload();
});
}
});
}
}