diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.html new file mode 100644 index 000000000..c31d2b9dc --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.html @@ -0,0 +1,8 @@ +

Calculate Interest

+
+

Are you sure you want to calculate interest ?

+
+ + + + diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.spec.ts new file mode 100644 index 000000000..56e05d8a5 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CalculateInterestDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CalculateInterestDialogComponent); + 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/calculate-interest-dialog/calculate-interest-dialog.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.ts new file mode 100644 index 000000000..02593c510 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component.ts @@ -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) { } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.html new file mode 100644 index 000000000..759431177 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.html @@ -0,0 +1,8 @@ +

Post Interest

+
+

Are you sure you want to post interest ?

+
+ + + + diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.spec.ts new file mode 100644 index 000000000..f8acdff28 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PostInterestDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PostInterestDialogComponent); + 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/post-interest-dialog/post-interest-dialog.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.ts new file mode 100644 index 000000000..691c724eb --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/post-interest-dialog/post-interest-dialog.component.ts @@ -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) { } + +} 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 59d9586bb..30c0a9394 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 @@ -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(); + }); + } + }); + } + } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts index 333961772..65a854e2f 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -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 { }