@@ -1,5 +1,5 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
@@ -8,7 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { SharesService } from 'app/shares/shares.service';
|
import { SharesService } from 'app/shares/shares.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App;y Shares Component
|
* Apply Shares Component
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'mifosx-apply-shares',
|
selector: 'mifosx-apply-shares',
|
||||||
@@ -17,7 +17,6 @@ import { SharesService } from 'app/shares/shares.service';
|
|||||||
})
|
})
|
||||||
export class ApplySharesComponent implements OnInit {
|
export class ApplySharesComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
/** Minimum date allowed. */
|
/** Minimum date allowed. */
|
||||||
minDate = new Date(2000, 0, 1);
|
minDate = new Date(2000, 0, 1);
|
||||||
/** Maximum date allowed. */
|
/** Maximum date allowed. */
|
||||||
@@ -26,8 +25,6 @@ export class ApplySharesComponent implements OnInit {
|
|||||||
applySharesForm: FormGroup;
|
applySharesForm: FormGroup;
|
||||||
/** Shares Account Id */
|
/** Shares Account Id */
|
||||||
accountId: any;
|
accountId: any;
|
||||||
/** Unit Price */
|
|
||||||
unitPrice: any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {FormBuilder} formBuilder Form Builder
|
* @param {FormBuilder} formBuilder Form Builder
|
||||||
@@ -81,7 +78,7 @@ export class ApplySharesComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
const data = {
|
const data = {
|
||||||
...this.applySharesForm.value,
|
...this.applySharesForm.value,
|
||||||
unitPrice: this.unitPrice,
|
unitPrice: this.applySharesForm.get('unitPrice').value,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
locale
|
locale
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="redeemSharesForm" (ngSubmit)="submit()">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<div fxLayout="column">
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Request Date</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="requestedDatePicker" required formControlName="requestedDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="requestedDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #requestedDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="redeemSharesForm.controls.requestedDate.hasError('required')">
|
||||||
|
Request Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Total No. of Shares</mat-label>
|
||||||
|
<input matInput required formControlName="requestedShares">
|
||||||
|
<mat-error *ngIf="redeemSharesForm.controls.requestedShares.hasError('required')">
|
||||||
|
Requested Shares is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Today's Price</mat-label>
|
||||||
|
<input matInput required formControlName="unitPrice">
|
||||||
|
</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]="!redeemSharesForm.valid">Confirm</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.container {
|
||||||
|
max-width: 37rem;
|
||||||
|
}
|
||||||
@@ -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<RedeemSharesComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ RedeemSharesComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(RedeemSharesComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,3 +4,4 @@
|
|||||||
<mifosx-activate-shares-account *ngIf="actions['Activate']"></mifosx-activate-shares-account>
|
<mifosx-activate-shares-account *ngIf="actions['Activate']"></mifosx-activate-shares-account>
|
||||||
<mifosx-undo-approval-shares-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-shares-account>
|
<mifosx-undo-approval-shares-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-shares-account>
|
||||||
<mifosx-apply-shares *ngIf="actions['Apply Additional Shares']"></mifosx-apply-shares>
|
<mifosx-apply-shares *ngIf="actions['Apply Additional Shares']"></mifosx-apply-shares>
|
||||||
|
<mifosx-redeem-shares *ngIf="actions['Redeem Shares']"></mifosx-redeem-shares>
|
||||||
@@ -22,13 +22,15 @@ export class SharesAccountActionsComponent {
|
|||||||
'Activate': boolean
|
'Activate': boolean
|
||||||
'Undo Approval': boolean
|
'Undo Approval': boolean
|
||||||
'Apply Additional Shares': boolean
|
'Apply Additional Shares': boolean
|
||||||
|
'Redeem Shares': boolean
|
||||||
} = {
|
} = {
|
||||||
'Approve': false,
|
'Approve': false,
|
||||||
'Reject': false,
|
'Reject': false,
|
||||||
'Close': false,
|
'Close': false,
|
||||||
'Activate': false,
|
'Activate': false,
|
||||||
'Undo Approval': false,
|
'Undo Approval': false,
|
||||||
'Apply Additional Shares': false
|
'Apply Additional Shares': false,
|
||||||
|
'Redeem Shares': false
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export class SharesAccountViewComponent implements OnInit {
|
|||||||
case 'Activate':
|
case 'Activate':
|
||||||
case 'Undo Approval':
|
case 'Undo Approval':
|
||||||
case 'Apply Additional Shares':
|
case 'Apply Additional Shares':
|
||||||
|
case 'Redeem Shares':
|
||||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||||
break;
|
break;
|
||||||
case 'Modify Application':
|
case 'Modify Application':
|
||||||
|
|||||||
@@ -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 { 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 { 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 { ApplySharesComponent } from './shares-account-actions/apply-shares/apply-shares.component';
|
||||||
|
import { RedeemSharesComponent } from './shares-account-actions/redeem-shares/redeem-shares.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shares Module
|
* Shares Module
|
||||||
@@ -54,7 +55,8 @@ import { ApplySharesComponent } from './shares-account-actions/apply-shares/appl
|
|||||||
CloseSharesAccountComponent,
|
CloseSharesAccountComponent,
|
||||||
ActivateSharesAccountComponent,
|
ActivateSharesAccountComponent,
|
||||||
UndoApprovalSharesAccountComponent,
|
UndoApprovalSharesAccountComponent,
|
||||||
ApplySharesComponent
|
ApplySharesComponent,
|
||||||
|
RedeemSharesComponent
|
||||||
],
|
],
|
||||||
providers: [DatePipe]
|
providers: [DatePipe]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user