feat: fixed deposits account actions (enable/disable withhold tax) (#971)
Fixes: #970
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
<h1 mat-dialog-title>{{ data.isEnable ? 'Enable' : 'Disable' }} Withhold Tax</h1>
|
||||
<div mat-dialog-content>
|
||||
<p>Are you sure you want to {{ data.isEnable ? 'enable' : 'disable' }} withhold tax for this account ?</p>
|
||||
</div>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>Cancel</button>
|
||||
<button mat-raised-button color="{{ data.isEnable ? 'accent' : 'warn' }}" [mat-dialog-close]="{ confirm: true }">Confirm</button>
|
||||
</mat-dialog-actions>
|
||||
+25
@@ -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<ToggleWithholdTaxDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ToggleWithholdTaxDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ToggleWithholdTaxDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+22
@@ -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<ToggleWithholdTaxDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) { }
|
||||
|
||||
}
|
||||
+42
-2
@@ -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();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user