diff --git a/ng6-seed/SE_PROD_030519.zip b/ng6-seed/SE_PROD_030519.zip new file mode 100644 index 000000000..b0176b990 Binary files /dev/null and b/ng6-seed/SE_PROD_030519.zip differ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html index e8c338fe2..87ebeb455 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html @@ -493,17 +493,81 @@ No - + + + + + + Working Capital Facilities availed + + + + + {{entityType.controls.name.value}} + + + + + + + other_reason_for_working_capital_facilities_availed Required - - + + reason_for_working_capital_facilities_availed Required + + + + reason_for_working_capital_facilities_availed Required + + + + + cash_credit_limit Required + + + + + cash_credit_limit Required + + + + + + letter_of_credit Required + + + + + + forfaiting Required + + + + + + forfaiting Required + + + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss index a52370444..e1a42d584 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss @@ -20,6 +20,10 @@ .mat-form-field-appearance-legacy .mat-hint{ color:rgba(0, 0, 0, 0.8) !important; } +.toggle{ + padding: 1.4rem; +} + .underline input { border: none; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts index d3b49460d..e1d97c6b3 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts @@ -123,8 +123,9 @@ export class FinancialInfoComponent implements OnInit { ngOnInit() { - this.initstockForm(); + + const businessActivityControl = this.financialForm.controls['select_working_capital_facilities_availed']; let params: any = {}; params.parent_pdid = this.parent_pdid; params.pd_id = this.pdid; @@ -137,6 +138,59 @@ export class FinancialInfoComponent implements OnInit { if (value.status == 200) { let retriveData = value.records; + let activityData = this.av.map(item => ({ name: item.name, id: item.id })) + let exist_activity_data: any = []; + + if (retriveData.select_working_capital_facilities_availed) { + exist_activity_data = Object.keys(retriveData.select_working_capital_facilities_availed).map(function (key) { + return retriveData.select_working_capital_facilities_availed[key].id; + }); + } + + let actual_businees_activity = activityData.map(item => item.id); + let check_exist_businees_activity = actual_businees_activity.map((id, index) => { + if (exist_activity_data.indexOf(id) < 0) { + activityData[index].exist_status = 0; + return activityData[index]; + } + else { + activityData[index].exist_status = 1; + return activityData[index]; + } + }).filter(item => item != undefined); + + if (check_exist_businees_activity.length > 0) { + check_exist_businees_activity.forEach(val => { + businessActivityControl.push(this.createEntityType(val)); + + if (val.exist_status == 1 && val.id == 2) { + this.financialForm.addControl('bank_guarantee', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 3) { + this.financialForm.addControl('cash_credit_limit', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 4) { + this.financialForm.addControl('factoring', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 5) { + this.financialForm.addControl('forfaiting', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 6) { + this.financialForm.addControl('letter_of_credit', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 7) { + this.financialForm.addControl('od_limit', new FormControl('', Validators.required)); + } + if (val.exist_status == 1 && val.id == 1) { + this.financialForm.addControl('other_reason_for_working_capital_facilities_availed', new FormControl('', Validators.required)); + this.financialForm.addControl('reason_for_working_capital_facilities_availed', new FormControl('', Validators.required)); + } + console.log(val); + }); + console.log('check_exist_businees_activity',check_exist_businees_activity); + retriveData.select_working_capital_facilities_availed = check_exist_businees_activity; + } + if(value.records.is_financial_statements == 'yes'){ this.isDisplay = true; @@ -195,12 +249,41 @@ export class FinancialInfoComponent implements OnInit { retriveData.formid = this.form_id; retriveData.company_id = this.company_id; retriveData.fk_createdby = this.pdid; - this.financialForm.setValue(retriveData); + this.financialForm.patchValue(retriveData); + } else { + let activityData = this.av.map(item => ({ name: item.name, id: item.id })) + let exist_activity_data: any = []; + // if (data.records.select_working_capital_facilities_availed) { + // exist_activity_data = Object.keys(data.records.select_working_capital_facilities_availed).map(function (key) { + // return data.records.select_working_capital_facilities_availed[key].id; + // }); + // } + + let actual_businees_activity = activityData.map(item => item.id); + let check_exist_businees_activity = actual_businees_activity.map((id, index) => { + if (exist_activity_data.indexOf(id) < 0) { + activityData[index].exist_status = 0; + return activityData[index]; + } + else { + activityData[index].exist_status = 1; + return activityData[index]; + } + }).filter(item => item != undefined); + + + if (check_exist_businees_activity.length > 0) { + check_exist_businees_activity.forEach(val => { + businessActivityControl.push(this.createEntityType(val)); + }); + // businessVal.select_working_capital_facilities_availed = check_exist_businees_activity; + } //financial_date.push(this.createDate()); //estimated_val.push(this.createValue('')); } }) + this._pd.retriveFile(this.pdid,this.form_id,this.company_id).subscribe(data => { if (data.status == 200) { if(data.records.length>0){ @@ -221,6 +304,16 @@ export class FinancialInfoComponent implements OnInit { } }); } + + createEntityType(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] + }); + + } + pdf(fileURL){ window.open(fileURL); } @@ -250,10 +343,11 @@ export class FinancialInfoComponent implements OnInit { 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([]) }); } @@ -286,6 +380,68 @@ export class FinancialInfoComponent implements OnInit { }); } + changeBusinessActivity(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('', Validators.required)); + } + 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('', Validators.required)); + } + 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('', Validators.required)); + } + 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('', Validators.required)); + } + 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('', Validators.required)); + } + 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('', Validators.required)); + } + 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('', Validators.required)); + this.financialForm.addControl('reason_for_working_capital_facilities_availed', new FormControl('', Validators.required)); + } + + // if(event.value.exist_status==true && event.value.id==1){ + // let othersControl = this.businessForm.controls['others_activity_details']; + // othersControl.controls = []; + // othersControl.setValue([]); + // } + // else if(event.value.exist_status==false && event.value.id==1){ + // let othersControl = this.businessForm.controls['others_activity_details']; + // othersControl.push(this.createOthersActivity()); + // } + // check activity type for make dosument sighted filed dynamically + } + /** CREATING financial Customer ( financial_year AutoGenerate ) */ createValue(date) { return this.fb.group({ @@ -1699,11 +1855,15 @@ export class FinancialInfoComponent implements OnInit { this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity(); } - // if (!this.financialForm.valid) { - // this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); - // return; - // } + if (!this.financialForm.valid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); + return; + } + console.log('this.financialForm.value',this.financialForm.value); let records = this.financialForm.value; + records.select_working_capital_facilities_availed = records.select_working_capital_facilities_availed.filter(value => value.exist_status == 1); + console.log('records',records); + this._pd.saveForm(records).subscribe(data => { if(data.status == 200) { this.notifier.notify('success', 'Saved Successfully.'); diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts index 73c67f6ea..8c52bd7e0 100755 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts @@ -208,13 +208,13 @@ export class DialogEntityEditListTatComponent implements OnInit { get f() { return this.tatListEditForm.controls }; get f1() { return this.tatEditAddForm.controls }; - // onSubmit() { - // this.submitted = true; - // if (this.tatListEditForm.invalid) { - // return; - // } else { - // } - // } + onSubmit() { + this.submitted = true; + if (this.tatListEditForm.invalid) { + return; + } else { + } + } onSubmitEditAddForm() {
Working Capital Facilities availed