From 5110296648a7e04e678ce16aab9e936a2fcc4c49 Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Fri, 3 Jul 2020 19:57:51 +0530 Subject: [PATCH] feat: fixed deposits actions (withdraw-by-client) (#977) Fixes: #976 --- .../fixed-deposit-account-view.component.ts | 2 +- ...ed-deposits-account-actions.component.html | 3 +- ...ixed-deposits-account-actions.component.ts | 2 - ...ient-fixed-deposits-account.component.html | 39 +++++++++ ...ient-fixed-deposits-account.component.scss | 3 + ...t-fixed-deposits-account.component.spec.ts | 25 ++++++ ...client-fixed-deposits-account.component.ts | 83 +++++++++++++++++++ .../fixed-deposits/fixed-deposits.module.ts | 4 +- 8 files changed, 155 insertions(+), 6 deletions(-) create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts 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 1b2d9a923..aa496b26f 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 @@ -93,9 +93,9 @@ export class FixedDepositAccountViewComponent implements OnInit { case 'Activate': case 'Close': case 'Undo Approval': - case 'Post Interest As On': case 'Add Charge': case 'Withdraw By Client': + case 'Premature Close': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Modify Application': 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 index 94e98892b..4c1449497 100644 --- 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 @@ -2,7 +2,6 @@ - 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 index 0048ad4d9..a73c28167 100644 --- 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 @@ -19,7 +19,6 @@ export class FixedDepositsAccountActionsComponent { 'Activate': boolean 'Close': boolean 'Undo Approval': boolean - 'Post Interest As On': boolean 'Add Charge': boolean 'Withdraw By Client': boolean } = { @@ -28,7 +27,6 @@ export class FixedDepositsAccountActionsComponent { 'Activate': false, 'Close': false, 'Undo Approval': false, - 'Post Interest As On': false, 'Add Charge': false, 'Withdraw By Client': false }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.html new file mode 100644 index 000000000..f87bc40b7 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.html @@ -0,0 +1,39 @@ +
+ + + +
+ + + +
+ + + Withdrawn On Date + + + + + Withdrawn On Date is required + + + + + Note + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.scss b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-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/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.spec.ts new file mode 100644 index 000000000..a244f6299 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WithdrawByClientFixedDepositsAccountComponent } from './withdraw-by-client-fixed-deposits-account.component'; + +describe('WithdrawByClientFixedDepositsAccountComponent', () => { + let component: WithdrawByClientFixedDepositsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WithdrawByClientFixedDepositsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WithdrawByClientFixedDepositsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts new file mode 100644 index 000000000..30caf1d92 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-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'; + +/** + * Withdraw By Client Fixed Deposits Account Component + */ +@Component({ + selector: 'mifosx-withdraw-by-client-fixed-deposits-account', + templateUrl: './withdraw-by-client-fixed-deposits-account.component.html', + styleUrls: ['./withdraw-by-client-fixed-deposits-account.component.scss'] +}) +export class WithdrawByClientFixedDepositsAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Withdraw Fixed Deposits Account form. */ + withdrawFixedDepositsAccountForm: 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 withdraw fixed deposits form. + */ + ngOnInit() { + this.createWithdrawFixedDepositsAccountForm(); + } + + /** + * Creates the withdraw fixed deposits account form. + */ + createWithdrawFixedDepositsAccountForm() { + this.withdrawFixedDepositsAccountForm = this.formBuilder.group({ + 'withdrawnOnDate': ['', Validators.required], + 'note': [''] + }); + } + + /** + * Submits the form and withdraws the fixed deposit account by client, + * 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 prevWithdrawnOnDate: Date = this.withdrawFixedDepositsAccountForm.value.withdrawnOnDate; + this.withdrawFixedDepositsAccountForm.patchValue({ + withdrawnOnDate: this.datePipe.transform(prevWithdrawnOnDate, dateFormat), + }); + const data = { + ...this.withdrawFixedDepositsAccountForm.value, + dateFormat, + locale + }; + this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'withdrawnByApplicant', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts index 7c6391032..1ad92ff54 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -25,6 +25,7 @@ import { CalculateInterestDialogComponent } from './fixed-deposit-account-view/c import { ToggleWithholdTaxDialogComponent } from './fixed-deposit-account-view/custom-dialogs/toggle-withhold-tax-dialog/toggle-withhold-tax-dialog.component'; import { ActivateFixedDepositsAccountComponent } from './fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component'; import { UndoApprovalFixedDepositsAccountComponent } from './fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component'; +import { WithdrawByClientFixedDepositsAccountComponent } from './fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component'; @NgModule({ declarations: [ @@ -43,7 +44,8 @@ import { UndoApprovalFixedDepositsAccountComponent } from './fixed-deposits-acco CalculateInterestDialogComponent, ToggleWithholdTaxDialogComponent, ActivateFixedDepositsAccountComponent, - UndoApprovalFixedDepositsAccountComponent + UndoApprovalFixedDepositsAccountComponent, + WithdrawByClientFixedDepositsAccountComponent ], imports: [ SharedModule,