From 48616be5dd0ecf713fc8388b77065fc7cc0fee89 Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Fri, 3 Jul 2020 13:19:20 +0530 Subject: [PATCH] feat: fixed deposit account actions (approve) (#963) Fixes: #962 --- .../fixed-deposit-account-view.component.html | 6 +- .../fixed-deposit-account-view.component.ts | 57 ++++++++++++- ...rove-fixed-deposits-account.component.html | 39 +++++++++ ...rove-fixed-deposits-account.component.scss | 3 + ...e-fixed-deposits-account.component.spec.ts | 25 ++++++ ...pprove-fixed-deposits-account.component.ts | 83 +++++++++++++++++++ ...ed-deposits-account-actions.component.html | 8 ++ ...ed-deposits-account-actions.component.scss | 0 ...deposits-account-actions.component.spec.ts | 25 ++++++ ...ixed-deposits-account-actions.component.ts | 52 ++++++++++++ .../fixed-deposits-routing.module.ts | 6 ++ .../fixed-deposits/fixed-deposits.module.ts | 6 +- .../fixed-deposits/fixed-deposits.service.ts | 11 +++ 13 files changed, 315 insertions(+), 6 deletions(-) create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.html index 81e866630..b707c6d6f 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.html @@ -35,15 +35,15 @@ - - + - + 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 02858231b..3e9181db4 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 @@ -1,8 +1,14 @@ /** Angular Imports */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialog } from '@angular/material'; + +/** Custom Button Config. */ import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.config'; +/** Custom Services */ +import { FixedDepositsService } from '../fixed-deposits.service'; + /** * Fixed Deposits Account View Component */ @@ -24,7 +30,10 @@ export class FixedDepositAccountViewComponent implements OnInit { * Fetches fixed deposits account data from `resolve` * @param {ActivatedRoute} route Activated Route */ - constructor(private route: ActivatedRoute) { + constructor(private route: ActivatedRoute, + private router: Router, + private fixedDepositsService: FixedDepositsService, + public dialog: MatDialog) { this.route.data.subscribe((data: { fixedDepositsAccountData: any, savingsDatatables: any }) => { this.fixedDepositsAccountData = data.fixedDepositsAccountData; this.savingsDatatables = data.savingsDatatables; @@ -54,4 +63,48 @@ export class FixedDepositAccountViewComponent implements OnInit { } } + /** + * Performs action button/option action. + * @param {string} name action name. + */ + doAction(name: string) { + switch (name) { + case 'Approve': + case 'Reject': + case 'Deposit': + case 'Activate': + case 'Close': + case 'Undo Approval': + case 'Post Interest As On': + case 'Assign Staff': + case 'Add Charge': + case 'Unassign Staff': + 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; + case 'Delete': + + break; + case 'Calculate Interest': + + break; + case 'Post Interest': + + break; + case 'Enable Withhold Tax': + + break; + case 'Disable Withhold Tax': + + break; + } + } + + } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.html new file mode 100644 index 000000000..60aa8fe32 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.html @@ -0,0 +1,39 @@ +
+ + + +
+ + + +
+ + + Approved On Date + + + + + Approved On Date is required + + + + + Note + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.scss b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.spec.ts new file mode 100644 index 000000000..392e41dbb --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ApproveFixedDepositsAccountComponent } from './approve-fixed-deposits-account.component'; + +describe('ApproveFixedDepositsAccountComponent', () => { + let component: ApproveFixedDepositsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ApproveFixedDepositsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ApproveFixedDepositsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts new file mode 100644 index 000000000..397626a74 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts @@ -0,0 +1,83 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { DatePipe } from '@angular/common'; +import { ActivatedRoute, Router } from '@angular/router'; + +/** Custom Services */ +import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; + +/** + * Approve Fixed Deposits Account Component + */ +@Component({ + selector: 'mifosx-approve-fixed-deposits-account', + templateUrl: './approve-fixed-deposits-account.component.html', + styleUrls: ['./approve-fixed-deposits-account.component.scss'] +}) +export class ApproveFixedDepositsAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Approve Fixed Deposits Account form. */ + approveFixedDepositsAccountForm: FormGroup; + /** Fixed Deposits Account Id */ + accountId: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service + * @param {DatePipe} datePipe Date Pipe + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + */ + constructor(private formBuilder: FormBuilder, + private fixedDepositsService: FixedDepositsService, + private datePipe: DatePipe, + private route: ActivatedRoute, + private router: Router) { + this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId']; + } + + /** + * Creates the approve fixed deposits form. + */ + ngOnInit() { + this.createApproveFixedDepositsAccountForm(); + } + + /** + * Creates the approve fixed deposits account form. + */ + createApproveFixedDepositsAccountForm() { + this.approveFixedDepositsAccountForm = this.formBuilder.group({ + 'approvedOnDate': ['', Validators.required], + 'note': [''] + }); + } + + /** + * Submits the form and approves the fixed deposit account, + * if successful redirects to the fixed deposit account. + */ + submit() { + // TODO: Update once language and date settings are setup + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const prevApprovedOnDate: Date = this.approveFixedDepositsAccountForm.value.approvedOnDate; + this.approveFixedDepositsAccountForm.patchValue({ + approvedOnDate: this.datePipe.transform(prevApprovedOnDate, dateFormat), + }); + const data = { + ...this.approveFixedDepositsAccountForm.value, + dateFormat, + locale + }; + this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'approve', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.html new file mode 100644 index 000000000..8bb4ee8cd --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.html @@ -0,0 +1,8 @@ + + diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.scss b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.spec.ts new file mode 100644 index 000000000..0f403eb59 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositsAccountActionsComponent } from './fixed-deposits-account-actions.component'; + +describe('FixedDepositsAccountActionsComponent', () => { + let component: FixedDepositsAccountActionsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositsAccountActionsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositsAccountActionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts new file mode 100644 index 000000000..01f79a4b5 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts @@ -0,0 +1,52 @@ +/** Angular Imports */ +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +/** + * Fixed deposits account actions component. + */ +@Component({ + selector: 'mifosx-fixed-deposits-account-actions', + templateUrl: './fixed-deposits-account-actions.component.html', + styleUrls: ['./fixed-deposits-account-actions.component.scss'] +}) +export class FixedDepositsAccountActionsComponent { + + /** Flag object to store possible actions and render appropriate UI to the user */ + actions: { + 'Approve': boolean + 'Reject': boolean + 'Withdrawal': boolean + 'Deposit': boolean + 'Activate': boolean + 'Close': boolean + 'Undo Approval': boolean + 'Post Interest As On': boolean + 'Assign Staff': boolean + 'Add Charge': boolean + 'Unassign Staff': boolean + 'Withdraw By Client': boolean + } = { + 'Approve': false, + 'Reject': false, + 'Withdrawal': false, + 'Deposit': false, + 'Activate': false, + 'Close': false, + 'Undo Approval': false, + 'Post Interest As On': false, + 'Assign Staff': false, + 'Add Charge': false, + 'Unassign Staff': false, + 'Withdraw By Client': false + }; + + /** + * @param {ActivatedRoute} route Activated Route + */ + constructor(private route: ActivatedRoute) { + const name = this.route.snapshot.params['name']; + this.actions[name] = true; + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts index e987f5e97..7efec564a 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts @@ -12,6 +12,7 @@ import { TransactionsTabComponent } from './fixed-deposit-account-view/transacti import { ChargesTabComponent } from './fixed-deposit-account-view/charges-tab/charges-tab.component'; import { StandingInstructionsTabComponent } from './fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component'; import { DatatableTabsComponent } from './fixed-deposit-account-view/datatable-tabs/datatable-tabs.component'; +import { FixedDepositsAccountActionsComponent } from './fixed-deposits-account-actions/fixed-deposits-account-actions.component'; /** Custom Resolvers */ import { FixedDepositsAccountViewResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-view.resolver'; @@ -71,6 +72,11 @@ const routes: Routes = [ ] } ] + }, + { + path: 'actions/:name', + data: { title: extract('Fixed Deposits Account Actions'), routeParamBreadcrumb: 'name' }, + component: FixedDepositsAccountActionsComponent } ] } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts index 9bce6339d..6cb23dfeb 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -17,6 +17,8 @@ import { InterestRateChartTabComponent } from './fixed-deposit-account-view/inte import { DatatableTabsComponent } from './fixed-deposit-account-view/datatable-tabs/datatable-tabs.component'; import { MultiRowComponent } from './fixed-deposit-account-view/datatable-tabs/multi-row/multi-row.component'; import { SingleRowComponent } from './fixed-deposit-account-view/datatable-tabs/single-row/single-row.component'; +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'; @NgModule({ declarations: [ @@ -27,7 +29,9 @@ import { SingleRowComponent } from './fixed-deposit-account-view/datatable-tabs/ InterestRateChartTabComponent, DatatableTabsComponent, MultiRowComponent, - SingleRowComponent + SingleRowComponent, + FixedDepositsAccountActionsComponent, + ApproveFixedDepositsAccountComponent ], imports: [ SharedModule, diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts index dd3eead71..d26785373 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -24,6 +24,17 @@ export class FixedDepositsService { return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams }); } + /** + * @param {string} accountId Savings Account Id + * @param {string} command Command + * @param {any} data Data + * @returns {Observable} + */ + executeFixedDepositsAccountCommand(accountId: string, command: string, data: any): Observable { + const httpParams = new HttpParams().set('command', command); + return this.http.post(`/fixeddepositaccounts/${accountId}`, data, { params: httpParams }); + } + /** * @param clientId Client Id * @param clientName Client Name