diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html index fac93f6bc..cf582b8f4 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html @@ -58,11 +58,18 @@
- +
+
+ + + requried + +
+
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts index fd6681916..8fc2f03dd 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts @@ -224,6 +224,7 @@ export class AddressComponent implements OnInit { address_type_others: [''], locality: ['', Validators.compose([Validators.required])], locality_others: [''], + locality_mixuse:[''], pd_location: ['', Validators.compose([Validators.required])], comment_locality: ['', Validators.compose([Validators.required])], other_comment_locality : [''], @@ -368,6 +369,19 @@ export class AddressComponent implements OnInit { onSubmit() { + if (this.addressForm.controls.address_type.value == 1) { + this.addressForm.controls['address_type_others'].setValidators([Validators.required]); + this.addressForm.controls['address_type_others'].updateValueAndValidity(); + } + if (this.addressForm.controls.locality.value == 1) { + this.addressForm.controls['locality_others'].setValidators([Validators.required]); + this.addressForm.controls['locality_others'].updateValueAndValidity(); + } + if (this.addressForm.controls.locality.value == 5) { + this.addressForm.controls['locality_mixuse'].setValidators([Validators.required]); + this.addressForm.controls['locality_mixuse'].updateValueAndValidity(); + } + if (!this.addressForm.valid) { this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; @@ -389,6 +403,9 @@ export class AddressComponent implements OnInit { if (this.locality.value == 1) { records.locality_others = this.addressForm.controls.locality_others.value; } + if(this.locality.value == 5){ + records.locality_mixuse = this.addressForm.controls.locality_mixuse.value; + } records.pd_location = this.pdLocation.value; records.comment_locality = this.commentlocality.value; records.other_comment_locality = this.other_comment_locality.value; @@ -446,6 +463,8 @@ export class AddressComponent implements OnInit { }); } + + ConvertMonthintoYear(e){ let business_year = this.addressForm.controls.business_years.value; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html index bfd8fd714..3ec76ed1b 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html @@ -176,7 +176,8 @@
- + +
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html index 6088e72cc..28a3a929b 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html @@ -53,7 +53,7 @@ - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts index a6951b0ba..71efc9288 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts @@ -15,30 +15,22 @@ export class OtherApplicantDetailsComponent implements OnInit { applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','is_applicant':false,'is_person_met':false, applicant_title_name:'',age:'', qualification:'',course_name:''}; titleList: any=[]; qualificationList: any=[]; - EditGeneralFormData: any=[]; - EditFlag: boolean = false; + //EditGeneralFormData: any=[]; + //EditFlag: boolean = false; constructor(private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public generalFormData : any, private dialogRef: MatDialogRef) { - if(generalFormData != ''){ - this.EditGeneralFormData = generalFormData.value; - this.EditFlag = true; - } - console.log(this.EditGeneralFormData); + // if(generalFormData != ''){ + // this.EditGeneralFormData = generalFormData.value; + // this.EditFlag = true; + // } + // console.log(this.EditGeneralFormData); } - ngOnInit() { - - if(!this.EditFlag){ - console.log('init if',this.EditGeneralFormData); - this.initFormDetails(null); - } - else{ - console.log('init else',this.EditGeneralFormData); - this.initFormDetails(this.EditGeneralFormData); - } + ngOnInit() { + this.initFormDetails(null); this.getMasterDetails('TITLES',1); this.getMasterDetails('EDUQUALIFICATION',2); } @@ -60,24 +52,15 @@ export class OtherApplicantDetailsComponent implements OnInit { // init form initFormDetails(data : any) { - console.log('data',data); if(data == null){ - console.log('if data',data); this._OtherForm = this._fb.group({ applicant_list: this._fb.array([this.createApplicant(this.applicantInfo)]), }); } - else{ - console.log('else data',data); - this._OtherForm = this._fb.group({ - applicant_list: this._fb.array([this.updateApplicant(this.EditGeneralFormData)]), - }); - } } // create applicant form array createApplicant(elementValue:any){ - console.log("create applicants",elementValue); return this._fb.group({ pd_co_applicant_id: [elementValue.pd_co_applicant_id], applicant_title_name: [elementValue.applicant_title_name, Validators.required], @@ -90,20 +73,6 @@ createApplicant(elementValue:any){ }); } -updateApplicant(elementValue:any){ - console.log("update applicants",elementValue); - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_title_name: [elementValue.applicant_title_name, Validators.required], - applicant_name:[elementValue.applicant_name,Validators.required], - is_applicant:[elementValue.is_applicant ? true : false], - is_person_met:[elementValue.is_person_met ? true : false], - age:[elementValue.age || ''], - qualification: [elementValue.qualification || ''], - course_name:[elementValue.course_name || ''] -}); -} - // add more addMoreApplicant(){ if (this._OtherForm.invalid) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html index 51370aed4..4bc1c1c34 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html @@ -361,7 +361,7 @@
-
Address Details of {{FamilyMemberAsLabel[ix]}}
+
Family Details of {{FamilyMemberAsLabel[ix]}}
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 897029a2f..8497c5c64 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 @@ -241,10 +241,10 @@ -->
- + - + @@ -272,10 +272,10 @@
- + - + 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 8eebd8b22..3aca4522f 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 @@ -205,9 +205,6 @@ export class FinancialInfoComponent implements OnInit { // } - - - /** CREATING financial Statement ( financial_year AutoGenerate ) */ createDate(date) { return this.fb.group({ @@ -418,7 +415,7 @@ export class FinancialInfoComponent implements OnInit { let array = this.financialForm.controls['date_per_financial']; let prev_annual_sale = array.value[index-1].financial_annual_sale; let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ; - detail.controls.financial_annualsales_variation.setValue(annual_sale_variation.toFixed(2)); + detail.controls.financial_annualsales_variation.setValue(annual_sale_variation!= Infinity ? annual_sale_variation.toFixed(2):0); } } @@ -429,7 +426,7 @@ export class FinancialInfoComponent implements OnInit { let array = this.financialForm.controls['estimated_value']; let prev_annual_sale = array.value[index-1].estimate_annual_sale; let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ; - detail.controls.estimate_annualsales_variation.setValue(annual_sale_variation.toFixed(2)); + detail.controls.estimate_annualsales_variation.setValue(annual_sale_variation!= Infinity ? annual_sale_variation.toFixed(2):0); } } @@ -464,7 +461,7 @@ export class FinancialInfoComponent implements OnInit { let variation = (((profit != '' ? profit : loss ) - (prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100; - detail.controls.financial_variation.setValue(variation.toFixed(2)); + detail.controls.financial_variation.setValue(variation!= Infinity ? variation.toFixed(2):0); } } } @@ -508,7 +505,7 @@ export class FinancialInfoComponent implements OnInit { } else{ profit_margin = (profit / salary) * 100; - detail.controls.financial_margin_of_profit.setValue(profit_margin.toFixed(2)); + detail.controls.financial_margin_of_profit.setValue(profit_margin!= Infinity ? profit_margin.toFixed(2):0); } } @@ -528,7 +525,7 @@ export class FinancialInfoComponent implements OnInit { } else{ loss_margin = (loss / salary) * 100 * (-1); - detail.controls.financial_margin_of_loss.setValue(loss_margin.toFixed(2)); + detail.controls.financial_margin_of_loss.setValue(loss_margin != Infinity ? loss_margin.toFixed(2): 0); // detail.controls.financial_margin.disable() } } @@ -582,7 +579,7 @@ export class FinancialInfoComponent implements OnInit { let variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100; - detail.controls.estimate_variation.setValue(variation.toFixed(2)); + detail.controls.estimate_variation.setValue(variation!= Infinity ? variation.toFixed(2) : 0); } } @@ -598,7 +595,7 @@ export class FinancialInfoComponent implements OnInit { if (salary != '' && profit != '') { let margin = profit / salary * 100; - detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2)); + detail.controls.estimate_margin_of_profit.setValue(margin!= Infinity ? margin.toFixed(2):0); } } else if (detail.value.estimate_profit_or_loss == 2){ @@ -606,7 +603,7 @@ export class FinancialInfoComponent implements OnInit { let loss = detail.value.estimate_net_loss; if (salary != '' && loss != '') { let margin = (loss / salary) * 100 * (-1); - detail.controls.estimate_margin_of_loss.setValue(margin.toFixed(2)); + detail.controls.estimate_margin_of_loss.setValue(margin!= Infinity ? margin.toFixed(2):0); } } @@ -619,7 +616,7 @@ export class FinancialInfoComponent implements OnInit { let margin_profit = detail.value.estimate_margin_of_profit; if (salary != '' && margin_profit != '') { let profit = (margin_profit/100)*salary; - detail.controls.estimate_net_profit.setValue(profit.toFixed(2)); + detail.controls.estimate_net_profit.setValue(profit!= Infinity ? profit.toFixed(2):0); this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(profit); } @@ -628,7 +625,7 @@ export class FinancialInfoComponent implements OnInit { let margin_loss = detail.value.estimate_margin_of_loss; if (salary != '' && margin_loss != '') { let loss = (margin_loss/100)*salary*(-1); - detail.controls.estimate_net_loss.setValue(loss.toFixed(2)); + detail.controls.estimate_net_loss.setValue(loss!= Infinity ? loss.toFixed(2):0); this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(loss); } } @@ -640,6 +637,13 @@ export class FinancialInfoComponent implements OnInit { let estimate_sales_to = +details.value.estimate_sales_to; if (estimate_sales_from != null && estimate_sales_to != null){ + + if(+estimate_sales_from>+estimate_sales_to){ + alert("Given To value is lower than From Value"); + details.controls.estimate_sales_to.setValue(''); + details.controls.estimate_sales_average.setValue(''); + return; + } let C = (estimate_sales_to - estimate_sales_from) let D = (C / estimate_sales_from) * 100; @@ -648,46 +652,46 @@ export class FinancialInfoComponent implements OnInit { if(D >= 20){ var r = confirm("Given Sales Range is greater than 20%"); if (r == true) { - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); }else{ details.controls.estimate_sales_to.setValue(''); return; } } else{ - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); } } else if(estimate_sales_from > 5000000 || estimate_sales_from <= 10000000){ if(D >= 15){ var r = confirm("Given Sales Range is greater than 15%"); if (r == true) { - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); }else{ details.controls.estimate_sales_to.setValue(''); return; } } else{ - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); } } else if(estimate_sales_from > 10000000){ if(D >= 10){ var r = confirm("Given Sales Range is greater than 10%"); if (r == true) { - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); }else{ details.controls.estimate_sales_to.setValue(''); return; } } else{ - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); } } else{ - details.controls.estimate_sales_to.setValue(estimate_sales_to); + details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0); } // if(D >= 30){ @@ -719,11 +723,11 @@ export class FinancialInfoComponent implements OnInit { let higer = ((+estimate_sales_to + +estimate_sales_from) / 2); if(lower > higer){ - details.controls.estimate_sales_average.setValue(higer.toFixed(2)); + details.controls.estimate_sales_average.setValue(higer!= Infinity ? higer.toFixed(2):0); this.AV_SalesInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); } else{ - details.controls.estimate_sales_average.setValue(lower.toFixed(2)); + details.controls.estimate_sales_average.setValue(lower!= Infinity ? lower.toFixed(2):0); this.AV_SalesInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); } @@ -737,19 +741,55 @@ export class FinancialInfoComponent implements OnInit { calculateMarginProfit( i, details){ let sales_average = details.value.estimate_sales_average; + if(sales_average == ''){ + alert("Considered Sales Average is Empty"); + details.controls.estimate_profit_range_from.setValue(''); + details.controls.estimate_profit_range_to.setValue(''); + details.controls.estimate_profit_margin.setValue(''); + details.controls.estimate_profit_margin_percent.setValue(''); + return; + } let estimate_profit_range_from = details.value.estimate_profit_range_from; + if(+estimate_profit_range_from > 100){ + alert('Given Profit percent is More Than 100'); + details.controls.estimate_profit_range_from.setValue(''); + details.controls.estimate_profit_range_to.setValue(''); + details.controls.estimate_profit_margin.setValue(''); + details.controls.estimate_profit_margin_percent.setValue(''); + return; + + } + let estimate_profit_range_to = details.value.estimate_profit_range_to; + + if(+estimate_profit_range_to > 100){ + alert('Given Profit percent is More Than 100'); + details.controls.estimate_profit_range_to.setValue(''); + details.controls.estimate_profit_margin.setValue(''); + details.controls.estimate_profit_margin_percent.setValue(''); + return; + + } if (sales_average != '' && estimate_profit_range_from != '' && estimate_profit_range_to != ''){ + if(+estimate_profit_range_from>+estimate_profit_range_to){ + alert("Given To value is lower than From Value"); + details.controls.estimate_profit_range_to.setValue(''); + details.controls.estimate_profit_margin.setValue(''); + details.controls.estimate_profit_margin_percent.setValue(''); + return; + } + let profit_percent = (estimate_profit_range_to + estimate_profit_range_from)/2; let Profit_Average = (profit_percent*sales_average)/100; + let difference = (estimate_profit_range_to - estimate_profit_range_from); - if(Profit_Average >= 3){ - var r = confirm("Given Profit Range is greater than 3%"); + if(difference > 3){ + var r = confirm("Given Profit Percent Range is greater than 3"); if (r == true) { - details.controls.estimate_profit_margin.setValue(Math.round(Profit_Average)); - details.controls.estimate_profit_margin_percent.setValue(profit_percent.toFixed(2)); + details.controls.estimate_profit_margin.setValue(Profit_Average!= Infinity ? Math.round(Profit_Average):0); + details.controls.estimate_profit_margin_percent.setValue(profit_percent!= Infinity ? profit_percent.toFixed(2):0); this.AV_marginProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(Profit_Average)); }else{ details.controls.estimate_profit_range_to.setValue(''); @@ -758,10 +798,10 @@ export class FinancialInfoComponent implements OnInit { return; } } - else{ - alert('else part'); - } - + + details.controls.estimate_profit_margin.setValue(Profit_Average!= Infinity ? Math.round(Profit_Average):0); + details.controls.estimate_profit_margin_percent.setValue(profit_percent!= Infinity ? profit_percent.toFixed(2):0); + this.AV_marginProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(Profit_Average)); // details.controls.estimate_profit_margin.setValue(Math.round(Profit_Average)); // details.controls.estimate_profit_margin_percent.setValue(profit_percent.toFixed(2)); @@ -774,65 +814,214 @@ export class FinancialInfoComponent implements OnInit { calculateProfitAmount( i, details){ let sales_average = details.value.estimate_sales_average; + if(sales_average == ''){ + alert("Considered Sales Average is Empty"); + details.controls.estimate_net_profit_from.setValue(''); + details.controls.estimate_net_profit_to.setValue(''); + details.controls.estimate_net_profit.setValue(''); + details.controls.estimate_net_profit_percent.setValue(''); + return; + } let estimate_net_profit_from = details.value.estimate_net_profit_from; let estimate_net_profit_to = details.value.estimate_net_profit_to; + if(+estimate_net_profit_to>+sales_average){ + + alert("Given Profit is Greater than Sales"); + details.controls.estimate_net_profit_from.setValue(''); + details.controls.estimate_net_profit_to.setValue(''); + details.controls.estimate_net_profit.setValue(''); + details.controls.estimate_net_profit_percent.setValue(''); + return; + } + + if (sales_average != '' && estimate_net_profit_from != '' && estimate_net_profit_to != ''){ - - let profit_amount = (estimate_net_profit_to + estimate_net_profit_from)/2; - let Profit_percent = (profit_amount/sales_average)*100; + if(+estimate_net_profit_from>+estimate_net_profit_to){ + alert("Given To value is lower than From Value"); + details.controls.estimate_net_profit_to.setValue(''); + details.controls.estimate_net_profit.setValue(''); + details.controls.estimate_net_profit_percent.setValue(''); + return; + } + + let C = (estimate_net_profit_to - estimate_net_profit_from) + let D = (C / estimate_net_profit_from) * 100; + + let range1 = +estimate_net_profit_from/10; + + let lower = (+estimate_net_profit_from)+range1; + let higer = ((+estimate_net_profit_to + +estimate_net_profit_from) / 2); - // details.controls.estimate_net_profit.setValue(Math.round(profit_amount)); - // details.controls.estimate_net_profit_percent.setValue(Profit_percent.toFixed(2)); - - // this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(profit_amount)); - if(Profit_percent >= 3){ - var r = confirm("Given Profit Percentage is greater than 3%"); + if(estimate_net_profit_from <= 5000000){ + if(D >= 20){ + var r = confirm("Given Profit Range is greater than 20%"); if (r == true) { - - details.controls.estimate_net_profit.setValue(Math.round(profit_amount)); - details.controls.estimate_net_profit_percent.setValue(Profit_percent.toFixed(2)); - this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(profit_amount)); - + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); }else{ - details.controls.estimate_net_profit_to.setValue(''); details.controls.estimate_net_profit.setValue(''); details.controls.estimate_net_profit_percent.setValue(''); return; - } + } + else{ + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + } + + if(lower > higer){ + details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0); + let Profit_percent = (higer/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0); + let Profit_percent = (lower/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } + } + else if(estimate_net_profit_from > 5000000 || estimate_net_profit_from <= 10000000){ + if(D >= 15){ + var r = confirm("Given Sales Range is greater than 15%"); + if (r == true) { + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + + }else{ + details.controls.estimate_net_profit_to.setValue(''); + details.controls.estimate_net_profit.setValue(''); + details.controls.estimate_net_profit_percent.setValue(''); + return; + } + } + else{ + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + } + + if(lower > higer){ + details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0); + let Profit_percent = (higer/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0); + let Profit_percent = (lower/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } + + } + else if(estimate_net_profit_from > 10000000){ + if(D >= 10){ + var r = confirm("Given Sales Range is greater than 10%"); + if (r == true) { + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + }else{ + details.controls.estimate_net_profit_to.setValue(''); + details.controls.estimate_net_profit.setValue(''); + details.controls.estimate_net_profit_percent.setValue(''); + return; + } + } + else{ + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + } + + if(lower > higer){ + details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0); + let Profit_percent = (higer/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0); + let Profit_percent = (lower/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } } else{ - alert('else part'); + details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0); + if(lower > higer){ + details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0); + let Profit_percent = (higer/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0); + let Profit_percent = (lower/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0); + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } } } - + } calculateMarginLoss( i, details){ let sales_average = details.value.estimate_sales_average; + if(sales_average == ''){ + alert("Considered Sales Average is Empty"); + details.controls.estimate_loss_range_from.setValue(''); + details.controls.estimate_loss_range_to.setValue(''); + details.controls.estimate_loss_margin.setValue(''); + details.controls.estimate_loss_margin_percent.setValue(''); + return; + } + // else{ let estimate_loss_range_from = details.value.estimate_loss_range_from; + if(+estimate_loss_range_from > 100){ + alert('Given Loss Percent is more than 100'); + details.controls.estimate_loss_range_from.setValue(''); + details.controls.estimate_loss_range_to.setValue(''); + details.controls.estimate_loss_margin.setValue(''); + details.controls.estimate_loss_margin_percent.setValue(''); + return; + + } + let estimate_loss_range_to = details.value.estimate_loss_range_to; + if(+estimate_loss_range_to > 100){ + alert('Given Loss Percent is more than 100'); + details.controls.estimate_loss_range_from.setValue(''); + details.controls.estimate_loss_range_to.setValue(''); + details.controls.estimate_loss_margin.setValue(''); + details.controls.estimate_loss_margin_percent.setValue(''); + return; + + } + if (sales_average != '' && estimate_loss_range_from != '' && estimate_loss_range_to != ''){ + + if(+estimate_loss_range_from>+estimate_loss_range_to){ + alert("Given To value is lower than From Value"); + details.controls.estimate_loss_range_to.setValue(''); + details.controls.estimate_loss_margin.setValue(''); + details.controls.estimate_loss_margin_percent.setValue(''); + return; + } let loss_percent = (estimate_loss_range_to + estimate_loss_range_from)/2; let loss_Average = (loss_percent*sales_average)/100; + let difference = (estimate_loss_range_to - estimate_loss_range_from) // details.controls.estimate_loss_margin.setValue(Math.round(loss_Average)); // details.controls.estimate_loss_margin_percent.setValue(loss_percent.toFixed(2)); // this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average)); - if(loss_Average >= 3){ - var r = confirm("Given Profit Range is greater than 3%"); + if(difference > 3){ + var r = confirm("Given Loss Percent Range is greater than 3"); if (r == true) { - details.controls.estimate_loss_margin.setValue(Math.round(loss_Average)); - details.controls.estimate_loss_margin_percent.setValue(loss_percent.toFixed(2)); + details.controls.estimate_loss_margin.setValue(loss_Average!= Infinity ? Math.round(loss_Average):0); + details.controls.estimate_loss_margin_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average)); }else{ @@ -841,71 +1030,235 @@ export class FinancialInfoComponent implements OnInit { details.controls.estimate_loss_margin_percent.setValue(''); return; } - } - else{ - alert('else part'); - } + } + details.controls.estimate_loss_margin.setValue(loss_Average!= Infinity ? Math.round(loss_Average):0); + details.controls.estimate_loss_margin_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average)); } } + calculateLossAmount( i, details){ let sales_average = details.value.estimate_sales_average; + if(sales_average == ''){ + alert("Considered Sales Average is Empty"); + details.controls.estimate_net_loss_from.setValue(''); + details.controls.estimate_net_loss_to.setValue(''); + details.controls.estimate_net_loss.setValue(''); + details.controls.estimate_net_loss_percent.setValue(''); + return; + } let estimate_net_loss_from = details.value.estimate_net_loss_from; let estimate_net_loss_to = details.value.estimate_net_loss_to; - if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){ + if(+estimate_net_loss_to > +sales_average){ + + alert("Given Loss is Greater than Sales"); + details.controls.estimate_net_loss_from.setValue(''); + details.controls.estimate_net_loss_to.setValue(''); + details.controls.estimate_net_loss.setValue(''); + details.controls.estimate_net_loss_percent.setValue(''); + return; + } + - // let profit_percent = (estimate_net_profit_to - estimate_net_profit_from)/estimate_net_profit_from * 100; - // let Profit_Average = (profit_percent*sales_average)/100; - let loss_amount = (estimate_net_loss_to + estimate_net_loss_from)/2; - let loss_percent = (loss_amount/sales_average)*100; + if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){ + if(+estimate_net_loss_from > +estimate_net_loss_to){ + alert("Given To value is Lower than From Value"); + details.controls.estimate_net_loss_to.setValue(''); + details.controls.estimate_net_loss.setValue(''); + details.controls.estimate_net_loss_percent.setValue(''); + return; + } + + + + // if(+estimate_net_loss_to > +estimate_net_loss_from){ + // alert("loss is greater than sales"); + // details.controls.estimate_net_loss_to.setValue(''); + // details.controls.estimate_net_loss.setValue(''); + // details.controls.estimate_net_loss_percent.setValue(''); + // return; + // } + + + let C = (estimate_net_loss_to - estimate_net_loss_from) + let D = (C / estimate_net_loss_from) * 100; + + let range1 = +estimate_net_loss_from/10; + + let lower = (+estimate_net_loss_from)+range1; + let higer = ((+estimate_net_loss_to + +estimate_net_loss_from) / 2); - // details.controls.estimate_net_loss.setValue(Math.round(loss_amount)); - // details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2)); - - // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount)); - if(loss_percent >= 3){ - var r = confirm("Given Loss Percentage is greater than 3%"); + if(estimate_net_loss_from <= 5000000){ + if(D >= 20){ + var r = confirm("Given Profit Range is greater than 20%"); if (r == true) { - - details.controls.estimate_net_loss.setValue(Math.round(loss_amount)); - details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2)); - - this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount)); - + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + }else{ - details.controls.estimate_net_loss_to.setValue(''); details.controls.estimate_net_loss.setValue(''); details.controls.estimate_net_loss_percent.setValue(''); return; - } + } + else{ + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + } + + if(lower > higer){ + details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0); + let loss_percent = (higer/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0); + let loss_percent = (lower/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } + + } + else if(estimate_net_loss_from > 5000000 || estimate_net_loss_from <= 10000000){ + if(D >= 15){ + var r = confirm("Given Sales Range is greater than 15%"); + if (r == true) { + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + }else{ + details.controls.estimate_net_loss_to.setValue(''); + details.controls.estimate_net_loss.setValue(''); + details.controls.estimate_net_loss_percent.setValue(''); + return; + } + } + else{ + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + } + + if(lower > higer){ + details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0); + let loss_percent = (higer/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0); + let loss_percent = (lower/sales_average)*100; + details.controls.estimate_net_profit_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } + } + else if(estimate_net_loss_from > 10000000){ + if(D >= 10){ + var r = confirm("Given Sales Range is greater than 10%"); + if (r == true) { + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + }else{ + details.controls.estimate_net_loss_to.setValue(''); + details.controls.estimate_net_loss.setValue(''); + details.controls.estimate_net_loss_percent.setValue(''); + return; + } + } + else{ + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + + } + if(lower > higer){ + details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0); + let loss_percent = (higer/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0); + let loss_percent = (lower/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } + } else{ - alert('else part'); + details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0); + if(lower > higer){ + details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0); + let loss_percent = (higer/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer)); + } + else{ + details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0); + let loss_percent = (lower/sales_average)*100; + details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower)); + } } } - - // let estimate_net_profit_from = details.value.estimate_net_profit_from; - // let estimate_net_profit_to = details.value.estimate_net_profit_to; - - // if (estimate_net_profit_from != '' && estimate_net_profit_to != ''){ - // let AB = (estimate_net_profit_to + estimate_net_profit_from)/2; - // let C = (estimate_net_profit_to - estimate_net_profit_from); - // let D = (C / estimate_net_profit_from); - // let E = D*100; - - // details.controls.estimate_net_profit_percent.setValue(E); - // details.controls.estimate_net_profit.setValue(AB); - - // } + } + // calculateLossAmount( i, details){ + + // let sales_average = details.value.estimate_sales_average; + + // let estimate_net_loss_from = details.value.estimate_net_loss_from; + // let estimate_net_loss_to = details.value.estimate_net_loss_to; + + // if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){ + + // // let profit_percent = (estimate_net_profit_to - estimate_net_profit_from)/estimate_net_profit_from * 100; + // // let Profit_Average = (profit_percent*sales_average)/100; + // let loss_amount = (estimate_net_loss_to + estimate_net_loss_from)/2; + // let loss_percent = (loss_amount/sales_average)*100; + + // // details.controls.estimate_net_loss.setValue(Math.round(loss_amount)); + // // details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2)); + + // // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount)); + // if(loss_percent >= 3){ + // var r = confirm("Given Loss Percentage is greater than 3%"); + // if (r == true) { + + // details.controls.estimate_net_loss.setValue(loss_amount!= Infinity ? Math.round(loss_amount):0); + // details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0); + + // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount)); + + // }else{ + + // details.controls.estimate_net_loss_to.setValue(''); + // details.controls.estimate_net_loss.setValue(''); + // details.controls.estimate_net_loss_percent.setValue(''); + // return; + + // } + // } + // else{ + // alert('else part'); + // } + + // } + + // // let estimate_net_profit_from = details.value.estimate_net_profit_from; + // // let estimate_net_profit_to = details.value.estimate_net_profit_to; + + // // if (estimate_net_profit_from != '' && estimate_net_profit_to != ''){ + // // let AB = (estimate_net_profit_to + estimate_net_profit_from)/2; + // // let C = (estimate_net_profit_to - estimate_net_profit_from); + // // let D = (C / estimate_net_profit_from); + // // let E = D*100; + + // // details.controls.estimate_net_profit_percent.setValue(E); + // // details.controls.estimate_net_profit.setValue(AB); + + // // } + // } submitDetails() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html index 1dac6787f..cf0bcf0c9 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html @@ -19,7 +19,8 @@ Name - {{details.value.applicant_name | titlecase}} + + @@ -61,11 +62,11 @@ - - @@ -257,7 +258,8 @@ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts index 2bd7823f3..0bb218c41 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts @@ -455,26 +455,24 @@ export class GeneralInfoComponent implements OnInit { } - /** Popup for EDIT Individuals */ - editIndividuals(arr) { - - console.log(arr); - - const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, { - data: arr, - width:'40%', - disableClose: true - }); + // remove individuals + // removeIndividuals(findex){ + // let control = this._generalForm.controls['individuals']; + // control.removeAt(findex); + // } - dialogRef.afterClosed() - .subscribe(dataresult => { - }); - } // remove individuals - removeIndividuals(findex){ - let control = this._generalForm.controls['individuals']; - control.removeAt(findex); + removeIndividuals(findex,details){ + + let control = this._generalForm.controls['individuals']; + control.removeAt(findex); + + let controls = this._generalForm.controls['persons_with_relationships']; + let name = details.value.applicant_name; + let index1 = controls.value.map(data => data.applicant_name).indexOf(name); + controls.removeAt(index1); + } // update personal relation diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts index 02bbdf249..0cc832b9d 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts @@ -138,9 +138,8 @@ export class LoanDetailsComponent implements OnInit { return {id:element.company_order_id.toString(),name:element.company_name,group_id:1}; }); this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:modifyCompanyList}) - this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:[{id:0,name:'Not Yet Finalised',group_id:2}]}) } - + let modifyApplicantList: any=[]; if(this.applicants.length > 0){ modifyApplicantList = this.applicants.map(element => { @@ -150,6 +149,7 @@ export class LoanDetailsComponent implements OnInit { // this.listOfLanguagues.splice(this.listOfLanguagues.indexOf(languague), 1); } + this.mergeCompanyApplicant.push({groupName:'OTHERS',groupValues:[{id:0,name:'Not Yet Finalised',group_id:2}]}) })