From 1213937b848898185fe09d3611acde0ba0e45b0f Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Wed, 30 Jan 2019 00:38:12 +0530 Subject: [PATCH] stock : ps --- .../start-pd/forms/stock/stock.component.html | 8 +- .../start-pd/forms/stock/stock.component.ts | 328 +++++++----------- 2 files changed, 124 insertions(+), 212 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html index 1632acb68..c54333f22 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html @@ -20,11 +20,11 @@ -
Manufacturing Details
+
Manufacturing Details
Raw Material #{{a+1}} @@ -176,7 +176,7 @@ -
Retail Trading Details
+
@@ -185,6 +185,7 @@
+
Retail Trading Details
Traded Goods #{{e+1}} @@ -268,12 +269,13 @@ -
Wholesale Trading Details
+
+
Wholesale Trading Details
Traded Goods #{{g+1}} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts index faaf2e270..f2f7e3030 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts @@ -48,10 +48,10 @@ export class StockComponent implements OnInit { // R_financialTradedGoodsValueInWords : any = []; // T_financialTradedGoodsValueInWords : any = []; - rawMaterialAccess: boolean; - finishedGoodsAccess: boolean; - tradeConcernAccess: boolean; - + rawMaterialAccess: Boolean = false; + finishedGoodsAccess: Boolean = false; + tradeConcernAccess: Boolean = false; + serviceAccess: Boolean = false; public submitted = false; noRecordsFound: Boolean = false; serviceProviderForm: Boolean = false; @@ -91,94 +91,23 @@ export class StockComponent implements OnInit { }; ngOnInit() { - - // this._pd.stockFormsAccess({pd_id:this.pdid}).subscribe(data => { - // if(data.status == 200){ - // this.initstockForms(data.record.type_of_activity); - // } - // }, err => { - // this.notifier.notify('warning', 'There is No Type Of Activity Please Check Bussiness Information.!'); - // }) - // "Manufacturing" - // products - // : - // (2) ["Rwas1", "123"] - // type_of_activity_id - // : - // 2 - //this._pd.getTypeofActivityForSuppliedInfoForm(this.pdid).subscribe( - // console.log(this.pdid); - // console.log(this.company_id); - + this._pd.stockFormAccess(this.pdid,this.company_id).subscribe(data => { - console.log(data); - console.log(data.record); - // return; if(data.dataStatus == true){ - let tempcount = 0; - - let datas = data.record; - let api = Object.keys(datas).map(function (key) { - return datas[key]; - }); - console.log(api); - if(api.length > 0){ - api.forEach(val => { - if (val.type_of_activity_id == 2) { - if(val.products){ - this.suppliers_raw_materials = val.products; - } - } - if (val.type_of_activity_id == 3) { - if(val.products){ - this.suppliers_finished_goods = val.products; - } - } - if (val.type_of_activity_id == 4) { - if(val.products){ - this.suppliers_trade_details = val.products; - } - } - if (val.type_of_activity_id == 5) { - if(val.products){ - this.suppliers_service_product = val.products; - } - console.log(this.suppliers_service_product); - } - tempcount++; - }); - // console.log('tempcount',tempcount); - if(tempcount>0){ - this.initstockForms(datas); - } - else{ - console.log('1'); - this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); - this.noRecordsFound = false; - } - - - } - else{ - console.log('2'); - this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); - this.noRecordsFound = false; - } - }else if(data.dataStatus == false) + this.initstockForms(data.record); + } + else if(data.dataStatus == false) { - console.log('3'); this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); this.noRecordsFound = false; return; } else{ - console.log('4'); this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); this.noRecordsFound = false; return; } }, err => { - console.log('5'); this.notifier.notify('warning', 'Business Type Of Activity Not Available Please Check Business Information.!'); this.noRecordsFound = false; }) @@ -187,20 +116,12 @@ export class StockComponent implements OnInit { } public initstockForms(record){ - // console.log(record); -// {: 2, name: "Manufacturing", products: Array(2)} -// 1 -// : -// {type_of_activity_id: 3, name: "Retail trading", products: Array(1)} -// 2 -// : -// {type_of_activity_id: 4, name: "Wholesale Trade", products: Array(1)} -// 3 -// : -// {type_of_activity_id: 5, name: "Service Provider", products: Array(1)} - - - + + let api = Object.keys(record).map(function (key) { + return record[key]; + }); + + let params: any = {}; params.pd_id = this.pdid; params.pd_form_id = this.form_id; @@ -214,40 +135,49 @@ export class StockComponent implements OnInit { formid: [this.form_id], company_id: [this.company_id], stock_remarks: [''], - manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), - retail_details : this.fb.array([this.retailFormCreation(record)]), - trade_details: this.fb.array([this.tradingFormCreation(record)]), + manufacturing_details: this.fb.array([this.manufacturingFormCreation(api)]), + retail_details : this.fb.array([this.retailFormCreation(api)]), + trade_details: this.fb.array([this.tradingFormCreation(api)]), }); - let arr = record.filter(data => data.type_of_activity_id == 2); - if(arr.length > 0) { - let manufacturing_temparr = []; - manufacturing_temparr['manufacturing_raw_materials'] = dataForm.manufacturing_details[0].manufacturing_raw_materials; - manufacturing_temparr['manufacturing_finished_goods'] = dataForm.manufacturing_details[0].manufacturing_finished_goods; - this.initManufacturingDetails(manufacturing_temparr); - } - - let arr1 = record.filter(data => data.type_of_activity_id == 3); - if(arr1.length > 0) { - let retail_temparr = []; - retail_temparr['retail_traded_goods'] = dataForm.retail_details[0].retail_traded_goods; - this.initRetailDetails(retail_temparr); - } - - let arr2 = record.filter(data => data.type_of_activity_id == 4); - if(arr2.length > 0) { + + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + let manufacturing_temparr = []; + manufacturing_temparr['manufacturing_raw_materials'] = dataForm.manufacturing_details[0].manufacturing_raw_materials; + manufacturing_temparr['manufacturing_finished_goods'] = dataForm.manufacturing_details[0].manufacturing_finished_goods; + this.initManufacturingDetails(manufacturing_temparr); + } + } + if (val.type_of_activity_id == 3) { + if(val.products){ + let retail_temparr = []; + retail_temparr['retail_traded_goods'] = dataForm.retail_details[0].retail_traded_goods; + this.initRetailDetails(retail_temparr); + } + } + if (val.type_of_activity_id == 4) { + if(val.products){ let trading_temparr = []; trading_temparr['trading_traded_goods'] = dataForm.trade_details[0].trading_traded_goods; this.initTradingDetails(trading_temparr); + } + } + if (val.type_of_activity_id == 5) { + if(val.products){ + this.serviceProviderForm = true; + } + + } + + }); + this.noRecordsFound = true; } - let arr3 = record.filter(data => data.type_of_activity_id == 5); - if(arr3.length > 0) { - this.serviceProviderForm = true; - } - this.noRecordsFound = true; } else{ - // console.log('dataForm',dataForm); + this.stockForms = this.fb.group({ pdid: [this.pdid], formid: [this.form_id], @@ -257,34 +187,38 @@ export class StockComponent implements OnInit { retail_details : this.fb.array([this.retailFormCreation(record)]), trade_details: this.fb.array([this.tradingFormCreation(record)]), }); - let arr = record.filter(data => data.type_of_activity_id == 2); - if(arr.length > 0) { - this.initManufacturingDetails(null); + + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + this.suppliers_raw_materials = val.products; + this.initManufacturingDetails(null); + } } - let arr1 = record.filter(data => data.type_of_activity_id == 3); - if(arr1.length > 0) { - this.initRetailDetails(null); + if (val.type_of_activity_id == 3) { + if(val.products){ + this.suppliers_finished_goods = val.products; + this.initRetailDetails(null); + } } - let arr2 = record.filter(data => data.type_of_activity_id == 4); - if(arr2.length > 0) { + if (val.type_of_activity_id == 4) { + if(val.products){ + this.suppliers_trade_details = val.products; this.initTradingDetails(null); - // this._pd.retriveForm({pd_id:this.pdid,pd_form_id:1}).subscribe(value => { - // if(value.status == 200){ - // // this.suppliers_raw_materials = value.records.manufacturing_details[0].main_raw_materials; - // // this.suppliers_finished_goods - // this.suppliers_trade_details = value.records.trade_details[0].trading_products; - // this.initTradingDetails(null); - // } - // else{ - // this.initTradingDetails(null); - // } - // }); + } } - let arr3 = record.filter(data => data.type_of_activity_id == 5); - if(arr3.length > 0) { - this.serviceProviderForm = true; - } - this.noRecordsFound = true; + if (val.type_of_activity_id == 5) { + if(val.products){ + this.suppliers_service_product = val.products; + this.serviceProviderForm = true; + } + + } + + }); + this.noRecordsFound = true; + } } } else { @@ -297,59 +231,40 @@ export class StockComponent implements OnInit { retail_details : this.fb.array([this.retailFormCreation(record)]), trade_details: this.fb.array([this.tradingFormCreation(record)]), }); - let arr = record.filter(data => data.type_of_activity_id == 2); - if(arr.length > 0) { - // this._pd.retriveForm({pd_id:this.pdid,pd_form_id:1}).subscribe(value => { - // if(value.status == 200){ - // this.suppliers_raw_materials = value.records.manufacturing_details[0].main_raw_materials; - // this.initManufacturingDetails(null); - // } - // else{ - this.initManufacturingDetails(null); - // } - // }); - } - let arr1 = record.filter(data => data.type_of_activity_id == 3); - if(arr1.length > 0) { - // this._pd.retriveForm({pd_id:this.pdid,pd_form_id:1}).subscribe(value => { - // if(value.status == 200){ - // this.suppliers_finished_goods = value.records.trade_details[0].trading_products; - // // value.records.manufacturing_details[0].main_raw_materials; - // this.initRetailDetails(null); - // } - // else{ - this.initRetailDetails(null); - // } - // }); - - } - let arr2 = record.filter(data => data.type_of_activity_id == 4); - if(arr2.length > 0) { - // this._pd.retriveForm({pd_id:this.pdid,pd_form_id:1}).subscribe(value => { - // if(value.status == 200){ - // this.suppliers_trade_details = value.records.trade_details[0].trading_products; - - // } - // else{ - this.initTradingDetails(null); - // } - - // this.initTradingDetails(null); - } - let arr3 = record.filter(data => data.type_of_activity_id == 5); - if(arr3.length > 0) { - this.serviceProviderForm = true; - } - this.noRecordsFound = true; + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + this.suppliers_raw_materials = val.products; + this.initManufacturingDetails(null); + } + } + if (val.type_of_activity_id == 3) { + if(val.products){ + this.suppliers_finished_goods = val.products; + this.initRetailDetails(null); + } + } + if (val.type_of_activity_id == 4) { + if(val.products){ + this.suppliers_trade_details = val.products; + this.initTradingDetails(null); + } + } + if (val.type_of_activity_id == 5) { + if(val.products){ + this.suppliers_service_product = val.products; + this.serviceProviderForm = true; + } + + } + + }); + this.noRecordsFound = true; + } + this.noRecordsFound = true; } }) - - // this.stockForms = this.fb.group({ - // stock_remarks: [''], - // raw_materials: this.fb.array([]), - // finished_goods: this.fb.array([]), - // traded_goods: this.fb.array([]) - // }); } manufacturingForm: Boolean = false; @@ -361,7 +276,6 @@ export class StockComponent implements OnInit { manufacturing_raw_materials: this.fb.array([]), manufacturing_finished_goods: this.fb.array([]), }) - // } } else { return; } @@ -407,8 +321,8 @@ tradingFormCreation(val) { const finishedGoods = this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods']; const control = this.stockForms.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; if(datas === null){ - // console.log('sdzsgfasdfasddfasdf'); - console.log(this.suppliers_raw_materials); + + if(this.suppliers_raw_materials.length > 0){ this.suppliers_raw_materials.forEach(val => { let Ref_RawMaterials : any = {'raw_name': val, @@ -445,13 +359,10 @@ tradingFormCreation(val) { } } else { - // console.log(305,'else') - // console.log(377,datas); - // console.log(datas.manufacturing_raw_materials); + if(datas.manufacturing_raw_materials != undefined){ for (let val of datas.manufacturing_raw_materials) { - // console.log(val); if(val.raw_value){ this.M_rawValueInWords = this._pd.convertNumberToWords(val.raw_value); // this.M_financialRawValueInWords = this._pd.convertNumberToWords(val.rawmaterial_value); @@ -464,7 +375,6 @@ tradingFormCreation(val) { } if(datas.manufacturing_finished_goods != undefined){ for (let val of datas.manufacturing_finished_goods) { - // console.log(val); if(val.goods_value){ this.M_goodsValueInWords = this._pd.convertNumberToWords(val.goods_value); // this.M_financialGoodsValueInWords = this._pd.convertNumberToWords(val.finished_goods_value); @@ -480,9 +390,9 @@ tradingFormCreation(val) { } createRawmaterial(records) { - // console.log(330,'function in'); + if(records === null) { - // console.log(331,'fif'); + return this.fb.group({ raw_name: [''], stock_observed:[''], @@ -495,7 +405,7 @@ tradingFormCreation(val) { rawmaterial_remarks:[''] }) } else { - // console.log(343,'else'); + return this.fb.group({ manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null], raw_name: [records.raw_name], @@ -518,7 +428,8 @@ tradingFormCreation(val) { if(datas === null){ if(this.suppliers_trade_details.length > 0){ - console.log(this.suppliers_trade_details); + this.rawMaterialAccess = true; + this.suppliers_trade_details.forEach(val => { let Ref_Trade_Goods : any = { 'traded_goods_name': val, @@ -539,7 +450,7 @@ tradingFormCreation(val) { } else { if(datas.retail_traded_goods !== undefined){ for (let val of datas.retail_traded_goods) { - // console.log(val); + if(val.estimated_traded_goods_value){ this.R_tradedGoodsValueInWords = this._pd.convertNumberToWords(val.estimated_traded_goods_value); // this.R_financialTradedGoodsValueInWords =this._pd.convertNumberToWords(val.traded_goods_value); @@ -797,8 +708,7 @@ tradingFormCreation(val) { // return; // } else { var answerFormValues = this.stockForms.value; -console.log(answerFormValues); -// return; + //To Remove The "Null" With Key also Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);