diff --git a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts
index c2bd9933c..761cf9ad9 100644
--- a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts
+++ b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts
@@ -1,5 +1,5 @@
/** Angular Imports */
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
@@ -8,7 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { SharesService } from 'app/shares/shares.service';
/**
- * App;y Shares Component
+ * Apply Shares Component
*/
@Component({
selector: 'mifosx-apply-shares',
@@ -17,7 +17,6 @@ import { SharesService } from 'app/shares/shares.service';
})
export class ApplySharesComponent implements OnInit {
-
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
@@ -26,8 +25,6 @@ export class ApplySharesComponent implements OnInit {
applySharesForm: FormGroup;
/** Shares Account Id */
accountId: any;
- /** Unit Price */
- unitPrice: any;
/**
* @param {FormBuilder} formBuilder Form Builder
@@ -81,7 +78,7 @@ export class ApplySharesComponent implements OnInit {
});
const data = {
...this.applySharesForm.value,
- unitPrice: this.unitPrice,
+ unitPrice: this.applySharesForm.get('unitPrice').value,
dateFormat,
locale
};
diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.html b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.html
new file mode 100644
index 000000000..bafbf681c
--- /dev/null
+++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.html
@@ -0,0 +1,47 @@
+
diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.scss b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.scss
new file mode 100644
index 000000000..d774f68da
--- /dev/null
+++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.scss
@@ -0,0 +1,3 @@
+.container {
+ max-width: 37rem;
+}
diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.spec.ts b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.spec.ts
new file mode 100644
index 000000000..33cc82d1e
--- /dev/null
+++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RedeemSharesComponent } from './redeem-shares.component';
+
+describe('RedeemSharesComponent', () => {
+ let component: RedeemSharesComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ RedeemSharesComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RedeemSharesComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts
new file mode 100644
index 000000000..77d1bbefb
--- /dev/null
+++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts
@@ -0,0 +1,90 @@
+/** 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 { SharesService } from 'app/shares/shares.service';
+
+/**
+ * Redeem Shares Component
+ */
+@Component({
+ selector: 'mifosx-redeem-shares',
+ templateUrl: './redeem-shares.component.html',
+ styleUrls: ['./redeem-shares.component.scss']
+})
+export class RedeemSharesComponent implements OnInit {
+
+ /** Minimum date allowed. */
+ minDate = new Date(2000, 0, 1);
+ /** Maximum date allowed. */
+ maxDate = new Date();
+ /** Redeem Share Account form. */
+ redeemSharesForm: FormGroup;
+ /** Shares Account Id */
+ accountId: any;
+
+ /**
+ * @param {FormBuilder} formBuilder Form Builder
+ * @param {SharesService} sharesService Shares Service
+ * @param {DatePipe} datePipe Date Pipe
+ * @param {ActivatedRoute} route Activated Route
+ * @param {Router} router Router
+ */
+ constructor(private formBuilder: FormBuilder,
+ private sharesService: SharesService,
+ private datePipe: DatePipe,
+ private route: ActivatedRoute,
+ private router: Router) {
+ this.accountId = this.route.parent.snapshot.params['shareAccountId'];
+ }
+
+ /**
+ * Creates the apply shares form.
+ * Fetching data from service as action buttons malfunction
+ * in clients view upon using a common resolver.
+ */
+ ngOnInit() {
+ this.createRedeemSharesAccountForm();
+ this.sharesService.getSharesAccountData(this.accountId, false).subscribe((response: any) => {
+ this.redeemSharesForm.get('unitPrice').patchValue(response.currentMarketPrice || '');
+ });
+ }
+
+ /**
+ * Creates the apply shares form.
+ */
+ createRedeemSharesAccountForm() {
+ this.redeemSharesForm = this.formBuilder.group({
+ 'requestedDate': ['', Validators.required],
+ 'requestedShares': ['', Validators.required],
+ 'unitPrice': [{value: '', disabled: true}]
+ });
+ }
+
+ /**
+ * Submits the form and applies additional shares to the share account,
+ * if successful redirects to the share account.
+ */
+ submit() {
+ // TODO: Update once language and date settings are setup
+ const locale = 'en';
+ const dateFormat = 'dd MMMM yyyy';
+ const prevRequestedDate: Date = this.redeemSharesForm.value.requestedDate;
+ this.redeemSharesForm.patchValue({
+ requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat),
+ });
+ const data = {
+ ...this.redeemSharesForm.value,
+ unitPrice: this.redeemSharesForm.get('unitPrice').value,
+ dateFormat,
+ locale
+ };
+ this.sharesService.executeSharesAccountCommand(this.accountId, 'redeemshares', data).subscribe(() => {
+ this.router.navigate(['../../'], { relativeTo: this.route });
+ });
+ }
+
+}
diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.html b/src/app/shares/shares-account-actions/shares-account-actions.component.html
index fb446b5e4..01b31ba19 100644
--- a/src/app/shares/shares-account-actions/shares-account-actions.component.html
+++ b/src/app/shares/shares-account-actions/shares-account-actions.component.html
@@ -3,4 +3,5 @@
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.ts b/src/app/shares/shares-account-actions/shares-account-actions.component.ts
index 818a61103..70bbbdf05 100644
--- a/src/app/shares/shares-account-actions/shares-account-actions.component.ts
+++ b/src/app/shares/shares-account-actions/shares-account-actions.component.ts
@@ -22,13 +22,15 @@ export class SharesAccountActionsComponent {
'Activate': boolean
'Undo Approval': boolean
'Apply Additional Shares': boolean
+ 'Redeem Shares': boolean
} = {
'Approve': false,
'Reject': false,
'Close': false,
'Activate': false,
'Undo Approval': false,
- 'Apply Additional Shares': false
+ 'Apply Additional Shares': false,
+ 'Redeem Shares': false
};
/**
diff --git a/src/app/shares/shares-account-view/shares-account-view.component.ts b/src/app/shares/shares-account-view/shares-account-view.component.ts
index 49202427f..52a1b83a3 100644
--- a/src/app/shares/shares-account-view/shares-account-view.component.ts
+++ b/src/app/shares/shares-account-view/shares-account-view.component.ts
@@ -88,6 +88,7 @@ export class SharesAccountViewComponent implements OnInit {
case 'Activate':
case 'Undo Approval':
case 'Apply Additional Shares':
+ case 'Redeem Shares':
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Modify Application':
diff --git a/src/app/shares/shares.module.ts b/src/app/shares/shares.module.ts
index 0058a8305..7240b3286 100644
--- a/src/app/shares/shares.module.ts
+++ b/src/app/shares/shares.module.ts
@@ -24,6 +24,7 @@ import { CloseSharesAccountComponent } from './shares-account-actions/close-shar
import { ActivateSharesAccountComponent } from './shares-account-actions/activate-shares-account/activate-shares-account.component';
import { UndoApprovalSharesAccountComponent } from './shares-account-actions/undo-approval-shares-account/undo-approval-shares-account.component';
import { ApplySharesComponent } from './shares-account-actions/apply-shares/apply-shares.component';
+import { RedeemSharesComponent } from './shares-account-actions/redeem-shares/redeem-shares.component';
/**
* Shares Module
@@ -54,7 +55,8 @@ import { ApplySharesComponent } from './shares-account-actions/apply-shares/appl
CloseSharesAccountComponent,
ActivateSharesAccountComponent,
UndoApprovalSharesAccountComponent,
- ApplySharesComponent
+ ApplySharesComponent,
+ RedeemSharesComponent
],
providers: [DatePipe]
})