Finanical : ps

This commit is contained in:
venbaSriram 2018-12-30 17:05:45 +05:30
parent c55c60a1c7
commit 7fd73eda09
3 changed files with 250 additions and 156 deletions

View File

@ -22,47 +22,62 @@
<mat-card-header>
<mat-card-title><p> Data as Per Financial Statements</p></mat-card-title>
</mat-card-header>
<mat-form-field style="width:35%">
<mat-label>Starting Financial Year</mat-label>
<input matInput autocomplete="off" placeholder="YYYY eg.2018" formControlName="staring_financial_year" (keypress)="keyPress($event)">
<mat-error> Invalid year format</mat-error>
</mat-form-field>
<!-- <mat-form-field hintLabel="Max 10 characters">
<input matInput #input maxlength="10" placeholder="Enter some input">
<mat-hint align="end">{{input.value?.length || 0}}/10</mat-hint>
</mat-form-field> -->
<mat-form-field style="width:35%">
<input matInput autocomplete="off" placeholder="Number of Financial Years" formControlName="total_financial_year" (change)="dynamicalFinYear($event)" (keypress)="keyPress($event)">
</mat-form-field>
<div style="width:100%">
<mat-form-field style="width:35%">
<mat-label>Starting Financial Year</mat-label>
<input matInput autocomplete="off" placeholder="YYYY eg.2018" formControlName="staring_financial_year" (keypress)="keyPress($event)">
<mat-error> Invalid year format</mat-error>
</mat-form-field>
<!-- <mat-form-field hintLabel="Max 10 characters">
<input matInput #input maxlength="10" placeholder="Enter some input">
<mat-hint align="end">{{input.value?.length || 0}}/10</mat-hint>
</mat-form-field> -->
<mat-form-field style="width:35%">
<input matInput autocomplete="off" placeholder="Number of Financial Years" formControlName="total_financial_year" (change)="dynamicalFinYear($event)" (keypress)="keyPress($event)" [readonly]="isReadOnly">
</mat-form-field>
</div>
<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-card-content class="matcard">
<mat-label class="highlight"> <i>Financial Year : {{details.get('financial_year').value}} </i> </mat-label>
<hr>
<div style="width:100%">
<mat-form-field>
<input matInput class="underline" formControlName="financial_year" type="hidden">
</mat-form-field>
<mat-label>{{details.get('financial_year').value}}</mat-label>
<hr>
<!-- -->
<mat-form-field style="width:25%">
<br>
<mat-form-field style="width:30%">
<!-- <input matInput autocomplete="off" placeholder="Annual Sale" formControlName="financial_annual_sale" (change)="calMargin(i, details)" type="number" > -->
<input matInput autocomplete="off" placeholder="Annual Sale" formControlName="financial_annual_sale" (change)="calFinAnnualSale(i, details)" (keypress)="keyPress($event)" (keyup)="inWords($event,i,1)">
<mat-hint align="end" *ngIf="details.get('financial_annual_sale').value != ''">{{"&#8377;"}} {{FY_annualSalesInwords2[i]}} Only</mat-hint>
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('financial_annual_sale').value != ''">{{"&#8377;"}} {{FY_annualSalesInwords[i]}} Only</mat-hint>
</mat-form-field>
<span *ngIf="i != 0">
<mat-form-field style="width:50%">
<input matInput autocomplete="off" placeholder="Annual Sale Variation from Previous Year" formControlName="financial_annualsales_variation" (keypress)="keyPress($event)" (change)="calFinAnnualSale( i, details);">
<mat-form-field style="width:60%">
<input matInput autocomplete="off" placeholder="Sale Variation from Previous Year in %" formControlName="financial_annualsales_variation" (keypress)="keyPress($event)" (change)="calFinAnnualSale( i, details);">
<mat-hint align="end" *ngIf="details.get('financial_annualsales_variation').value != '' " >
<span *ngIf="details.get('financial_annualsales_variation').value == 0">
No differents in Sales in FY <i> {{details.get('financial_year').value}} </i> over Sales in FY <i> {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} </i>
</span>
<span *ngIf="details.get('financial_annualsales_variation').value > 0" class="greenhighlight">
Increase in Sales in FY <i> {{details.get('financial_year').value}} </i> over Sales in FY <i> {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} </i> <b>{{details.get('financial_annualsales_variation').value}} % </b>
</span>
<span *ngIf="details.get('financial_annualsales_variation').value < 0" class="highlight">
Decrease in Sales in FY <i> {{details.get('financial_year').value}} </i> over Sales in FY <i>{{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}}</i> <b>{{details.get('financial_annualsales_variation').value}} % </b>
</span>
</mat-hint>
</mat-form-field>
</span>
</div>
<div style="width:100%">
<mat-form-field style="width:35%">
<mat-form-field style="width:30%">
<!-- <input matInput autocomplete="off" placeholder="Net Profit / Loss" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" > -->
<mat-select placeholder="Is there Net Profit or Net Loss?" formControlName="finanical_profit_or_loss" >
<mat-option value="1" >Net Profit</mat-option>
@ -70,33 +85,37 @@
</mat-select>
</mat-form-field>
<span *ngIf="details.get('finanical_profit_or_loss').value == 1 ">
<mat-form-field style="width:25%">
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Profit Amount" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" (keypress)="keyPress($event)" (keyup)="inWords($event,i,2)">
<mat-hint align="end" *ngIf="details.get('financial_net_profit').value != ''">{{"&#8377;"}} {{FY_netProfitAmtInwords[i]}} Only</mat-hint>
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('financial_net_profit').value != ''">{{"&#8377;"}} {{FY_netProfitAmtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:25%">
<input matInput autocomplete="off" placeholder="Net Profit to Sales" formControlName="financial_margin_of_profit" (keypress)="keyPress($event)" >
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Profit to Sales in %" formControlName="financial_margin_of_profit" (keypress)="keyPress($event)" >
</mat-form-field>
</span>
<span *ngIf="details.get('finanical_profit_or_loss').value == 2 ">
<mat-form-field style="width:25%">
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Loss Amount" formControlName="financial_net_loss" (change)="calMargin( i, details); calYearVariation( i, details)" (keypress)="keyPress($event)" (keyup)="inWords($event,i,3)">
<mat-hint align="end" *ngIf="details.get('financial_net_loss').value != ''">{{"&#8377;"}} {{FY_netLossAmtInwords2[i]}} Only</mat-hint>
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('financial_net_loss').value != ''">{{"&#8377;"}} {{FY_netLossAmtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:25%">
<input matInput autocomplete="off" placeholder="Net Loss to Sales" formControlName="financial_margin_of_loss" (keypress)="keyPress($event)">
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Loss to Sales in %" formControlName="financial_margin_of_loss" (keypress)="keyPress($event)">
</mat-form-field>
</span>
</div>
<span *ngIf="i != 0">
<mat-form-field style="width:65%">
<input matInput autocomplete="off" [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 autocomplete="off" [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Profit Variation from Previous Year in %" formControlName="financial_variation" (keypress)="keyPress($event)">
<mat-hint align="end" *ngIf="i != 0 && details.get('financial_variation').value != '' " [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" >
<span *ngIf="details.get('financial_variation').value == 0">
No differents in Profit in FY {{details.get('financial_year').value}} over sales in FY {{details.get('financial_year').value}}
No differents in Profit in FY <i> {{details.get('financial_year').value}} </i> over Profit in FY <i> {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} </i>
</span>
<span *ngIf="details.get('financial_variation').value >= 0">
{{details.get('financial_variation').value >= 0 ? 'Increase in Profit in FY ' : 'Decrease in Profit in FY'}} {{details.get('financial_year').value}} over Profit in FY {{details.get('financial_year').value}} {{details.get('financial_variation').value}} %
<span *ngIf="details.get('financial_variation').value > 0" class="greenhighlight">
Increase in Profit in FY <i> {{details.get('financial_year').value}} </i> over Profit in FY <i> {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} </i> <b> {{details.get('financial_variation').value}} % </b>
</span>
<span *ngIf="details.get('financial_variation').value < 0" class="highlight">
Decrease in Profit in FY <i> {{details.get('financial_year').value}} </i> over Profit in FY <i> {{financialForm.controls.date_per_financial['controls'][i-1].get('financial_year').value}} </i> <b> {{details.get('financial_variation').value}} % </b>
</span>
</mat-hint>
<!-- “Increase in Sales in FY 2017-2018 over sales in FY 2016-2017 is 11.11%” -->
@ -113,10 +132,10 @@
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 type="button" mat-raised-button mat-icon-button (click)="deleteDate(i)"
<!-- <button align="end" 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>
</button>
</button> -->
</mat-card-content>
</div>
</div>
@ -142,66 +161,91 @@
<div *ngFor="let details of financialForm.controls.estimated_value['controls']; let i=index"
[formGroupName]="i">
<mat-card-content class="matcard">
<div style="width:100%">
<mat-form-field style="width:25%">
<!-- <input matInput autocomplete="off" placeholder="Year (format: 2015-16)" formControlName="estimate_year" > -->
<input matInput autocomplete="off" placeholder="Year" formControlName="estimate_year" >
</mat-form-field>
<mat-form-field style="width:25%">
<input matInput autocomplete="off" placeholder="Annual Sale" formControlName="estimate_annual_sale" (change)="calMarginVal( i, details)" (keypress)="keyPress($event)" (keyup)="inWords($event,i,4)" >
<mat-hint align="end" *ngIf="details.get('estimate_annual_sale').value != ''">{{"&#8377;"}} {{AV_annualSalesInwords2[i]}} Only</mat-hint>
</mat-form-field>
</div>
<div style="width:100%">
<mat-form-field style="width:35%">
<!-- <input matInput autocomplete="off" placeholder="Net Profit / Loss" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" > -->
<mat-select placeholder="Is there Net Profit or Net Loss?" formControlName="estimate_profit_or_loss" >
<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 style="width:25%">
<input matInput autocomplete="off" placeholder="Net Profit Amount" formControlName="estimate_net_profit" (change)="calMarginVal( i, details); calVariation( i, details)" (keyup)="inWords($event,i,5)">
<mat-hint align="end" style=" font-size: 2%;" *ngIf="details.get('estimate_net_profit').value != ''">{{"&#8377;"}} {{AV_netProfitAmtInwords2[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:25%">
<input matInput autocomplete="off" disabled placeholder="Net Profit to Sales" formControlName="estimate_margin_of_profit" (keypress)="keyPress($event)" >
</mat-form-field>
</span>
<span *ngIf="details.get('estimate_profit_or_loss').value == 2 ">
<mat-form-field style="width:25%">
<input matInput autocomplete="off" placeholder="Net Loss" formControlName="estimate_net_loss" (change)="calMarginVal( i, details); calVariation( i, details)" (keyup)="inWords($event,i,6)">
<mat-hint align="end" *ngIf="details.get('estimate_net_loss').value != ''">{{"&#8377;"}} {{AV_netLossAmtInwords2[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:25%">
<input matInput autocomplete="off" disabled placeholder="Net Loss to Sales" formControlName="estimate_margin_of_loss" (keypress)="keyPress($event)" (change)="calAmount(i, details); calVariation( i, details)" >
</mat-form-field>
</span>
</div>
<mat-form-field *ngIf="i != 0" style="width:65%">
<input matInput autocomplete="off" placeholder="Aunnal Sales Variation" formControlName="estimate_annualsales_variation" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field *ngIf="i != 0" style="width:65%">
<input matInput autocomplete="off" [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>
<input matInput autocomplete="off" placeholder="Reason For Major Difference" formControlName="estimate_reason" >
</mat-form-field>-->
<!-- <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">
<mat-icon>add</mat-icon>
</button> -->
<button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(i)"
<mat-label class="highlight"> <i>Financial Year : {{details.get('estimate_year').value}} </i> </mat-label>
<hr>
<div style="width:100%">
<br>
<!-- <mat-form-field style="width:25%">
<!-- <input matInput autocomplete="off" placeholder="Year (format: 2015-16)" formControlName="estimate_year" > ->
<input matInput autocomplete="off" placeholder="Year" formControlName="estimate_year" >
</mat-form-field> -->
<mat-form-field style="width:30%">
<input matInput autocomplete="off" placeholder="Annual Sale" formControlName="estimate_annual_sale" (change)="calMarginVal( i, details)" (keypress)="keyPress($event)" (keyup)="inWords($event,i,4)" >
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('estimate_annual_sale').value != ''">{{"&#8377;"}} {{AV_annualSalesInwords[i]}} Only</mat-hint>
</mat-form-field>
<span *ngIf="i != 0">
<mat-form-field style="width:60%">
<input matInput autocomplete="off" placeholder="Sale Variation from Previous Year in %" formControlName="estimate_annualsales_variation" (keypress)="keyPress($event)" (change)="calEstAnnualSale( i,details);">
<mat-hint align="end" *ngIf="details.get('estimate_annualsales_variation').value != '' " >
<span *ngIf="details.get('estimate_annualsales_variation').value == 0">
No differents in Sales in FY <i> {{details.get('estimate_year').value}} </i> over Sales in FY <i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i>
</span>
<span *ngIf="details.get('estimate_annualsales_variation').value > 0" class="greenhighlight">
Increase in Sales in FY <i> {{details.get('estimate_year').value}} </i> over Sales in FY <i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i><b> {{details.get('estimate_annualsales_variation').value}} % </b>
</span>
<span *ngIf="details.get('estimate_annualsales_variation').value < 0" class="highlight">
Decrease in Sales in FY <i> {{details.get('estimate_year').value}} </i> over Sales in FY <i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i><b> {{details.get('estimate_annualsales_variation').value}} % </b>
</span>
</mat-hint>
</mat-form-field>
</span>
</div>
<div style="width:100%">
<mat-form-field style="width:30%">
<!-- <input matInput autocomplete="off" placeholder="Net Profit / Loss" formControlName="financial_net_profit" (change)="calMargin( i, details); calYearVariation( i, details)" type="number" > -->
<mat-select placeholder="Is there Net Profit or Net Loss?" formControlName="estimate_profit_or_loss" >
<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 style="width:28%">
<input matInput autocomplete="off" placeholder="Net Profit Amount" formControlName="estimate_net_profit" (change)="calMarginVal( i, details); calVariation( i, details)" (keyup)="inWords($event,i,5)">
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('estimate_net_profit').value != ''">{{"&#8377;"}} {{AV_netProfitAmtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Profit to Sales in %" formControlName="estimate_margin_of_profit" (change)="calProfitAndLossVal(i,details); calVariation( i, details)" (keypress)="keyPress($event)" >
</mat-form-field>
</span>
<span *ngIf="details.get('estimate_profit_or_loss').value == 2 ">
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Loss" formControlName="estimate_net_loss" (change)="calMarginVal( i, details); calVariation( i, details)" (keyup)="inWords($event,i,6)">
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('estimate_net_loss').value != ''">{{"&#8377;"}} {{AV_netLossAmtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field style="width:28%">
<input matInput autocomplete="off" placeholder="Net Loss to Sales" formControlName="estimate_margin_of_loss" (keypress)="keyPress($event)" (change)="calProfitAndLossVal(i,details); calVariation( i, details)" >
</mat-form-field>
</span>
</div>
<mat-form-field *ngIf="i != 0" style="width:65%">
<input matInput autocomplete="off" [ngClass]="{'highlight': details.controls['estimate_variation'].value >= 40 || details.controls['estimate_variation'].value >= -40}" placeholder="Variation from Previous Year in %" formControlName="estimate_variation" (keypress)="keyPress($event)">
<mat-hint align="end" [ngClass]="{'highlight': (details.controls['estimate_variation'].value >= 40) || (details.controls['estimate_variation'].value < -40)}" >
<span *ngIf="details.get('estimate_variation').value == 0">
No differents in Profit in FY <i> {{details.get('estimate_year').value}} </i> over Profit in FY <i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i>
</span>
<span *ngIf="details.get('estimate_variation').value > 0" class="greenhighlight">
Increase in Profit in FY <i> {{details.get('estimate_year').value}} </i> over Profit in FY<i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i> <b>{{details.get('estimate_variation').value}} % </b>
</span>
<span *ngIf="details.get('estimate_variation').value < 0" class="highlight">
Decrease in Profit in FY <i> {{details.get('estimate_year').value}} </i>over Profit in FY <i> {{financialForm.controls.estimated_value['controls'][i-1].get('estimate_year').value}} </i> <b>{{details.get('estimate_variation').value}} % </b>
</span>
<!-- {{details.controls[''].value}} {{details.controls[''].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>
<input matInput autocomplete="off" placeholder="Reason For Major Difference" formControlName="estimate_reason" >
</mat-form-field>-->
<!-- <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">
<mat-icon>add</mat-icon>
</button> -->
<!-- <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">
<mat-icon>delete</mat-icon>
</button>
</button> -->
</mat-card-content>
</div>
</div>
@ -354,7 +398,7 @@
<input matInput autocomplete="off" placeholder="Net Profit to Sales" formControlName="financial_margin" (keypress)="keyPress($event)" >
</mat-form-field>
<mat-form-field *ngIf="i != 0">
<input matInput autocomplete="off" [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 autocomplete="off" [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Variation from Previous Year in %" formControlName="financial_variation" (keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field>
<input matInput autocomplete="off" placeholder="Reason For Major Difference" formControlName="financial_reason" >
@ -393,7 +437,7 @@
<input matInput autocomplete="off" disabled placeholder="Margin" formControlName="estimate_margin" (keypress)="keyPress($event)" >
</mat-form-field>
<mat-form-field *ngIf="i != 0">
<input matInput autocomplete="off" [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 autocomplete="off" [ngClass]="{'highlight': details.controls['estimate_variation'].value >= 40 || details.controls['estimate_variation'].value >= -40}" placeholder="Variation from Previous Year in %" formControlName="estimate_variation" (keypress)="keyPress($event)">
</mat-form-field>
<!--<mat-form-field>
<input matInput autocomplete="off" placeholder="Reason For Major Difference" formControlName="estimate_reason" >

View File

@ -22,6 +22,10 @@
border: none;
}
.greenhighlight {
color: green;
}
.highlight {
color: red;
}

View File

@ -22,7 +22,7 @@ import {
/** Service */
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
import {ActivatedRoute, Router} from '@angular/router';
import { Alert } from 'selenium-webdriver';
//import { Alert } from 'selenium-webdriver';
@Component({
selector: 'app-financial-info',
@ -40,12 +40,13 @@ export class FinancialInfoComponent implements OnInit {
placeholderName : any = [];
setmargin: AbstractControl;
customerCommentsFlag :boolean;
FY_annualSalesInwords2 : any = [];
FY_annualSalesInwords : any = [];
FY_netProfitAmtInwords : any = [];
FY_netLossAmtInwords2 : any = [];
AV_annualSalesInwords2 : any = [];
AV_netProfitAmtInwords2 : any = [];
AV_netLossAmtInwords2 : any = [];
FY_netLossAmtInwords : any = [];
AV_annualSalesInwords : any = [];
AV_netProfitAmtInwords : any = [];
AV_netLossAmtInwords : any = [];
isReadOnly : boolean = false;
constructor(notifier: NotifierService,
private fb: FormBuilder,
@ -88,6 +89,7 @@ export class FinancialInfoComponent implements OnInit {
const estimated_val = <FormArray>this.financialForm.controls['estimated_value'];
if (value.status == 200) {
let retriveData = value.records;
this.isReadOnly = true;
let result = Object.keys(value.records.date_per_financial).map(function(key) {
return value.records.date_per_financial[key];
});
@ -95,9 +97,12 @@ export class FinancialInfoComponent implements OnInit {
return value.records.estimated_value[key];
});
if (result.length > 0) {
result.forEach(val => {
result.forEach((val,index) => {
//financial_date.push(this.createDate());
financial_date.push(this.createDate(''));
this.FY_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale);
this.FY_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit);
this.FY_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss);
financial_date.push(this.createDate(''));
});
retriveData.date_per_financial = result;
} else {
@ -105,7 +110,12 @@ export class FinancialInfoComponent implements OnInit {
financial_date.push(this.createDate(''));
}
if (result_val.length > 0) {
result_val.forEach(val => {
console.log(result_val);
result_val.forEach((val,index) => {
//console.log('dedrf',val.estimate_annual_sale);
this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.estimate_annual_sale);
this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_profit);
this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.estimate_net_loss);
estimated_val.push(this.createValue(''));
});
retriveData.estimated_value = result_val;
@ -251,8 +261,8 @@ export class FinancialInfoComponent implements OnInit {
if(array.length > 0 ){
console.log(array.length);
for (let val of array.value) {
array.value.forEach((val,index)=>{
let vals = {
estimate_year: val.financial_year,
estimate_annual_sale: val.financial_annual_sale,
@ -262,10 +272,13 @@ export class FinancialInfoComponent implements OnInit {
estimate_margin_of_profit: val.financial_margin_of_profit,
estimate_margin_of_loss: val.financial_margin_of_loss,
estimate_variation: val.financial_variation,
estimate_annualsales_variation : val.financial_annualsales_variation
estimate_annualsales_variation : val.financial_annualsales_variation,
};
this.AV_annualSalesInwords[index] = this._pd.convertNumberToWords(val.financial_annual_sale);
this.AV_netProfitAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_profit);
this.AV_netLossAmtInwords[index] = this._pd.convertNumberToWords(val.financial_net_loss);
control.push(this.createValuewithData(vals));
}
});
}
@ -317,11 +330,23 @@ export class FinancialInfoComponent implements OnInit {
let array = <FormArray>this.financialForm.controls['date_per_financial'];
let prev_annual_sale = array.value[index-1].financial_annual_sale;
let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ;
detail.controls.financial_annualsales_variation.setValue(annual_sale_variation.toFixed(2)+'%');
detail.controls.financial_annualsales_variation.setValue(annual_sale_variation.toFixed(2));
console.log('annual sales variation in %',annual_sale_variation);
}
}
calEstAnnualSale(index,detail){
let annual_sale = detail.value.estimate_annual_sale;
if (index != 0) {
let array = <FormArray>this.financialForm.controls['estimated_value'];
let prev_annual_sale = array.value[index-1].estimate_annual_sale;
let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ;
detail.controls.estimate_annualsales_variation.setValue(annual_sale_variation.toFixed(2));
console.log('estimate annual sales variation in %',annual_sale_variation);
}
}
calYearVariation(index, detail) {
let annual_sale = detail.value.financial_annual_sale;
@ -401,18 +426,18 @@ export class FinancialInfoComponent implements OnInit {
let profit = detail.value.financial_net_profit;
if (salary != '' && profit != '') {
if(salary < profit){
alert('if condition salary = '+salary);
alert('if condition Profit = '+profit);
detail.controls.financial_margin_of_profit.setValue('');
}
else{
alert('else condition salary = '+salary);
alert('else condition Profit = '+profit);
let margin = (profit / salary) * 100;
alert(' '+margin);
detail.controls.financial_margin_of_profit.setValue(margin.toFixed(2)+'%')
}
// if(salary < profit){
// alert('if condition salary = '+salary);
// alert('if condition Profit = '+profit);
// detail.controls.financial_margin_of_profit.setValue('');
// }
// else{
// alert('else condition salary = '+salary);
// alert('else condition Profit = '+profit);
let margin = (profit / salary) * 100;
// alert(' '+margin);
detail.controls.financial_margin_of_profit.setValue(margin.toFixed(2)+'%')
// }
// detail.controls.financial_margin.disable()
}
@ -422,8 +447,8 @@ export class FinancialInfoComponent implements OnInit {
let loss = detail.value.financial_net_loss;
if (salary != '' && loss != '') {
alert('if condition salary = '+salary);
alert('if condition loss = '+loss);
// alert('if condition salary = '+salary);
// alert('if condition loss = '+loss);
let margin = (loss / salary) * 100;
detail.controls.financial_margin_of_loss.setValue(margin.toFixed(2));
// detail.controls.financial_margin.disable()
@ -485,14 +510,12 @@ export class FinancialInfoComponent implements OnInit {
let margin = profit / salary * 100;
console.log('margin',margin);
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);
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);
@ -504,31 +527,53 @@ export class FinancialInfoComponent implements OnInit {
}
calAmount(i, detail) {
calProfitAndLossVal( i, detail) {
console.log(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 profit = (margin_profit/100)*salary;
detail.controls.estimate_net_profit.setValue(profit.toFixed(2));
this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(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 margin_loss = detail.value.estimate_margin_of_loss;
if (salary != '' && margin_loss != '') {
let loss = (margin_loss/100)*salary;
detail.controls.estimate_net_loss.setValue(loss.toFixed(2));
this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(loss);
}
}
}
// calAmount(i, detail) {
// console.log(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;
@ -542,7 +587,7 @@ export class FinancialInfoComponent implements OnInit {
// }
// }
}
//}
submitDetails() {
if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 1){
@ -599,7 +644,8 @@ export class FinancialInfoComponent implements OnInit {
/** On Key Press Event For Input Field */
keyPress(event: any) {
const pattern = /[0-9]/;
//const pattern = /[0-9\-\.\ ]/;
const pattern = /[0-9\.]/;
let inputChar = String.fromCharCode(event.charCode);
if (event.keyCode != 8 && !pattern.test(inputChar)) {
@ -616,7 +662,7 @@ export class FinancialInfoComponent implements OnInit {
switch(flag){
case 1 :
this.FY_annualSalesInwords2[i] = this._pd.convertNumberToWords(e.target.value);
this.FY_annualSalesInwords[i] = this._pd.convertNumberToWords(e.target.value);
// this.placeholderName[i] = 'Weekly Instalment Amount'; break;
break;
case 2 :
@ -624,17 +670,17 @@ export class FinancialInfoComponent implements OnInit {
//alert('Fin net Profit'+this.FY_netProfitAmtInwords[i]);
break;
case 3 :
this.FY_netLossAmtInwords2[i] = this._pd.convertNumberToWords(e.target.value);
// alert('Fin net Loss'+this.FY_netLossAmtInwords2[i]);
this.FY_netLossAmtInwords[i] = this._pd.convertNumberToWords(e.target.value);
// alert('Fin net Loss'+this.FY_netLossAmtInwords[i]);
break;
case 4 :
this.AV_annualSalesInwords2[i] = this._pd.convertNumberToWords(e.target.value);
this.AV_annualSalesInwords[i] = this._pd.convertNumberToWords(e.target.value);
break;
case 5 :
this.AV_netProfitAmtInwords2[i] = this._pd.convertNumberToWords(e.target.value);
this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(e.target.value);
break;
case 6 :
this.AV_netLossAmtInwords2[i] = this._pd.convertNumberToWords(e.target.value);
this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(e.target.value);
break;
default:
break;