feat: fixed deposit account actions (undo-approval) (#975)

Fixes: #974
This commit is contained in:
Karan Takalkar
2020-07-03 18:15:39 +05:30
committed by GitHub
parent a60e4339c9
commit 05d2292597
6 changed files with 125 additions and 3 deletions
@@ -1,8 +1,8 @@
<mifosx-approve-fixed-deposits-account *ngIf="actions['Approve']"></mifosx-approve-fixed-deposits-account>
<mifosx-reject-fixed-deposits-account *ngIf="actions['Reject']"></mifosx-reject-fixed-deposits-account>
<mifosx-activate-fixed-deposits-account *ngIf="actions['Activate']"></mifosx-activate-fixed-deposits-account>
<!-- <mifosx-undo-approval-fixed-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-fixed-deposits-account>
<mifosx-post-interest-as-on-fixed-deposits-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-fixed-deposits-account>
<mifosx-undo-approval-fixed-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-fixed-deposits-account>
<!-- <mifosx-post-interest-as-on-fixed-deposits-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-fixed-deposits-account>
<mifosx-withdraw-by-client-fixed-deposits-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-fixed-deposits-account>
<mifosx-add-charge-fixed-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-fixed-deposits-account>
<mifosx-close-fixed-deposits-account *ngIf="actions['Close']"></mifosx-close-fixed-deposits-account> -->
@@ -0,0 +1,25 @@
<div class="container">
<mat-card>
<form [formGroup]="undoApprovalFixedDepositsAccountForm" (ngSubmit)="submit()">
<mat-card-content>
<mat-form-field fxFlex>
<mat-label>Note</mat-label>
<textarea matInput formControlName="note"></textarea>
</mat-form-field>
</mat-card-content>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button mat-raised-button color="warn" [disabled]="!undoApprovalFixedDepositsAccountForm.valid">Confirm</button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -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<UndoApprovalFixedDepositsAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UndoApprovalFixedDepositsAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UndoApprovalFixedDepositsAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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 });
});
}
}
@@ -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,