feat; savings account actions (enable/disable-withhold-tax) (#945)
Fixes: #944
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) { }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import { MatDialog } from '@angular/material';
|
|||||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||||
import { CalculateInterestDialogComponent } from './custom-dialogs/calculate-interest-dialog/calculate-interest-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 { 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 */
|
/** Custom Buttons Configuration */
|
||||||
import { SavingsButtonsConfiguration } from './savings-buttons.config';
|
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.
|
* Performs action button/option action.
|
||||||
* @param {string} name action name.
|
* @param {string} name action name.
|
||||||
@@ -132,6 +145,12 @@ export class SavingsAccountViewComponent implements OnInit {
|
|||||||
case 'Post Interest':
|
case 'Post Interest':
|
||||||
this.postInterest();
|
this.postInterest();
|
||||||
break;
|
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
|
* Enables withhold tax for savings account.
|
||||||
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
|
|
||||||
*/
|
*/
|
||||||
private reload() {
|
private enableWithHoldTax() {
|
||||||
const clientId = this.savingsAccountData.clientId;
|
const deleteSavingsAccountDialogRef = this.dialog.open(ToggleWithholdTaxDialogComponent, {
|
||||||
const url: string = this.router.url;
|
data: { isEnable: true }
|
||||||
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
|
});
|
||||||
.then(() => this.router.navigate([url]));
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import { InactivateChargeDialogComponent } from './savings-account-view/custom-d
|
|||||||
import { WithdrawByClientSavingsAccountComponent } from './saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component';
|
import { WithdrawByClientSavingsAccountComponent } from './saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component';
|
||||||
import { AddChargeSavingsAccountComponent } from './saving-account-actions/add-charge-savings-account/add-charge-savings-account.component';
|
import { AddChargeSavingsAccountComponent } from './saving-account-actions/add-charge-savings-account/add-charge-savings-account.component';
|
||||||
import { CloseSavingsAccountComponent } from './saving-account-actions/close-savings-account/close-savings-account.component';
|
import { CloseSavingsAccountComponent } from './saving-account-actions/close-savings-account/close-savings-account.component';
|
||||||
|
import { ToggleWithholdTaxDialogComponent } from './savings-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,14 +88,16 @@ import { CloseSavingsAccountComponent } from './saving-account-actions/close-sav
|
|||||||
InactivateChargeDialogComponent,
|
InactivateChargeDialogComponent,
|
||||||
WithdrawByClientSavingsAccountComponent,
|
WithdrawByClientSavingsAccountComponent,
|
||||||
AddChargeSavingsAccountComponent,
|
AddChargeSavingsAccountComponent,
|
||||||
CloseSavingsAccountComponent
|
CloseSavingsAccountComponent,
|
||||||
|
ToggleWithholdTaxDialogComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
CalculateInterestDialogComponent,
|
CalculateInterestDialogComponent,
|
||||||
PostInterestDialogComponent,
|
PostInterestDialogComponent,
|
||||||
UndoTransactionDialogComponent,
|
UndoTransactionDialogComponent,
|
||||||
WaiveChargeDialogComponent,
|
WaiveChargeDialogComponent,
|
||||||
InactivateChargeDialogComponent
|
InactivateChargeDialogComponent,
|
||||||
|
ToggleWithholdTaxDialogComponent
|
||||||
|
|
||||||
],
|
],
|
||||||
providers: [DatePipe]
|
providers: [DatePipe]
|
||||||
|
|||||||
@@ -184,6 +184,17 @@ export class SavingsService {
|
|||||||
return this.http.post(`/savingsaccounts/${accountId}`, data, { params: httpParams });
|
return this.http.post(`/savingsaccounts/${accountId}`, data, { params: httpParams });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} accountId Savings Account Id
|
||||||
|
* @param {string} command Command
|
||||||
|
* @param {any} data Data
|
||||||
|
* @returns {Observable<any>} Savings data.
|
||||||
|
*/
|
||||||
|
executeSavingsAccountUpdateCommand(accountId: string, command: string, data: any): Observable<any> {
|
||||||
|
const httpParams = new HttpParams().set('command', command);
|
||||||
|
return this.http.put(`/savingsaccounts/${accountId}`, data, { params: httpParams });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} accountId Savings Account Id
|
* @param {string} accountId Savings Account Id
|
||||||
* @param {string} transactionId Transaction Id
|
* @param {string} transactionId Transaction Id
|
||||||
|
|||||||
Reference in New Issue
Block a user