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 3892f2571..89052f951 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
@@ -4,4 +4,5 @@
+
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html
new file mode 100644
index 000000000..b18dd6cd1
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html
@@ -0,0 +1,73 @@
+
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.scss b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.scss
new file mode 100644
index 000000000..d774f68da
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-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/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.spec.ts
new file mode 100644
index 000000000..b7e8c1d62
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { PrematureCloseFixedDepositsAccountComponent } from './premature-close-fixed-deposits-account.component';
+
+describe('PrematureCloseFixedDepositsAccountComponent', () => {
+ let component: PrematureCloseFixedDepositsAccountComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ PrematureCloseFixedDepositsAccountComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(PrematureCloseFixedDepositsAccountComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts
new file mode 100644
index 000000000..8bf427d3c
--- /dev/null
+++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts
@@ -0,0 +1,143 @@
+/** 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';
+
+/**
+ * Premature Close Fixed Deposits Account Component
+ */
+@Component({
+ selector: 'mifosx-premature-close-fixed-deposits-account',
+ templateUrl: './premature-close-fixed-deposits-account.component.html',
+ styleUrls: ['./premature-close-fixed-deposits-account.component.scss']
+})
+export class PrematureCloseFixedDepositsAccountComponent implements OnInit {
+
+ /** Minimum date allowed. */
+ minDate = new Date(2000, 0, 1);
+ /** Maximum date allowed. */
+ maxDate = new Date();
+ /** Premature Close FD Account form. */
+ prematureCloseAccountForm: FormGroup;
+ /** Savings Account Data */
+ savingsAccountsData: any;
+ /** On account Closure Options */
+ onAccountClosureOptions: any;
+ /** Fixed Deposits Account Id */
+ accountId: any;
+ /** Form submission event */
+ isSubmitted = false;
+
+
+ /**
+ * @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.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
+ }
+
+ /**
+ * Creates the premature close fd account form.
+ */
+ ngOnInit() {
+ this.createPrematureCloseAccountForm();
+ this.buildDependencies();
+ }
+
+ /**
+ * Creates the premature close fd account form.
+ */
+ createPrematureCloseAccountForm() {
+ this.prematureCloseAccountForm = this.formBuilder.group({
+ 'closedOnDate': ['', Validators.required]
+ });
+ }
+
+ /**
+ * Subscribes to value changes of parent control.
+ */
+ buildDependencies() {
+ this.prematureCloseAccountForm.get('closedOnDate').valueChanges.subscribe((value: Date) => {
+ if (!this.isSubmitted) {
+ this.calculatePrematureAmount(value);
+ }
+ });
+ }
+
+ /**
+ * Calculates prematue amount based on closed on date.
+ * @param {Date} date Premature Close Date
+ */
+ calculatePrematureAmount(date: Date) {
+ // TODO: Update once language and date settings are setup
+ const locale = 'en';
+ const dateFormat = 'dd MMMM yyyy';
+ const data = {
+ closedOnDate: this.datePipe.transform(date, dateFormat),
+ dateFormat,
+ locale
+ };
+ this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'calculatePrematureAmount', data)
+ .subscribe((response: any) => {
+ this.savingsAccountsData = response.savingsAccounts;
+ this.onAccountClosureOptions = response.onAccountClosureOptions;
+ this.prematureCloseAccountForm.addControl('maturityAmount', new FormControl({value: '', disabled: true}));
+ this.prematureCloseAccountForm.addControl('onAccountClosureId', new FormControl('', Validators.required));
+ this.prematureCloseAccountForm.addControl('note', new FormControl(''));
+ this.prematureCloseAccountForm.get('maturityAmount').patchValue(response.maturityAmount);
+ this.addTransferDetails();
+ });
+
+ }
+
+ /**
+ * Subscribes to value changes of `onAccountClosureId` adds and removes transfer details accordingly.
+ */
+ addTransferDetails() {
+ this.prematureCloseAccountForm.get('onAccountClosureId').valueChanges.subscribe((id: any) => {
+ if (id === 200) {
+ this.prematureCloseAccountForm.addControl('toSavingsAccountId', new FormControl('', Validators.required));
+ this.prematureCloseAccountForm.addControl('transferDescription', new FormControl(''));
+ } else {
+ this.prematureCloseAccountForm.removeControl('toSavingsAccountId');
+ this.prematureCloseAccountForm.removeControl('transferDescription');
+ }
+ });
+ }
+
+ /**
+ * Submits the form and premature closes the fd account,
+ * if successful redirects to the fd account.
+ */
+ submit() {
+ this.isSubmitted = true;
+ // TODO: Update once language and date settings are setup
+ const locale = 'en';
+ const dateFormat = 'dd MMMM yyyy';
+ const prevClosedDate: Date = this.prematureCloseAccountForm.value.closedOnDate;
+ this.prematureCloseAccountForm.patchValue({
+ closedOnDate: this.datePipe.transform(prevClosedDate, dateFormat),
+ });
+ const data = {
+ ...this.prematureCloseAccountForm.value,
+ dateFormat,
+ locale
+ };
+ this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'prematureClose', 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 26ce13df3..8c57a7033 100644
--- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts
+++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts
@@ -30,6 +30,7 @@ import { ViewTransactionComponent } from './fixed-deposit-account-view/view-tran
import { WaiveChargeDialogComponent } from './fixed-deposit-account-view/custom-dialogs/waive-charge-dialog/waive-charge-dialog.component';
import { InactivateChargeDialogComponent } from './fixed-deposit-account-view/custom-dialogs/inactivate-charge-dialog/inactivate-charge-dialog.component';
import { AddChargeFixedDepositsAccountComponent } from './fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component';
+import { PrematureCloseFixedDepositsAccountComponent } from './fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component';
@NgModule({
declarations: [
@@ -53,7 +54,8 @@ import { AddChargeFixedDepositsAccountComponent } from './fixed-deposits-account
ViewTransactionComponent,
WaiveChargeDialogComponent,
InactivateChargeDialogComponent,
- AddChargeFixedDepositsAccountComponent
+ AddChargeFixedDepositsAccountComponent,
+ PrematureCloseFixedDepositsAccountComponent
],
imports: [
SharedModule,