feat: add create shares account page (#877)

Fixes: #223
This commit is contained in:
Karan Takalkar
2020-06-15 21:18:14 +05:30
committed by GitHub
parent 5304774e26
commit d51bd6466a
26 changed files with 1103 additions and 5 deletions
@@ -0,0 +1,105 @@
<form [formGroup]="sharesAccountTermsForm">
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column" fxLayoutAlign.gt-sm="start center">
<mat-form-field fxFlex="48%">
<mat-label>Currency</mat-label>
<input matInput formControlName="currencyCode">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Decimal Places</mat-label>
<input type="number" matInput formControlName="decimal">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Total Number of Shares</mat-label>
<input type="number" matInput formControlName="requestedShares" required>
<mat-error>
Total Number of Shares is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Today's Price</mat-label>
<input type="number" matInput formControlName="unitPrice">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Currency in multiples of</mat-label>
<input type="number" matInput formControlName="currencyMultiple" >
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Default Savings Account</mat-label>
<mat-select formControlName="savingsAccountId" required>
<mat-option *ngFor="let account of savingsAccountsData" [value]="account.id">
{{ account.accountNo }}
</mat-option>
</mat-select>
<mat-error>
Default Savings Account is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Application Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="applicationDatePicker"
formControlName="applicationDate" required>
<mat-datepicker-toggle matSuffix [for]="applicationDatePicker"></mat-datepicker-toggle>
<mat-datepicker #applicationDatePicker></mat-datepicker>
<mat-error>
Application Date is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-checkbox labelPosition="before" formControlName="allowDividendCalculationForInactiveClients" fxFlex="48%">
Allow dividends for inactive clients
</mat-checkbox>
<h4 fxFlex="98%" class="mat-h4">Minimum Active Period</h4>
<mat-form-field fxFlex="48%">
<mat-label>Frequency</mat-label>
<input type="number" matInput formControlName="minimumActivePeriod">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Type</mat-label>
<mat-select formControlName="minimumActivePeriodFrequencyType">
<mat-option *ngFor="let minimumActivePeriodFrequencyType of minimumActivePeriodFrequencyTypeData" [value]="minimumActivePeriodFrequencyType.id">
{{ minimumActivePeriodFrequencyType.value }}
</mat-option>
</mat-select>
</mat-form-field>
<h4 fxFlex="98%" class="mat-h4">Lock-in Period</h4>
<mat-form-field fxFlex="48%">
<mat-label>Frequency</mat-label>
<input type="number" matInput formControlName="lockinPeriodFrequency">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Type</mat-label>
<mat-select formControlName="lockinPeriodFrequencyType">
<mat-option *ngFor="let lockinPeriodFrequencyType of lockinPeriodFrequencyTypeData" [value]="lockinPeriodFrequencyType.id">
{{ lockinPeriodFrequencyType.value }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
<button mat-raised-button matStepperPrevious disabled>
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;
Previous
</button>
<button mat-raised-button matStepperNext>
Next&nbsp;&nbsp;
<fa-icon icon="arrow-right"></fa-icon>
</button>
</div>
</form>
@@ -0,0 +1,8 @@
h4 {
font-weight: 500;
margin: 1em 0;
}
.margin-t {
margin-top: 1em;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SharesAccountTermsStepComponent } from './shares-account-terms-step.component';
describe('SharesAccountTermsStepComponent', () => {
let component: SharesAccountTermsStepComponent;
let fixture: ComponentFixture<SharesAccountTermsStepComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SharesAccountTermsStepComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SharesAccountTermsStepComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,79 @@
/** Angular Imports */
import { Component, OnChanges, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
/**
* Shares Account Terms Step
*/
@Component({
selector: 'mifosx-shares-account-terms-step',
templateUrl: './shares-account-terms-step.component.html',
styleUrls: ['./shares-account-terms-step.component.scss']
})
export class SharesAccountTermsStepComponent implements OnChanges {
/** Shares Account and Product Template */
@Input() sharesAccountProductTemplate: any;
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Shares Account Terms Form */
sharesAccountTermsForm: FormGroup;
/** Minimum Active Period Frequency Type Data */
minimumActivePeriodFrequencyTypeData: any;
/** Lockin Period Frequency Type Data */
lockinPeriodFrequencyTypeData: any;
/** Savings Accounts Data */
savingsAccountsData: any;
/**
* @param {FormBuilder} formBuilder Form Builder
*/
constructor(private formBuilder: FormBuilder) {
this.createSharesAccountTermsForm();
}
ngOnChanges() {
if (this.sharesAccountProductTemplate) {
this.sharesAccountTermsForm.patchValue({
'currencyCode': this.sharesAccountProductTemplate.currency.code,
'decimal': this.sharesAccountProductTemplate.currency.decimalPlaces,
'currencyMultiple': this.sharesAccountProductTemplate.currency.inMultiplesOf,
'unitPrice': this.sharesAccountProductTemplate.currentMarketPrice
});
this.minimumActivePeriodFrequencyTypeData = this.sharesAccountProductTemplate.minimumActivePeriodFrequencyTypeOptions;
this.lockinPeriodFrequencyTypeData = this.sharesAccountProductTemplate.lockinPeriodFrequencyTypeOptions;
this.savingsAccountsData = this.sharesAccountProductTemplate.clientSavingsAccounts;
}
}
/**
* Creates shares account terms form.
*/
createSharesAccountTermsForm() {
this.sharesAccountTermsForm = this.formBuilder.group({
'currencyCode': [{value: '', disabled: true}],
'decimal': [{value: '', disabled: true}],
'requestedShares': ['', Validators.required],
'unitPrice': [{value: '', disabled: true}],
'currencyMultiple': [{value: '', disabled: true}],
'savingsAccountId': ['', Validators.required],
'minimumActivePeriod': [''],
'minimumActivePeriodFrequencyType': [''],
'lockinPeriodFrequency': [''],
'lockinPeriodFrequencyType': [''],
'applicationDate': ['', Validators.required],
'allowDividendCalculationForInactiveClients': [false],
});
}
/**
* Returns shares account terms form value.
*/
get sharesAccountTerms() {
return this.sharesAccountTermsForm.value;
}
}