business form changes

This commit is contained in:
gandhimathi 2019-01-05 20:00:13 +05:30
parent a9673a0da7
commit dbc5678bca
3 changed files with 69 additions and 68 deletions

View File

@ -102,24 +102,35 @@
[formGroupName]="i">
<mat-card-content>
<mat-form-field style="width: 45%;">
<input matInput placeholder="Name"
formControlName="partner_name" required>
<mat-select placeholder="Name" formControlName="partner_name" style="width: 90%;" (selectionChange)="changePartnerGroup(members.value.partner_name,i)" required>
<mat-option *ngFor="let app_par of applicants" [value]="app_par.applicant_name">{{app_par.applicant_name | titlecase}}</mat-option>
<mat-option value="Others">Others</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 45%;">
<mat-form-field style="width: 45%;" *ngIf="members.value.partner_name=='Others'">
<input matInput placeholder="Specify Others"
formControlName="partner_other_name" required>
</mat-form-field>
<mat-form-field style="width: 45%;" *ngIf="businessForm.controls.business_entity_type.value!='3' && businessForm.controls.business_entity_type.value!='8' && businessForm.controls.business_entity_type.value!=''">
<input matInput placeholder="Share of Profit / Shareholding (%)" (keypress)="keyPress($event)"
formControlName="shareholding" required>
formControlName="shareholding">
</mat-form-field>
<p style="padding-left: 2% !important">No of Years in Current Business</p>
<mat-form-field style="width: 20%;">
<input matInput type="number" placeholder="Year" formControlName="current_business_experiance_year" required min='0'>
<input matInput type="number" placeholder="Year" formControlName="current_business_experiance_year" (keyup)="getWorkExperience(members.value,i)" required min='0'>
</mat-form-field>
<mat-form-field style="width: 21%;">
<input matInput type="number" placeholder="Month" formControlName="current_business_experiance_month" required min='0' max='12'>
</mat-form-field>
<mat-form-field style="width: 35%;">
<input matInput placeholder="Total Business Experience"
formControlName="total_business_experiance" required>
<input matInput type="number" placeholder="Total Work Experience"
formControlName="total_business_experiance" (keyup)="getWorkExperience(members.value,i)" required>
</mat-form-field>
<mat-form-field style="width: 82%;" *ngIf="members.value.total_business_previous_experience!=undefined">
<input matInput placeholder="Previous Work Experience Details"
formControlName="total_business_previous_experience" required>
</mat-form-field>
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="addPartnerDetails()"
matTooltip="Add More" matTooltipPosition="above" color="primary" *ngIf="i==0">
<mat-icon>add</mat-icon>
@ -280,8 +291,8 @@
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" *ngFor="let saleList of manufacturing.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<!-- this is for other than pan india -->
<div fxFlex="100" *ngIf="manufacturing.value.pan_india_options=='No'">
<mat-form-field style="width:35%;">
<div class="state-margin" fxFlex="100" *ngIf="manufacturing.value.pan_india_options=='No'">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -361,8 +372,8 @@
</mat-form-field>
</div>
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" *ngFor="let saleList of manufacturing.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<div class="state-margin" fxLayout="row nowrap" *ngFor="let saleList of manufacturing.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -475,9 +486,8 @@
</mat-form-field>
<ng-container *ngIf="retail.value.india_where_sale_done !=undefined && retail.value.countries_where_export_done ==undefined">
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" *ngFor="let saleList of retail.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<div class="state-margin" fxLayout="row nowrap" *ngFor="let saleList of retail.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -558,8 +568,8 @@
</mat-form-field>
</div>
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" class="tab_class" *ngFor="let saleList of retail.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<div fxLayout="row nowrap" class="state-margin" *ngFor="let saleList of retail.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -674,9 +684,9 @@
</mat-form-field>
<ng-container *ngIf="wholesale.value.india_where_sale_done !=undefined && wholesale.value.countries_where_export_done ==undefined">
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" *ngFor="let saleList of wholesale.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<div class="state-margin" fxLayout="row nowrap" *ngFor="let saleList of wholesale.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -756,8 +766,8 @@
</mat-form-field>
</div>
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" class="tab_class" *ngFor="let saleList of wholesale.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<div fxLayout="row nowrap" class="state-margin" *ngFor="let saleList of wholesale.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:34%;">
<mat-select placeholder="State" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -871,9 +881,9 @@
</mat-form-field>
<ng-container *ngIf="serviceprovider.value.india_where_sale_done !=undefined && serviceprovider.value.countries_where_export_done ==undefined">
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" *ngFor="let saleList of serviceprovider.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<div class="state-margin" fxLayout="row nowrap" *ngFor="let saleList of serviceprovider.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<mat-form-field style="width:34%;">
<mat-select placeholder="Where, In India, Is The Service Provided" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -953,8 +963,8 @@
</mat-form-field>
</div>
<div formArrayName="india_where_sale_done">
<div fxLayout="row nowrap" class="tab_class" *ngFor="let saleList of serviceprovider.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:35%;">
<div fxLayout="row nowrap" class="state-margin" *ngFor="let saleList of serviceprovider.get('india_where_sale_done').controls; let s = index" [formGroupName]="s">
<mat-form-field style="width:34%;">
<mat-select placeholder="Where, In India, Is The Service Provided" formControlName="state_name" required>
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">
{{SL.state_name}}
@ -1067,39 +1077,8 @@
</mat-card-actions>
</mat-card>
<mat-card>
<mat-card-title>Seasonality</mat-card-title>
<mat-card-content>
<div fxLayout="row nowrap">
<mat-form-field style="width: 60%">
<mat-select placeholder="Either Currently Running The Business / Are Loan Applicants"
formControlName="main_person" required>
<!-- <mat-option value="applicants">One of the applicants</mat-option> -->
<mat-option value="{{owner.pd_co_applicant_id}}" *ngFor="let owner of applicants">{{owner.applicant_name}}</mat-option>
<mat-option value="Relative">Relative of An Applicant</mat-option>
<mat-option value="Others">Others</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 28%" *ngIf="businessForm.controls['main_person'].value == 'Others'">
<input matInput placeholder="Specify other person"
formControlName="other_main_person">
</mat-form-field>
</div>
<div fxLayout="row nowrap">
<mat-form-field style="width: 60%">
<mat-select placeholder="Were They Involved In Any Other Business Before Starting This Business"
formControlName="before_business" required>
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row nowrap">
<mat-form-field style="width: 60%" *ngIf="businessForm.controls['before_business'].value == 'yes'">
<textarea matInput placeholder="Description For Before Starting This Business"
formControlName="before_business_description"></textarea>
</mat-form-field>
</div>
<div fxLayout="row wrap">
<mat-form-field style="width: 28%">
<!-- <input matInput placeholder="Seasonality" formControlName="seasonality" required> -->
@ -1127,7 +1106,6 @@
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row nowrap" *ngIf="businessForm.controls['seasonality'].value == 'yes'">
<mat-form-field style="width: 60%">

View File

@ -137,4 +137,7 @@ mat-header-cell mat-cell {
.tab_class {
margin-top: 3%;
}
.state-margin {
margin-left: 2%;
}

View File

@ -110,7 +110,7 @@ export class BusinessInfoComponent implements OnInit {
let businessVal = data.records;
let constVal: any;
//const Desgn = <FormArray>this.businessForm.controls['designation'];
const Partnr = <FormArray>this.businessForm.controls['partners'];
const Partnr: any = <FormArray>this.businessForm.controls['partners'];
const otherDoc = <FormArray>this.businessForm.controls['documents'];
const personRel = <FormArray>this.businessForm.controls['persons_with_relationships'];
const businessActivityControl = <FormArray>this.businessForm.controls['select_business_activity_type'];
@ -119,9 +119,6 @@ export class BusinessInfoComponent implements OnInit {
const wholesaleControl: any = <FormArray>this.businessForm.controls['wholesale_trading_activity_details'];
const serviceProviderControl: any = <FormArray>this.businessForm.controls['service_provider_activity_details'];
const othersControl: any = <FormArray>this.businessForm.controls['others_activity_details'];
if (data.status == 200) {
let DocArray: any;
// let DesgnArray = Object.keys(data.records.designation).map(function (key) {
@ -142,8 +139,17 @@ export class BusinessInfoComponent implements OnInit {
if (PartnrArray.length == 0) {
Partnr.push(this.createPartners());
} else {
PartnrArray.forEach(datas => {
PartnrArray.forEach((datas,key) => {
Partnr.push(this.createPartners());
if(datas.partner_name=='Others') {
Partnr.controls[key].addControl('partner_other_name', new FormControl('', Validators.required))
}
if(parseInt(datas.total_business_experiance) > parseInt(datas.current_business_experiance_year)) {
Partnr.controls[key].addControl('total_business_previous_experience', new FormControl('', Validators.required))
}
else {
Partnr.controls[key].removeControl('total_business_previous_experience')
}
});
}
if (data.records.other_documents == 'yes') {
@ -355,7 +361,6 @@ export class BusinessInfoComponent implements OnInit {
}
else {
businessVal.retail_trading_activity_details=[];
}
// update whole sale details
@ -603,10 +608,6 @@ export class BusinessInfoComponent implements OnInit {
other_documents: ['', Validators.compose([Validators.required])],
documents: this.fb.array([]),
business_remarks: ['', Validators.compose([Validators.required])],
main_person: ['', Validators.compose([Validators.required])],
other_main_person: [''],
before_business: ['', Validators.compose([Validators.required])],
before_business_description: [''],
//any_delays: ['', Validators.compose([Validators.required])],
persons_with_relationships:this.fb.array([]),
select_business_activity_type: this.fb.array([]),
@ -870,7 +871,7 @@ export class BusinessInfoComponent implements OnInit {
createPartners(): FormGroup {
return this.fb.group({
partner_name: ['', Validators.compose([Validators.required])],
shareholding: ['', Validators.compose([Validators.required])],
shareholding: [''],
current_business_experiance_year: ['', Validators.compose([Validators.required])],
current_business_experiance_month: ['', Validators.compose([Validators.required])],
total_business_experiance: ['', Validators.compose([Validators.required])],
@ -1174,6 +1175,25 @@ export class BusinessInfoComponent implements OnInit {
let othersControl = <FormArray>this.businessForm.controls['others_activity_details'];
othersControl.push(this.createOthersActivity());
}
// update partner group other form control
changePartnerGroup(value,key) {
let control: any = this.businessForm.get('partners') as FormArray;
value=='Others' ? control.controls[key].addControl('partner_other_name', new FormControl('', Validators.required)) : control.controls[key].removeControl('partner_other_name');
}
// get work experience based on create form control
getWorkExperience(event, key) {
let current_experience = event.current_business_experiance_year=='' ? 0 : parseInt(event.current_business_experiance_year);
let total_experience = event.total_business_experiance=='' ? 0 : parseInt(event.total_business_experiance);
let control: any = this.businessForm.get('partners') as FormArray;
if(total_experience > current_experience) {
control.controls[key].addControl('total_business_previous_experience', new FormControl('', Validators.required))
}
else {
control.controls[key].removeControl('total_business_previous_experience')
}
}
submitDetails() {
// let family: any = [];
if (!this.businessForm.valid) {