form clubed

This commit is contained in:
venbatechnologies@gmail.com 2021-10-29 21:21:02 +05:30
parent 16567a3558
commit b126685d12
2 changed files with 287 additions and 13 deletions

View File

@ -81,11 +81,12 @@
</button>
</div>
</h2>
<mat-dialog-content style="border-bottom: 2px solid #e2412f8f;">
<mat-dialog-content style="border-bottom: 2px solid red;">
<mat-tab-group>
<mat-tab label="Details">
<mat-card>
<div style="border: 2px solid rgb(223, 213, 213);">
<mat-card-content>
<mat-form-field style="width:60% !important;">
<mat-select placeholder="Is the Banking Infomation Available" formControlName="bank_info_available" (selectionChange)="onChangeAvailable($event.value)">
@ -183,17 +184,27 @@
<label>Number of Years / Months since account was started</label>
<br>
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field>
<mat-form-field style="padding-top: 8px;">
<mat-label>Year</mat-label>
<input matInput placeholder="No of years (Eg. 10)" autocomplete="off"
formControlName="vintage_year" OnlyNumber type="text">
</mat-form-field>
<mat-form-field>
<mat-form-field style="padding-top: 8px;">
<mat-label>Month</mat-label>
<input matInput placeholder="No of months (Eg. 6)" autocomplete="off"
formControlName="vintage_month" OnlyNumber type="text" (change)="ConvertMonthintoYear(itemrow,$event.target.value)">
formControlName="vintage_month" OnlyNumber type="text" (change)="ConvertMonthintoYear(itemrow1,$event.target.value)">
</mat-form-field>
<mat-form-field >
<mat-select placeholder="Is this same AC used for?
" formControlName="same_ac_used_for">
<mat-option>Select</mat-option>
<mat-option value="personal">Personal</mat-option>
<mat-option value="business">Business</mat-option>
<mat-option value="both">Both</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<mat-action-row>
<div fxFlex="100" align="center">
@ -229,6 +240,152 @@
</div>
</mat-card-content>
</div>
<div style="border: 2px solid rgb(223, 213, 213);">
<mat-card-content>
<mat-form-field style="width:60% !important;">
<mat-select placeholder="Is the Business Infomation Available" formControlName="bank_info_available_business" (selectionChange)="onChangeAvailablebusiness($event.value)">
<mat-option>Select</mat-option>
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<div formArrayName="itemRows1" autocomplete="off">
<mat-accordion *ngFor="let itemrow1 of bankingForm.controls.itemRows1['controls']; let l=index;let last=last"
[formGroupName]="l">
<mat-expansion-panel class="banlFields" [expanded]="step == l">
<mat-expansion-panel-header>
<mat-panel-title>
<p>Business Details {{l+1}}
</p>
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<mat-select placeholder="Account Holders Name" formControlName="applicant_name_business"
[compareWith]="compareObjects">
<mat-option>Select</mat-option>
<mat-optgroup *ngFor="let group of mergeCompanyApplicant" [label]="group.groupName">
<mat-option *ngFor="let val of group.groupValues" [value]="val">
{{val.group_id != 2 ? val.name : val.name | titlecase}}
</mat-option>
</mat-optgroup>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="checkOthers1(itemrow1.get('applicant_name_business').value)===true"
style="width:45%">
<input matInput placeholder="Specify Account Holders Name" formControlName="other_applicant_business"
autocomplete="off" [value]="itemrow1.get('other_applicant_business').value" appCustomTitleCase>
<mat-error *ngIf="itemrow1.controls['other_applicant_business'].hasError('required')">Applicant Name Required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="Bank Name" formControlName="bank_name_business">
<mat-option>
<ngx-mat-select-search [formControl]="bankFilterCtrl"
[placeholderLabel]="'Search Bank...'"
[noEntriesFoundLabel]="'no matching records found'"></ngx-mat-select-search>
</mat-option>
<mat-option>Select</mat-option>
<mat-option *ngFor="let btLen of filtered_m_btLenderList | async" [value]="btLen.bt_lender_list_id">{{
btLen.lender_name }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="itemrow1.get('bank_name_business').value == 1">
<input matInput placeholder="Specify Bank Name" formControlName="other_bank_business"
autocomplete="off">
<mat-error *ngIf="itemrow1.controls['other_bank_business'].hasError('required')">Bank Name Required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select (selectionChange)="selectedAccTypeChanges($event.value,i)"
placeholder="Account Type" formControlName="account_type_business">
<mat-option>Select</mat-option>
<mat-option *ngFor="let prop of m_accountType" [value]="prop.id">{{
prop.name }}</mat-option>
</mat-select>
</mat-form-field>
<!--<mat-form-field *ngIf="pd_cus_segment!='SAL'">
<mat-select placeholder="Is this the main business account"
formControlName="is_main" >
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>-->
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field style="width: 35%;" *ngIf="salaryField">
<mat-select placeholder="Salary Credited in this account" formControlName="salary_business">
<mat-option>Select</mat-option>
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
<mat-option value="NA">NA</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 45%;" *ngIf="this.limitCaseFlag[i]">
<!-- *ngIf="itemrow.get('account_type').value != 2">
<input matInput autocomplete="off" placeholder="Limit in case of OD / CC account"
formControlName="limit" OnlyNumber type="text" (keyup)="inWords($event,i,1)">
<mat-hint align="start" style="font-size:90%" *ngIf="itemrow.get('limit').value != ''">{{"&#8377;"}}
{{amtInwords[i]}} Only</mat-hint>-->
<input matInput autocomplete="off" placeholder="Limit in case of OD / CC account"
formControlName="limit_business" OnlyNumber type="text">
<mat-hint align="start" style="font-size:90%" *ngIf="itemrow1.get('limit').value != ''">{{"&#8377;"}} {{itemrow1.get('limit').value | numberToWords}} Only</mat-hint>
</mat-form-field>
</div>
<div>
<label>Number of Years / Months since account was started</label>
<br>
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field>
<mat-label>Year</mat-label>
<input matInput placeholder="No of years (Eg. 10)" autocomplete="off"
formControlName="vintage_year_business" OnlyNumber type="text">
</mat-form-field>
<mat-form-field>
<mat-label>Month</mat-label>
<input matInput placeholder="No of months (Eg. 6)" autocomplete="off"
formControlName="vintage_month_business" OnlyNumber type="text" (change)="ConvertMonthintoYear_business(itemrow1,$event.target.value)">
</mat-form-field>
</div>
</div>
<mat-action-row>
<div fxFlex="100" align="center">
<button type="button" mat-flat-button color="primary" (click)="addBusinessdetails(i, $event)"
matTooltip="Add More" matTooltipPosition="above" *ngIf="last">
<strong>Add More Business Details</strong>
</button>
</div>
<div align="right">
<button mat-raised-button mat-icon-button matTooltip="Delete Banking Details"
matTooltipPosition="above" (click)="deleteBusinessdetails(i)" *ngIf="bankingForm.controls.itemRows1.controls.length > 1">
<mat-icon>delete</mat-icon>
</button>
</div>
<!-- <button type="button" mat-button (click)="deleteBankdetails(i)" color="warn"
matTooltip="Delete"matTooltipPosition="left" *ngIf="!last">
<strong>Delete Banking Details</strong>
</button> -->
<!-- <button mat-button color="warn" (click)="prevStep()">Previous</button>
<button mat-button color="primary" (click)="nextStep()">End</button> -->
<!-- ngIf="i > 0" -->
</mat-action-row>
</mat-expansion-panel>
<!-- <div style="text-align: right;" class="pt-1" *ngIf="bankingForm.controls.itemRows['controls'].length == (i+1)">
<button class="mr-1 mb-1 hover-icon" color="primary" mat-raised-button mat-icon-button matTooltip="Add More Banking Details" matTooltipPosition="above" >
<mat-icon >add</mat-icon>
</button></div> -->
</mat-accordion>
</div>
</mat-card-content>
</div>
</mat-card>
</mat-tab>
<mat-tab label="Docs">
@ -285,6 +442,7 @@
</mat-tab>
</mat-tab-group>
</mat-dialog-content>
<mat-dialog-actions>
<div fxFlex="60" class="pb-0 text-sm-left" align="left">

View File

@ -38,6 +38,7 @@ export class BankingDetailsComponent implements OnInit {
pdid: number;
pageTitle: string = "Banking Details of Individuals";
public bankingForm: FormGroup;
public businessForm: FormGroup;
step: number;
private notifier: NotifierService;
public pd_cus_segment: string;
@ -104,18 +105,19 @@ export class BankingDetailsComponent implements OnInit {
ngOnInit() {
this.step = 0;
this.initBankingForm();
// this.initBusinessForm();
this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data => {
if (data.dataStatus) {
this.existCompanyList = data.records.filter(val => val.is_active === true);
}
// let modifyCompanyList : any=[];
// if(this.existCompanyList.length>0){
// modifyCompanyList = this.existCompanyList.map(element => {
// return {id:element.company_order_id.toString(),name:element.company_name,group_id:1};
// });
// this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:modifyCompanyList})
// }
let modifyCompanyList : any=[];
if(this.existCompanyList.length>0){
modifyCompanyList = this.existCompanyList.map(element => {
return {id:element.company_order_id.toString(),name:element.company_name,group_id:1};
});
this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:modifyCompanyList})
}
});
let modifyApplicantList: any = [];
@ -150,7 +152,14 @@ export class BankingDetailsComponent implements OnInit {
params.pd_id = this.pdid;
params.pd_form_id = '7';
this._pd.retriveForm(params).subscribe(data => {
console.log('itemrows');
console.log(this.bankingForm);
console.log(this.businessForm);
const control = <FormArray>this.bankingForm.controls['itemRows'];
const control1=<FormArray>this.bankingForm.controls['itemRows1'];
console.log('test');
console.log(control);
console.log(control1);
if (data.status == 200) {
this.bankingForm.controls.banking_form_remark.setValue(data.records.banking_form_remark);
let bank_info=data.records.hasOwnProperty('bank_info_available') ? data.records.bank_info_available == true ? 'Yes' : 'No' : 'Yes'
@ -167,8 +176,24 @@ export class BankingDetailsComponent implements OnInit {
this.selectedAccTypeChanges(+datas.account_type, index)
// this.emiAmtInwords[index] = this._pd.convertNumberToWords(val.emi);
control.push(this.createBankarray());
control1.push(this.createBusinessarray());
});
let reeult1=[{account_type: "1",bank_name: "60",
limit: "",
other_applicant: "",
other_bank: "",
salary: "",
vintage_month: "",
same_ac_used_for:"",
vintage_year: 18,applicant_name:{group_id: 2,
id: "5521",
name: "Test1"}}]
this.bankingForm.controls.itemRows.setValue(result);
//this.businessForm.controls.itemRows1.setValue(result);
// console.log(result);
//console.log('1va');
//console.log(this.bankingForm.controls.itemRows);
}
} else {
// control.push(this.createBankarray());
@ -227,9 +252,18 @@ export class BankingDetailsComponent implements OnInit {
this.bankingForm = this.fb.group({
banking_form_remark: [''],
bank_info_available:[''],
itemRows: this.fb.array([])
bank_info_available_business:[''],
itemRows: this.fb.array([]),
itemRows1: this.fb.array([]),
});
}
// public initBusinessForm():void{
// this.businessForm = this.fb.group({
// banking_form_remark_business: [''],
// bank_info_available_business:[''],
// itemRows1: this.fb.array([]),
// });
// }
createBankarray() {
return this.fb.group({
@ -238,6 +272,7 @@ export class BankingDetailsComponent implements OnInit {
bank_name: [''],
other_bank: [''],
account_type: [''],
//salary: [''],
salary: this.pd_cus_segment.substring(0, 2) == 'SE' ? [''] : [''],
limit: [''],
@ -247,6 +282,26 @@ export class BankingDetailsComponent implements OnInit {
// is_main: this.pd_cus_segment == 'SAL' ? [''] : [''],
vintage_year: [''],
vintage_month: [''],
same_ac_used_for:[''],
})
}
createBusinessarray()
{
return this.fb.group({
applicant_name_business: [''],
other_applicant_business: [''],
bank_name_business: [''],
other_bank_business: [''],
account_type_business: [''],
//salary: [''],
salary_business: this.pd_cus_segment.substring(0, 2) == 'SE' ? [''] : [''],
limit_business: [''],
//is_main: [''],
//is_main: [this.pd_cus_segment == 'SAL' ? '' : ''],
//is_main:[''],
// is_main: this.pd_cus_segment == 'SAL' ? [''] : [''],
vintage_year_business: [''],
vintage_month_business: [''],
});
}
@ -262,12 +317,30 @@ export class BankingDetailsComponent implements OnInit {
// this.bankingForm.controls.is_main.updateValueAndValidity();
// }
}
addBusinessdetails(index, event)
{
event.stopPropagation();
const control = <FormArray>this.bankingForm.controls['itemRows1'];
let length = control.length;
this.step = length;
control.push(this.createBusinessarray());
// if(this.pd_cus_segment != 'SAL') {
// this.bankingForm.controls.is_main.setValidators([Validators.required]);
// this.bankingForm.controls.is_main.updateValueAndValidity();
// }
}
deleteBankdetails(index: number) {
const control = <FormArray>this.bankingForm.controls['itemRows'];
control.removeAt(index);
}
deleteBusinessdetails(index: number) {
const control = <FormArray>this.bankingForm.controls['itemRows1'];
control.removeAt(index);
}
setStep(index: number) {
@ -277,6 +350,8 @@ export class BankingDetailsComponent implements OnInit {
bankSubmit() {
const control = <FormArray>this.bankingForm.controls.itemRows;
console.log('controlll');
console.log(control);
let CtrlLength = control.controls.length;
if (CtrlLength > 0) {
@ -327,7 +402,10 @@ export class BankingDetailsComponent implements OnInit {
records.bank_info_available=this.bankingForm.controls.bank_info_available.value == 'Yes' ? true : this.bankingForm.controls.bank_info_available.value == 'No' ? false : ''
// records.fk_createdby = '252';
records.banking_details = this.bankingForm.controls['itemRows'].value;
records.business_details=this.bankingForm.controls['itemRows1'].value;
console.log('record');
console.log(records);
return
this._pd.saveForm(records).subscribe(data => {
if (data.status == 200) {
this.notifier.notify('success', 'Saved Successfully.');
@ -385,6 +463,15 @@ export class BankingDetailsComponent implements OnInit {
return false;
}
}
checkOthers1(values) {
if (values != null) {
return values.id == 0 ? true : false;
}
else {
return false;
}
}
selectedAccTypeChanges(event: any, i) {
@ -415,6 +502,16 @@ export class BankingDetailsComponent implements OnInit {
itemrow.controls.vintage_month.setValue(Math.floor(converted_month));
}
ConvertMonthintoYear_business(itemrow1, e)
{
let year = itemrow1.controls.vintage_year_business.value;
let converted_month: number = e % 12;
let converted_year: number = e / 12;
itemrow1.controls.vintage_year_business.setValue(+year + +Math.floor(converted_year));
itemrow1.controls.vintage_month_business.setValue(Math.floor(converted_month));
}
pdf(fileURL){
window.open(fileURL);
@ -464,12 +561,31 @@ export class BankingDetailsComponent implements OnInit {
onChangeAvailable(value){
console.log(value)
const control = <FormArray>this.bankingForm.controls['itemRows'];
// const control1 = <FormArray>this.businessForm.controls['itemRows1'];
if(value == 'Yes'){
control.push(this.createBankarray())
// control1.push(this.createBusinessarray())
}
else{
while(control.length!=0){
control.removeAt(0)
// control1.removeAt(0)
}
}
}
onChangeAvailablebusiness(value){
console.log(value)
const control1 = <FormArray>this.bankingForm.controls['itemRows1'];
// const control1 = <FormArray>this.businessForm.controls['itemRows1'];
if(value == 'Yes'){
control1.push(this.createBusinessarray())
}
else{
while(control1.length!=0){
control1.removeAt(0)
// control1.removeAt(0)
}
}