feat: add recurring deposit action (withdrawn by client) (#1016)

Fixes: #1014
This commit is contained in:
Muskan Khedia
2020-07-07 21:36:08 +05:30
committed by GitHub
parent 9b492ac7af
commit c388e767b6
8 changed files with 160 additions and 3 deletions
@@ -1,4 +1,5 @@
<mifosx-activate-recurring-deposits-account *ngIf="actions['Activate']"></mifosx-activate-recurring-deposits-account>
<mifosx-undo-approval-recurring-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-recurring-deposits-account>
<mifosx-approve-recurring-deposits-account *ngIf="actions['Approve']"></mifosx-approve-recurring-deposits-account>
<mifosx-reject-recurring-deposits-account *ngIf="actions['Reject']"></mifosx-reject-recurring-deposits-account>
<mifosx-reject-recurring-deposits-account *ngIf="actions['Reject']"></mifosx-reject-recurring-deposits-account>
<mifosx-withdraw-by-client-recurring-deposits-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-recurring-deposits-account>
@@ -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
};
/**
@@ -0,0 +1,40 @@
<div class="container">
<mat-card>
<form [formGroup]="withdrawRecurringDepositsAccountForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field>
<mat-label>Withdrawn On Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="withdrawnOnDatePicker" required
formControlName="withdrawnOnDate">
<mat-datepicker-toggle matSuffix [for]="withdrawnOnDatePicker"></mat-datepicker-toggle>
<mat-datepicker #withdrawnOnDatePicker></mat-datepicker>
<mat-error *ngIf="withdrawRecurringDepositsAccountForm.controls.withdrawnOnDate.hasError('required')">
Withdrawn On Date is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Note</mat-label>
<textarea matInput formControlName="note"></textarea>
</mat-form-field>
</div>
</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="primary" [disabled]="!withdrawRecurringDepositsAccountForm.valid">Confirm</button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -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<WithdrawByClientRecurringDepositsAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WithdrawByClientRecurringDepositsAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WithdrawByClientRecurringDepositsAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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 });
});
}
}
@@ -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;
}
@@ -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]
})