diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html index df33a08dc..ca2995d5d 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html @@ -102,11 +102,13 @@
+ formControlName="vintage_year" OnlyNumber type="text" (change)="checkWithExistBusinessYear(itemrow,$event.target.value,i)"> + {{yearErrorMessage[i]}} + formControlName="vintage_month" OnlyNumber type="text" (change)="ConvertMonthintoYear(itemrow,$event.target.value,i)"> + {{monthErrorMessage[i]}}
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts index bc6dc9f84..0c34fbeae 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts @@ -52,6 +52,12 @@ export class BusinessBankingDetailsComponent implements OnInit { existCompanyList: any = []; mergeCompanyApplicant: any = []; company_id: String; + + generalExistBusinessYear: Number; + generalExistBusinessMonth: Number; + yearErrorMessage: any = []; + monthErrorMessage: any = []; + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, @@ -70,6 +76,8 @@ export class BusinessBankingDetailsComponent implements OnInit { this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + this.generalExistBusinessYear = this.pd_all_details.business_years; + this.generalExistBusinessMonth = this.pd_all_details.business_month; } public viewerOptions: any = { @@ -122,33 +130,6 @@ export class BusinessBankingDetailsComponent implements OnInit { this.salaryField = this.pd_cus_segment.substring(0, 2) == 'SE' ? false : true; - this._pd.retriveForm({'pd_id':this.pdid,'pd_form_id':13,'company_id':this.company_id}).subscribe(data => { - // let businessVal = data.records; - // console.log('businessVal',businessVal,data.records.partners); - if (data.status == 200) { - let PartnrArray = Object.keys(data.records.partners).map(function (key) { - return data.records.partners[key]; - }); - console.log(PartnrArray); - console.log(data.records.partners); - PartnrArray.forEach((datas,index) => { - let sum1 = PartnrArray.map(officer => officer.Current_business_experiance_month).reduce((sum, val) => sum + +val, 0); - // console.log('SumOfYear',SumOfYear); - // console.log('SumOfMonth',SumOfMonth); - }); - - // let SumOfYear = PartnrArray[index].Current_business_experiance_month.reduce((sum, val) => sum + +val, 0); - // let SumOfMonth = PartnrArray[index].Current_business_experiance_year.reduce((sum, val) => sum + +val, 0); - - // let SumOfYear = month.reduce((sum, val) => sum + +val, 0); - // let SumOfMonth = year.reduce((sum, val) => sum + +val, 0); - - let sum1 = PartnrArray.map(arr => arr.map(data => data.Current_business_experiance_month).reduce((sum, val) => sum + +val, 0)) - console.log('sum1',sum1); - - } - }); - let params: any = {}; params.pd_id = this.pdid; params.pd_form_id = '21'; @@ -330,17 +311,48 @@ export class BusinessBankingDetailsComponent implements OnInit { } } + + checkWithExistBusinessYear(itemrow,e, i) { + + if (+e > this.generalExistBusinessYear) { + this.yearErrorMessage[i] = "Higher than Business Vintage"; + itemrow.controls.vintage_year.setValue(''); + } + else { + this.yearErrorMessage[i] = ''; + } + } + /** To Convert Month into Year */ - ConvertMonthintoYear(itemrow, e) { + ConvertMonthintoYear(itemrow, e,i) { let year = itemrow.controls.vintage_year.value; let converted_month: number = e % 12; let converted_year: number = e / 12; + let Year = +year + +Math.floor(converted_year); + + if (Year > this.generalExistBusinessYear) { + this.yearErrorMessage[i] = "Higher than Business Vintage"; + itemrow.controls.vintage_year.setValue(''); + itemrow.controls.vintage_month.setValue(''); + + } + else { + if (Year == this.generalExistBusinessYear && +converted_month > this.generalExistBusinessMonth) { + this.monthErrorMessage[i] = "Higher than Business Vintage"; + itemrow.controls.vintage_year.setValue(''); + itemrow.controls.vintage_month.setValue(''); + + } else { + this.monthErrorMessage[i] = ''; + this.yearErrorMessage[i] = ''; + itemrow.controls.vintage_year.setValue(Year); + itemrow.controls.vintage_month.setValue(Math.floor(converted_month)); + } + } - itemrow.controls.vintage_year.setValue(+year + +Math.floor(converted_year)); - itemrow.controls.vintage_month.setValue(Math.floor(converted_month)); } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html index a99a6439b..f48d6bb09 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html @@ -41,6 +41,7 @@ Select Add Stock Details No Stock Observed + Stock not required to be maintained @@ -97,6 +98,7 @@ Select Yes No + Not Applicable @@ -125,6 +127,7 @@ Select Add Stock Details No Stock Observed + Stock not required to be maintained @@ -200,6 +203,7 @@ Select Add Stock Details No Stock Observed + Stock not required to be maintained @@ -278,6 +282,7 @@ Select Add Stock Details No stock observed + Stock not required to be maintained @@ -341,6 +346,7 @@ Select Yes No + Not Applicable diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts index ca8550641..050a9fe1f 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts @@ -144,6 +144,7 @@ export class StockComponent implements OnInit { this._pd.retriveForm(params).subscribe(value => { if (value.status == 200) { let dataForm = value.records; + console.log(value.records); if (dataForm !== undefined) { this.stockForms = this.fb.group({ pdid: [this.pdid], @@ -747,27 +748,55 @@ export class StockComponent implements OnInit { RetailCounterArray: any = []; WholeSaleCounterArray: any = []; + not_stock_of_rm: any = []; + not_stock_of_fg: any = []; + not_stock_of_tg: any = []; + not_stock_of_ws: any = []; + checkComments(value, flag, index) { + + if (flag == 1) { - this.ManufacturingCounterArray[index] = value == "yes" ? 1 : 0 + this.ManufacturingCounterArray[index] = value == "yes" ? 1 : 0; + this.not_stock_of_rm[index] = value == "stock not required to be maintained" ? 1 : 0; + let RMOverallCount = this.ManufacturingCounterArray.reduce((sum, val) => sum + +val, 0); this.RMCommentCard = RMOverallCount > 0 ? true : false; + + let not_stock1 = this.not_stock_of_rm.reduce((sum, val) => sum + +val, 0); + if(not_stock1 > 0){ this.stockForms.controls['manufacturing_details']['controls'][0].controls['is_sufficiant_raw'].setValue('not applicable') } } if (flag == 2) { this.FinishedCounterArray[index] = value == "yes" ? 1 : 0 + this.not_stock_of_fg[index] = value == "stock not required to be maintained" ? 1 : 0; } if (flag == 3) { this.RetailCounterArray[index] = value == "yes" ? 1 : 0 + this.not_stock_of_tg[index] = value == "stock not required to be maintained" ? 1 : 0; } if (flag == 4) { this.WholeSaleCounterArray[index] = value == "yes" ? 1 : 0 + this.not_stock_of_ws[index] = value == "stock not required to be maintained" ? 1 : 0; } let FGOverallCount = this.FinishedCounterArray.reduce((sum, val) => sum + +val, 0); let RTGOverallCount = this.RetailCounterArray.reduce((sum, val) => sum + +val, 0); let WTGOverallCount = this.WholeSaleCounterArray.reduce((sum, val) => sum + +val, 0); let TGOverallCount = FGOverallCount + RTGOverallCount + WTGOverallCount; this.TGCommentCard = TGOverallCount > 0 ? true : false; + + let not_stock_fg = this.not_stock_of_rm.reduce((sum, val) => sum + +val, 0); + let not_stock_rt = this.not_stock_of_rm.reduce((sum, val) => sum + +val, 0); + let not_stock_tg = this.not_stock_of_rm.reduce((sum, val) => sum + +val, 0); + let not_stock2 = not_stock_fg + not_stock_rt + not_stock_tg; + + if(not_stock2 > 0){ + this.stockForms.controls['is_sufficiant_finished_and_traded_goods'].setValue('not applicable'); + } + // else if(not_stock == 0){ + // this.stockForms.controls['is_sufficiant_finished_and_traded_goods'].setValue(''); + // } + } // checkComments(e,flag,index){