assets , current loan details changes : kdk

This commit is contained in:
dineshkumarkannan 2018-11-17 10:33:52 +05:30
parent 606715f979
commit ec5044bb9f
5 changed files with 335 additions and 294 deletions

View File

@ -1,6 +1,6 @@
<!--<pre> {{ m_group | json}}</pre>--> <!--<pre> {{ m_group | json}}</pre>-->
<mat-card style="min-height: 550px;" > <mat-card style="min-height: 550px;">
<mat-card-content> <mat-card-content>
<p>Assets Details</p> <p>Assets Details</p>
<form *ngIf="apiLoadFinish && loadDetails" [formGroup]="_assetsQuesFrom" (submit)="onSubmit()" novalidate> <form *ngIf="apiLoadFinish && loadDetails" [formGroup]="_assetsQuesFrom" (submit)="onSubmit()" novalidate>
@ -42,7 +42,7 @@
<div [formGroupName]="s"> <div [formGroupName]="s">
<div> <div>
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<input matInput placeholder="Manufacturer, Model" formControlName="manufacturer_model"> <input matInput placeholder="Manufacturer, Model" formControlName="manufacturer_model_four_weeler">
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
@ -56,15 +56,15 @@
<div [formGroupName]="s"> <div [formGroupName]="s">
<div> <div>
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<input matInput placeholder="Manufacturer, Model" formControlName="manufacturer_model"> <input matInput placeholder="Manufacturer, Model" formControlName="manufacturer_model_two_weeler">
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!--jwell details <!--jwell details -->
<div *ngIf="sup.get('assets_mode').value == 4"> <!--<div *ngIf="sup.get('assets_mode').value == 4">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none"> <div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<div *ngFor="let detail of sup['controls'].details['controls']; let s = index"> <div *ngFor="let detail of sup['controls'].details['controls']; let s = index">
<div [formGroupName]="s"> <div [formGroupName]="s">
@ -193,23 +193,6 @@
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
<!--<div *ngIf="sup.get('assets_mode').value == 1 || sup.get('assets_mode').value == 2 || sup.get('assets_mode').value == 3 || sup.get('assets_mode').value == 5">
<div fxFlex="33">
<div>
<label>Year and Month of Purchase?</label>
<br>
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field>
<input matInput type="number" placeholder="Year" formControlName="purchase_year">
</mat-form-field>
<mat-form-field>
<input matInput type="number" placeholder="Month" formControlName="purchase_month">
</mat-form-field>
</div>
</div>
</div>
</div>-->
</div> </div>
<div *ngIf="sup.get('assets_mode').value == 1 || sup.get('assets_mode').value == 2 || sup.get('assets_mode').value == 3 || sup.get('assets_mode').value == 5"> <div *ngIf="sup.get('assets_mode').value == 1 || sup.get('assets_mode').value == 2 || sup.get('assets_mode').value == 3 || sup.get('assets_mode').value == 5">
<label>Year and Month of Purchase?</label> <label>Year and Month of Purchase?</label>
@ -223,17 +206,14 @@
</div> </div>
</div> </div>
<div *ngIf="sup.get('assets_mode').value == 1 || sup.get('assets_mode').value == 2 || sup.get('assets_mode').value == 3 || sup.get('assets_mode').value == 4 || sup.get('assets_mode').value == 5"> <div *ngIf="sup.get('assets_mode').value == 1 || sup.get('assets_mode').value == 2 || sup.get('assets_mode').value == 3 || sup.get('assets_mode').value == 4 || sup.get('assets_mode').value == 5">
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none"> <div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<div fxFlex="33"> <div fxFlex="33">
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<mat-select placeholder="Is there a loan?" <mat-select placeholder="Is there a loan?" formControlName="emi">
formControlName="emi">
<mat-option value="yes">Yes</mat-option> <mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option> <mat-option value="no">No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<!--<mat-checkbox formControlName="emi" [ngModel]="sup.get('emi').value === '1' ? true : false" (ngModelChange)="sup.get('emi').value = $event ? '1' : '0'">Is there a loan?</mat-checkbox>-->
</div> </div>
<div *ngIf="sup.get('emi').value === 'yes'" fxFlex="33"> <div *ngIf="sup.get('emi').value === 'yes'" fxFlex="33">
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
@ -255,19 +235,15 @@
<div fxLayout="row" fxLayoutGap="12px" fxLayoutAlign="start none"> <div fxLayout="row" fxLayoutGap="12px" fxLayoutAlign="start none">
<div fxFlex="20"> <div fxFlex="20">
<span *ngIf="_assetsQuesFrom.controls.assets_details.controls.length > 1" (click)="removeLanguage(i)"> <span *ngIf="_assetsQuesFrom.controls.assets_details.controls.length > 1" (click)="removeLanguage(i)">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</div> </div>
</div> </div>
</div> </div>
<!--<div fxLayout="row"> <!--<div fxLayout="row">
<div fxFlex="60" class="pb-0 text-sm-left"> <div fxFlex="60" class="pb-0 text-sm-left">

View File

@ -297,10 +297,10 @@ public m_investmentType = [];
return this._formBuilder.group({ return this._formBuilder.group({
assets_mode: ['', Validators.compose([Validators.required])], assets_mode: ['', Validators.compose([Validators.required])],
details: this._formBuilder.array([]), details: this._formBuilder.array([]),
approximate_market_value: ['', Validators.compose([Validators.required])], approximate_market_value: ['', Validators.compose([])],
name_of_the_owner: ['', Validators.compose([Validators.required])], name_of_the_owner: ['', Validators.compose([])],
purchase_year: ['', Validators.compose([Validators.required])], purchase_year: ['', Validators.compose([])],
purchase_month: ['', Validators.compose([Validators.required])], purchase_month: ['', Validators.compose([])],
emi: [''], emi: [''],
emi_paid: [''], emi_paid: [''],
elapsed_tenure: [''], elapsed_tenure: [''],
@ -323,12 +323,12 @@ public m_investmentType = [];
} }
case '2': { case '2': {
const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray; const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray;
control.push(this.load_Two_Four_Weeler()); control.push(this.load_Four_Weeler());
break; break;
} }
case '3': { case '3': {
const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray; const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray;
control.push(this.load_Two_Four_Weeler()); control.push(this.load_Two_Weeler());
break; break;
} }
case '4': { case '4': {
@ -371,7 +371,7 @@ public m_investmentType = [];
loadJwellDescription() { loadJwellDescription() {
return this._formBuilder.group({ return this._formBuilder.group({
jwell_description: ['', Validators.compose([Validators.required])] jwell_description: ['', Validators.compose([])]
}); });
} }
@ -405,9 +405,15 @@ public m_investmentType = [];
}); });
} }
load_Two_Four_Weeler() { load_Four_Weeler() {
return this._formBuilder.group({ return this._formBuilder.group({
manufacturer_model: ['', Validators.compose([Validators.required])] manufacturer_model_four_weeler: ['', Validators.compose([Validators.required])]
});
}
load_Two_Weeler() {
return this._formBuilder.group({
manufacturer_model_two_weeler: ['', Validators.compose([Validators.required])]
}); });
} }
@ -455,21 +461,28 @@ public m_investmentType = [];
}); });
} }
load_Two_Four_WeelerWithData(data) { load_Four_WeelerWithData(data) {
return this._formBuilder.group({ return this._formBuilder.group({
manufacturer_model: [data.manufacturer_model, Validators.compose([Validators.required])] manufacturer_model_four_weeler: [data.manufacturer_model_four_weeler, Validators.compose([Validators.required])]
}); });
} }
load_Two_WeelerWithData(data) {
return this._formBuilder.group({
manufacturer_model_two_weeler: [data.manufacturer_model_two_weeler, Validators.compose([Validators.required])]
});
}
initDetailsWithdata(data) { initDetailsWithdata(data) {
return this._formBuilder.group({ return this._formBuilder.group({
assets_mode: [data.assets_mode, Validators.compose([Validators.required])], assets_mode: [data.assets_mode, Validators.compose([Validators.required])],
details: this._formBuilder.array([]), details: this._formBuilder.array([]),
approximate_market_value: [data.approximate_market_value, Validators.compose([Validators.required])], approximate_market_value: [data.approximate_market_value, Validators.compose([])],
name_of_the_owner: [data.name_of_the_owner, Validators.compose([Validators.required])], name_of_the_owner: [data.name_of_the_owner, Validators.compose([])],
purchase_year: [data.purchase_year, Validators.compose([Validators.required])], purchase_year: [data.purchase_year, Validators.compose([])],
purchase_month: [data.purchase_month, Validators.compose([Validators.required])], purchase_month: [data.purchase_month, Validators.compose([])],
emi: [data.emi || 0], emi: [data.emi || 0],
emi_paid: [data.emi_paid || ''], emi_paid: [data.emi_paid || ''],
elapsed_tenure: [data.elapsed_tenure || ''], elapsed_tenure: [data.elapsed_tenure || ''],
@ -519,12 +532,12 @@ public m_investmentType = [];
} }
case '2': { case '2': {
const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray; const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray;
control.push(this.load_Two_Four_WeelerWithData(data)); control.push(this.load_Four_WeelerWithData(data));
break; break;
} }
case '3': { case '3': {
const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray; const control = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray;
control.push(this.load_Two_Four_WeelerWithData(data)); control.push(this.load_Two_WeelerWithData(data));
break; break;
} }
case '4': { case '4': {

View File

@ -33,63 +33,98 @@ export class ClientInfoComponent implements OnInit {
public _clientQuesFrom: FormGroup; public _clientQuesFrom: FormGroup;
public submitted = false; public submitted = false;
public m_paymentModeType= [
{
'id': "1",
'name': 'Immediate Or Advanced Payment'
},
{
'id': "2",
'name': 'Credit'
},
{
'id': "3",
'name': 'Combination of Both'
},
];
public m_freqOfPurchase= [ public m_paymentModeType= [];
{ // public m_paymentModeType= [
'id': "1", // {
'name': 'Daily' // 'id': "1",
}, // 'name': 'Immediate Or Advanced Payment'
{ // },
'id': "2", // {
'name': 'Weekly' // 'id': "2",
}, // 'name': 'Credit'
{ // },
'id': "3", // {
'name': 'Monthly' // 'id': "3",
}, // 'name': 'Combination of Both'
{ // },
'id': "4", // ];
'name': 'Every 3 months' public m_freqOfPurchase= [];
}, // public m_freqOfPurchase= [
{ // {
'id': "5", // 'id': "1",
'name': 'Half yearly' // 'name': 'Daily'
}, // },
{ // {
'id': "6", // 'id': "2",
'name': 'Yearly' // 'name': 'Weekly'
}, // },
{ // {
'id': "7", // 'id': "3",
'name': 'As and when required' // 'name': 'Monthly'
}, // },
{ // {
'id': "8", // 'id': "4",
'name': 'Others' // 'name': 'Every 3 months'
} // },
] // {
// 'id': "5",
// 'name': 'Half yearly'
// },
// {
// 'id': "6",
// 'name': 'Yearly'
// },
// {
// 'id': "7",
// 'name': 'As and when required'
// },
// {
// 'id': "8",
// 'name': 'Others'
// }
// ]
constructor( constructor(
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private pdTrigerService: PdTrigerService) { } private pdTrigerService: PdTrigerService) { }
ngOnInit() { ngOnInit() {
this.getM_FreqOfPurchase();
this.getM_PaymentModeType();
this.getClientFormDetails(); this.getClientFormDetails();
} }
// ==================
getM_FreqOfPurchase() {
this.pdTrigerService.getAllMasterDatas('FREQUENCY').subscribe(
data => {
this.m_freqOfPurchase = data.records.filter(data => data.isactive == 1);
},
error => {
// this.notifier.notify('warning', 'No Category Records Found.!');
// this.m_assets_type = "No Category Records Found.";
}
)
}
getM_PaymentModeType() {
this.pdTrigerService.getAllMasterDatas('PAYMENTMODE').subscribe(
data => {
this.m_paymentModeType = data.records.filter(data => data.isactive == 1);
},
error => {
// this.notifier.notify('warning', 'No Category Records Found.!');
// this.m_assets_type = "No Category Records Found.";
}
)
}
// ==================
apiLoadFinish: boolean = false; apiLoadFinish: boolean = false;
getClientFormDetails() { getClientFormDetails() {
this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '2').subscribe( this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '2').subscribe(

View File

@ -3,7 +3,7 @@
<p>Current Loan Details</p> <p>Current Loan Details</p>
<form [formGroup]="currentLoanForm" class="address"> <form [formGroup]="currentLoanForm" class="address">
<mat-form-field> <mat-form-field>
<mat-select placeholder="Do you have any other existing loan" <mat-select (selectionChange)="selectedLoanChanges($event)" placeholder="Do you have any other existing loan"
formControlName="existing_loan"> formControlName="existing_loan">
<mat-option value="Yes">Yes</mat-option> <mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option> <mat-option value="No">No</mat-option>

View File

@ -21,7 +21,7 @@ import {
} from '@angular/material'; } from '@angular/material';
/** Service */ /** Service */
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
import {ActivatedRoute, Router} from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
@Component({ @Component({
selector: 'app-current-loan', selector: 'app-current-loan',
@ -49,11 +49,14 @@ export class CurrentLoanComponent implements OnInit {
console.log('value', value); console.log('value', value);
const control = <FormArray>this.currentLoanForm.controls['loan_details']; const control = <FormArray>this.currentLoanForm.controls['loan_details'];
if (value.status == 200) { if (value.status == 200) {
var result = Object.keys(value.records.loan_details).map(function(key) {
return value.records.loan_details[key];
});
this.currentLoanForm.controls['existing_loan'].setValue(value.records.existing_loan); this.currentLoanForm.controls['existing_loan'].setValue(value.records.existing_loan);
this.currentLoanForm.controls['currentloan_remarks'].setValue(value.records.currentloan_remarks); this.currentLoanForm.controls['currentloan_remarks'].setValue(value.records.currentloan_remarks);
if (value.records.existing_loan == 'Yes') {
var result = Object.keys(value.records.loan_details).map(function (key) {
return value.records.loan_details[key];
});
if (result.length > 0) { if (result.length > 0) {
result.forEach(val => { result.forEach(val => {
control.push(this.createLoanDetail()); control.push(this.createLoanDetail());
@ -62,6 +65,7 @@ export class CurrentLoanComponent implements OnInit {
} else { } else {
control.push(this.createLoanDetail()); control.push(this.createLoanDetail());
} }
}
} else { } else {
control.push(this.createLoanDetail()); control.push(this.createLoanDetail());
} }
@ -74,6 +78,16 @@ export class CurrentLoanComponent implements OnInit {
loan_details: this.fb.array([]), loan_details: this.fb.array([]),
}); });
} }
selectedLoanChanges(e): void {
if (e.value == 'Yes') {
const control = <FormArray>this.currentLoanForm.controls['loan_details'];
control.push(this.createLoanDetail());
} else if (e.value == 'No') {
const arr = <FormArray>this.currentLoanForm.controls.loan_details;
arr.removeAt(0);
}
}
createLoanDetail() { createLoanDetail() {
return this.fb.group({ return this.fb.group({
loan_amount: ['', Validators.compose([Validators.required])], loan_amount: ['', Validators.compose([Validators.required])],
@ -94,6 +108,7 @@ export class CurrentLoanComponent implements OnInit {
} }
submitCurrentloan() { submitCurrentloan() {
if (!this.currentLoanForm.valid) { if (!this.currentLoanForm.valid) {
console.log("data invalid")
return; return;
} }
let records: any = {}; let records: any = {};
@ -102,7 +117,9 @@ export class CurrentLoanComponent implements OnInit {
records.fk_createdby = this.pdid; records.fk_createdby = this.pdid;
records.existing_loan = this.currentLoanForm.controls['existing_loan'].value; records.existing_loan = this.currentLoanForm.controls['existing_loan'].value;
records.currentloan_remarks = this.currentLoanForm.controls['currentloan_remarks'].value; records.currentloan_remarks = this.currentLoanForm.controls['currentloan_remarks'].value;
if (records.existing_loan == 'Yes') {
records.loan_details = this.currentLoanForm.controls['loan_details'].value; records.loan_details = this.currentLoanForm.controls['loan_details'].value;
}
console.log('data', records); console.log('data', records);
this._pd.saveForm(records).subscribe(data => { this._pd.saveForm(records).subscribe(data => {
console.log('data', data); console.log('data', data);
@ -115,7 +132,7 @@ export class CurrentLoanComponent implements OnInit {
Object.keys(formGroup.controls).forEach(field => { Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field); const control = formGroup.get(field);
if (control instanceof FormControl) { if (control instanceof FormControl) {
control.markAsTouched({onlySelf: true}); control.markAsTouched({ onlySelf: true });
} else if (control instanceof FormGroup) { } else if (control instanceof FormGroup) {
this.validateAllFormFields(control); this.validateAllFormFields(control);
} }