Address and Financial : ps
This commit is contained in:
parent
2c91799dd6
commit
70f6310d1e
@ -51,7 +51,7 @@
|
||||
formControlName="locality_others">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<mat-select placeholder="Approach to PD Location" formControlName="pd_location" required>
|
||||
<mat-option value="{{data.pd_location_approach_id}}"
|
||||
*ngFor="let data of locationdata">{{data.description}}
|
||||
@ -59,7 +59,7 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<mat-select placeholder="Comment on Locality" formControlName="comment_locality" required>
|
||||
<mat-option value="{{data.comments_on_locality_id}}"
|
||||
*ngFor="let data of commentData">{{data.rating}}
|
||||
@ -86,11 +86,15 @@
|
||||
</mat-select>
|
||||
</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">
|
||||
</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?"
|
||||
formControlName="bussiness_activity" required>
|
||||
<mat-option value="yes">Yes</mat-option>
|
||||
@ -98,18 +102,64 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'">
|
||||
<mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type">
|
||||
<mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'" style="width: 100%">
|
||||
<!-- <mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type">
|
||||
<mat-option value="{{m_addressType.address_type_id}}"
|
||||
*ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
|
||||
</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="addressForm.controls['bussiness_address_type'].value == 12">
|
||||
<input matInput placeholder="Bussiness Address Type Others" formControlName="bussiness_address_type_others">
|
||||
<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-form-field>
|
||||
|
||||
<!-- <mat-form-field *ngIf="addressForm.controls['premises_ownership'].value == 4 "> -->
|
||||
<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 *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) --
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
|
||||
@ -37,13 +37,23 @@ export class AddressComponent implements OnInit {
|
||||
|
||||
loadDataStatus: boolean=true;
|
||||
|
||||
PremisesOtherFlag:boolean;
|
||||
PremisesLabel : any = [];
|
||||
|
||||
locationdata: any = [];
|
||||
commentData: any = [];
|
||||
//customerData: any = []; 221118 review doc s.no 3.e
|
||||
addressData:any = [];
|
||||
localityData:any = [];
|
||||
ownerShipData:any = [];
|
||||
cityData:any = [];
|
||||
|
||||
|
||||
|
||||
z = 0;
|
||||
|
||||
formPremisesArray: any = [];
|
||||
relativeNames2: any = [];
|
||||
//neighbourStatusData:any=["Yes","No"];
|
||||
//applicantOwnerData:any=["Yes","No","Dont Know"];
|
||||
|
||||
@ -58,6 +68,7 @@ export class AddressComponent implements OnInit {
|
||||
public customerBehaviour: AbstractControl;
|
||||
public ownership: AbstractControl;
|
||||
public other_ownership: AbstractControl;
|
||||
public rent_amt : AbstractControl;
|
||||
public bussinessActivity: AbstractControl;
|
||||
//constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , ) {
|
||||
constructor(private el: ElementRef, notifier: NotifierService,
|
||||
@ -81,6 +92,7 @@ export class AddressComponent implements OnInit {
|
||||
this.getMasterDetails('LOCALITY',4);
|
||||
this.getMasterDetails('ADDRESSTYPE',5);
|
||||
this.getMasterDetails('RESIDENCEOWNERSHIP',6);
|
||||
this.getMasterDetails('CITY',7);
|
||||
this.initAddressForm();
|
||||
let params: any = {};
|
||||
params.pd_id = this.pdid;
|
||||
@ -88,10 +100,12 @@ export class AddressComponent implements OnInit {
|
||||
this._pd.retriveForm(params).subscribe(data => {
|
||||
console.log('data', data);
|
||||
//const control = <FormArray>this.addressForm.controls['neighbourhood'];
|
||||
const control = <FormArray>this.addressForm.controls['premises'];
|
||||
if(data.status == 200) {
|
||||
// var result = Object.keys(data.records.neighbourhood).map(function (key) {
|
||||
// return data.records.neighbourhood[key];
|
||||
// });
|
||||
|
||||
this.addressForm.controls.address.setValue(data.records.address);
|
||||
this.addressForm.controls.pd_location.setValue(data.records.pd_location);
|
||||
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_ownership.setValue(data.records.address_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);
|
||||
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) {
|
||||
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_ownership:[''],
|
||||
other_ownership:[''],
|
||||
rent_amt:[''],
|
||||
bussiness_activity:[''],
|
||||
bussiness_address_type:[''],
|
||||
bussiness_address_type_others: ['']
|
||||
bussiness_address_type_others: [''],
|
||||
premises: this.fb.array([])
|
||||
});
|
||||
this.address = this.addressForm.controls['address'];
|
||||
this.addressType = this.addressForm.controls['address_type'];
|
||||
@ -153,6 +199,7 @@ export class AddressComponent implements OnInit {
|
||||
//this.customerBehaviour = this.addressForm.controls['customer_behaviour'];
|
||||
this.ownership = this.addressForm.controls['address_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.bussiessAddressType = this.addressForm.controls['bussiness_address_type'];
|
||||
}
|
||||
@ -165,6 +212,16 @@ export class AddressComponent implements OnInit {
|
||||
// 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){
|
||||
this._pd.getAllMasterDatas(table).subscribe(data => {
|
||||
data.records.forEach(val => {
|
||||
@ -186,6 +243,9 @@ export class AddressComponent implements OnInit {
|
||||
else if(type==6 && val.isactive == 1){
|
||||
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_ownership = this.ownership.value;
|
||||
records.other_ownership = this.other_ownership.value;
|
||||
records.rent_amt = this.rent_amt.value;
|
||||
records.bussiness_activity = this.bussinessActivity.value;
|
||||
|
||||
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) {
|
||||
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.formid = '5';
|
||||
// records.fk_createdby = '250';
|
||||
@ -242,6 +312,67 @@ export class AddressComponent implements OnInit {
|
||||
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) {
|
||||
Object.keys(formGroup.controls).forEach(field => {
|
||||
const control = formGroup.get(field);
|
||||
|
||||
@ -23,33 +23,62 @@
|
||||
<mat-card-header>
|
||||
<p>Data as Per Financial Statements<p>
|
||||
</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"
|
||||
[formGroupName]="i">
|
||||
<mat-card-content class="matcard">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</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">
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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">
|
||||
<mat-icon>add</mat-icon>
|
||||
</button>
|
||||
</button> -->
|
||||
<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">
|
||||
<mat-icon>delete</mat-icon>
|
||||
@ -72,7 +101,8 @@
|
||||
[formGroupName]="i">
|
||||
<mat-card-content class="matcard">
|
||||
<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>
|
||||
<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;
|
||||
private notifier: NotifierService;
|
||||
marginVal: any = [] ;
|
||||
placeholderName : any = [];
|
||||
setmargin: AbstractControl;
|
||||
constructor(notifier: NotifierService,
|
||||
private fb: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private _pd: PdTrigerService,
|
||||
private dialogRef: MatDialogRef<FinancialInfoComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||
this.form_id = 14;
|
||||
@ -65,11 +67,13 @@ export class FinancialInfoComponent implements OnInit {
|
||||
});
|
||||
if (result.length > 0) {
|
||||
result.forEach(val => {
|
||||
financial_date.push(this.createDate());
|
||||
//financial_date.push(this.createDate());
|
||||
financial_date.push(this.createDate(''));
|
||||
});
|
||||
retriveData.date_per_financial = result;
|
||||
} else {
|
||||
financial_date.push(this.createDate());
|
||||
//financial_date.push(this.createDate());
|
||||
financial_date.push(this.createDate(''));
|
||||
}
|
||||
if (result_val.length > 0) {
|
||||
result_val.forEach(val => {
|
||||
@ -84,7 +88,7 @@ export class FinancialInfoComponent implements OnInit {
|
||||
retriveData.fk_createdby = this.pdid;
|
||||
this.financialForm.setValue(retriveData);
|
||||
} else {
|
||||
financial_date.push(this.createDate());
|
||||
//financial_date.push(this.createDate());
|
||||
estimated_val.push(this.createValue());
|
||||
}
|
||||
})
|
||||
@ -95,16 +99,31 @@ export class FinancialInfoComponent implements OnInit {
|
||||
formid: this.form_id,
|
||||
fk_createdby: this.pdid,
|
||||
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([]),
|
||||
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({
|
||||
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_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||
financial_margin: ['', Validators.compose([Validators.required])],
|
||||
finanical_profit_or_loss:['', 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_reason: ['', Validators.compose([Validators.required])],
|
||||
});
|
||||
@ -121,7 +140,7 @@ export class FinancialInfoComponent implements OnInit {
|
||||
}
|
||||
addDate() {
|
||||
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||
control.push(this.createDate());
|
||||
//control.push(this.createDate());
|
||||
}
|
||||
deleteDate(index) {
|
||||
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||
@ -135,26 +154,116 @@ export class FinancialInfoComponent implements OnInit {
|
||||
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||
control.removeAt(index);
|
||||
}
|
||||
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()
|
||||
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) {
|
||||
|
||||
let profit = detail.value.financial_net_profit;
|
||||
let loss = detail.value.financial_net_loss;
|
||||
|
||||
if ( profit != '' || loss != '' && index != 0) {
|
||||
|
||||
let array = <FormArray>this.financialForm.controls['date_per_financial']
|
||||
|
||||
let prev_profit = array.value[index - 1].financial_net_profit != '' ? array.value[index - 1].financial_net_profit : 0;
|
||||
let prev_loss = array.value[index - 1].financial_net_loss !='' ? array.value[index - 1].financial_net_loss : 0 ;
|
||||
|
||||
|
||||
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) {
|
||||
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()
|
||||
}
|
||||
|
||||
if(detail.value.finanical_profit_or_loss == 1){
|
||||
|
||||
let profit = detail.value.financial_net_profit;
|
||||
|
||||
if (salary != '' && profit != '') {
|
||||
let margin = (profit / salary) * 100;
|
||||
detail.controls.financial_margin_of_profit.setValue(margin.toFixed(2))
|
||||
// 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) {
|
||||
let profit = detail.value.estimate_net_profit;
|
||||
@ -176,6 +285,35 @@ export class FinancialInfoComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -184,6 +322,7 @@ export class FinancialInfoComponent implements OnInit {
|
||||
this._pd.saveForm(records).subscribe(data => {
|
||||
console.log('data', data);
|
||||
this.notifier.notify('success', 'Saved Successfully.');
|
||||
//this.dialogRef.close();
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user