From c388e767b6fde3cb7cd39b196b6aaeddd4028c2d Mon Sep 17 00:00:00 2001 From: Muskan Khedia <36980003+muskankhedia@users.noreply.github.com> Date: Tue, 7 Jul 2020 21:36:08 +0530 Subject: [PATCH] feat: add recurring deposit action (withdrawn by client) (#1016) Fixes: #1014 --- ...ng-deposits-account-actions.component.html | 3 +- ...ring-deposits-account-actions.component.ts | 4 +- ...-recurring-deposits-account.component.html | 40 +++++++++ ...-recurring-deposits-account.component.scss | 3 + ...curring-deposits-account.component.spec.ts | 25 ++++++ ...nt-recurring-deposits-account.component.ts | 83 +++++++++++++++++++ ...curring-deposits-account-view.component.ts | 1 + .../recurring-deposits.module.ts | 4 +- 8 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.html create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.scss create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.spec.ts create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.html index deb13e31a..1e9c0370b 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.html @@ -1,4 +1,5 @@ - \ No newline at end of file + + diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.ts index 23a009663..9083d3162 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/recurring-deposits-account-actions.component.ts @@ -14,11 +14,13 @@ export class RecurringDepositsAccountActionsComponent { 'Undo Approval': boolean 'Approve': boolean 'Reject': boolean + 'Withdraw By Client': boolean } = { 'Activate': false, 'Undo Approval': false, 'Approve': false, - 'Reject': false + 'Reject': false, + 'Withdraw By Client': false }; /** diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.html new file mode 100644 index 000000000..39d737af3 --- /dev/null +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.html @@ -0,0 +1,40 @@ +
+ + + +
+ + + +
+ + + Withdrawn On Date + + + + + Withdrawn On Date is required + + + + + Note + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.scss b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.spec.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.spec.ts new file mode 100644 index 000000000..c87ace164 --- /dev/null +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WithdrawByClientRecurringDepositsAccountComponent } from './withdraw-by-client-recurring-deposits-account.component'; + +describe('WithdrawByClientRecurringDepositsAccountComponent', () => { + let component: WithdrawByClientRecurringDepositsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WithdrawByClientRecurringDepositsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WithdrawByClientRecurringDepositsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts new file mode 100644 index 000000000..d9ba7f9fb --- /dev/null +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-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 { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service'; + +/** + * Withdraw By Client Recurring Deposits Account Component + */ +@Component({ + selector: 'mifosx-withdraw-by-client-recurring-deposits-account', + templateUrl: './withdraw-by-client-recurring-deposits-account.component.html', + styleUrls: ['./withdraw-by-client-recurring-deposits-account.component.scss'] +}) +export class WithdrawByClientRecurringDepositsAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Withdraw Recurring Deposits Account form. */ + withdrawRecurringDepositsAccountForm: FormGroup; + /** Recurring Deposits Account Id */ + accountId: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service + * @param {DatePipe} datePipe Date Pipe + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + */ + constructor(private formBuilder: FormBuilder, + private recurringDepositsService: RecurringDepositsService, + private datePipe: DatePipe, + private route: ActivatedRoute, + private router: Router) { + this.accountId = this.route.parent.snapshot.params['recurringDepositAccountId']; + } + + /** + * Creates the withdraw recurring deposits form. + */ + ngOnInit() { + this.createWithdrawRecurringDepositsAccountForm(); + } + + /** + * Creates the withdraw recurring deposits account form. + */ + createWithdrawRecurringDepositsAccountForm() { + this.withdrawRecurringDepositsAccountForm = this.formBuilder.group({ + 'withdrawnOnDate': ['', Validators.required], + 'note': [''] + }); + } + + /** + * Submits the form and withdraws the recurring deposit account by client, + * if successful redirects to the recurring deposit account. + */ + submit() { + // TODO: Update once language and date settings are setup + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const prevWithdrawnOnDate: Date = this.withdrawRecurringDepositsAccountForm.value.withdrawnOnDate; + this.withdrawRecurringDepositsAccountForm.patchValue({ + withdrawnOnDate: this.datePipe.transform(prevWithdrawnOnDate, dateFormat), + }); + const data = { + ...this.withdrawRecurringDepositsAccountForm.value, + dateFormat, + locale + }; + this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, 'withdrawnByApplicant', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts index ecaa629dc..574d6e63f 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts @@ -81,6 +81,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit { case 'Approve': case 'Reject': case 'Undo Approval': + case 'Withdraw By Client': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits.module.ts b/src/app/deposits/recurring-deposits/recurring-deposits.module.ts index 62a5f3e32..5058ef2c3 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits.module.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits.module.ts @@ -30,6 +30,7 @@ import { ActivateRecurringDepositsAccountComponent } from './recurring-deposits- import { UndoApprovalRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/undo-approval-recurring-deposits-account/undo-approval-recurring-deposits-account.component'; import { ApproveRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component'; import { RejectRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component'; +import { WithdrawByClientRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component'; /** * RecurringDeposits Module @@ -64,7 +65,8 @@ import { RejectRecurringDepositsAccountComponent } from './recurring-deposits-ac ActivateRecurringDepositsAccountComponent, UndoApprovalRecurringDepositsAccountComponent, ApproveRecurringDepositsAccountComponent, - RejectRecurringDepositsAccountComponent + RejectRecurringDepositsAccountComponent, + WithdrawByClientRecurringDepositsAccountComponent ], providers: [DatePipe] })