business : ps
This commit is contained in:
parent
7447c9eb4c
commit
30b9b6fa32
@ -1217,93 +1217,18 @@ export class BusinessInfoComponent implements OnInit {
|
||||
/**
|
||||
* This Function For validate For Appx. sale based on Type OF Activities
|
||||
*/
|
||||
validateAppxSales(records){
|
||||
// validateAppxSales(records){
|
||||
|
||||
//console.log(records.manufacturing_activity_details.length);
|
||||
// //console.log(records.manufacturing_activity_details.length);
|
||||
|
||||
//this Variable For Validation
|
||||
let validationFlag : number = 0;
|
||||
// //this Variable For Validation
|
||||
|
||||
|
||||
//type 1: Checking manufacturing_activity_details
|
||||
if(records.manufacturing_activity_details.length > 0){
|
||||
|
||||
records.manufacturing_activity_details.forEach((val,index) => {
|
||||
|
||||
let ManufacturingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = ManufacturingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//type 3 checking wholesale_trading_activity_details
|
||||
if(records.wholesale_trading_activity_details.length > 0){
|
||||
|
||||
records.wholesale_trading_activity_details.forEach((val,index) => {
|
||||
|
||||
let WholesaleTradingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = WholesaleTradingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//type 2 checking retail_trading_activity_details
|
||||
if(records.retail_trading_activity_details.length > 0){
|
||||
|
||||
records.retail_trading_activity_details.forEach((val,index) => {
|
||||
|
||||
let RetailTradingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = RetailTradingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//type 4 checking service_provider_activity_details
|
||||
if(records.service_provider_activity_details.length > 0){
|
||||
|
||||
records.service_provider_activity_details.forEach((val,index) => {
|
||||
|
||||
let ServiceProviderArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = ServiceProviderArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//validationFlag is greater then 0 means its display the notifer as warning
|
||||
if(validationFlag > 0){
|
||||
this.notifier.notify('warning',"Approximate sales doesn't add upto 100%");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
submitDetails() {
|
||||
// let family: any = [];
|
||||
//console.log(this.businessForm.value);
|
||||
console.log(this.businessForm.value);
|
||||
|
||||
if (!this.businessForm.valid) {
|
||||
//console.log(' Requried validation error');
|
||||
@ -1313,7 +1238,7 @@ export class BusinessInfoComponent implements OnInit {
|
||||
let records = this.businessForm.value;
|
||||
|
||||
//to check the Appx. sale validation.
|
||||
this.validateAppxSales(records);
|
||||
// this.validateAppxSales(records);
|
||||
|
||||
if (records.other_documents == 'no') {
|
||||
delete records.documents;
|
||||
@ -1324,6 +1249,88 @@ export class BusinessInfoComponent implements OnInit {
|
||||
if (records.ownership_others == '') {
|
||||
delete records.ownership_others;
|
||||
}
|
||||
|
||||
|
||||
let validationFlag : number = 0;
|
||||
|
||||
//type 1: Checking manufacturing_activity_details
|
||||
if(records.manufacturing_activity_details.length > 0){
|
||||
|
||||
|
||||
records.manufacturing_activity_details.forEach((val,index) => {
|
||||
if(records.manufacturing_activity_details.area_of_sale != "Within India"){
|
||||
let ManufacturingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = ManufacturingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//type 3 checking wholesale_trading_activity_details
|
||||
if(records.wholesale_trading_activity_details.length > 0){
|
||||
|
||||
|
||||
records.wholesale_trading_activity_details.forEach((val,index) => {
|
||||
if(records.wholesale_trading_activity_details.area_of_sale != "Within India"){
|
||||
let WholesaleTradingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = WholesaleTradingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//type 2 checking retail_trading_activity_details
|
||||
if(records.retail_trading_activity_details.length > 0){
|
||||
|
||||
records.retail_trading_activity_details.forEach((val,index) => {
|
||||
if(records.retail_trading_activity_details.area_of_sale != "Within India"){
|
||||
let RetailTradingArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = RetailTradingArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//type 4 checking service_provider_activity_details
|
||||
if(records.service_provider_activity_details.length > 0){
|
||||
|
||||
records.service_provider_activity_details.forEach((val,index) => {
|
||||
if(records.service_provider_activity_details.area_of_sale != "Within India"){
|
||||
|
||||
let ServiceProviderArray = Object.keys(val.countries_where_export_done).map(function (key) {
|
||||
return val.countries_where_export_done[key];
|
||||
});
|
||||
let total = ServiceProviderArray.reduce((sum, item) => sum + +item.approx_sale, 0);
|
||||
if(total > 100 || total < 100){
|
||||
validationFlag++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//validationFlag is greater then 0 means its display the notifer as warning
|
||||
if(validationFlag > 0){
|
||||
this.notifier.notify('warning',"Approximate sales doesn't add upto 100%");
|
||||
return;
|
||||
}
|
||||
|
||||
records.select_business_activity_type = records.select_business_activity_type.filter(value=>value.exist_status==1);
|
||||
this._pd.saveForm(records).subscribe(data => {
|
||||
@ -1393,36 +1400,39 @@ export class BusinessInfoComponent implements OnInit {
|
||||
}
|
||||
|
||||
filterMaxSaleCities(datasource: any,filterValues:any) {
|
||||
// console.log(datasource);
|
||||
console.log('Whole State data',datasource); // Whole State data
|
||||
console.log('Filtered state id',filterValues); // Filtered state id
|
||||
if(filterValues){
|
||||
let getOriginalStateList = datasource.map(dval => dval.state_id);//only stateid have this
|
||||
|
||||
let getOriginalStateList = datasource.map(dval => dval.state_id);
|
||||
console.log('Whole State id from Datasources',getOriginalStateList)//Whole State id from Datasources
|
||||
|
||||
let setCityFilter = filterValues.map(x => {
|
||||
let findIndex = getOriginalStateList.indexOf(x);
|
||||
findIndex = datasource[findIndex].cities;
|
||||
return findIndex;
|
||||
});
|
||||
|
||||
//console.log(this.filterCityList);
|
||||
//let temp = this.filterCityList.filter(val =>val.city_name).map(mapVal => mapVal.city_name)
|
||||
//console.log('temp',temp);
|
||||
let getFilteredCityValues = [].concat.apply([],this.filterCityList.filter(val =>val.city_name).map(mapVal => mapVal.city_name));
|
||||
|
||||
// console.log('asd',getFilteredCityValues);
|
||||
// console.log(setCityFilter);
|
||||
|
||||
// let setStateFilter2: any=[];
|
||||
// setStateFilter2 = getFilteredCityValues.map(x => {
|
||||
// let findIndex = setCityFilter.indexOf(x);
|
||||
// return datasource[findIndex].cities;
|
||||
// });
|
||||
// console.log(setStateFilter2);
|
||||
// let setCityFilter2 = getFilteredCityValues.filter(
|
||||
// d => d == setCityFilter.city_id);
|
||||
// console.log(setCityFilter2);
|
||||
// console.log(this.filterCityList.city_name);
|
||||
// console.log('Filtered City Array Based on State Wise',setCityFilter)//Filtered City Array
|
||||
// console.log('Previous filtered City id List ',this.filterCityList);
|
||||
|
||||
let merged = [].concat.apply([], setCityFilter);
|
||||
let getFilteredCityValues = [].concat.apply([],this.filterCityList.filter(val =>val.city_name).map(mapVal => mapVal.city_name));
|
||||
let getOriginalCityList = merged.map(dval => dval.city_id);
|
||||
|
||||
let Filter: any=[];
|
||||
|
||||
Filter = getFilteredCityValues.map(x => {
|
||||
let findIndex = getOriginalCityList.indexOf(x);
|
||||
findIndex = merged[findIndex];
|
||||
console.log('findIndex',findIndex);
|
||||
//return findIndex.filter(x => x !== undefined);
|
||||
});
|
||||
|
||||
Filter = getFilteredCityValues.filter(x => x !== undefined);
|
||||
|
||||
return merged.length > 0 ? merged : [];
|
||||
//return Filter.length > 0 ? Filter : [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user