diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.html
new file mode 100644
index 000000000..5f58d474d
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.html
@@ -0,0 +1,8 @@
+
{{ data.isEnable ? 'Enable' : 'Disable' }} Withhold Tax
+
+
Are you sure you want to {{ data.isEnable ? 'enable' : 'disable' }} withhold tax for this account ?
+
+
+
+
+
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.spec.ts
new file mode 100644
index 000000000..f0214dca7
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ToggleWithholdTaxDialogComponent } from './toggle-withhold-tax-dialog.component';
+
+describe('ToggleWithholdTaxDialogComponent', () => {
+ let component: ToggleWithholdTaxDialogComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ ToggleWithholdTaxDialogComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ToggleWithholdTaxDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.ts
new file mode 100644
index 000000000..11aee1734
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component.ts
@@ -0,0 +1,22 @@
+/** Angular Imports */
+import { Component, Inject } from '@angular/core';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
+
+/**
+ * Toggle withhold tax dialog dialog component.
+ */
+@Component({
+ selector: 'mifosx-toggle-withhold-tax-dialog',
+ templateUrl: './toggle-withhold-tax-dialog.component.html',
+ styleUrls: ['./toggle-withhold-tax-dialog.component.scss']
+})
+export class ToggleWithholdTaxDialogComponent {
+
+ /**
+ * @param {MatDialogRef} dialogRef Component reference to dialog.
+ * @param {any} data.
+ */
+ constructor(public dialogRef: MatDialogRef,
+ @Inject(MAT_DIALOG_DATA) public data: any) { }
+
+}
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts
index 30c0a9394..1b2d9a923 100644
--- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts
+++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts
@@ -7,12 +7,14 @@ 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 Button Config. */
import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.config';
/** Custom Services */
import { FixedDepositsService } from '../fixed-deposits.service';
+import { SavingsService } from 'app/savings/savings.service';
/**
* Fixed Deposits Account View Component
@@ -38,6 +40,7 @@ export class FixedDepositAccountViewComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router,
private fixedDepositsService: FixedDepositsService,
+ private savingsService: SavingsService,
public dialog: MatDialog) {
this.route.data.subscribe((data: { fixedDepositsAccountData: any, savingsDatatables: any }) => {
this.fixedDepositsAccountData = data.fixedDepositsAccountData;
@@ -108,10 +111,10 @@ export class FixedDepositAccountViewComponent implements OnInit {
this.postInterest();
break;
case 'Enable Withhold Tax':
-
+ this.enableWithHoldTax();
break;
case 'Disable Withhold Tax':
-
+ this.disableWithHoldTax();
break;
}
}
@@ -160,4 +163,41 @@ export class FixedDepositAccountViewComponent implements OnInit {
});
}
+
+ /**
+ * Enables withhold tax for fixed deposits account.
+ * Fixed deposits endpoint is not supported so using Savings endpoint.
+ */
+ private enableWithHoldTax() {
+ const deleteSavingsAccountDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
+ data: { isEnable: true }
+ });
+ deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.confirm) {
+ this.savingsService.executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', { withHoldTax: true})
+ .subscribe(() => {
+ this.reload();
+ });
+ }
+ });
+ }
+
+ /**
+ * Disables withhold tax for fixed deposits account
+ * Fixed deposits endpoint is not supported so using Savings endpoint.
+ */
+ private disableWithHoldTax() {
+ const disableWithHoldTaxDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
+ data: { isEnable: false }
+ });
+ disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.confirm) {
+ this.savingsService.executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', { withHoldTax: false})
+ .subscribe(() => {
+ this.reload();
+ });
+ }
+ });
+ }
+
}
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts
index 65a854e2f..b05512cb3 100644
--- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts
+++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts
@@ -22,6 +22,7 @@ import { ApproveFixedDepositsAccountComponent } from './fixed-deposits-account-a
import { RejectFixedDepositsAccountComponent } from './fixed-deposits-account-actions/reject-fixed-deposits-account/reject-fixed-deposits-account.component';
import { PostInterestDialogComponent } from './fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component';
import { CalculateInterestDialogComponent } from './fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component';
+import { ToggleWithholdTaxDialogComponent } from './fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component';
@NgModule({
declarations: [
@@ -37,7 +38,8 @@ import { CalculateInterestDialogComponent } from './fixed-deposit-account-view/c
ApproveFixedDepositsAccountComponent,
RejectFixedDepositsAccountComponent,
PostInterestDialogComponent,
- CalculateInterestDialogComponent
+ CalculateInterestDialogComponent,
+ ToggleWithholdTaxDialogComponent
],
imports: [
SharedModule,
@@ -47,7 +49,8 @@ import { CalculateInterestDialogComponent } from './fixed-deposit-account-view/c
],
entryComponents: [
PostInterestDialogComponent,
- CalculateInterestDialogComponent
+ CalculateInterestDialogComponent,
+ ToggleWithholdTaxDialogComponent
],
providers: [DatePipe]
})