diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.ts index a3aea72e1..ed4fdeeb0 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.ts @@ -191,6 +191,7 @@ public m_investmentType = []; notifier: NotifierService, private _formBuilder: FormBuilder, private pdTrigerService: PdTrigerService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.applicants = this.pd_all_details.pdapplicants_detials; @@ -1025,6 +1026,7 @@ public m_investmentType = []; // stop here if form is invalid if (this._assetsQuesFrom.invalid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } else { var answerFormValues = this._assetsQuesFrom.value; @@ -1034,14 +1036,15 @@ public m_investmentType = []; // Save the data with help of Service this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe( dataresult => { - if (dataresult.status == 200) { - this.notifier.notify('success', 'Record Saved Successfully.!'); - // this.dialogRef.close(); - // alert("sample alert for Saving"); - } - else { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - } + if(dataresult.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); // this.dialogRef.close(); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts index 5fd1a0254..e4e0a4d80 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts @@ -49,6 +49,7 @@ export class BankingDetailsComponent implements OnInit { constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.pd_cus_segment = this.pd_all_details.pdmaster_details.customer_segment_abbr.toUpperCase(); @@ -164,7 +165,7 @@ export class BankingDetailsComponent implements OnInit { getM_BTLenderList(){ this._pd.getAllMasterDatas('BTLENDERLIST').subscribe( data => { - this.m_btLenderList = data.records.filter(data => data.isactive == 1); + this.m_btLenderList = data.records.filter(data => data.isactive == 1 && data.lender_type == 1); }) } @@ -226,8 +227,16 @@ export class BankingDetailsComponent implements OnInit { records.banking_details = this.bankingForm.controls['itemRows'].value; // console.log('data', records); this._pd.saveForm(records).subscribe(data => { - // console.log('data', data); - this.notifier.notify('success', 'Saved Successfully.'); + if(data.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + // this.dialogRef.close(); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else{ + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); }); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html index 2c7bd44e2..b7ee5981c 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html @@ -36,52 +36,23 @@
+ + + + {{types.loan_type_name}} + + + + + + {{"₹"}} {{amtInwords[i]}} Only - - - {{freq.name}} - - - - - - - - - {{"₹"}} {{emiAmtInwords[i]}} Only - - - - {{types.loan_type_name}} - - - - - - - - - - - - {{val.name}} - - - - - - - - - {{ btLen.lender_name }} @@ -90,18 +61,54 @@ + + + + + + {{val.name}} + + + + + + + + + + + + + {{freq.name}} + + + + + + {{"₹"}} {{emiAmtInwords[i]}} Only + + + +
- + - + Invalid Balance Tenure. + + +
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts index b3096d798..2c3d74e6e 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts @@ -330,6 +330,7 @@ export class FamilyDetailsComponent implements OnInit { constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { console.log(pd_all_details); this.selectPerson = this.pd_all_details.pdapplicants_detials; @@ -385,6 +386,7 @@ export class FamilyDetailsComponent implements OnInit { non_earning_occupation: [val.non_earning_occupation, Validators.compose([])], non_earning_if_others: [val.non_earning_if_others, Validators.compose([])], non_earning_if_retired_from: [val.non_earning_if_retired_from, Validators.compose([])], + non_earning_if_schoolorcollege: [val.non_earning_if_schoolorcollege], }) } @@ -540,6 +542,7 @@ export class FamilyDetailsComponent implements OnInit { non_earning_occupation: [vals.non_earning_occupation || null, Validators.compose([])], non_earning_if_others: [vals.non_earning_if_others || null, Validators.compose([])], non_earning_if_retired_from: [vals.non_earning_if_retired_from || null, Validators.compose([])], + non_earning_if_schoolorcollege: [val.non_earning_if_schoolorcollege || null], }); control.push(datas); } @@ -592,6 +595,7 @@ export class FamilyDetailsComponent implements OnInit { non_earning_occupation: ['', Validators.compose([])], non_earning_if_others: ['', Validators.compose([])], non_earning_if_retired_from: ['', Validators.compose([])], + non_earning_if_schoolorcollege: [''], }) } @@ -622,6 +626,7 @@ export class FamilyDetailsComponent implements OnInit { submitFamily() { if (!this.familyForm.valid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } var records = this.familyForm.value; @@ -633,7 +638,16 @@ export class FamilyDetailsComponent implements OnInit { // records.fk_createdby = '251'; console.log(JSON.stringify(records)); this._pd.saveForm(records).subscribe(data => { - this.notifier.notify('success', 'Saved Successfully.'); + // this.notifier.notify('success', 'Saved Successfully.'); + if(data.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); }); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts index 236cb9d79..457a884c8 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts @@ -47,6 +47,7 @@ export class FinalRemarksComponent implements OnInit { notifier: NotifierService, private _formBuilder: FormBuilder, private pdTrigerService: PdTrigerService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.form_id = 20; @@ -114,6 +115,7 @@ export class FinalRemarksComponent implements OnInit { this.submitted = true; // stop here if form is invalid if (this._finalRemarkForm.invalid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } else { var answerFormValues = this._finalRemarkForm.value; @@ -125,14 +127,13 @@ export class FinalRemarksComponent implements OnInit { this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe( dataresult => { if (dataresult.status == 200) { - // console.log(dataresult); - this.notifier.notify('success', 'Record Saved Successfully.!'); - // this.dialogRef.close(); - // alert("sample alert for Saving"); + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); } - else { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - // this.errorMessage = "Some Thing Wents Wrong Try Again !"; + else{ + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); 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 af2bc494f..847832004 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 @@ -1,5 +1,5 @@ - -
+ +

@@ -20,32 +20,46 @@
-

Data as Per Financial Statements

+ + +

Data as Per Financial Statements

+
- +
- + + + + Yes + No + + + + + + Enter year from which financials provided - + Invalid year format - + - - + + +
-
+
Financial Year : {{details.get('financial_year').value}} -
+

@@ -61,7 +75,7 @@ - No differents in Sales in FY {{details.get('financial_year').value}} over Sales in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} + No difference in Sales in FY {{details.get('financial_year').value}} over Sales in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} Increase in Sales in FY {{details.get('financial_year').value}} over Sales in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} {{details.get('financial_annualsales_variation').value}} % @@ -107,11 +121,11 @@
- + - No differents in Profit in FY {{details.get('financial_year').value}} over Profit in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} + No difference in Profit in FY {{details.get('financial_year').value}} over Profit in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} Increase in Profit in FY {{details.get('financial_year').value}} over Profit in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} {{details.get('financial_variation').value}} % @@ -123,40 +137,46 @@ - - - - - - + + + + + + No difference in Profit sales % in FY {{details.get('financial_year').value}} over Profit sales % in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} + + + Increase in Profit sales % in FY {{details.get('financial_year').value}} over Profit sales % in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} {{details.get('financial_profit_to_sale_variation').value}} % + + + Decrease in Profit sales % in FY {{details.get('financial_year').value}} over Profit sales % in FY {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} {{(details.get('financial_profit_to_sale_variation').value).replace('-', '')}} % + + + + +
- - + + +
- +

Financial as per Customer

- - + + Yes No @@ -165,39 +185,31 @@
- - Financial Year : {{details.get('estimate_year').value}} -
- - -
-
- - - - {{"₹"}} {{AV_annualSalesInwords[i]}} Only + + + + + +
+ + + + + + + + + + + + + {{"₹"}} {{AV_SalesInwords[i]}} Only - - - - - - No differents in Sales in FY {{details.get('estimate_year').value}} over Sales in FY {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} - - - Increase in Sales in FY {{details.get('estimate_year').value}} over Sales in FY {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} {{details.get('estimate_annualsales_variation').value}} % - - - Decrease in Sales in FY {{details.get('estimate_year').value}} over Sales in FY {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} {{(details.get('estimate_annualsales_variation').value).replace('-', '')}} % - - - -
+ +
@@ -208,29 +220,81 @@ - + + +
+ + + + + + + + + {{"₹"}} {{details.get('estimate_profit_margin').value}} ( {{AV_marginProfitAmtInwords[i]}} Only ) + +
+
+ + + + + + + + + {{"₹"}} {{AV_netProfitAmtInwords[i]}} Only ( {{details.get('estimate_net_profit_percent').value }} % ) + +
+ + - +
+ + + + + + + + + {{"₹"}} {{details.get('estimate_Loss_margin').value}} ( {{AV_marginLossAmtInwords[i]}} Only ) + +
+
+ + + + + + + + + {{"₹"}} {{AV_netLossAmtInwords[i]}} Only ( {{details.get('estimate_net_loss_percent').value }} % ) + + +
+
- + - - + @@ -258,7 +322,6 @@
-
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 af31668e9..251f1b486 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 @@ -30,25 +30,37 @@ import {ActivatedRoute, Router} from '@angular/router'; styleUrls: ['./financial-info.component.scss'] }) export class FinancialInfoComponent implements OnInit { + //Common Declaration pageTitle: string ="Financial Information"; - pdid: string; - form_id: number; - company_id: string; + pdid: string; + form_id: number; + company_id: string; + public financialForm: FormGroup; private notifier: NotifierService; - SalesStatement : any = []; - marginVal: any = [] ; - placeholderName : any = []; - setmargin: AbstractControl; + + // SalesStatement : any = []; + // marginVal: any = [] ; + // placeholderName : any = []; + // setmargin: AbstractControl; + customerCommentsFlag :boolean; + + //Array for Amount Inwords FY_annualSalesInwords : any = []; FY_netProfitAmtInwords : any = []; FY_netLossAmtInwords : any = []; + AV_SalesInwords : any = []; AV_annualSalesInwords : any = []; + AV_marginProfitAmtInwords : any = []; AV_netProfitAmtInwords : any = []; + AV_marginLossAmtInwords : any = []; AV_netLossAmtInwords : any = []; + + //isreadonly for edit(no of year Fields and Starting Years ) isReadOnly : boolean = false; - + isDisplay : boolean ; + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, @@ -61,25 +73,29 @@ export class FinancialInfoComponent implements OnInit { this.company_id =this.pd_all_details.company_id; this.notifier = notifier; } + + //ViewerOption For Docs Display public viewerOptions: any = { - navbar: false, - toolbar: { - zoomIn: 4, - zoomOut: 4, - oneToOne: 4, - reset: 4, - prev: 4, - play: { - show: 4, - size: 'large', - }, - next: 4, - rotateLeft: 4, - rotateRight: 4, - flipHorizontal: 4, - flipVertical: 4, - } -}; + navbar: false, + toolbar: { + zoomIn: 4, + zoomOut: 4, + oneToOne: 4, + reset: 4, + prev: 4, + play: { + show: 4, + size: 'large', + }, + next: 4, + rotateLeft: 4, + rotateRight: 4, + flipHorizontal: 4, + flipVertical: 4, + } + }; + + ngOnInit() { this.initstockForm(); @@ -87,45 +103,57 @@ export class FinancialInfoComponent implements OnInit { params.pd_id = this.pdid; params.pd_form_id = this.form_id; params.company_id = this.company_id; + this._pd.retriveForm(params).subscribe(value => { const financial_date = this.financialForm.controls['date_per_financial']; const estimated_val = this.financialForm.controls['estimated_value']; if (value.status == 200) { let retriveData = value.records; - this.isReadOnly = true; + // this.isReadOnly = true; + + /** Backend Data of Asper Statement */ let result = Object.keys(value.records.date_per_financial).map(function(key) { return value.records.date_per_financial[key]; }); + + if (result.length > 0) { + this.customerCommentsFlag = result.length == 1 ? false : true; + result.forEach((val,index) => { + //financial_date.push(this.createDate()); + this.FY_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale); + this.FY_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit); + this.FY_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss); + financial_date.push(this.createDate('')); + }); + retriveData.date_per_financial = result; + } else { + //financial_date.push(this.createDate()); + financial_date.push(this.createDate('')); + } + + /** Backend Data of Asper Customer */ let result_val = Object.keys(value.records.estimated_value).map(function(key) { return value.records.estimated_value[key]; }); - if (result.length > 0) { - this.customerCommentsFlag = result.length == 1 ? false : true; - result.forEach((val,index) => { - //financial_date.push(this.createDate()); - this.FY_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale); - this.FY_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit); - this.FY_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss); - financial_date.push(this.createDate('')); - }); - retriveData.date_per_financial = result; - } else { - //financial_date.push(this.createDate()); - financial_date.push(this.createDate('')); - } - if (result_val.length > 0) { - result_val.forEach((val,index) => { - //console.log('dedrf',val.estimate_annual_sale); - this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.estimate_annual_sale); - this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_profit); - this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_loss); - estimated_val.push(this.createValue('')); - }); - retriveData.estimated_value = result_val; - } else { - estimated_val.push(this.createValue('')); - } + + if (result_val.length > 0) { + result_val.forEach((val,index) => { + //console.log('dedrf',val.estimate_annual_sale); + // this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.estimate_annual_sale); + // this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_profit); + // this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_loss); + this.AV_SalesInwords = this._pd.convertNumberToWords(val.estimate_sales_average); + this.AV_marginProfitAmtInwords = this._pd.convertNumberToWords(val.estimate_profit_margin); + this.AV_netProfitAmtInwords = this._pd.convertNumberToWords(val.estimate_net_profit); + this.AV_marginLossAmtInwords = this._pd.convertNumberToWords(val.estimate_loss_margin); + this.AV_netLossAmtInwords = this._pd.convertNumberToWords(val.estimate_net_loss); + estimated_val.push(this.createValue('')); + }); + retriveData.estimated_value = result_val; + } else { + estimated_val.push(this.createValue('')); + } retriveData.pdid = this.pdid; retriveData.formid = this.form_id; retriveData.company_id = this.company_id; @@ -133,10 +161,12 @@ export class FinancialInfoComponent implements OnInit { this.financialForm.setValue(retriveData); } else { //financial_date.push(this.createDate()); - //estimated_val.push(this.createValue('')); + //estimated_val.push(this.createValue('')); } }) } + + /** financial Form Controls */ public initstockForm(): void { this.financialForm = this.fb.group({ pdid: this.pdid, @@ -144,14 +174,19 @@ export class FinancialInfoComponent implements OnInit { company_id: this.company_id, fk_createdby: this.pdid, financial_remarks: [''], - staring_financial_year : ['',Validators.compose([Validators.minLength(4),Validators.maxLength(4)])], - total_financial_year : [''], + is_financial_statements:[''], + is_financial_customer:[''], + financial_starting_year : ['',Validators.compose([Validators.minLength(4),Validators.maxLength(4)])], + financial_no_of_year : [''], financial_reason: [''], - same_as_financial_statements:[''], + financial_customer:[''], + // same_as_financial_statements:[''], date_per_financial: this.fb.array([]), estimated_value: this.fb.array([]) }); } + + /** Old code For CREATING financial Statement */ // createDate() { // return this.fb.group({ // financial_year: ['', Validators.compose([ Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], @@ -162,6 +197,9 @@ export class FinancialInfoComponent implements OnInit { // financial_reason: [''], // }); // } + + + /** CREATING financial Statement ( financial_year AutoGenerate ) */ createDate(date) { return this.fb.group({ financial_year: [date, Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], @@ -172,38 +210,99 @@ export class FinancialInfoComponent implements OnInit { financial_margin_of_profit: [''], financial_margin_of_loss: [''], financial_variation: [''], + financial_profit_to_sale_variation:[''], financial_annualsales_variation : [''], - }); } + + /** CREATING financial Customer ( financial_year AutoGenerate ) */ createValue(date) { return this.fb.group({ - estimate_year: [date, Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], - estimate_annual_sale: ['', Validators.compose([Validators.pattern(/^[0-9\(\)]+$/)])], + // estimate_year: [date, Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + // estimate_annual_sale: ['', Validators.compose([Validators.pattern(/^[0-9\(\)]+$/)])], + // estimate_sales_from: [''], + // estimate_sales_to: [''], + // estimate_sales_average: [''], + // estimate_profit_or_loss:[''], + // estimate_net_profit: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], + // estimate_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], + // //estimate_margin: [''], + // estimate_margin_of_profit: [''], + // estimate_margin_of_loss: [''], + // estimate_variation: [''], + // estimate_annualsales_variation : [''], + // estimate_reason: [''], + + // estimate_year: ['', Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + estimate_sales_from: [''], + estimate_sales_to: [''], + estimate_sales_average: [''], estimate_profit_or_loss:[''], - estimate_net_profit: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], - estimate_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], - //estimate_margin: [''], - estimate_margin_of_profit: [''], - estimate_margin_of_loss: [''], - estimate_variation: [''], - estimate_annualsales_variation : [''], + estimate_profit_range_from:[''], + estimate_profit_range_to:[''], + estimate_profit_margin_percent:[''], + estimate_profit_margin:[''], + estimate_net_profit_from:[''], + estimate_net_profit_to:[''], + estimate_net_profit_percent:[''], + estimate_net_profit:[''], + estimate_loss_range_from:[''], + estimate_loss_range_to:[''], + estimate_loss_margin_percent:[''], + estimate_loss_margin:[''], + estimate_net_loss_from:[''], + estimate_net_loss_to:[''], + estimate_net_loss_percent:[''], + estimate_net_loss:[''], + + // estimate_net_profit: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], + // estimate_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], + // estimate_margin: [''], + // estimate_margin_of_profit: [''], + // estimate_margin_of_loss: [''], + // estimate_variation: [''], + // estimate_annualsales_variation : [''], // estimate_reason: [''], }); } + /** Feteching financial Customer */ createValuewithData(value) { return this.fb.group({ - estimate_year: [value.estimate_year, Validators.compose([ Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], - estimate_annual_sale: [value.estimate_annual_sale, Validators.compose([ Validators.pattern(/^[0-9\(\)]+$/)])], + // estimate_year: [value.estimate_year, Validators.compose([ Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + // estimate_year: [date, Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + estimate_sales_from: [value.estimate_sales_from], + estimate_sales_to: [value.estimate_sales_to], + estimate_sales_average: [value.estimate_sales_average], estimate_profit_or_loss:[value.estimate_profit_or_loss], - estimate_net_loss: [value.estimate_net_loss, Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], - estimate_net_profit: [value.estimate_net_profit, Validators.compose([ Validators.pattern(/^-?[1-9]\d*|0$/)])], - //estimate_margin: [value.], - estimate_margin_of_profit: [value.estimate_margin_of_profit], - estimate_margin_of_loss: [value.estimate_margin_of_loss], - estimate_variation: [value.estimate_variation], - estimate_annualsales_variation : [value.estimate_annualsales_variation], + estimate_profit_range_from:[value.estimate_profit_range_from], + estimate_profit_range_to:[value.estimate_profit_range_to], + estimate_profit_margin_percent:[value.estimate_profit_margin_percent], + estimate_profit_margin:[value.estimate_profit_margin], + estimate_net_profit_from:[value.estimate_net_profit_from], + estimate_net_profit_to:[value.estimate_net_profit_to], + estimate_net_profit_percent:[value.estimate_net_profit_percent], + estimate_net_profit:[value.estimate_net_profit], + estimate_loss_range_from:[value.estimate_loss_range_from], + estimate_loss_range_to:[value.estimate_loss_range_to], + estimate_loss_margin_percent:[value.estimate_loss_margin_percent], + estimate_loss_margin:[value.estimate_loss_margin], + estimate_net_loss_from:[value.estimate_net_loss_from], + estimate_net_loss_to:[value.estimate_net_loss_to], + estimate_net_loss_percent:[value.estimate_net_loss_percent], + estimate_net_loss:[value.estimate_net_loss], + // estimate_annual_sale: [value.estimate_annual_sale, Validators.compose([ Validators.pattern(/^[0-9\(\)]+$/)])], + // estimate_sales_from: [''], + // estimate_sales_to: [''], + // estimate_sales_average: [''], + // estimate_profit_or_loss:[value.estimate_profit_or_loss], + // estimate_net_loss: [value.estimate_net_loss, Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])], + // estimate_net_profit: [value.estimate_net_profit, Validators.compose([ Validators.pattern(/^-?[1-9]\d*|0$/)])], + // //estimate_margin: [value.], + // estimate_margin_of_profit: [value.estimate_margin_of_profit], + // estimate_margin_of_loss: [value.estimate_margin_of_loss], + // estimate_variation: [value.estimate_variation], + // estimate_annualsales_variation : [value.estimate_annualsales_variation], // estimate_reason: [''], }); } @@ -216,6 +315,7 @@ export class FinancialInfoComponent implements OnInit { const control = this.financialForm.controls['date_per_financial']; control.removeAt(index); } + addGoods() { const control = this.financialForm.controls['estimated_value']; //control.push(this.createValue()); @@ -224,9 +324,11 @@ export class FinancialInfoComponent implements OnInit { const control = this.financialForm.controls['estimated_value']; control.removeAt(index); } + + /** For Auto-generating FinYear */ dynamicalFinYear($event){ - //console.log(this.financialForm.controls['total_financial_year'].value); + //console.log(this.financialForm.controls['financial_no_of_year'].value); //console.log('data',$event.target.value); let e = $event.target.value; if(e == 1){ @@ -236,7 +338,7 @@ export class FinancialInfoComponent implements OnInit { this.customerCommentsFlag = true; } - let startingYear = this.financialForm.controls['staring_financial_year'].value; + let startingYear = this.financialForm.controls['financial_starting_year'].value; const control = this.financialForm.controls['date_per_financial']; @@ -248,73 +350,148 @@ export class FinancialInfoComponent implements OnInit { for(let i = 1 ; i<= e ; i++ ){ let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i)); control.push(this.createDate(Year)); - //console.log(this.financialForm.controls['staring_financial_year'].value); + //console.log(this.financialForm.controls['financial_starting_year'].value); } } } - selectedType(e: any): void { + selectedStatement(e :any):void{ + if(e.value == 'yes'){ - let startingYear = this.financialForm.controls['staring_financial_year'].value; - let totalFinYear = this.financialForm.controls['total_financial_year'].value; - //let YearParam = (+startingYear) +'-'+ ((+startingYear+1)); - let array = this.financialForm.controls['date_per_financial']; + + this.isDisplay = true; + this.financialForm.controls['is_financial_customer'].setValue(''); const control = this.financialForm.controls['estimated_value']; - while (control.length !== 0) { control.removeAt(0); } - - if(array.length > 0 ){ - array.value.forEach((val,index)=>{ - let vals = { - estimate_year: val.financial_year, - estimate_annual_sale: val.financial_annual_sale, - estimate_profit_or_loss:val.finanical_profit_or_loss, - estimate_net_loss: val.financial_net_loss, - estimate_net_profit: val.financial_net_profit, - estimate_margin_of_profit: val.financial_margin_of_profit, - estimate_margin_of_loss: val.financial_margin_of_loss, - estimate_variation: val.financial_variation, - estimate_annualsales_variation : val.financial_annualsales_variation, - }; - this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale); - this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit); - this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss); - control.push(this.createValuewithData(vals)); - }); - } - - //control.controls[0].get('raw_quantity').setValidators([Validators.required]); - - // for(let i = 1 ; i<= totalFinYear ; i++ ){ - // let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i)); - // control.push(this.createValue(Year)); - // } - - //control.push(this.createValue(YearParam)); - } else if (e.value == 'no'){ - - let startingYear = this.financialForm.controls['staring_financial_year'].value; - let totalFinYear = this.financialForm.controls['total_financial_year'].value; + + this.isDisplay = false; + // let startingYear = this.financialForm.controls['financial_starting_year'].value; + // let totalFinYear = this.financialForm.controls['financial_no_of_year'].value; const control = this.financialForm.controls['estimated_value']; while (control.length !== 0) { control.removeAt(0); } - - if(totalFinYear > 0 ){ - for(let i = 1 ; i<= totalFinYear ; i++ ){ - let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i)); - control.push(this.createValue(Year)); - //console.log(this.financialForm.controls['staring_financial_year'].value); - } + + const statementControl = this.financialForm.controls['date_per_financial']; + + while (statementControl.length !== 0) { + statementControl.removeAt(0); } + + this.financialForm.controls['financial_starting_year'].setValue(''); + this.financialForm.controls['financial_no_of_year'].setValue(''); + + + // alert((new Date()).getFullYear()); + let year1 = (new Date()).getFullYear(); + let year2 = ((new Date()).getFullYear() + 1); + + let Year = year1 +'-'+ year2; + control.push(this.createValue('')); + + } + } + /** fin customer data from Fin statement*/ + selectedFinancialCustomer(e: any): void { + if(e.value == 'yes'){ + const control = this.financialForm.controls['estimated_value']; + + while (control.length !== 0) { + control.removeAt(0); + } + } + // if(e.value == 'yes'){ + // let startingYear = this.financialForm.controls['financial_starting_year'].value; + + // const control = this.financialForm.controls['date_per_financial']; + + // while (control.length !== 0) { + // control.removeAt(0); + // } + + // if(e > 0 ){ + // for(let i = 1 ; i<= e ; i++ ){ + // let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i)); + // control.push(this.createDate(Year)); + // //console.log(this.financialForm.controls['financial_starting_year'].value); + // } + // } + // } + + // if(e.value == 'yes'){ + // let startingYear = this.financialForm.controls['financial_starting_year'].value; + // let totalFinYear = this.financialForm.controls['financial_no_of_year'].value; + + // const control = this.financialForm.controls['estimated_value']; + + // while (control.length !== 0) { + // control.removeAt(0); + // } + + // if(totalFinYear > 0 ){ + // for(let i = 1 ; i<= totalFinYear ; i++ ){ + // let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i)); + // control.push(this.createValue(Year)); + // //console.log(this.financialForm.controls['financial_starting_year'].value); + // } + // } + + // if(array.length > 0 ){ + + // array.value.forEach((val,index)=>{ + // let vals = { + // estimate_year: val.financial_year, + // estimate_sales_from: '', + // estimate_sales_to: '', + // estimate_sales_average: '', + // // estimate_annual_sale: val.financial_annual_sale, + // estimate_profit_or_loss:val.finanical_profit_or_loss, + // estimate_net_loss: val.financial_net_loss, + // estimate_net_profit: val.financial_net_profit, + // estimate_margin_of_profit: val.financial_margin_of_profit, + // estimate_margin_of_loss: val.financial_margin_of_loss, + // estimate_variation: val.financial_variation, + // estimate_annualsales_variation : val.financial_annualsales_variation, + // }; + // this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale); + // this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit); + // this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss); + // control.push(this.createValuewithData(vals)); + // }); + + // } + + //control.controls[0].get('raw_quantity').setValidators([Validators.required]); + //control.push(this.createValue(YearParam)); + + // } + else if (e.value == 'no'){ + + // let startingYear = this.financialForm.controls['financial_starting_year'].value; + // let totalFinYear = this.financialForm.controls['financial_no_of_year'].value; + + const control = this.financialForm.controls['estimated_value']; + + while (control.length !== 0) { + control.removeAt(0); + } + + alert((new Date()).getFullYear()); + let year1 = (new Date()).getFullYear(); + let year2 = ((new Date()).getFullYear() - 1); + + let Year = year2 +'-'+ year1; + alert(Year); + control.push(this.createValue(Year)); + } } @@ -329,6 +506,8 @@ export class FinancialInfoComponent implements OnInit { // // detail.controls.financial_variation.disable() // } // } + + /**calculating Annual Sale for financial Statement */ calFinAnnualSale(index,detail){ let annual_sale = detail.value.financial_annual_sale; if (index != 0) { @@ -339,8 +518,8 @@ export class FinancialInfoComponent implements OnInit { } } - calculateEstimationAnnualSale(index,detail){ - //alert('Function Inside'); + /** calculating Annual Sale for financial Customer */ + calculateEstimationAnnualSale(index,detail){ let annual_sale = detail.value.estimate_annual_sale; if (index != 0) { let array = this.financialForm.controls['estimated_value']; @@ -350,6 +529,8 @@ export class FinancialInfoComponent implements OnInit { } } + + /** calculating Yearwise Variation for financial statement */ calYearVariation(index, detail) { let profit = detail.value.financial_net_profit; @@ -361,56 +542,18 @@ export class FinancialInfoComponent implements OnInit { let prev_profit = array.value[index - 1].financial_net_profit != '' ? array.value[index - 1].financial_net_profit : 0; let prev_loss = array.value[index - 1].financial_net_loss !='' ? array.value[index - 1].financial_net_loss : 0 ; - let prev_year = array.value[index - 1].financial_year; - let prev_annual_sale = array.value[index-1].financial_annual_sale; + loss = loss != 0 ? loss * (-1) : loss; prev_loss = prev_loss != 0 ? prev_loss * (-1) : prev_loss ; - //let variation2 = ((())) - let variation = (((profit != '' ? profit : loss ) - (prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100; - //console.log('console.log(Math.abs(profit));',Math.abs(variation)); - // let variation ; - // if(profit != ''){ - // variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? prev_profit : prev_loss)) * 100 * (profit != '' ? (1) : (-1)) ; - // } - // else if(loss != ''){ - // variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? prev_profit : prev_loss)) * 100 * (profit != '' ? (1) : (-1)); - // } - + + let variation = (((profit != '' ? profit : loss ) - (prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100; -// let annual_sale_variation = (annual_sale - prev_annual_sale) * 100 ; - detail.controls.financial_variation.setValue(variation.toFixed(2)); - - //Increase in Sales in FY 2017-18 over sales in FY 2016-17 is 11.11% - - // this.SalesStatement[index] = ( variation <= 0 ? 'Decreases ' : 'Increases ' ) + 'in Sales in FY ' + curr_year + ' Over Sales in FY '+ prev_year + ' is ' + variation.toFixed(2) + '%'; - // console.log('this.SlesStatement',this.SalesStatement); } + } - // if(detail.value.finanical_profit_or_loss == 1){ - // let profit = detail.value.financial_net_profit; - - // if ( profit != '' && index != 0) { - - // let array = this.financialForm.controls['date_per_financial'] - // let prev_profit = array.value[index - 1].financial_net_profit; - // let variation = ((profit - prev_profit)/ prev_profit) * 100; - // detail.controls.financial_variation.setValue(variation.toFixed(2)) - // } - // }else if (detail.value.finanical_profit_or_loss == 2){ - // let loss = detail.value.financial_net_loss; - - // if ( loss != '' && index != 0) { - - // let array = this.financialForm.controls['date_per_financial'] - // let prev_loss = array.value[index - 1].financial_net_loss; - // let variation = ((loss - prev_loss)/ prev_loss) * 100; - // detail.controls.financial_variation.setValue(variation.toFixed(2)) - - // } - // } -} + /** old code == calculating Sale PERCENTAGE for financial statement */ // calMargin(index, detail) { // console.log('detail', detail); // let salary = detail.value.financial_annual_sale; @@ -422,31 +565,30 @@ export class FinancialInfoComponent implements OnInit { // } // } + /** For Financial Statement + * Calculating Sale percentage based on profit and loss + * And calculating Variation over sales + */ calMargin(index, detail) { -// let array = this.financialForm.controls['date_per_financial']; - let salary = detail.value.financial_annual_sale; - // let prev_annual_sale = array.value[index-1].financial_annual_sale; - // let annual_sale_variation = ((prev_annual_sale - salary)/salary ) * 100 ; + let salary = detail.value.financial_annual_sale; + let profit_margin; + let loss_margin; + // let prev_annual_sale = array.value[index-1].financial_annual_sale; + // let annual_sale_variation = ((prev_annual_sale - salary)/salary ) * 100 ; if(detail.value.finanical_profit_or_loss == 1){ let profit = detail.value.financial_net_profit; - + if (salary != '' && profit != '') { // if(salary < profit){ - // alert('if condition salary = '+salary); - // alert('if condition Profit = '+profit); // detail.controls.financial_margin_of_profit.setValue(''); // } // else{ - // alert('else condition salary = '+salary); - // alert('else condition Profit = '+profit); - let margin = (profit / salary) * 100; - // alert(' '+margin); - detail.controls.financial_margin_of_profit.setValue(margin.toFixed(2)); + profit_margin = (profit / salary) * 100; + detail.controls.financial_margin_of_profit.setValue(profit_margin.toFixed(2)); // } - // detail.controls.financial_margin.disable() } } @@ -454,16 +596,44 @@ export class FinancialInfoComponent implements OnInit { let loss = detail.value.financial_net_loss; - if (salary != '' && loss != '') { - // alert('if condition salary = '+salary); - // alert('if condition loss = '+loss); - let margin = (loss / salary) * 100 * (-1); - detail.controls.financial_margin_of_loss.setValue(margin.toFixed(2)); + if (salary != '' && loss != '') { + + loss_margin = (loss / salary) * 100 * (-1); + detail.controls.financial_margin_of_loss.setValue(loss_margin.toFixed(2)); // detail.controls.financial_margin.disable() - } + + } + } + + + if ((profit_margin != '' || loss_margin != '') && index != 0) { + + // console.log('profit_margin',profit_margin); + // console.log('loss_margin',loss_margin); + // console.log('index',index); + + let array = this.financialForm.controls['date_per_financial']; + // console.log('array',array); + let prev_profit_margin = array.value[index - 1].financial__margin_of_profit != '' ? array.value[index - 1].financial_margin_of_profit : 0; + let prev_loss_margin = array.value[index - 1].financial__margin_of_loss !='' ? array.value[index - 1].financial_margin_of_loss : 0 ; + + // console.log('preprofit_margin',prev_profit_margin); + // console.log('preloss_margin',prev_profit_margin); + + loss_margin = loss_margin != 0 ? loss_margin * (-1) : loss_margin; + prev_loss_margin = prev_loss_margin != 0 ? prev_loss_margin * (-1) : prev_loss_margin ; + + let variation_percent = (((profit_margin != '' ? profit_margin : loss_margin ) - (prev_profit_margin != '' ? prev_profit_margin : prev_loss_margin ))/ (prev_profit_margin != '' ? Math.abs(prev_profit_margin) : Math.abs(prev_loss_margin))) * 100; + + detail.controls.financial_profit_to_sale_variation.setValue(variation_percent.toFixed(2)); + } //detail.controls.financial_annualsales_variation.setValue(annual_sale_variation.toFixed(2)); } + + /** For Financial Customer + * Calculating Yearwise Variation + */ calVariation(index, detail) { // console.log('CalVar In'); // let profit = detail.value.estimate_net_profit; @@ -487,7 +657,7 @@ export class FinancialInfoComponent implements OnInit { let prev_profit = array.value[index - 1].estimate_net_profit != '' ? array.value[index - 1].estimate_net_profit : 1; let prev_loss = array.value[index - 1].estimate_net_loss !='' ? array.value[index - 1].estimate_net_loss : 1; - let prev_year = array.value[index - 1].estimate_year; + // let prev_year = array.value[index - 1].estimate_year; loss = loss != 0 ? loss * (-1) : loss; prev_loss = prev_loss != 0 ? prev_loss * (-1) : prev_loss ; @@ -504,6 +674,9 @@ export class FinancialInfoComponent implements OnInit { } } + /** For Financial Customer + * Calculating AnnualSales Variation + */ calMarginVal(index, detail) { let salary = detail.value.estimate_annual_sale; @@ -622,6 +795,181 @@ export class FinancialInfoComponent implements OnInit { // } //} + + confirmAlert(i, details){ + + let estimate_sales_from = +details.value.estimate_sales_from; + let estimate_sales_to = +details.value.estimate_sales_to; + + if (estimate_sales_from != null && estimate_sales_to != null){ + + let C = (estimate_sales_to - estimate_sales_from) + let D = (C / estimate_sales_from) * 100; + // % Decrease = Decrease ÷ Original Number × 100 + + if(D >= 30){ + var r = confirm("Given Sales Range is greater than 30%"); + if (r == true) { + details.controls.estimate_sales_to.setValue(estimate_sales_to); + }else{ + details.controls.estimate_sales_to.setValue(''); + return; + } + } + else{ + details.controls.estimate_sales_to.setValue(estimate_sales_to); + } + } + this.calculateSalesAverage(i, details); + } + + calculateSalesAverage(i, details){ + + let estimate_sales_from = details.value.estimate_sales_from; + let estimate_sales_to = details.value.estimate_sales_to; + + if(estimate_sales_from != '' && estimate_sales_to != ''){ + + let range1 = +estimate_sales_from/10; + + // console.log('range1',range1); + + let lower = (+estimate_sales_from)+range1; + let higer = ((+estimate_sales_to + +estimate_sales_from) / 2); + // console.log(lower); + // console.log(higer); + + if(lower > higer){ + details.controls.estimate_sales_average.setValue(higer.toFixed(2)); + this.AV_SalesInwords[i] = this._pd.convertNumberToWords(higer); + + + } + else{ + details.controls.estimate_sales_average.setValue(lower.toFixed(2)); + this.AV_SalesInwords[i] = this._pd.convertNumberToWords(lower); + } + + } + else{ + // alert('Check Both Sales Range Fields'); + details.controls.estimate_sales_average.setValue(''); + } + + } + + calculateMarginProfit( i, details){ + + let sales_average = details.value.estimate_sales_average; + let estimate_profit_range_from = details.value.estimate_profit_range_from; + let estimate_profit_range_to = details.value.estimate_profit_range_to; + + if (sales_average != '' && estimate_profit_range_from != '' && estimate_profit_range_to != ''){ + + let profit_percent = (estimate_profit_range_to + estimate_profit_range_from)/2; + let Profit_Average = (profit_percent*sales_average)/100; + + details.controls.estimate_profit_margin.setValue(Math.round(Profit_Average)); + details.controls.estimate_profit_margin_percent.setValue(profit_percent); + + this.AV_marginProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(Profit_Average)); + + } + + } + + calculateProfitAmount( i, details){ + + let sales_average = details.value.estimate_sales_average; + + let estimate_net_profit_from = details.value.estimate_net_profit_from; + let estimate_net_profit_to = details.value.estimate_net_profit_to; + + if (sales_average != '' && estimate_net_profit_from != '' && estimate_net_profit_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 profit_amount = (estimate_net_profit_to + estimate_net_profit_from)/2; + let Profit_percent = (profit_amount/sales_average)*100; + + details.controls.estimate_net_profit.setValue(Math.round(profit_amount)); + details.controls.estimate_net_profit_percent.setValue(Profit_percent); + + this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(profit_amount)); + + } + + // 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); + + // } + } + + calculateMarginLoss( i, details){ + + let sales_average = details.value.estimate_sales_average; + let estimate_loss_range_from = details.value.estimate_loss_range_from; + let estimate_loss_range_to = details.value.estimate_loss_range_to; + + if (sales_average != '' && estimate_loss_range_from != '' && estimate_loss_range_to != ''){ + + let loss_percent = (estimate_loss_range_to + estimate_loss_range_from)/2; + let loss_Average = (loss_percent*sales_average)/100; + + details.controls.estimate_loss_margin.setValue(Math.round(loss_Average)); + details.controls.estimate_loss_margin_percent.setValue(loss_percent); + + this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average)); + + } + + } + + 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_profit.setValue(Math.round(loss_amount)); + details.controls.estimate_net_profit_percent.setValue(loss_percent); + + this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount)); + + } + + // 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() { if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 1){ @@ -653,16 +1001,27 @@ 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; // } let records = this.financialForm.value; this._pd.saveForm(records).subscribe(data => { - this.notifier.notify('success', 'Saved Successfully.'); + if(data.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + // this.dialogRef.close(); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else{ + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } //this.dialogRef.close(); }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); }) } + validateAllFormFields(formGroup: FormGroup) { Object.keys(formGroup.controls).forEach(field => { const control = formGroup.get(field); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/neighbour-hood/neighbour-hood.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/neighbour-hood/neighbour-hood.component.ts index 2e827388d..e5c4a6ffc 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/neighbour-hood/neighbour-hood.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/neighbour-hood/neighbour-hood.component.ts @@ -26,7 +26,7 @@ export class NeighbourHoodComponent implements OnInit { {'id': 2,'name': "Negative"}, {'id': 3,'name': "Insufficient information provided"}]; amtInwords : any = []; - constructor(notifier: NotifierService, private _pd: PdTrigerService ,private _fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: any,) { + constructor(notifier: NotifierService, private _pd: PdTrigerService ,private _fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: any,private dialogRef: MatDialogRef) { this.pdid = this.data.pdmaster_details.pd_id; this.notifier = notifier; this.form_id = 19; @@ -209,6 +209,7 @@ export class NeighbourHoodComponent implements OnInit { let resultMessage:string=''; if (this._neighbourhoodForm.invalid) { this.validateAllFormFields(this._neighbourhoodForm); + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } else{ @@ -260,13 +261,15 @@ export class NeighbourHoodComponent implements OnInit { saveRecords.neighbour_reference_remark=formData.neighbour_reference_remark; this._pd.savePDFormDetailsWithID(saveRecords).subscribe( dataresult => { + // this.notifier.notify('success', resultMessage); if (dataresult.status == 200) { - this.notifier.notify('success', resultMessage); - + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); } - else { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - // this.errorMessage = "Some Thing Wents Wrong Try Again !"; + else{ + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts index d4ba70d4a..f1474c601 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts @@ -50,6 +50,7 @@ export class OtherIncomeComponent implements OnInit { private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; @@ -169,6 +170,7 @@ public viewerOptions: any = { } submitCurrentDetails() { if (!this.otherIncomeForm.valid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } let records: any = {}; @@ -184,8 +186,15 @@ public viewerOptions: any = { // console.log('data', records); this._pd.saveForm(records).subscribe(data => { - // console.log('data', data); - this.notifier.notify('success', 'Saved Successfully.'); + if(data.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); }) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts index 57dfaafdc..953ca9246 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts @@ -31,6 +31,7 @@ export class RentalInfoComponent implements OnInit { private _fb: FormBuilder, private _pd: PdTrigerService, private _aws:AwsService, + private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.notifier = notifier; @@ -180,13 +181,21 @@ export class RentalInfoComponent implements OnInit { rentalSubmit() { if (!this.rentalForm.valid) { + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } - console.log('form', this.rentalForm.value); + // console.log('form', this.rentalForm.value); let records = this.rentalForm.value; this._pd.saveForm(records).subscribe(data => { - console.log('data', data); - this.notifier.notify('success', 'Saved Successfully.'); + if (data.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() =>{ + this.dialogRef.close(); + },3000); + } + else{ + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); })