import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { EmployeeSalaryServices } from '../emp-salary-services'; import { EmpSalaryMastModel } from '../emp-salary-class'; import { LocalService } from '../../../_services/local.service'; @Component({ selector: 'app-emp-salery-invoice', templateUrl: './emp-salery-invoice.component.html', }) export class EmpSaleryInvoiceComponent implements OnInit { public commision = null; constructor( private activatedRoute: ActivatedRoute, private _employeeSalaryServices: EmployeeSalaryServices, private _localService: LocalService ) { } ngOnInit() { this.activatedRoute.queryParams.subscribe(params => { const accId = params['id']; if (accId != null) { this.getSalaryInvDetail(accId); } else { } }); } public isReimbursementVisible = false; public itemRate = 0; public itemTotal = 0; public getSalaryInvDetail(e) { this._employeeSalaryServices.getSalaryInvDetail(e).subscribe((res: any) => { if (res) { console.log(res); this.commision = new EmpSalaryMastModel(); this.commision = res; this.commision.EmpList = res.EmpList; this.commision.CreationDate = new Date(res.CreationDate); this.commision.ToDate = new Date(res.ToDate); this.commision.FromDate = new Date(res.FromDate); var percentage = (this.commision.Total * .5); console.log(percentage); console.log(this.commision.Total); var val = this.commision.Total - percentage; console.log(val); console.log(this.commision.VatAmount); this.itemRate = (((this.commision.VatAmount * 100) / 5) / this.commision.EmpList.length); this.itemTotal = ((((this.commision.VatAmount * 100) / 5) / this.commision.EmpList.length) * this.commision.EmpList.length); if (((this.commision.Total * .5) - this.commision.Total) == this.commision.VatAmount) { this.isReimbursementVisible = false; } else { this.isReimbursementVisible = true; } } }, err => { }); } }