stock : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-01-30 00:38:12 +05:30
parent f47ec6b33b
commit 1213937b84
2 changed files with 124 additions and 212 deletions

View File

@ -20,11 +20,11 @@
<!-- <mat-card-header> <!-- <mat-card-header>
<mat-card-title class="highlight"> Manufacturing Details </mat-card-title> <mat-card-title class="highlight"> Manufacturing Details </mat-card-title>
</mat-card-header> --> </mat-card-header> -->
<h5 class="highlight" style="margin: 12px;">Manufacturing Details</h5>
<div formArrayName="manufacturing_details"> <div formArrayName="manufacturing_details">
<div *ngFor="let md of stockForms.controls.manufacturing_details['controls']; let i=index" [formGroupName]="i"> <div *ngFor="let md of stockForms.controls.manufacturing_details['controls']; let i=index" [formGroupName]="i">
<div formArrayName="manufacturing_raw_materials"> <div formArrayName="manufacturing_raw_materials">
<div *ngFor="let mrm of md.controls.manufacturing_raw_materials['controls']; let a=index; let last=last" [formGroupName]="a"> <div *ngFor="let mrm of md.controls.manufacturing_raw_materials['controls']; let a=index; let last=last" [formGroupName]="a">
<h5 class="highlight" style="margin: 12px;">Manufacturing Details</h5>
<mat-card style="margin: 12px;"> <mat-card style="margin: 12px;">
<mat-label class="highlight"> <i>Raw Material #{{a+1}} </i> </mat-label> <mat-label class="highlight"> <i>Raw Material #{{a+1}} </i> </mat-label>
<mat-card-content class="matcard"> <mat-card-content class="matcard">
@ -176,7 +176,7 @@
<!-- <mat-card-header> <!-- <mat-card-header>
<mat-card-title class="highlight"><p>Retail Details</p></mat-card-title> <mat-card-title class="highlight"><p>Retail Details</p></mat-card-title>
</mat-card-header> --> </mat-card-header> -->
<h5 class="highlight" style="margin: 12px;">Retail Trading Details</h5>
<div formArrayName="retail_details"> <div formArrayName="retail_details">
<div *ngFor="let rd of stockForms.controls.retail_details['controls']; let j=index" [formGroupName]="j"> <div *ngFor="let rd of stockForms.controls.retail_details['controls']; let j=index" [formGroupName]="j">
@ -185,6 +185,7 @@
<div formArrayName="retail_traded_goods"> <div formArrayName="retail_traded_goods">
<div *ngFor="let item of rd.controls.retail_traded_goods['controls']; let e=index;let last =last" [formGroupName]="e"> <div *ngFor="let item of rd.controls.retail_traded_goods['controls']; let e=index;let last =last" [formGroupName]="e">
<h5 class="highlight" style="margin: 12px;">Retail Trading Details</h5>
<mat-card style="margin: 12px;"> <mat-card style="margin: 12px;">
<mat-label class="highlight"> <i>Traded Goods #{{e+1}} </i> </mat-label> <mat-label class="highlight"> <i>Traded Goods #{{e+1}} </i> </mat-label>
<mat-card-content class="matcard"> <mat-card-content class="matcard">
@ -268,12 +269,13 @@
<!-- <mat-card-header> <!-- <mat-card-header>
<mat-card-title class="highlight"><p>Trading Details</p></mat-card-title> <mat-card-title class="highlight"><p>Trading Details</p></mat-card-title>
</mat-card-header> --> </mat-card-header> -->
<h5 class="highlight" style="margin: 12px;">Wholesale Trading Details</h5>
<div formArrayName="trade_details"> <div formArrayName="trade_details">
<div *ngFor="let td of stockForms.controls.trade_details['controls']; let k=index" [formGroupName]="k"> <div *ngFor="let td of stockForms.controls.trade_details['controls']; let k=index" [formGroupName]="k">
<div formArrayName="trading_traded_goods"> <div formArrayName="trading_traded_goods">
<div *ngFor="let tradetg of td.controls.trading_traded_goods['controls']; let g=index;let last = last" [formGroupName]="g"> <div *ngFor="let tradetg of td.controls.trading_traded_goods['controls']; let g=index;let last = last" [formGroupName]="g">
<h5 class="highlight" style="margin: 12px;">Wholesale Trading Details</h5>
<mat-card style="margin: 12px;"> <mat-card style="margin: 12px;">
<mat-label class="highlight"> <i>Traded Goods #{{g+1}} </i> </mat-label> <mat-label class="highlight"> <i>Traded Goods #{{g+1}} </i> </mat-label>
<mat-card-content class="matcard"> <mat-card-content class="matcard">

View File

@ -48,10 +48,10 @@ export class StockComponent implements OnInit {
// R_financialTradedGoodsValueInWords : any = []; // R_financialTradedGoodsValueInWords : any = [];
// T_financialTradedGoodsValueInWords : any = []; // T_financialTradedGoodsValueInWords : any = [];
rawMaterialAccess: boolean; rawMaterialAccess: Boolean = false;
finishedGoodsAccess: boolean; finishedGoodsAccess: Boolean = false;
tradeConcernAccess: boolean; tradeConcernAccess: Boolean = false;
serviceAccess: Boolean = false;
public submitted = false; public submitted = false;
noRecordsFound: Boolean = false; noRecordsFound: Boolean = false;
serviceProviderForm: Boolean = false; serviceProviderForm: Boolean = false;
@ -91,94 +91,23 @@ export class StockComponent implements OnInit {
}; };
ngOnInit() { 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 => { this._pd.stockFormAccess(this.pdid,this.company_id).subscribe(data => {
console.log(data);
console.log(data.record);
// return;
if(data.dataStatus == true){ if(data.dataStatus == true){
let tempcount = 0; this.initstockForms(data.record);
}
let datas = data.record; else if(data.dataStatus == false)
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)
{ {
console.log('3');
this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id );
this.noRecordsFound = false; this.noRecordsFound = false;
return; return;
} }
else{ else{
console.log('4');
this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id ); this.notifier.notify('warning', 'Fill Business Form First! / No Company Found at this ID '+ this.company_id );
this.noRecordsFound = false; this.noRecordsFound = false;
return; return;
} }
}, err => { }, err => {
console.log('5');
this.notifier.notify('warning', 'Business Type Of Activity Not Available Please Check Business Information.!'); this.notifier.notify('warning', 'Business Type Of Activity Not Available Please Check Business Information.!');
this.noRecordsFound = false; this.noRecordsFound = false;
}) })
@ -187,20 +116,12 @@ export class StockComponent implements OnInit {
} }
public initstockForms(record){ public initstockForms(record){
// console.log(record);
// {: 2, name: "Manufacturing", products: Array(2)} let api = Object.keys(record).map(function (key) {
// 1 return record[key];
// : });
// {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 params: any = {}; let params: any = {};
params.pd_id = this.pdid; params.pd_id = this.pdid;
params.pd_form_id = this.form_id; params.pd_form_id = this.form_id;
@ -214,40 +135,49 @@ export class StockComponent implements OnInit {
formid: [this.form_id], formid: [this.form_id],
company_id: [this.company_id], company_id: [this.company_id],
stock_remarks: [''], stock_remarks: [''],
manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), manufacturing_details: this.fb.array([this.manufacturingFormCreation(api)]),
retail_details : this.fb.array([this.retailFormCreation(record)]), retail_details : this.fb.array([this.retailFormCreation(api)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]), trade_details: this.fb.array([this.tradingFormCreation(api)]),
}); });
let arr = record.filter(data => data.type_of_activity_id == 2);
if(arr.length > 0) { if(api.length > 0){
let manufacturing_temparr = []; api.forEach(val => {
manufacturing_temparr['manufacturing_raw_materials'] = dataForm.manufacturing_details[0].manufacturing_raw_materials; if (val.type_of_activity_id == 2) {
manufacturing_temparr['manufacturing_finished_goods'] = dataForm.manufacturing_details[0].manufacturing_finished_goods; if(val.products){
this.initManufacturingDetails(manufacturing_temparr); 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;
let arr1 = record.filter(data => data.type_of_activity_id == 3); this.initManufacturingDetails(manufacturing_temparr);
if(arr1.length > 0) { }
let retail_temparr = []; }
retail_temparr['retail_traded_goods'] = dataForm.retail_details[0].retail_traded_goods; if (val.type_of_activity_id == 3) {
this.initRetailDetails(retail_temparr); if(val.products){
} let retail_temparr = [];
retail_temparr['retail_traded_goods'] = dataForm.retail_details[0].retail_traded_goods;
let arr2 = record.filter(data => data.type_of_activity_id == 4); this.initRetailDetails(retail_temparr);
if(arr2.length > 0) { }
}
if (val.type_of_activity_id == 4) {
if(val.products){
let trading_temparr = []; let trading_temparr = [];
trading_temparr['trading_traded_goods'] = dataForm.trade_details[0].trading_traded_goods; trading_temparr['trading_traded_goods'] = dataForm.trade_details[0].trading_traded_goods;
this.initTradingDetails(trading_temparr); 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{ else{
// console.log('dataForm',dataForm);
this.stockForms = this.fb.group({ this.stockForms = this.fb.group({
pdid: [this.pdid], pdid: [this.pdid],
formid: [this.form_id], formid: [this.form_id],
@ -257,34 +187,38 @@ export class StockComponent implements OnInit {
retail_details : this.fb.array([this.retailFormCreation(record)]), retail_details : this.fb.array([this.retailFormCreation(record)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]), trade_details: this.fb.array([this.tradingFormCreation(record)]),
}); });
let arr = record.filter(data => data.type_of_activity_id == 2);
if(arr.length > 0) { if(api.length > 0){
this.initManufacturingDetails(null); 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 (val.type_of_activity_id == 3) {
if(arr1.length > 0) { if(val.products){
this.initRetailDetails(null); this.suppliers_finished_goods = val.products;
this.initRetailDetails(null);
}
} }
let arr2 = record.filter(data => data.type_of_activity_id == 4); if (val.type_of_activity_id == 4) {
if(arr2.length > 0) { if(val.products){
this.suppliers_trade_details = val.products;
this.initTradingDetails(null); 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 (val.type_of_activity_id == 5) {
if(arr3.length > 0) { if(val.products){
this.serviceProviderForm = true; this.suppliers_service_product = val.products;
} this.serviceProviderForm = true;
this.noRecordsFound = true; }
}
});
this.noRecordsFound = true;
}
} }
} }
else { else {
@ -297,59 +231,40 @@ export class StockComponent implements OnInit {
retail_details : this.fb.array([this.retailFormCreation(record)]), retail_details : this.fb.array([this.retailFormCreation(record)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]), trade_details: this.fb.array([this.tradingFormCreation(record)]),
}); });
let arr = record.filter(data => data.type_of_activity_id == 2); if(api.length > 0){
if(arr.length > 0) { api.forEach(val => {
// this._pd.retriveForm({pd_id:this.pdid,pd_form_id:1}).subscribe(value => { if (val.type_of_activity_id == 2) {
// if(value.status == 200){ if(val.products){
// this.suppliers_raw_materials = value.records.manufacturing_details[0].main_raw_materials; this.suppliers_raw_materials = val.products;
// this.initManufacturingDetails(null); this.initManufacturingDetails(null);
// } }
// else{ }
this.initManufacturingDetails(null); if (val.type_of_activity_id == 3) {
// } if(val.products){
// }); this.suppliers_finished_goods = val.products;
} this.initRetailDetails(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 (val.type_of_activity_id == 4) {
// if(value.status == 200){ if(val.products){
// this.suppliers_finished_goods = value.records.trade_details[0].trading_products; this.suppliers_trade_details = val.products;
// // value.records.manufacturing_details[0].main_raw_materials; this.initTradingDetails(null);
// this.initRetailDetails(null); }
// } }
// else{ if (val.type_of_activity_id == 5) {
this.initRetailDetails(null); if(val.products){
// } this.suppliers_service_product = val.products;
// }); this.serviceProviderForm = true;
}
}
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.noRecordsFound = true;
// this.suppliers_trade_details = value.records.trade_details[0].trading_products; }
this.noRecordsFound = true;
// }
// 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;
} }
}) })
// 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; manufacturingForm: Boolean = false;
@ -361,7 +276,6 @@ export class StockComponent implements OnInit {
manufacturing_raw_materials: this.fb.array([]), manufacturing_raw_materials: this.fb.array([]),
manufacturing_finished_goods: this.fb.array([]), manufacturing_finished_goods: this.fb.array([]),
}) })
// }
} else { } else {
return; return;
} }
@ -407,8 +321,8 @@ tradingFormCreation(val) {
const finishedGoods = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods']; const finishedGoods = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['main_raw_materials'];
if(datas === null){ if(datas === null){
// console.log('sdzsgfasdfasddfasdf');
console.log(this.suppliers_raw_materials);
if(this.suppliers_raw_materials.length > 0){ if(this.suppliers_raw_materials.length > 0){
this.suppliers_raw_materials.forEach(val => { this.suppliers_raw_materials.forEach(val => {
let Ref_RawMaterials : any = {'raw_name': val, let Ref_RawMaterials : any = {'raw_name': val,
@ -445,13 +359,10 @@ tradingFormCreation(val) {
} }
} else { } else {
// console.log(305,'else')
// console.log(377,datas);
// console.log(datas.manufacturing_raw_materials);
if(datas.manufacturing_raw_materials != undefined){ if(datas.manufacturing_raw_materials != undefined){
for (let val of datas.manufacturing_raw_materials) { for (let val of datas.manufacturing_raw_materials) {
// console.log(val);
if(val.raw_value){ if(val.raw_value){
this.M_rawValueInWords = this._pd.convertNumberToWords(val.raw_value); this.M_rawValueInWords = this._pd.convertNumberToWords(val.raw_value);
// this.M_financialRawValueInWords = this._pd.convertNumberToWords(val.rawmaterial_value); // this.M_financialRawValueInWords = this._pd.convertNumberToWords(val.rawmaterial_value);
@ -464,7 +375,6 @@ tradingFormCreation(val) {
} }
if(datas.manufacturing_finished_goods != undefined){ if(datas.manufacturing_finished_goods != undefined){
for (let val of datas.manufacturing_finished_goods) { for (let val of datas.manufacturing_finished_goods) {
// console.log(val);
if(val.goods_value){ if(val.goods_value){
this.M_goodsValueInWords = this._pd.convertNumberToWords(val.goods_value); this.M_goodsValueInWords = this._pd.convertNumberToWords(val.goods_value);
// this.M_financialGoodsValueInWords = this._pd.convertNumberToWords(val.finished_goods_value); // this.M_financialGoodsValueInWords = this._pd.convertNumberToWords(val.finished_goods_value);
@ -480,9 +390,9 @@ tradingFormCreation(val) {
} }
createRawmaterial(records) { createRawmaterial(records) {
// console.log(330,'function in');
if(records === null) { if(records === null) {
// console.log(331,'fif');
return this.fb.group({ return this.fb.group({
raw_name: [''], raw_name: [''],
stock_observed:[''], stock_observed:[''],
@ -495,7 +405,7 @@ tradingFormCreation(val) {
rawmaterial_remarks:[''] rawmaterial_remarks:['']
}) })
} else { } else {
// console.log(343,'else');
return this.fb.group({ return this.fb.group({
manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null], manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null],
raw_name: [records.raw_name], raw_name: [records.raw_name],
@ -518,7 +428,8 @@ tradingFormCreation(val) {
if(datas === null){ if(datas === null){
if(this.suppliers_trade_details.length > 0){ if(this.suppliers_trade_details.length > 0){
console.log(this.suppliers_trade_details); this.rawMaterialAccess = true;
this.suppliers_trade_details.forEach(val => { this.suppliers_trade_details.forEach(val => {
let Ref_Trade_Goods : any = { let Ref_Trade_Goods : any = {
'traded_goods_name': val, 'traded_goods_name': val,
@ -539,7 +450,7 @@ tradingFormCreation(val) {
} else { } else {
if(datas.retail_traded_goods !== undefined){ if(datas.retail_traded_goods !== undefined){
for (let val of datas.retail_traded_goods) { for (let val of datas.retail_traded_goods) {
// console.log(val);
if(val.estimated_traded_goods_value){ if(val.estimated_traded_goods_value){
this.R_tradedGoodsValueInWords = this._pd.convertNumberToWords(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); // this.R_financialTradedGoodsValueInWords =this._pd.convertNumberToWords(val.traded_goods_value);
@ -797,8 +708,7 @@ tradingFormCreation(val) {
// return; // return;
// } else { // } else {
var answerFormValues = this.stockForms.value; var answerFormValues = this.stockForms.value;
console.log(answerFormValues);
// return;
//To Remove The "Null" With Key also //To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);