Address and Financial : ps
This commit is contained in:
parent
2c91799dd6
commit
70f6310d1e
@ -51,7 +51,7 @@
|
|||||||
formControlName="locality_others">
|
formControlName="locality_others">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field style="width: 30%">
|
||||||
<mat-select placeholder="Approach to PD Location" formControlName="pd_location" required>
|
<mat-select placeholder="Approach to PD Location" formControlName="pd_location" required>
|
||||||
<mat-option value="{{data.pd_location_approach_id}}"
|
<mat-option value="{{data.pd_location_approach_id}}"
|
||||||
*ngFor="let data of locationdata">{{data.description}}
|
*ngFor="let data of locationdata">{{data.description}}
|
||||||
@ -59,7 +59,7 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field style="width: 30%">
|
||||||
<mat-select placeholder="Comment on Locality" formControlName="comment_locality" required>
|
<mat-select placeholder="Comment on Locality" formControlName="comment_locality" required>
|
||||||
<mat-option value="{{data.comments_on_locality_id}}"
|
<mat-option value="{{data.comments_on_locality_id}}"
|
||||||
*ngFor="let data of commentData">{{data.rating}}
|
*ngFor="let data of commentData">{{data.rating}}
|
||||||
@ -86,11 +86,15 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 4 ">
|
<mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 4 " style="width: 38%">
|
||||||
<input matInput placeholder="Specify Other Ownership" formControlName="other_ownership">
|
<input matInput placeholder="Specify Other Ownership" formControlName="other_ownership">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 3 " style="width: 38%">
|
||||||
|
<input matInput placeholder="What is the monthly rent paid?" formControlName="rent_amt">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 42%">
|
||||||
<mat-select placeholder="Is there any business activity is being run?"
|
<mat-select placeholder="Is there any business activity is being run?"
|
||||||
formControlName="bussiness_activity" required>
|
formControlName="bussiness_activity" required>
|
||||||
<mat-option value="yes">Yes</mat-option>
|
<mat-option value="yes">Yes</mat-option>
|
||||||
@ -98,18 +102,64 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'">
|
<mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'" style="width: 100%">
|
||||||
<mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type">
|
<!-- <mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type">
|
||||||
<mat-option value="{{m_addressType.address_type_id}}"
|
<mat-option value="{{m_addressType.address_type_id}}"
|
||||||
*ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
|
*ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
</mat-select> -->
|
||||||
|
<mat-select placeholder="Type of Premises" formControlName="bussiness_address_type" multiple>
|
||||||
|
<mat-option *ngFor="let m_addressType of addressData" [value]="m_addressType.address_type_id" (onSelectionChange)="SelectedPremises($event)" > {{m_addressType.address_type}} </mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field *ngIf="PremisesOtherFlag == true" style="width: 40%">
|
||||||
|
<input matInput placeholder="Specify Other Premises Type" formControlName="bussiness_address_type_others">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-card formArrayName="premises">
|
||||||
|
<div
|
||||||
|
*ngFor="let item of addressForm.controls.premises['controls']; let i = index;" [formGroupName]="i">
|
||||||
|
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>{{i+1}} . {{PremisesLabel[i]}}</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<mat-form-field style="width: 40%;">
|
||||||
|
<input matInput placeholder="Number Of Additional Units"
|
||||||
|
formControlName="no_of_additional_units">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field *ngIf="item.get('no_of_additional_units').value > 2" style="width: 40%;">
|
||||||
|
|
||||||
|
<mat-select placeholder="City" formControlName="premises_city"> <!--multiple (selectionChange)="relationChanged($event)"> -->
|
||||||
|
<mat-option *ngFor="let CL of cityData" [value]="CL.city_id">
|
||||||
|
{{CL.name}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field *ngIf="item.get('no_of_additional_units').value <= 2 && item.get('no_of_additional_units').value != '' " style="width: 40%;">
|
||||||
|
<mat-select placeholder="Ownership" formControlName="premises_ownership">
|
||||||
|
<mat-option value="{{ownerShip.id}}" *ngFor="let ownerShip of ownerShipData">
|
||||||
|
{{ownerShip.name}}
|
||||||
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field *ngIf="addressForm.controls['bussiness_address_type'].value == 12">
|
<!-- <mat-form-field *ngIf="addressForm.controls['premises_ownership'].value == 4 "> -->
|
||||||
<input matInput placeholder="Bussiness Address Type Others" formControlName="bussiness_address_type_others">
|
<mat-form-field *ngIf="item.get('premises_ownership').value == 4" style="width: 40%;">
|
||||||
|
<input matInput placeholder="Specify Other Ownership" formControlName="premises_ownership_others">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-form-field *ngIf="item.get('premises_ownership').value == 3" style="width: 40%;">
|
||||||
|
<input matInput placeholder="What is the monthly rent paid?" formControlName="premises_rent_amt">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Remarks"
|
||||||
|
formControlName="premises_remarks" style="width: 65%;">
|
||||||
|
</mat-form-field>
|
||||||
|
</mat-card-content>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
<!--- Don't Remove To replace atlast of the PD Completion and creating new form (Neighbourhood check) --
|
<!--- Don't Remove To replace atlast of the PD Completion and creating new form (Neighbourhood check) --
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
|
|||||||
@ -37,13 +37,23 @@ export class AddressComponent implements OnInit {
|
|||||||
|
|
||||||
loadDataStatus: boolean=true;
|
loadDataStatus: boolean=true;
|
||||||
|
|
||||||
|
PremisesOtherFlag:boolean;
|
||||||
|
PremisesLabel : any = [];
|
||||||
|
|
||||||
locationdata: any = [];
|
locationdata: any = [];
|
||||||
commentData: any = [];
|
commentData: any = [];
|
||||||
//customerData: any = []; 221118 review doc s.no 3.e
|
//customerData: any = []; 221118 review doc s.no 3.e
|
||||||
addressData:any = [];
|
addressData:any = [];
|
||||||
localityData:any = [];
|
localityData:any = [];
|
||||||
ownerShipData:any = [];
|
ownerShipData:any = [];
|
||||||
|
cityData:any = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
z = 0;
|
||||||
|
|
||||||
|
formPremisesArray: any = [];
|
||||||
|
relativeNames2: any = [];
|
||||||
//neighbourStatusData:any=["Yes","No"];
|
//neighbourStatusData:any=["Yes","No"];
|
||||||
//applicantOwnerData:any=["Yes","No","Dont Know"];
|
//applicantOwnerData:any=["Yes","No","Dont Know"];
|
||||||
|
|
||||||
@ -58,6 +68,7 @@ export class AddressComponent implements OnInit {
|
|||||||
public customerBehaviour: AbstractControl;
|
public customerBehaviour: AbstractControl;
|
||||||
public ownership: AbstractControl;
|
public ownership: AbstractControl;
|
||||||
public other_ownership: AbstractControl;
|
public other_ownership: AbstractControl;
|
||||||
|
public rent_amt : AbstractControl;
|
||||||
public bussinessActivity: AbstractControl;
|
public bussinessActivity: AbstractControl;
|
||||||
//constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , ) {
|
//constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , ) {
|
||||||
constructor(private el: ElementRef, notifier: NotifierService,
|
constructor(private el: ElementRef, notifier: NotifierService,
|
||||||
@ -81,6 +92,7 @@ export class AddressComponent implements OnInit {
|
|||||||
this.getMasterDetails('LOCALITY',4);
|
this.getMasterDetails('LOCALITY',4);
|
||||||
this.getMasterDetails('ADDRESSTYPE',5);
|
this.getMasterDetails('ADDRESSTYPE',5);
|
||||||
this.getMasterDetails('RESIDENCEOWNERSHIP',6);
|
this.getMasterDetails('RESIDENCEOWNERSHIP',6);
|
||||||
|
this.getMasterDetails('CITY',7);
|
||||||
this.initAddressForm();
|
this.initAddressForm();
|
||||||
let params: any = {};
|
let params: any = {};
|
||||||
params.pd_id = this.pdid;
|
params.pd_id = this.pdid;
|
||||||
@ -88,10 +100,12 @@ export class AddressComponent implements OnInit {
|
|||||||
this._pd.retriveForm(params).subscribe(data => {
|
this._pd.retriveForm(params).subscribe(data => {
|
||||||
console.log('data', data);
|
console.log('data', data);
|
||||||
//const control = <FormArray>this.addressForm.controls['neighbourhood'];
|
//const control = <FormArray>this.addressForm.controls['neighbourhood'];
|
||||||
|
const control = <FormArray>this.addressForm.controls['premises'];
|
||||||
if(data.status == 200) {
|
if(data.status == 200) {
|
||||||
// var result = Object.keys(data.records.neighbourhood).map(function (key) {
|
// var result = Object.keys(data.records.neighbourhood).map(function (key) {
|
||||||
// return data.records.neighbourhood[key];
|
// return data.records.neighbourhood[key];
|
||||||
// });
|
// });
|
||||||
|
|
||||||
this.addressForm.controls.address.setValue(data.records.address);
|
this.addressForm.controls.address.setValue(data.records.address);
|
||||||
this.addressForm.controls.pd_location.setValue(data.records.pd_location);
|
this.addressForm.controls.pd_location.setValue(data.records.pd_location);
|
||||||
this.addressForm.controls.address_type.setValue(data.records.address_type);
|
this.addressForm.controls.address_type.setValue(data.records.address_type);
|
||||||
@ -104,9 +118,39 @@ export class AddressComponent implements OnInit {
|
|||||||
this.addressForm.controls.address_form_remark.setValue(data.records.address_form_remark);
|
this.addressForm.controls.address_form_remark.setValue(data.records.address_form_remark);
|
||||||
this.addressForm.controls.address_ownership.setValue(data.records.address_ownership);
|
this.addressForm.controls.address_ownership.setValue(data.records.address_ownership);
|
||||||
this.addressForm.controls.other_ownership.setValue(data.records.other_ownership);
|
this.addressForm.controls.other_ownership.setValue(data.records.other_ownership);
|
||||||
|
this.addressForm.controls.rent_amt.setValue(data.records.rent_amt);
|
||||||
this.addressForm.controls.bussiness_activity.setValue(data.records.bussiness_activity);
|
this.addressForm.controls.bussiness_activity.setValue(data.records.bussiness_activity);
|
||||||
if(data.records.bussiness_activity == 'yes') {
|
if(data.records.bussiness_activity == 'yes') {
|
||||||
this.addressForm.controls.bussiness_address_type.setValue(data.records.bussiness_address_type);
|
let selectedMembers = Object.keys(data.records.bussiness_address_type).map(function (key) {
|
||||||
|
return data.records.bussiness_address_type[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
let enduse: any = [];
|
||||||
|
let existPremises: any =[];
|
||||||
|
|
||||||
|
selectedMembers.forEach(val => {
|
||||||
|
enduse.push(val.premises);
|
||||||
|
existPremises.push(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.formPremisesArray = existPremises;
|
||||||
|
|
||||||
|
this.addressForm.controls.bussiness_address_type.setValue(enduse);
|
||||||
|
|
||||||
|
var result = Object.keys(data.records.premises).map(function (key) {
|
||||||
|
return data.records.premises[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.length == 0) {
|
||||||
|
control.push(this.createPremises());
|
||||||
|
} else {
|
||||||
|
result.forEach(datas => {
|
||||||
|
control.push(this.createPremises());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addressForm.controls['premises'].setValue(result);
|
||||||
|
|
||||||
if(data.records.bussiness_address_type == 12) {
|
if(data.records.bussiness_address_type == 12) {
|
||||||
this.addressForm.controls.bussiness_address_type_others.setValue(data.records.bussiness_address_type_others);
|
this.addressForm.controls.bussiness_address_type_others.setValue(data.records.bussiness_address_type_others);
|
||||||
}
|
}
|
||||||
@ -141,9 +185,11 @@ export class AddressComponent implements OnInit {
|
|||||||
address_form_remark:[''],
|
address_form_remark:[''],
|
||||||
address_ownership:[''],
|
address_ownership:[''],
|
||||||
other_ownership:[''],
|
other_ownership:[''],
|
||||||
|
rent_amt:[''],
|
||||||
bussiness_activity:[''],
|
bussiness_activity:[''],
|
||||||
bussiness_address_type:[''],
|
bussiness_address_type:[''],
|
||||||
bussiness_address_type_others: ['']
|
bussiness_address_type_others: [''],
|
||||||
|
premises: this.fb.array([])
|
||||||
});
|
});
|
||||||
this.address = this.addressForm.controls['address'];
|
this.address = this.addressForm.controls['address'];
|
||||||
this.addressType = this.addressForm.controls['address_type'];
|
this.addressType = this.addressForm.controls['address_type'];
|
||||||
@ -153,6 +199,7 @@ export class AddressComponent implements OnInit {
|
|||||||
//this.customerBehaviour = this.addressForm.controls['customer_behaviour'];
|
//this.customerBehaviour = this.addressForm.controls['customer_behaviour'];
|
||||||
this.ownership = this.addressForm.controls['address_ownership'];
|
this.ownership = this.addressForm.controls['address_ownership'];
|
||||||
this.other_ownership = this.addressForm.controls['other_ownership'];
|
this.other_ownership = this.addressForm.controls['other_ownership'];
|
||||||
|
this.rent_amt = this.addressForm.controls['rent_amt'];
|
||||||
this.bussinessActivity = this.addressForm.controls['bussiness_activity'];
|
this.bussinessActivity = this.addressForm.controls['bussiness_activity'];
|
||||||
// this.bussiessAddressType = this.addressForm.controls['bussiness_address_type'];
|
// this.bussiessAddressType = this.addressForm.controls['bussiness_address_type'];
|
||||||
}
|
}
|
||||||
@ -165,6 +212,16 @@ export class AddressComponent implements OnInit {
|
|||||||
// is_owner: ['', Validators.compose([Validators.required])],
|
// is_owner: ['', Validators.compose([Validators.required])],
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
createPremises(): FormGroup {
|
||||||
|
return this.fb.group({
|
||||||
|
no_of_additional_units: [''],
|
||||||
|
premises_city: [''],
|
||||||
|
premises_remarks: [''],
|
||||||
|
premises_ownership: [''],
|
||||||
|
premises_ownership_others: [''],
|
||||||
|
premises_rent_amt:[''],
|
||||||
|
});
|
||||||
|
}
|
||||||
getMasterDetails(table:string,type:number){
|
getMasterDetails(table:string,type:number){
|
||||||
this._pd.getAllMasterDatas(table).subscribe(data => {
|
this._pd.getAllMasterDatas(table).subscribe(data => {
|
||||||
data.records.forEach(val => {
|
data.records.forEach(val => {
|
||||||
@ -186,6 +243,9 @@ export class AddressComponent implements OnInit {
|
|||||||
else if(type==6 && val.isactive == 1){
|
else if(type==6 && val.isactive == 1){
|
||||||
this.ownerShipData.push(val);
|
this.ownerShipData.push(val);
|
||||||
}
|
}
|
||||||
|
else if(type==7 && val.isactive == 1){
|
||||||
|
this.cityData.push(val);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -223,13 +283,23 @@ export class AddressComponent implements OnInit {
|
|||||||
records.address_form_remark = this.addressForm.controls.address_form_remark.value;
|
records.address_form_remark = this.addressForm.controls.address_form_remark.value;
|
||||||
records.address_ownership = this.ownership.value;
|
records.address_ownership = this.ownership.value;
|
||||||
records.other_ownership = this.other_ownership.value;
|
records.other_ownership = this.other_ownership.value;
|
||||||
|
records.rent_amt = this.rent_amt.value;
|
||||||
records.bussiness_activity = this.bussinessActivity.value;
|
records.bussiness_activity = this.bussinessActivity.value;
|
||||||
|
|
||||||
if (this.bussinessActivity.value == 'yes') {
|
if (this.bussinessActivity.value == 'yes') {
|
||||||
records.bussiness_address_type = this.addressForm.controls.bussiness_address_type.value;
|
|
||||||
|
// records.bussiness_address_type = this.addressForm.controls.bussiness_address_type.value;
|
||||||
|
records.bussiness_address_type = this.formPremisesArray;
|
||||||
|
|
||||||
if (records.bussiness_address_type == 12) {
|
if (records.bussiness_address_type == 12) {
|
||||||
records.bussiness_address_type_others = this.addressForm.controls.bussiness_address_type_others.value;
|
records.bussiness_address_type_others = this.addressForm.controls.bussiness_address_type_others.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
records.premises = this.addressForm.controls.premises.value;
|
||||||
|
|
||||||
|
console.log(this.addressForm.controls.premises.value);
|
||||||
|
|
||||||
records.pdid = this.pdid;
|
records.pdid = this.pdid;
|
||||||
records.formid = '5';
|
records.formid = '5';
|
||||||
// records.fk_createdby = '250';
|
// records.fk_createdby = '250';
|
||||||
@ -242,6 +312,67 @@ export class AddressComponent implements OnInit {
|
|||||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relationChanged(event) {
|
||||||
|
this.relativeNames2 = [];
|
||||||
|
event.value.forEach(option => {
|
||||||
|
this.relativeNames2.push({city: option});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedPremises($event){
|
||||||
|
|
||||||
|
let premisesData = $event.source.value;
|
||||||
|
|
||||||
|
|
||||||
|
if($event.source._selected === true ){
|
||||||
|
|
||||||
|
//this.formPremisesArray.push({member: $event.source.value});
|
||||||
|
//this.selectedSegmentDatas.push(CustomerSegmentName.name);
|
||||||
|
//console.log('true',premisesData);
|
||||||
|
|
||||||
|
//console.log(this.formPremisesArray);
|
||||||
|
|
||||||
|
this.formPremisesArray.push({premises: $event.source.value});
|
||||||
|
|
||||||
|
//console.log(this.formPremisesArray);
|
||||||
|
|
||||||
|
let array = this.addressData.filter(data => data.address_type_id == premisesData);
|
||||||
|
|
||||||
|
if(premisesData == 12){
|
||||||
|
this.PremisesOtherFlag = true;
|
||||||
|
this.PremisesLabel[this.z] = this.addressForm.get('bussiness_address_type_others').value;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.PremisesLabel[this.z] = array[0].address_type;
|
||||||
|
}
|
||||||
|
this.z++;
|
||||||
|
|
||||||
|
|
||||||
|
const control = <FormArray>this.addressForm.controls['premises'];
|
||||||
|
control.push(this.createPremises());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if($event.source._selected === false ){
|
||||||
|
|
||||||
|
console.log('false',premisesData);
|
||||||
|
|
||||||
|
|
||||||
|
if(premisesData == 12){
|
||||||
|
this.PremisesOtherFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const control = <FormArray>this.addressForm.controls['neighbourhood'];
|
||||||
|
control.removeAt(this.z);
|
||||||
|
this.z--;
|
||||||
|
//let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);
|
||||||
|
//this.selectedSegmentDatas.splice(index,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
validateAllFormFields(formGroup: FormGroup) {
|
validateAllFormFields(formGroup: FormGroup) {
|
||||||
Object.keys(formGroup.controls).forEach(field => {
|
Object.keys(formGroup.controls).forEach(field => {
|
||||||
const control = formGroup.get(field);
|
const control = formGroup.get(field);
|
||||||
|
|||||||
@ -23,33 +23,62 @@
|
|||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<p>Data as Per Financial Statements<p>
|
<p>Data as Per Financial Statements<p>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<div formArrayName="date_per_financial">
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Starting Financial Year" formControlName="staring_financial_year" required>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Total Financial Year" formControlName="total_financial_year" required (change)="dynamicalFinYear($event)">
|
||||||
|
</mat-form-field>
|
||||||
|
<div *ngIf="total_financial_year != ''" formArrayName="date_per_financial">
|
||||||
|
<!-- <div formArrayName="date_per_financial"> -->
|
||||||
<div *ngFor="let details of financialForm.controls.date_per_financial['controls']; let i=index"
|
<div *ngFor="let details of financialForm.controls.date_per_financial['controls']; let i=index"
|
||||||
[formGroupName]="i">
|
[formGroupName]="i">
|
||||||
<mat-card-content class="matcard">
|
<mat-card-content class="matcard">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Year (format: 2015-16)" formControlName="financial_year" required>
|
<!-- <input matInput placeholder="Year (format: 2015-16)" formControlName="financial_year" required> -->
|
||||||
|
<input matInput placeholder="Latest Financial Year" formControlName="financial_year" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Annual Sale" formControlName="financial_annual_sale" (change)="calMargin(i, details)" type="number" required>
|
<!-- <input matInput placeholder="Annual Sale" formControlName="financial_annual_sale" (change)="calMargin(i, details)" type="number" required> -->
|
||||||
|
<input matInput placeholder="Annual Sale" formControlName="financial_annual_sale" (change)="calMargin(i, details)" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Net Profit / Loss" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" required>
|
<!-- <input matInput placeholder="Net Profit / Loss" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" required> -->
|
||||||
|
<mat-select placeholder="Is there Net Profit or Net Loss?" formControlName="finanical_profit_or_loss" required>
|
||||||
|
<mat-option value="1" >Net Profit</mat-option>
|
||||||
|
<mat-option value="2" >Net Loss</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<span *ngIf="details.get('finanical_profit_or_loss').value == 1 ">
|
||||||
|
<mat-form-field>
|
||||||
|
<!-- <input matInput placeholder="Net Profit to Sales %" formControlName="financial_margin" (keypress)="keyPress($event)" required> -->
|
||||||
|
<input matInput placeholder="Net Profit Amount" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Net Profit to Sales %" formControlName="financial_margin" (keypress)="keyPress($event)" required>
|
<input matInput placeholder="Net Profit to Sales %" formControlName="financial_margin_of_profit" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
</span>
|
||||||
|
<span *ngIf="details.get('finanical_profit_or_loss').value == 2 ">
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Net Loss Amount" formControlName="financial_net_loss" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" required>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Net Loss to Sales %" formControlName="financial_margin_of_loss" (keypress)="keyPress($event)" required>
|
||||||
|
</mat-form-field>
|
||||||
|
</span>
|
||||||
<mat-form-field *ngIf="i != 0">
|
<mat-form-field *ngIf="i != 0">
|
||||||
<input matInput [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Variation from Previous Year" formControlName="financial_variation" (keypress)="keyPress($event)">
|
<input matInput [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Variation from Previous Year" formControlName="financial_variation" (keypress)="keyPress($event)">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Reason For Major Difference" formControlName="financial_reason" required>
|
<!-- <input matInput placeholder="Reason For Major Difference" formControlName="financial_reason" required> -->
|
||||||
|
<input matInput placeholder="Customer Comments on variances in Financials" formControlName="financial_reason" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<button type="button" mat-raised-button mat-icon-button (click)="addDate()"
|
<!-- <button type="button" mat-raised-button mat-icon-button (click)="addDate()"
|
||||||
matTooltip="Add More Financial Statements" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0">
|
matTooltip="Add More Financial Statements" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
</button>
|
</button> -->
|
||||||
<button type="button" mat-raised-button mat-icon-button (click)="deleteDate(i)"
|
<button type="button" mat-raised-button mat-icon-button (click)="deleteDate(i)"
|
||||||
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="i>0">
|
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="i>0">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
@ -72,7 +101,8 @@
|
|||||||
[formGroupName]="i">
|
[formGroupName]="i">
|
||||||
<mat-card-content class="matcard">
|
<mat-card-content class="matcard">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Year (format: 2015-16)" formControlName="estimate_year" required>
|
<!-- <input matInput placeholder="Year (format: 2015-16)" formControlName="estimate_year" required> -->
|
||||||
|
<input matInput placeholder="Year (format: 2015-2016)" formControlName="estimate_year" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Annual Sale" formControlName="estimate_annual_sale" (change)="calMarginVal( i, details)" type="number" required>
|
<input matInput placeholder="Annual Sale" formControlName="estimate_annual_sale" (change)="calMarginVal( i, details)" type="number" required>
|
||||||
|
|||||||
@ -35,12 +35,14 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
public financialForm: FormGroup;
|
public financialForm: FormGroup;
|
||||||
private notifier: NotifierService;
|
private notifier: NotifierService;
|
||||||
marginVal: any = [] ;
|
marginVal: any = [] ;
|
||||||
|
placeholderName : any = [];
|
||||||
setmargin: AbstractControl;
|
setmargin: AbstractControl;
|
||||||
constructor(notifier: NotifierService,
|
constructor(notifier: NotifierService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private _pd: PdTrigerService,
|
private _pd: PdTrigerService,
|
||||||
|
private dialogRef: MatDialogRef<FinancialInfoComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
||||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||||
this.form_id = 14;
|
this.form_id = 14;
|
||||||
@ -65,11 +67,13 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
result.forEach(val => {
|
result.forEach(val => {
|
||||||
financial_date.push(this.createDate());
|
//financial_date.push(this.createDate());
|
||||||
|
financial_date.push(this.createDate(''));
|
||||||
});
|
});
|
||||||
retriveData.date_per_financial = result;
|
retriveData.date_per_financial = result;
|
||||||
} else {
|
} else {
|
||||||
financial_date.push(this.createDate());
|
//financial_date.push(this.createDate());
|
||||||
|
financial_date.push(this.createDate(''));
|
||||||
}
|
}
|
||||||
if (result_val.length > 0) {
|
if (result_val.length > 0) {
|
||||||
result_val.forEach(val => {
|
result_val.forEach(val => {
|
||||||
@ -84,7 +88,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
retriveData.fk_createdby = this.pdid;
|
retriveData.fk_createdby = this.pdid;
|
||||||
this.financialForm.setValue(retriveData);
|
this.financialForm.setValue(retriveData);
|
||||||
} else {
|
} else {
|
||||||
financial_date.push(this.createDate());
|
//financial_date.push(this.createDate());
|
||||||
estimated_val.push(this.createValue());
|
estimated_val.push(this.createValue());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -95,16 +99,31 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
formid: this.form_id,
|
formid: this.form_id,
|
||||||
fk_createdby: this.pdid,
|
fk_createdby: this.pdid,
|
||||||
financial_remarks: ['', Validators.compose([Validators.required])],
|
financial_remarks: ['', Validators.compose([Validators.required])],
|
||||||
|
staring_financial_year : ['', Validators.compose([Validators.required])],
|
||||||
|
total_financial_year : ['', Validators.compose([Validators.required])],
|
||||||
date_per_financial: this.fb.array([]),
|
date_per_financial: this.fb.array([]),
|
||||||
estimated_value: this.fb.array([])
|
estimated_value: this.fb.array([])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
createDate() {
|
// createDate() {
|
||||||
|
// return this.fb.group({
|
||||||
|
// financial_year: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
||||||
|
// financial_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
||||||
|
// financial_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
// financial_margin: ['', Validators.compose([Validators.required])],
|
||||||
|
// financial_variation: [''],
|
||||||
|
// financial_reason: ['', Validators.compose([Validators.required])],
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
createDate(date) {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
financial_year: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
financial_year: [date, Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
||||||
financial_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
financial_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
||||||
financial_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
finanical_profit_or_loss:['', Validators.compose([Validators.required])],
|
||||||
financial_margin: ['', Validators.compose([Validators.required])],
|
financial_net_profit: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
financial_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
financial_margin_of_profit: [''],
|
||||||
|
financial_margin_of_loss: [''],
|
||||||
financial_variation: [''],
|
financial_variation: [''],
|
||||||
financial_reason: ['', Validators.compose([Validators.required])],
|
financial_reason: ['', Validators.compose([Validators.required])],
|
||||||
});
|
});
|
||||||
@ -121,7 +140,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
addDate() {
|
addDate() {
|
||||||
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||||
control.push(this.createDate());
|
//control.push(this.createDate());
|
||||||
}
|
}
|
||||||
deleteDate(index) {
|
deleteDate(index) {
|
||||||
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||||
@ -135,25 +154,115 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
control.removeAt(index);
|
control.removeAt(index);
|
||||||
}
|
}
|
||||||
|
dynamicalFinYear($event){
|
||||||
|
|
||||||
|
//console.log(this.financialForm.controls['total_financial_year'].value);
|
||||||
|
//console.log('data',$event.target.value);
|
||||||
|
let e = $event.target.value;
|
||||||
|
let startingYear = this.financialForm.controls['staring_financial_year'].value;
|
||||||
|
|
||||||
|
const control = <FormArray>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['staring_financial_year'].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// calYearVariation(index, detail) {
|
||||||
|
// let profit = detail.value.financial_net_profit;
|
||||||
|
// if ( profit != '' && index != 0) {
|
||||||
|
// console.log('value')
|
||||||
|
// let array = <FormArray>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))
|
||||||
|
// // detail.controls.financial_variation.disable()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
calYearVariation(index, detail) {
|
calYearVariation(index, detail) {
|
||||||
|
|
||||||
let profit = detail.value.financial_net_profit;
|
let profit = detail.value.financial_net_profit;
|
||||||
if ( profit != '' && index != 0) {
|
let loss = detail.value.financial_net_loss;
|
||||||
console.log('value')
|
|
||||||
|
if ( profit != '' || loss != '' && index != 0) {
|
||||||
|
|
||||||
let array = <FormArray>this.financialForm.controls['date_per_financial']
|
let array = <FormArray>this.financialForm.controls['date_per_financial']
|
||||||
let prev_profit = array.value[index - 1].financial_net_profit;
|
|
||||||
let variation = ((profit - prev_profit)/ prev_profit) * 100;
|
let prev_profit = array.value[index - 1].financial_net_profit != '' ? array.value[index - 1].financial_net_profit : 0;
|
||||||
detail.controls.financial_variation.setValue(variation.toFixed(2))
|
let prev_loss = array.value[index - 1].financial_net_loss !='' ? array.value[index - 1].financial_net_loss : 0 ;
|
||||||
// detail.controls.financial_variation.disable()
|
|
||||||
}
|
|
||||||
|
let variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? prev_profit : prev_loss)) * 100;
|
||||||
|
|
||||||
|
|
||||||
|
detail.controls.financial_variation.setValue(variation.toFixed(2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(detail.value.finanical_profit_or_loss == 1){
|
||||||
|
// let profit = detail.value.financial_net_profit;
|
||||||
|
|
||||||
|
// if ( profit != '' && index != 0) {
|
||||||
|
|
||||||
|
// let array = <FormArray>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 = <FormArray>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))
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// calMargin(index, detail) {
|
||||||
|
// console.log('detail', detail);
|
||||||
|
// let salary = detail.value.financial_annual_sale;
|
||||||
|
// let profit = detail.value.financial_net_profit;
|
||||||
|
// if (salary != '' && profit != '') {
|
||||||
|
// let margin = (profit / salary) * 100;
|
||||||
|
// detail.controls.financial_margin.setValue(margin.toFixed(2))
|
||||||
|
// // detail.controls.financial_margin.disable()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
calMargin(index, detail) {
|
calMargin(index, detail) {
|
||||||
console.log('detail', detail);
|
console.log('detail', detail);
|
||||||
let salary = detail.value.financial_annual_sale;
|
let salary = detail.value.financial_annual_sale;
|
||||||
|
|
||||||
|
if(detail.value.finanical_profit_or_loss == 1){
|
||||||
|
|
||||||
let profit = detail.value.financial_net_profit;
|
let profit = detail.value.financial_net_profit;
|
||||||
|
|
||||||
if (salary != '' && profit != '') {
|
if (salary != '' && profit != '') {
|
||||||
let margin = (profit / salary) * 100;
|
let margin = (profit / salary) * 100;
|
||||||
detail.controls.financial_margin.setValue(margin.toFixed(2))
|
detail.controls.financial_margin_of_profit.setValue(margin.toFixed(2))
|
||||||
// detail.controls.financial_margin.disable()
|
// detail.controls.financial_margin.disable()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (detail.value.finanical_profit_or_loss == 2){
|
||||||
|
|
||||||
|
let loss = detail.value.financial_net_loss;
|
||||||
|
|
||||||
|
if (salary != '' && loss != '') {
|
||||||
|
let margin = (loss / salary) * 100;
|
||||||
|
detail.controls.financial_margin_of_loss.setValue(margin.toFixed(2))
|
||||||
|
// detail.controls.financial_margin.disable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calVariation(index, detail) {
|
calVariation(index, detail) {
|
||||||
@ -176,6 +285,35 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
submitDetails() {
|
submitDetails() {
|
||||||
|
console.log(this.financialForm.value.date_per_financial['financial_variation']);
|
||||||
|
if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 1){
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_profit'].setValidators([Validators.required]);
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_profit'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_loss'].clearValidators();
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_loss'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_profit'].setValidators([Validators.required]);
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_profit'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_loss'].clearValidators();
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity();
|
||||||
|
|
||||||
|
}else if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 2) {
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_profit'].clearValidators();
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_profit'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_loss'].setValidators([Validators.required]);
|
||||||
|
this.financialForm.value.date_per_financial['financial_net_loss'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_profit'].clearValidators();
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_profit'].updateValueAndValidity();
|
||||||
|
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_loss'].setValidators([Validators.required]);
|
||||||
|
this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity();
|
||||||
|
}
|
||||||
if (!this.financialForm.valid) {
|
if (!this.financialForm.valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -184,6 +322,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
this._pd.saveForm(records).subscribe(data => {
|
this._pd.saveForm(records).subscribe(data => {
|
||||||
console.log('data', data);
|
console.log('data', data);
|
||||||
this.notifier.notify('success', 'Saved Successfully.');
|
this.notifier.notify('success', 'Saved Successfully.');
|
||||||
|
//this.dialogRef.close();
|
||||||
}, error => {
|
}, error => {
|
||||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user