From 05d2292597bf2b8d3f737ec2980c7eede4d0f595 Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Fri, 3 Jul 2020 18:15:39 +0530 Subject: [PATCH] feat: fixed deposit account actions (undo-approval) (#975) Fixes: #974 --- ...ed-deposits-account-actions.component.html | 4 +- ...oval-fixed-deposits-account.component.html | 25 +++++++ ...oval-fixed-deposits-account.component.scss | 3 + ...l-fixed-deposits-account.component.spec.ts | 25 +++++++ ...proval-fixed-deposits-account.component.ts | 67 +++++++++++++++++++ .../fixed-deposits/fixed-deposits.module.ts | 4 +- 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts 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 629853983..94e98892b 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 @@ -1,8 +1,8 @@ - diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.html new file mode 100644 index 000000000..ea2eb275e --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.html @@ -0,0 +1,25 @@ +
+ + + +
+ + + + + Note + + + + + + + + + + +
+ +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.scss b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-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/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.spec.ts new file mode 100644 index 000000000..d250797cb --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UndoApprovalFixedDepositsAccountComponent } from './undo-approval-fixed-deposits-account.component'; + +describe('UndoApprovalFixedDepositsAccountComponent', () => { + let component: UndoApprovalFixedDepositsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ UndoApprovalFixedDepositsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(UndoApprovalFixedDepositsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts new file mode 100644 index 000000000..270e0b9fc --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts @@ -0,0 +1,67 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; + +/** Custom Services */ +import { SavingsService } from 'app/savings/savings.service'; + +/** + * Undo Approval Fixed Deposits Account Component + */ +@Component({ + selector: 'mifosx-undo-approval-fixed-deposits-account', + templateUrl: './undo-approval-fixed-deposits-account.component.html', + styleUrls: ['./undo-approval-fixed-deposits-account.component.scss'] +}) +export class UndoApprovalFixedDepositsAccountComponent implements OnInit { + + /** Undo Approval Fixed Deposits Account form. */ + undoApprovalFixedDepositsAccountForm: FormGroup; + /** Fixed Deposits Account Id */ + accountId: any; + + /** + * Fixed deposits endpoint is not supported so using Savings endpoint. + * @param {FormBuilder} formBuilder Form Builder + * @param {SavingsService} savingsService Savings Service + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + */ + constructor(private formBuilder: FormBuilder, + private savingsService: SavingsService, + private route: ActivatedRoute, + private router: Router) { + this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId']; + } + + /** + * Creates the undo-approval fixed deposits form. + */ + ngOnInit() { + this.createUndoApprovalFixedDepositsAccountForm(); + } + + /** + * Creates the undo-approval fixed deposits account form. + */ + createUndoApprovalFixedDepositsAccountForm() { + this.undoApprovalFixedDepositsAccountForm = this.formBuilder.group({ + 'note': [''] + }); + } + + /** + * Submits the form and undo the approval of fixed deposits account, + * if successful redirects to the share account. + */ + submit() { + const data = { + ...this.undoApprovalFixedDepositsAccountForm.value, + }; + this.savingsService.executeSavingsAccountCommand(this.accountId, 'undoapproval', 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 cfbe8d411..7c6391032 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -24,6 +24,7 @@ import { PostInterestDialogComponent } from './fixed-deposit-account-view/custom import { CalculateInterestDialogComponent } from './fixed-deposit-account-view/custom-dialogs/calculate-interest-dialog/calculate-interest-dialog.component'; 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'; @NgModule({ declarations: [ @@ -41,7 +42,8 @@ import { ActivateFixedDepositsAccountComponent } from './fixed-deposits-account- PostInterestDialogComponent, CalculateInterestDialogComponent, ToggleWithholdTaxDialogComponent, - ActivateFixedDepositsAccountComponent + ActivateFixedDepositsAccountComponent, + UndoApprovalFixedDepositsAccountComponent ], imports: [ SharedModule,