+73
@@ -0,0 +1,73 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="closeOnMaturityAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Closed On Date</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="closeOnMaturityAccountForm.controls.closedOnDate.hasError('required')">
|
||||
Closed On Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Maturity Amount</mat-label>
|
||||
<input type=number matInput formControlName="maturityAmount"/>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Action</mat-label>
|
||||
<mat-select required formControlName="onAccountClosureId">
|
||||
<mat-option *ngFor="let closureOption of onAccountClosureOptions" [value]="closureOption.id">
|
||||
{{ closureOption.value }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="closeOnMaturityAccountForm.controls.onAccountClosureId.hasError('required')">
|
||||
Account action is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="closeOnMaturityAccountForm.contains('toSavingsAccountId')">
|
||||
<mat-label>Transfer to Savings</mat-label>
|
||||
<mat-select required formControlName="toSavingsAccountId">
|
||||
<mat-option *ngFor="let account of savingsAccountsData" [value]="account.id">
|
||||
{{ account.accountNo }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="closeOnMaturityAccountForm.controls.toSavingsAccountId.hasError('required')">
|
||||
Transfer to savings account is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="closeOnMaturityAccountForm.contains('transferDescription')">
|
||||
<mat-label>Transfer Description</mat-label>
|
||||
<input matInput formControlName="transferDescription"/>
|
||||
</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="warn" [disabled]="!closeOnMaturityAccountForm.valid">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 { CloseFixedDepositsAccountComponent } from './close-fixed-deposits-account.component';
|
||||
|
||||
describe('CloseFixedDepositsAccountComponent', () => {
|
||||
let component: CloseFixedDepositsAccountComponent;
|
||||
let fixture: ComponentFixture<CloseFixedDepositsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CloseFixedDepositsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CloseFixedDepositsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { FixedDepositsService } from '../../fixed-deposits.service';
|
||||
|
||||
/**
|
||||
* Close On Maturity Fixed Deposits Account Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-close-fixed-deposits-account',
|
||||
templateUrl: './close-fixed-deposits-account.component.html',
|
||||
styleUrls: ['./close-fixed-deposits-account.component.scss']
|
||||
})
|
||||
export class CloseFixedDepositsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Close on maturity FD Account form. */
|
||||
closeOnMaturityAccountForm: FormGroup;
|
||||
/** Savings Account Data */
|
||||
savingsAccountsData: any;
|
||||
/** On account Closure Options */
|
||||
onAccountClosureOptions: any;
|
||||
/** Fixed Deposits Account Id */
|
||||
accountId: any;
|
||||
/** Maturity Amount */
|
||||
maturityAmount: any;
|
||||
|
||||
/**
|
||||
* Fetches close action data from `resolve`
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private fixedDepositsService: FixedDepositsService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.route.data.subscribe((data: { fixedDepositsAccountActionData: any }) => {
|
||||
this.savingsAccountsData = data.fixedDepositsAccountActionData.savingsAccounts;
|
||||
this.onAccountClosureOptions = data.fixedDepositsAccountActionData.onAccountClosureOptions;
|
||||
this.maturityAmount = data.fixedDepositsAccountActionData.maturityAmount;
|
||||
});
|
||||
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the close on maturity fd account form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createCloseOnMaturityAccountForm();
|
||||
this.addTransferDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the close on maturity fd account form.
|
||||
*/
|
||||
createCloseOnMaturityAccountForm() {
|
||||
this.closeOnMaturityAccountForm = this.formBuilder.group({
|
||||
'closedOnDate': ['', Validators.required],
|
||||
'maturityAmount': [{value: this.maturityAmount, disabled: true}],
|
||||
'onAccountClosureId': ['', Validators.required],
|
||||
'note': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to value changes of `onAccountClosureId` adds and removes transfer details accordingly.
|
||||
*/
|
||||
addTransferDetails() {
|
||||
this.closeOnMaturityAccountForm.get('onAccountClosureId').valueChanges.subscribe((id: any) => {
|
||||
if (id === 200) {
|
||||
this.closeOnMaturityAccountForm.addControl('toSavingsAccountId', new FormControl('', Validators.required));
|
||||
this.closeOnMaturityAccountForm.addControl('transferDescription', new FormControl(''));
|
||||
} else {
|
||||
this.closeOnMaturityAccountForm.removeControl('toSavingsAccountId');
|
||||
this.closeOnMaturityAccountForm.removeControl('transferDescription');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and close the fd account on maturity,
|
||||
* if successful redirects to the fd account.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevClosedDate: Date = this.closeOnMaturityAccountForm.value.closedOnDate;
|
||||
this.closeOnMaturityAccountForm.patchValue({
|
||||
closedOnDate: this.datePipe.transform(prevClosedDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.closeOnMaturityAccountForm.value,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'close', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -5,4 +5,4 @@
|
||||
<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-premature-close-fixed-deposits-account *ngIf="actions['Premature Close']"></mifosx-premature-close-fixed-deposits-account>
|
||||
<!-- <mifosx-close-fixed-deposits-account *ngIf="actions['Close']"></mifosx-close-fixed-deposits-account> -->
|
||||
<mifosx-close-fixed-deposits-account *ngIf="actions['Close']"></mifosx-close-fixed-deposits-account>
|
||||
|
||||
Reference in New Issue
Block a user