feat: add recurring deposit action (premature-close) (#1024)
Fixes: #1021
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="prematureCloseRecurringDepositsAccountForm" (ngSubmit)="submit()">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<div fxLayout="column">
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Closed On</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="closedOnDatePicker" required
|
||||||
|
formControlName="closedOnDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="closedOnDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #closedOnDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="prematureCloseRecurringDepositsAccountForm.controls.closedOnDate.hasError('required')">
|
||||||
|
Closed On Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</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="accent" [disabled]="!prematureCloseRecurringDepositsAccountForm">Confirm</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
.container {
|
||||||
|
max-width: 37rem;
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { PrematureCloseRecurringDepositAccountComponent } from './premature-close-recurring-deposit-account.component';
|
||||||
|
|
||||||
|
describe('PrematureCloseRecurringDepositAccountComponent', () => {
|
||||||
|
let component: PrematureCloseRecurringDepositAccountComponent;
|
||||||
|
let fixture: ComponentFixture<PrematureCloseRecurringDepositAccountComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ PrematureCloseRecurringDepositAccountComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(PrematureCloseRecurringDepositAccountComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
+83
@@ -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 '../../recurring-deposits.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Premature Close Recurring Deposits Account Component
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-premature-close-recurring-deposit-account',
|
||||||
|
templateUrl: './premature-close-recurring-deposit-account.component.html',
|
||||||
|
styleUrls: ['./premature-close-recurring-deposit-account.component.scss']
|
||||||
|
})
|
||||||
|
export class PrematureCloseRecurringDepositAccountComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Minimum date allowed. */
|
||||||
|
minDate = new Date(2000, 0, 1);
|
||||||
|
/** Maximum date allowed. */
|
||||||
|
maxDate = new Date();
|
||||||
|
/** premature close Recurring Deposits Account form. */
|
||||||
|
prematureCloseRecurringDepositsAccountForm: 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 premature close recurring deposits form.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.createprematureCloseRecurringDepositsAccountForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the premature close recurring deposits account form.
|
||||||
|
*/
|
||||||
|
createprematureCloseRecurringDepositsAccountForm() {
|
||||||
|
this.prematureCloseRecurringDepositsAccountForm = this.formBuilder.group({
|
||||||
|
'closedOnDate': ['', Validators.required]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits the form and premature closes the recurring deposit account,
|
||||||
|
* 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 prevClosedOnDate: Date = this.prematureCloseRecurringDepositsAccountForm.value.closedOnDate;
|
||||||
|
this.prematureCloseRecurringDepositsAccountForm.patchValue({
|
||||||
|
closedOnDate: this.datePipe.transform(prevClosedOnDate, dateFormat),
|
||||||
|
});
|
||||||
|
const data = {
|
||||||
|
...this.prematureCloseRecurringDepositsAccountForm.value,
|
||||||
|
dateFormat,
|
||||||
|
locale
|
||||||
|
};
|
||||||
|
this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, 'prematureClose', data).subscribe(() => {
|
||||||
|
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -4,3 +4,4 @@
|
|||||||
<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>
|
<mifosx-withdraw-by-client-recurring-deposits-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-recurring-deposits-account>
|
||||||
<mifosx-add-charge-recurring-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-recurring-deposits-account>
|
<mifosx-add-charge-recurring-deposits-account *ngIf="actions['Add Charge']"></mifosx-add-charge-recurring-deposits-account>
|
||||||
|
<mifosx-premature-close-recurring-deposit-account *ngIf="actions['Premature Close']"></mifosx-premature-close-recurring-deposit-account>
|
||||||
+1
@@ -145,6 +145,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
|
|||||||
case 'Undo Approval':
|
case 'Undo Approval':
|
||||||
case 'Add Charge':
|
case 'Add Charge':
|
||||||
case 'Withdraw By Client':
|
case 'Withdraw By Client':
|
||||||
|
case 'Premature Close':
|
||||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||||
break;
|
break;
|
||||||
case 'Modify Application':
|
case 'Modify Application':
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import { AddChargeRecurringDepositsAccountComponent } from './recurring-deposits
|
|||||||
/* Dialog Components */
|
/* Dialog Components */
|
||||||
import { RecurringDepositConfirmationDialogComponent } from './recurring-deposits-account-view/custom-dialogs/recurring-deposit-confirmation-dialog/recurring-deposit-confirmation-dialog.component';
|
import { RecurringDepositConfirmationDialogComponent } from './recurring-deposits-account-view/custom-dialogs/recurring-deposit-confirmation-dialog/recurring-deposit-confirmation-dialog.component';
|
||||||
import { EditRecurringDepositAccountComponent } from './edit-recurring-deposit-account/edit-recurring-deposit-account.component';
|
import { EditRecurringDepositAccountComponent } from './edit-recurring-deposit-account/edit-recurring-deposit-account.component';
|
||||||
|
import { PrematureCloseRecurringDepositAccountComponent } from './recurring-deposits-account-actions/premature-close-recurring-deposit-account/premature-close-recurring-deposit-account.component';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +76,8 @@ import { EditRecurringDepositAccountComponent } from './edit-recurring-deposit-a
|
|||||||
WithdrawByClientRecurringDepositsAccountComponent,
|
WithdrawByClientRecurringDepositsAccountComponent,
|
||||||
AddChargeRecurringDepositsAccountComponent,
|
AddChargeRecurringDepositsAccountComponent,
|
||||||
RecurringDepositConfirmationDialogComponent,
|
RecurringDepositConfirmationDialogComponent,
|
||||||
EditRecurringDepositAccountComponent
|
EditRecurringDepositAccountComponent,
|
||||||
|
PrematureCloseRecurringDepositAccountComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
RecurringDepositConfirmationDialogComponent
|
RecurringDepositConfirmationDialogComponent
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export class RecurringDepositsService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} accountId Account Id
|
* @param {any} accountId Account Id
|
||||||
* @param {any} fixedDepositAccountData Recurring Deposit Account Data
|
* @param {any} recurringDepositAccountData Recurring Deposit Account Data
|
||||||
* @returns {Observable<any>}
|
* @returns {Observable<any>}
|
||||||
*/
|
*/
|
||||||
updateRecurringDepositAccount(accountId: any, recurringDepositAccountData: any): Observable<any> {
|
updateRecurringDepositAccount(accountId: any, recurringDepositAccountData: any): Observable<any> {
|
||||||
|
|||||||
Reference in New Issue
Block a user