feat: fixed deposit actions (caclulate/post interest) (#969)

Fixes: #968
This commit is contained in:
Karan Takalkar
2020-07-03 15:14:58 +05:30
committed by GitHub
parent 5c0941b9a9
commit a8b7f0c082
10 changed files with 158 additions and 7 deletions
@@ -0,0 +1,8 @@
<h1 mat-dialog-title>Calculate Interest</h1>
<div mat-dialog-content>
<p>Are you sure you want to calculate interest ?</p>
</div>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="primary" [mat-dialog-close]="{ confirm: true }">Confirm</button>
</mat-dialog-actions>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CalculateInterestDialogComponent } from './calculate-interest-dialog.component';
describe('CalculateInterestDialogComponent', () => {
let component: CalculateInterestDialogComponent;
let fixture: ComponentFixture<CalculateInterestDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CalculateInterestDialogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CalculateInterestDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,20 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material';
/**
* Calculate interest dialog component.
*/
@Component({
selector: 'mifosx-calculate-interest-dialog',
templateUrl: './calculate-interest-dialog.component.html',
styleUrls: ['./calculate-interest-dialog.component.scss']
})
export class CalculateInterestDialogComponent {
/**
* @param {MatDialogRef} dialogRef Component reference to dialog.
*/
constructor(public dialogRef: MatDialogRef<CalculateInterestDialogComponent>) { }
}
@@ -0,0 +1,8 @@
<h1 mat-dialog-title>Post Interest</h1>
<div mat-dialog-content>
<p>Are you sure you want to post interest ?</p>
</div>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="primary" [mat-dialog-close]="{ confirm: true }">Confirm</button>
</mat-dialog-actions>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PostInterestDialogComponent } from './post-interest-dialog.component';
describe('PostInterestDialogComponent', () => {
let component: PostInterestDialogComponent;
let fixture: ComponentFixture<PostInterestDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PostInterestDialogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PostInterestDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,20 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material';
/**
* Post interest dialog component.
*/
@Component({
selector: 'mifosx-post-interest-dialog',
templateUrl: './post-interest-dialog.component.html',
styleUrls: ['./post-interest-dialog.component.scss']
})
export class PostInterestDialogComponent {
/**
* @param {MatDialogRef} dialogRef Component reference to dialog.
*/
constructor(public dialogRef: MatDialogRef<PostInterestDialogComponent>) { }
}
@@ -5,6 +5,8 @@ import { MatDialog } from '@angular/material';
/** Custom Dialogs */
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';
/** Custom Button Config. */
import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.config';
@@ -66,6 +68,17 @@ export class FixedDepositAccountViewComponent implements OnInit {
}
}
/**
* Refetches data fot the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
reload() {
const clientId = this.fixedDepositsAccountData.clientId;
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/fixed-deposits-accounts`, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}
/**
* Performs action button/option action.
* @param {string} name action name.
@@ -74,7 +87,6 @@ export class FixedDepositAccountViewComponent implements OnInit {
switch (name) {
case 'Approve':
case 'Reject':
case 'Deposit':
case 'Activate':
case 'Close':
case 'Undo Approval':
@@ -83,9 +95,6 @@ export class FixedDepositAccountViewComponent implements OnInit {
case 'Withdraw By Client':
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Withdraw':
this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route });
break;
case 'Modify Application':
this.router.navigate(['edit-savings-account'], { relativeTo: this.route });
break;
@@ -93,10 +102,10 @@ export class FixedDepositAccountViewComponent implements OnInit {
this.deleteFixedDepositsAccount();
break;
case 'Calculate Interest':
this.calculateInterest();
break;
case 'Post Interest':
this.postInterest();
break;
case 'Enable Withhold Tax':
@@ -123,4 +132,32 @@ export class FixedDepositAccountViewComponent implements OnInit {
});
}
/**
* Calculates savings account's interest
*/
private calculateInterest() {
const calculateInterestAccountDialogRef = this.dialog.open(CalculateInterestDialogComponent);
calculateInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
this.fixedDepositsService.executeFixedDepositsAccountCommand(this.fixedDepositsAccountData.id, 'calculateInterest', {}).subscribe(() => {
this.reload();
});
}
});
}
/**
* Posts savings account's interest
*/
private postInterest() {
const postInterestAccountDialogRef = this.dialog.open(PostInterestDialogComponent);
postInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
this.fixedDepositsService.executeFixedDepositsAccountCommand(this.fixedDepositsAccountData.id, 'postInterest', {}).subscribe(() => {
this.reload();
});
}
});
}
}
@@ -20,6 +20,8 @@ import { SingleRowComponent } from './fixed-deposit-account-view/datatable-tabs/
import { FixedDepositsAccountActionsComponent } from './fixed-deposits-account-actions/fixed-deposits-account-actions.component';
import { ApproveFixedDepositsAccountComponent } from './fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component';
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';
@NgModule({
declarations: [
@@ -33,7 +35,9 @@ import { RejectFixedDepositsAccountComponent } from './fixed-deposits-account-ac
SingleRowComponent,
FixedDepositsAccountActionsComponent,
ApproveFixedDepositsAccountComponent,
RejectFixedDepositsAccountComponent
RejectFixedDepositsAccountComponent,
PostInterestDialogComponent,
CalculateInterestDialogComponent
],
imports: [
SharedModule,
@@ -41,6 +45,10 @@ import { RejectFixedDepositsAccountComponent } from './fixed-deposits-account-ac
DirectivesModule,
FixedDepositsRoutingModule
],
entryComponents: [
PostInterestDialogComponent,
CalculateInterestDialogComponent
],
providers: [DatePipe]
})
export class FixedDepositsModule { }