Changes in build : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-05-10 14:52:25 +05:30
parent 54ab40eca3
commit fbff71164d
3 changed files with 215 additions and 9 deletions

View File

@ -363,17 +363,84 @@
<mat-option value="no">No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls.is_there_working_capital_available.value == 'yes'">
<!-- <mat-form-field style="width:100%;" *ngIf="financialForm.controls.is_there_working_capital_available.value == 'yes'">
<mat-select multiple formControlName="working_capital_facilities_availed"
placeholder="Working Capital Facilities availed">
<!-- <mat-option>Select</mat-option> -->
<mat-option>Select</mat-option>
<mat-option *ngFor="let a of av" [value]="a.id">{{a.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls.is_there_working_capital_available.value == 'yes' && financialForm.controls.working_capital_facilities_availed.value != ''">
</mat-form-field> -->
<!-- <mat-form-field style="width:100%;" *ngIf="financialForm.controls.is_there_working_capital_available.value == 'yes' && financialForm.controls.working_capital_facilities_availed.value != ''">
<input matInput autocomplete="off" placeholder="Details of Facility"
formControlName="reason_for_working_capital_facilities_availed">
</mat-form-field>
</mat-form-field> -->
<div *ngIf="financialForm.controls.is_there_working_capital_available.value == 'yes'">
<mat-card-subtitle>
<p>Working Capital Facilities availed</p>
</mat-card-subtitle>
<div class="toggle" fxLayout="row wrap" formArrayName="select_working_capital_facilities_availed">
<div fxFlex.xs="100" fxFlex.sm="50" fxFlex.md="25" fxFlex.lg="25" fxFlex.xl="25"
*ngFor="let entityType of financialForm.controls.select_working_capital_facilities_availed['controls']; let e = index;"
[formGroupName]="e">
<mat-checkbox class="example-margin" color="primary" formControlName="exist_status"
(click)="changeWorkingCapitalFacilities(entityType)">{{entityType.controls.name.value}}</mat-checkbox>
</div>
</div>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['other_reason_for_working_capital_facilities_availed']">
<input matInput autocomplete="off" placeholder="Others Working Capital Facilities availed"
formControlName="other_reason_for_working_capital_facilities_availed">
<!-- <mat-error *ngIf="financialForm.controls['other_reason_for_working_capital_facilities_availed'].hasError('required')">other_reason_for_working_capital_facilities_availed Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['reason_for_working_capital_facilities_availed']">
<input matInput autocomplete="off" placeholder="Details of Others Facility"
formControlName="reason_for_working_capital_facilities_availed">
<!-- <mat-error *ngIf="financialForm.controls['reason_for_working_capital_facilities_availed'].hasError('required')">reason_for_working_capital_facilities_availed Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['bank_guarantee']">
<input matInput autocomplete="off" placeholder="Details of Bank Guarantee Facility"
formControlName="bank_guarantee">
<!-- <mat-error *ngIf="financialForm.controls['bank_guarantee'].hasError('required')">reason_for_working_capital_facilities_availed Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['cash_credit_limit']">
<input matInput autocomplete="off" placeholder="Details of Cash Credit Limit"
formControlName="cash_credit_limit">
<!-- <mat-error *ngIf="financialForm.controls['cash_credit_limit'].hasError('required')">cash_credit_limit Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['factoring']">
<input matInput autocomplete="off" placeholder="Details of Factoring"
formControlName="factoring">
<!-- <mat-error *ngIf="financialForm.controls['factoring'].hasError('required')">cash_credit_limit Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['letter_of_credit']">
<input matInput autocomplete="off" placeholder="Details of Letter of Credit"
formControlName="letter_of_credit">
<!-- <mat-error *ngIf="financialForm.controls['letter_of_credit'].hasError('required')">letter_of_credit Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['forfaiting']">
<input matInput autocomplete="off" placeholder="Details of Forfaiting"
formControlName="factoring">
<!-- <mat-error *ngIf="financialForm.controls['forfaiting'].hasError('required')">forfaiting Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width:100%;" *ngIf="financialForm.controls['od_limit']">
<input matInput autocomplete="off" placeholder="Details of OD Limit"
formControlName="od_limit">
<!-- <mat-error *ngIf="financialForm.controls['od_limit'].hasError('required')">forfaiting Required</mat-error> -->
</mat-form-field>
</div>
</mat-card-content>
</mat-card>

View File

@ -65,5 +65,7 @@ page-pd-question-financial-info {
height: 28px;
}
.toggle{
padding: 1.4rem;
}
}

View File

@ -3,7 +3,7 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {AwsServiceProvider} from '../../../../providers/aws-service/aws-service'
import {ToastProvider} from '../../../../providers/common-provider/toast'
import {QuestionCategoryProvider} from '../../../../providers/question-category/question-category'
import { FormGroup,Validators,FormBuilder, FormArray } from '@angular/forms'
import { FormGroup,Validators,FormBuilder, FormArray, FormControl } from '@angular/forms'
import {ConstantsProvider} from '../../../../providers/constants/constants'
import {CameraProvider} from '../../../../providers/common-provider/camera'
import {LoadingProvider} from '../../../../providers/common-provider/loading'
@ -231,10 +231,11 @@ this.complete_status = this.pdDetails.pd_status == 'COMPLETED' ? true : false;
unsold_stock_lies_in_days:[''],
is_there_working_capital_available:[''],
working_capital_facilities_availed:[''],
reason_for_working_capital_facilities_availed:[''],
// reason_for_working_capital_facilities_availed:[''],
// same_as_financial_statements:[''],
date_per_financial: this.fb.array([]),
estimated_value: this.fb.array([])
estimated_value: this.fb.array([]),
select_working_capital_facilities_availed : this.fb.array([])
});
}
createDate(date){
@ -340,6 +341,8 @@ submitDetails(){
//financeDate.push(this.createDate(''))
const estimate= <FormArray> this.financialForm.controls['estimated_value']
//estimate.push(this.createValue(''))
const workingCptlControl = <FormArray>this.financialForm.controls['select_working_capital_facilities_availed'];
let params:any={}
params.parent_pdid=this.pdDetails.parent_pd_id
params.pd_id=this.pdDetails.pd_id
@ -399,15 +402,149 @@ submitDetails(){
retrieveData.company_id=this.company_id
retrieveData.fk_createdby=this.users
retrieveData.formid=this.FormId
let avData = this.av.map(item => ({ name: item.name, id: item.id }))
let exist_av_data: any = [];
if (retrieveData.select_working_capital_facilities_availed) {
exist_av_data = Object.keys(retrieveData.select_working_capital_facilities_availed).map(function (key) {
return retrieveData.select_working_capital_facilities_availed[key].id;
});
}
let actual_av = avData.map(item => item.id);
let check_exist_av = actual_av.map((id, index) => {
if (exist_av_data.indexOf(id) < 0) {
avData[index].exist_status = 0;
return avData[index];
}
else {
avData[index].exist_status = 1;
return avData[index];
}
}).filter(item => item != undefined);
if (check_exist_av.length > 0) {
check_exist_av.forEach(val => {
workingCptlControl.push(this.workingCptl(val));
if (val.exist_status == 1 && val.id == 2) {
this.financialForm.addControl('bank_guarantee', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 3) {
this.financialForm.addControl('cash_credit_limit', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 4) {
this.financialForm.addControl('factoring', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 5) {
this.financialForm.addControl('forfaiting', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 6) {
this.financialForm.addControl('letter_of_credit', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 7) {
this.financialForm.addControl('od_limit', new FormControl(''));
}
if (val.exist_status == 1 && val.id == 1) {
this.financialForm.addControl('other_reason_for_working_capital_facilities_availed', new FormControl(''));
this.financialForm.addControl('reason_for_working_capital_facilities_availed', new FormControl(''));
}
console.log(val);
});
console.log('check_exist_businees_activity',check_exist_av);
retrieveData.select_working_capital_facilities_availed = check_exist_av;
}
this.financialForm.setValue(retrieveData)
}
else {
let avData = this.av.map(item => ({ name: item.name, id: item.id }))
let exist_av_data: any = [];
let actual_av = avData.map(item => item.id);
let check_exist_av = actual_av.map((id, index) => {
if (exist_av_data.indexOf(id) < 0) {
avData[index].exist_status = 0;
return avData[index];
}
else {
avData[index].exist_status = 1;
return avData[index];
}
}).filter(item => item != undefined);
if (check_exist_av.length > 0) {
check_exist_av.forEach(val => {
workingCptlControl.push(this.workingCptl(val));
});
}
//financial_date.push(this.createDate());
//estimated_val.push(this.createValue(''));
}
})
}
workingCptl(details: any): FormGroup {
return this.fb.group({
id: [details.id, Validators.compose([Validators.required])],
name: [details.name, Validators.compose([Validators.required])],
exist_status: [details.exist_status == 1 ? true : false]
});
}
changeWorkingCapitalFacilities(event: any) {
console.log('event',event);
if (event.value.exist_status == true && event.value.id == 2) {
console.log('event.value.exist_status == true && event.value.id == 2',event.value.exist_status,event.value.id)
this.financialForm.removeControl('bank_guarantee');
}
else if (event.value.exist_status == false && event.value.id == 2) {
console.log('event.value.exist_status == true && event.value.id == 2',event.value.exist_status,event.value.id)
this.financialForm.addControl('bank_guarantee', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 3) {
this.financialForm.removeControl('cash_credit_limit');
}
else if (event.value.exist_status == false && event.value.id == 3) {
this.financialForm.addControl('cash_credit_limit', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 4) {
this.financialForm.removeControl('factoring');
}
else if (event.value.exist_status == false && event.value.id == 4) {
this.financialForm.addControl('factoring', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 5) {
this.financialForm.removeControl('forfaiting');
}
else if (event.value.exist_status == false && event.value.id == 5) {
this.financialForm.addControl('forfaiting', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 6) {
this.financialForm.removeControl('letter_of_credit');
}
else if (event.value.exist_status == false && event.value.id == 6) {
this.financialForm.addControl('letter_of_credit', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 7) {
this.financialForm.removeControl('od_limit');
}
else if (event.value.exist_status == false && event.value.id == 7) {
this.financialForm.addControl('od_limit', new FormControl(''));
}
if (event.value.exist_status == true && event.value.id == 1) {
this.financialForm.removeControl('other_reason_for_working_capital_facilities_availed');
this.financialForm.removeControl('reason_for_working_capital_facilities_availed');
}
else if (event.value.exist_status == false && event.value.id == 1) {
this.financialForm.addControl('other_reason_for_working_capital_facilities_availed', new FormControl(''));
this.financialForm.addControl('reason_for_working_capital_facilities_availed', new FormControl(''));
}
}
/**
* New Calculation for Finanical Statement
**/