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

@ -42,7 +42,7 @@
<div [formGroupName]="s">
<div>
<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>
</div>
</div>
@ -56,15 +56,15 @@
<div [formGroupName]="s">
<div>
<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>
</div>
</div>
</div>
</div>
</div>
<!--jwell details
<div *ngIf="sup.get('assets_mode').value == 4">
<!--jwell details -->
<!--<div *ngIf="sup.get('assets_mode').value == 4">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<div *ngFor="let detail of sup['controls'].details['controls']; let s = index">
<div [formGroupName]="s">
@ -193,23 +193,6 @@
</mat-form-field>
</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 *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>
@ -223,17 +206,14 @@
</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 fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<div fxFlex="33">
<mat-form-field class="ml-xs example-full-width">
<mat-select placeholder="Is there a loan?"
formControlName="emi">
<mat-select placeholder="Is there a loan?" formControlName="emi">
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
</mat-select>
</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 *ngIf="sup.get('emi').value === 'yes'" fxFlex="33">
<mat-form-field class="ml-xs example-full-width">
@ -255,19 +235,15 @@
<div fxLayout="row" fxLayoutGap="12px" fxLayoutAlign="start none">
<div fxFlex="20">
<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>
</span>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</div>
</div>
</div>
<!--<div fxLayout="row">
<div fxFlex="60" class="pb-0 text-sm-left">

View File

@ -297,10 +297,10 @@ public m_investmentType = [];
return this._formBuilder.group({
assets_mode: ['', Validators.compose([Validators.required])],
details: this._formBuilder.array([]),
approximate_market_value: ['', Validators.compose([Validators.required])],
name_of_the_owner: ['', Validators.compose([Validators.required])],
purchase_year: ['', Validators.compose([Validators.required])],
purchase_month: ['', Validators.compose([Validators.required])],
approximate_market_value: ['', Validators.compose([])],
name_of_the_owner: ['', Validators.compose([])],
purchase_year: ['', Validators.compose([])],
purchase_month: ['', Validators.compose([])],
emi: [''],
emi_paid: [''],
elapsed_tenure: [''],
@ -323,12 +323,12 @@ public m_investmentType = [];
}
case '2': {
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;
}
case '3': {
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;
}
case '4': {
@ -371,7 +371,7 @@ public m_investmentType = [];
loadJwellDescription() {
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({
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({
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) {
return this._formBuilder.group({
assets_mode: [data.assets_mode, Validators.compose([Validators.required])],
details: this._formBuilder.array([]),
approximate_market_value: [data.approximate_market_value, Validators.compose([Validators.required])],
name_of_the_owner: [data.name_of_the_owner, Validators.compose([Validators.required])],
purchase_year: [data.purchase_year, Validators.compose([Validators.required])],
purchase_month: [data.purchase_month, Validators.compose([Validators.required])],
approximate_market_value: [data.approximate_market_value, Validators.compose([])],
name_of_the_owner: [data.name_of_the_owner, Validators.compose([])],
purchase_year: [data.purchase_year, Validators.compose([])],
purchase_month: [data.purchase_month, Validators.compose([])],
emi: [data.emi || 0],
emi_paid: [data.emi_paid || ''],
elapsed_tenure: [data.elapsed_tenure || ''],
@ -519,12 +532,12 @@ public m_investmentType = [];
}
case '2': {
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;
}
case '3': {
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;
}
case '4': {

View File

@ -33,63 +33,98 @@ export class ClientInfoComponent implements OnInit {
public _clientQuesFrom: FormGroup;
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= [
{
'id': "1",
'name': 'Daily'
},
{
'id': "2",
'name': 'Weekly'
},
{
'id': "3",
'name': 'Monthly'
},
{
'id': "4",
'name': 'Every 3 months'
},
{
'id': "5",
'name': 'Half yearly'
},
{
'id': "6",
'name': 'Yearly'
},
{
'id': "7",
'name': 'As and when required'
},
{
'id': "8",
'name': 'Others'
}
]
public m_paymentModeType= [];
// 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_freqOfPurchase= [
// {
// 'id': "1",
// 'name': 'Daily'
// },
// {
// 'id': "2",
// 'name': 'Weekly'
// },
// {
// 'id': "3",
// 'name': 'Monthly'
// },
// {
// 'id': "4",
// '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(
private _formBuilder: FormBuilder,
private pdTrigerService: PdTrigerService) { }
ngOnInit() {
this.getM_FreqOfPurchase();
this.getM_PaymentModeType();
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;
getClientFormDetails() {
this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '2').subscribe(

View File

@ -3,7 +3,7 @@
<p>Current Loan Details</p>
<form [formGroup]="currentLoanForm" class="address">
<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">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>

View File

@ -49,11 +49,14 @@ export class CurrentLoanComponent implements OnInit {
console.log('value', value);
const control = <FormArray>this.currentLoanForm.controls['loan_details'];
if (value.status == 200) {
this.currentLoanForm.controls['existing_loan'].setValue(value.records.existing_loan);
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];
});
this.currentLoanForm.controls['existing_loan'].setValue(value.records.existing_loan);
this.currentLoanForm.controls['currentloan_remarks'].setValue(value.records.currentloan_remarks);
if (result.length > 0) {
result.forEach(val => {
control.push(this.createLoanDetail());
@ -62,6 +65,7 @@ export class CurrentLoanComponent implements OnInit {
} else {
control.push(this.createLoanDetail());
}
}
} else {
control.push(this.createLoanDetail());
}
@ -74,6 +78,16 @@ export class CurrentLoanComponent implements OnInit {
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() {
return this.fb.group({
loan_amount: ['', Validators.compose([Validators.required])],
@ -94,6 +108,7 @@ export class CurrentLoanComponent implements OnInit {
}
submitCurrentloan() {
if (!this.currentLoanForm.valid) {
console.log("data invalid")
return;
}
let records: any = {};
@ -102,7 +117,9 @@ export class CurrentLoanComponent implements OnInit {
records.fk_createdby = this.pdid;
records.existing_loan = this.currentLoanForm.controls['existing_loan'].value;
records.currentloan_remarks = this.currentLoanForm.controls['currentloan_remarks'].value;
if (records.existing_loan == 'Yes') {
records.loan_details = this.currentLoanForm.controls['loan_details'].value;
}
console.log('data', records);
this._pd.saveForm(records).subscribe(data => {
console.log('data', data);