finanical form chnges : ps
This commit is contained in:
parent
f791d3d2b7
commit
85efbafe4c
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
|
|
||||||
|
|
||||||
<mat-tab-group>
|
<mat-tab-group>
|
||||||
<mat-tab label="Questions">
|
<mat-tab label="Questions">
|
||||||
<ng-template matTabContent>
|
<ng-template matTabContent>
|
||||||
@ -61,16 +60,18 @@
|
|||||||
</span>
|
</span>
|
||||||
<span *ngIf="details.get('finanical_profit_or_loss').value == 2 ">
|
<span *ngIf="details.get('finanical_profit_or_loss').value == 2 ">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Net Loss Amount" formControlName="financial_net_loss" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" required>
|
<input matInput placeholder="Net Loss Amount" formControlName="financial_net_loss" (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 Loss to Sales %" formControlName="financial_margin_of_loss" (keypress)="keyPress($event)" required>
|
<input matInput placeholder="Net Loss to Sales %" formControlName="financial_margin_of_loss" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</span>
|
</span>
|
||||||
<mat-form-field *ngIf="i != 0">
|
<mat-form-field *ngIf="i != 0" style="width:65%">
|
||||||
<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-hint align="end" *ngIf="i != 0" [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" >{{SalesStatement[i]}}</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
|
||||||
|
<mat-form-field *ngIf="customerCommentsFlag" style="width:65%">
|
||||||
<!-- <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>
|
<input matInput placeholder="Customer Comments on variances in Financials" formControlName="financial_reason" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -96,33 +97,60 @@
|
|||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<p>Actual Values as per Customer<p>
|
<p>Actual Values as per Customer<p>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
|
<mat-form-field *ngIf="total_financial_year != ''">
|
||||||
|
<mat-select placeholder="Same as Financial Statements?" formControlName="same_as_financial_statements" (selectionChange)="selectedType($event)">
|
||||||
|
<mat-option value="yes">Yes</mat-option>
|
||||||
|
<mat-option value="no">No</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
<div formArrayName="estimated_value">
|
<div formArrayName="estimated_value">
|
||||||
<div *ngFor="let details of financialForm.controls.estimated_value['controls']; let i=index"
|
<div *ngFor="let details of financialForm.controls.estimated_value['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="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>
|
<input matInput placeholder="Year" 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)" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Net Profit / Loss" formControlName="estimate_net_profit" (change)="calMarginVal( i, details); calVariation( 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="estimate_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('estimate_profit_or_loss').value == 1 ">
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Net Profit Amount" formControlName="estimate_net_profit" (change)="calMarginVal( i, details); calVariation( i, details)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput disabled placeholder="Margin" formControlName="estimate_margin" (keypress)="keyPress($event)" required>
|
<input matInput disabled placeholder="Margin" formControlName="estimate_margin_of_profit" (keypress)="keyPress($event)" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field *ngIf="i != 0">
|
</span>
|
||||||
|
<span *ngIf="details.get('estimate_profit_or_loss').value == 2 ">
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput placeholder="Net Loss" formControlName="estimate_net_loss" (change)="calMarginVal( i, details); calVariation( i, details)" required>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput disabled placeholder="Margin" formControlName="estimate_margin_of_loss" (keypress)="keyPress($event)" (change)="calAmount( i, details); calVariation( i, details)" required>
|
||||||
|
</mat-form-field>
|
||||||
|
</span>
|
||||||
|
<mat-form-field *ngIf="i != 0" style="width:65%">
|
||||||
<input matInput [ngClass]="{'highlight': details.controls['estimate_variation'].value >= 40 || details.controls['estimate_variation'].value >= -40}" placeholder="Variation from Previous Year" formControlName="estimate_variation" (keypress)="keyPress($event)">
|
<input matInput [ngClass]="{'highlight': details.controls['estimate_variation'].value >= 40 || details.controls['estimate_variation'].value >= -40}" placeholder="Variation from Previous Year" formControlName="estimate_variation" (keypress)="keyPress($event)">
|
||||||
|
<mat-hint align="end" [ngClass]="{'highlight': (details.controls['estimate_variation'].value >= 40) || (details.controls['estimate_variation'].value < -40)}" > {{details.controls['estimate_variation'].value}} {{details.controls['estimate_year'].value}}
|
||||||
|
<!-- 'details.controls['estimate_variation'].value <= 0' ? 'Decreases ' : 'Increases ' + 'in Sales in FY ' + curr_year + ' Over Sales in FY '+ prev_year + ' is ' + {{details.controls['estimate_variation'].value}} + '%'; -->
|
||||||
|
</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<!--<mat-form-field>
|
<!--<mat-form-field>
|
||||||
<input matInput placeholder="Reason For Major Difference" formControlName="estimate_reason" required>
|
<input matInput placeholder="Reason For Major Difference" formControlName="estimate_reason" required>
|
||||||
</mat-form-field>-->
|
</mat-form-field>-->
|
||||||
<button type="button" mat-raised-button mat-icon-button (click)="addGoods()"
|
<!-- <button type="button" mat-raised-button mat-icon-button (click)="addGoods()"
|
||||||
matTooltip="Add More Estimated Value" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0">
|
matTooltip="Add More Estimated Value" 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)="deleteGoods(i)"
|
<button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(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>
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
// background: #62B013;
|
// background: #62B013;
|
||||||
// color: white;
|
// color: white;
|
||||||
// }
|
// }
|
||||||
// .highlight {
|
.highlight {
|
||||||
// color: red;
|
color: red;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
.paragraph_change {
|
.paragraph_change {
|
||||||
|
|||||||
@ -34,9 +34,11 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
form_id: number;
|
form_id: number;
|
||||||
public financialForm: FormGroup;
|
public financialForm: FormGroup;
|
||||||
private notifier: NotifierService;
|
private notifier: NotifierService;
|
||||||
|
SalesStatement : any = [];
|
||||||
marginVal: any = [] ;
|
marginVal: any = [] ;
|
||||||
placeholderName : any = [];
|
placeholderName : any = [];
|
||||||
setmargin: AbstractControl;
|
setmargin: AbstractControl;
|
||||||
|
customerCommentsFlag :boolean;
|
||||||
constructor(notifier: NotifierService,
|
constructor(notifier: NotifierService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -96,11 +98,11 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
if (result_val.length > 0) {
|
if (result_val.length > 0) {
|
||||||
result_val.forEach(val => {
|
result_val.forEach(val => {
|
||||||
estimated_val.push(this.createValue());
|
estimated_val.push(this.createValue(''));
|
||||||
});
|
});
|
||||||
retriveData.estimated_value = result_val;
|
retriveData.estimated_value = result_val;
|
||||||
} else {
|
} else {
|
||||||
estimated_val.push(this.createValue());
|
estimated_val.push(this.createValue(''));
|
||||||
}
|
}
|
||||||
retriveData.pdid = this.pdid;
|
retriveData.pdid = this.pdid;
|
||||||
retriveData.formid = this.form_id;
|
retriveData.formid = this.form_id;
|
||||||
@ -108,7 +110,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
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(''));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -120,6 +122,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
financial_remarks: ['', Validators.compose([Validators.required])],
|
financial_remarks: ['', Validators.compose([Validators.required])],
|
||||||
staring_financial_year : ['', Validators.compose([Validators.required])],
|
staring_financial_year : ['', Validators.compose([Validators.required])],
|
||||||
total_financial_year : ['', Validators.compose([Validators.required])],
|
total_financial_year : ['', Validators.compose([Validators.required])],
|
||||||
|
same_as_financial_statements:[''],
|
||||||
date_per_financial: this.fb.array([]),
|
date_per_financial: this.fb.array([]),
|
||||||
estimated_value: this.fb.array([])
|
estimated_value: this.fb.array([])
|
||||||
});
|
});
|
||||||
@ -147,16 +150,36 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
financial_reason: ['', Validators.compose([Validators.required])],
|
financial_reason: ['', Validators.compose([Validators.required])],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
createValue() {
|
createValue(date) {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
estimate_year: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
estimate_year: [date, Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
||||||
estimate_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
estimate_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
||||||
|
estimate_profit_or_loss:['', Validators.compose([Validators.required])],
|
||||||
estimate_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
estimate_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
estimate_margin: ['', Validators.compose([Validators.required])],
|
estimate_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
//estimate_margin: ['', Validators.compose([Validators.required])],
|
||||||
|
estimate_margin_of_profit: [''],
|
||||||
|
estimate_margin_of_loss: [''],
|
||||||
estimate_variation: [''],
|
estimate_variation: [''],
|
||||||
// estimate_reason: ['', Validators.compose([Validators.required])],
|
// estimate_reason: ['', Validators.compose([Validators.required])],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createValuewithData(value) {
|
||||||
|
return this.fb.group({
|
||||||
|
estimate_year: [value.estimate_year, Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
|
||||||
|
estimate_annual_sale: [value.estimate_annual_sale, Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])],
|
||||||
|
estimate_profit_or_loss:[value.estimate_profit_or_loss, Validators.compose([Validators.required])],
|
||||||
|
estimate_net_loss: [value.estimate_net_loss, Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
estimate_net_profit: [value.estimate_net_profit, Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])],
|
||||||
|
//estimate_margin: [value., Validators.compose([Validators.required])],
|
||||||
|
estimate_margin_of_profit: [value.estimate_margin_of_profit],
|
||||||
|
estimate_margin_of_loss: [value.estimate_margin_of_loss],
|
||||||
|
estimate_variation: [value.estimate_variation],
|
||||||
|
// estimate_reason: ['', Validators.compose([Validators.required])],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
@ -167,7 +190,7 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
addGoods() {
|
addGoods() {
|
||||||
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
control.push(this.createValue());
|
//control.push(this.createValue());
|
||||||
}
|
}
|
||||||
deleteGoods(index) {
|
deleteGoods(index) {
|
||||||
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
@ -178,6 +201,13 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
//console.log(this.financialForm.controls['total_financial_year'].value);
|
//console.log(this.financialForm.controls['total_financial_year'].value);
|
||||||
//console.log('data',$event.target.value);
|
//console.log('data',$event.target.value);
|
||||||
let e = $event.target.value;
|
let e = $event.target.value;
|
||||||
|
if(e == 1){
|
||||||
|
this.customerCommentsFlag = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.customerCommentsFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
let startingYear = this.financialForm.controls['staring_financial_year'].value;
|
let startingYear = this.financialForm.controls['staring_financial_year'].value;
|
||||||
|
|
||||||
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
const control = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||||
@ -194,6 +224,70 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedType(e: any): void {
|
||||||
|
console.log(e);
|
||||||
|
if(e.value == 'yes'){
|
||||||
|
let startingYear = this.financialForm.controls['staring_financial_year'].value;
|
||||||
|
let totalFinYear = this.financialForm.controls['total_financial_year'].value;
|
||||||
|
//let YearParam = (+startingYear) +'-'+ ((+startingYear+1));
|
||||||
|
let array = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||||
|
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
|
|
||||||
|
while (control.length !== 0) {
|
||||||
|
control.removeAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array.length > 0 ){
|
||||||
|
console.log(array.length);
|
||||||
|
|
||||||
|
for (let val of array.value) {
|
||||||
|
let vals = {
|
||||||
|
estimate_year: val.financial_year,
|
||||||
|
estimate_annual_sale: val.financial_annual_sale,
|
||||||
|
estimate_profit_or_loss:val.finanical_profit_or_loss,
|
||||||
|
estimate_net_loss: val.financial_net_loss,
|
||||||
|
estimate_net_profit: val.financial_net_profit,
|
||||||
|
estimate_margin_of_profit: val.financial_margin_of_profit,
|
||||||
|
estimate_margin_of_loss: val.financial_margin_of_loss,
|
||||||
|
estimate_variation: val.financial_variation,
|
||||||
|
};
|
||||||
|
control.push(this.createValuewithData(vals));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//control.controls[0].get('raw_quantity').setValidators([Validators.required]);
|
||||||
|
|
||||||
|
// for(let i = 1 ; i<= totalFinYear ; i++ ){
|
||||||
|
// let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i));
|
||||||
|
// control.push(this.createValue(Year));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//control.push(this.createValue(YearParam));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (e.value == 'no'){
|
||||||
|
|
||||||
|
let startingYear = this.financialForm.controls['staring_financial_year'].value;
|
||||||
|
let totalFinYear = this.financialForm.controls['total_financial_year'].value;
|
||||||
|
|
||||||
|
const control = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
|
|
||||||
|
while (control.length !== 0) {
|
||||||
|
control.removeAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(totalFinYear > 0 ){
|
||||||
|
for(let i = 1 ; i<= totalFinYear ; i++ ){
|
||||||
|
let Year = (+startingYear+(i-1)) +'-'+ ((+startingYear)+(+i));
|
||||||
|
control.push(this.createValue(Year));
|
||||||
|
//console.log(this.financialForm.controls['staring_financial_year'].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// calYearVariation(index, detail) {
|
// calYearVariation(index, detail) {
|
||||||
// let profit = detail.value.financial_net_profit;
|
// let profit = detail.value.financial_net_profit;
|
||||||
// if ( profit != '' && index != 0) {
|
// if ( profit != '' && index != 0) {
|
||||||
@ -209,20 +303,28 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
|
|
||||||
let profit = detail.value.financial_net_profit;
|
let profit = detail.value.financial_net_profit;
|
||||||
let loss = detail.value.financial_net_loss;
|
let loss = detail.value.financial_net_loss;
|
||||||
|
let curr_year = detail.value.financial_year;
|
||||||
|
this.SalesStatement[0] = 0.00;
|
||||||
|
|
||||||
if ( profit != '' || loss != '' && index != 0) {
|
if ( (profit != '' || loss != '') && index != 0) {
|
||||||
|
|
||||||
let array = <FormArray>this.financialForm.controls['date_per_financial']
|
let array = <FormArray>this.financialForm.controls['date_per_financial'];
|
||||||
|
console.log(array.value[index - 1].financial_net_profit);
|
||||||
|
|
||||||
let prev_profit = array.value[index - 1].financial_net_profit != '' ? array.value[index - 1].financial_net_profit : 0;
|
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 prev_loss = array.value[index - 1].financial_net_loss !='' ? array.value[index - 1].financial_net_loss : 0 ;
|
||||||
|
|
||||||
|
let prev_year = array.value[index - 1].financial_year;
|
||||||
|
|
||||||
let variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? prev_profit : prev_loss)) * 100;
|
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));
|
detail.controls.financial_variation.setValue(variation.toFixed(2));
|
||||||
|
|
||||||
|
//Increase in Sales in FY 2017-18 over sales in FY 2016-17 is 11.11%
|
||||||
|
console.log('variation',variation);
|
||||||
|
this.SalesStatement[index] = ( variation <= 0 ? 'Decreases ' : 'Increases ' ) + 'in Sales in FY ' + curr_year + ' Over Sales in FY '+ prev_year + ' is ' + variation.toFixed(2) + '%';
|
||||||
|
console.log('this.SlesStatement',this.SalesStatement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(detail.value.finanical_profit_or_loss == 1){
|
// if(detail.value.finanical_profit_or_loss == 1){
|
||||||
@ -279,29 +381,121 @@ export class FinancialInfoComponent implements OnInit {
|
|||||||
|
|
||||||
if (salary != '' && loss != '') {
|
if (salary != '' && loss != '') {
|
||||||
let margin = (loss / salary) * 100;
|
let margin = (loss / salary) * 100;
|
||||||
detail.controls.financial_margin_of_loss.setValue(margin.toFixed(2))
|
detail.controls.financial_margin_of_loss.setValue(margin.toFixed(2));
|
||||||
// detail.controls.financial_margin.disable()
|
// detail.controls.financial_margin.disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calVariation(index, detail) {
|
calVariation(index, detail) {
|
||||||
|
// console.log('CalVar In');
|
||||||
|
// let profit = detail.value.estimate_net_profit;
|
||||||
|
// let curr_year = detail.value.financial_year;
|
||||||
|
// if ( profit != '' && index != 0) {
|
||||||
|
// let array = <FormArray>this.financialForm.controls['estimated_value']
|
||||||
|
// let prev_profit = array.value[index - 1].estimate_net_profit;
|
||||||
|
// let variation = ((profit - prev_profit) / prev_profit) * 100;
|
||||||
|
// detail.controls.estimate_variation.setValue(variation.toFixed(2))
|
||||||
|
// let prev_year = array.value[index - 1].financial_year;
|
||||||
|
// // detail.controls.estimate_variation.disable()
|
||||||
|
// }
|
||||||
|
|
||||||
let profit = detail.value.estimate_net_profit;
|
let profit = detail.value.estimate_net_profit;
|
||||||
if ( profit != '' && index != 0) {
|
let loss = detail.value.estimate_net_loss;
|
||||||
let array = <FormArray>this.financialForm.controls['estimated_value']
|
let curr_year = detail.value.estimate_year;
|
||||||
let prev_profit = array.value[index - 1].estimate_net_profit;
|
|
||||||
let variation = ((profit - prev_profit) / prev_profit) * 100;
|
if ( (profit != '' || loss != '') && index != 0) {
|
||||||
detail.controls.estimate_variation.setValue(variation.toFixed(2))
|
|
||||||
// detail.controls.estimate_variation.disable()
|
let array = <FormArray>this.financialForm.controls['estimated_value'];
|
||||||
|
console.log(array.value[index - 1].financial_net_profit);
|
||||||
|
|
||||||
|
let prev_profit = array.value[index - 1].estimate_net_profit != '' ? array.value[index - 1].estimate_net_profit : 0;
|
||||||
|
let prev_loss = array.value[index - 1].estimate_net_loss !='' ? array.value[index - 1].estimate_net_loss : 0 ;
|
||||||
|
let prev_year = array.value[index - 1].estimate_year;
|
||||||
|
|
||||||
|
let variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? prev_profit : prev_loss)) * 100;
|
||||||
|
|
||||||
|
detail.controls.estimate_variation.setValue(variation.toFixed(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calMarginVal(index, detail) {
|
calMarginVal(index, detail) {
|
||||||
|
console.log('Margin Estimate VAR',detail);
|
||||||
let salary = detail.value.estimate_annual_sale;
|
let salary = detail.value.estimate_annual_sale;
|
||||||
let profit = detail.value.estimate_net_profit;
|
console.log('Margin Estimate Vsalary',salary);
|
||||||
if (salary != '' && profit != '') {
|
|
||||||
|
// if (salary != '' && profit != '') {
|
||||||
|
// let margin = profit / salary * 100;
|
||||||
|
// detail.controls.estimate_margin.setValue(margin.toFixed(2))
|
||||||
|
// // detail.controls.estimate_margin.disable()
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(detail.value.estimate_profit_or_loss == 1){
|
||||||
|
|
||||||
|
let profit = detail.value.estimate_net_profit;
|
||||||
|
console.log('if Margin Profit',profit);
|
||||||
|
|
||||||
|
if (salary != '' && profit != '') {
|
||||||
|
console.log('if if Margin Estimate salary',salary);
|
||||||
|
console.log('if if Margin Profit',profit);
|
||||||
let margin = profit / salary * 100;
|
let margin = profit / salary * 100;
|
||||||
detail.controls.estimate_margin.setValue(margin.toFixed(2))
|
console.log('margin',margin);
|
||||||
// detail.controls.estimate_margin.disable()
|
detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2));
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (detail.value.estimate_profit_or_loss == 2){
|
||||||
|
|
||||||
|
let loss = detail.value.estimate_net_profit;
|
||||||
|
console.log('else if Margin loss',loss);
|
||||||
|
if (salary != '' && loss != '') {
|
||||||
|
console.log('elseif if Margin Estimate salary',salary);
|
||||||
|
console.log('alseif if Margin loss',loss);
|
||||||
|
let margin = (loss / salary) * 100;
|
||||||
|
detail.controls.estimate_margin_of_loss.setValue(margin.toFixed(2));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
calAmount(index, detail) {
|
||||||
|
|
||||||
|
let salary = detail.value.estimate_annual_sale;
|
||||||
|
|
||||||
|
if(detail.value.estimate_profit_or_loss == 1){
|
||||||
|
|
||||||
|
// let profit = detail.value.estimate_net_profit;
|
||||||
|
let margin_profit = detail.value.estimate_margin_of_profit;
|
||||||
|
|
||||||
|
|
||||||
|
if (salary != '' && margin_profit != '') {
|
||||||
|
|
||||||
|
|
||||||
|
//let margin = profit / salary * 100;
|
||||||
|
let profit = margin_profit / salary * 100;
|
||||||
|
|
||||||
|
console.log('margin',margin_profit);
|
||||||
|
console.log('profit',profit);
|
||||||
|
//detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2));
|
||||||
|
detail.controls.estimate_net_profit.setValue(profit.toFixed(2));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if (detail.value.estimate_profit_or_loss == 2){
|
||||||
|
|
||||||
|
// let loss = detail.value.estimate_net_profit;
|
||||||
|
// console.log('else if Margin loss',loss);
|
||||||
|
// if (salary != '' && loss != '') {
|
||||||
|
// console.log('elseif if Margin Estimate salary',salary);
|
||||||
|
// console.log('alseif if Margin loss',loss);
|
||||||
|
// let margin = (loss / salary) * 100;
|
||||||
|
// detail.controls.estimate_margin_of_loss.setValue(margin.toFixed(2));
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
submitDetails() {
|
submitDetails() {
|
||||||
console.log(this.financialForm.value.date_per_financial['financial_variation']);
|
console.log(this.financialForm.value.date_per_financial['financial_variation']);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user