import { Component, OnInit } from '@angular/core'; import { KGridHelper } from '../../../_helpers/k-grid.class'; import { IncomeStatementViewModel } from '../income-statement-report/income-statement-report.component'; import { Subject, Subscription } from 'rxjs'; import { DataStateChangeEvent } from '@progress/kendo-angular-grid'; import { AccountService } from '../../accounts/accounts-services'; import { NotificationService } from '../../../_services/notification.service'; import { ReportingService } from '../reporting.service'; import { AuthenticationService } from '../../../_services/authentication.service'; @Component({ selector: 'app-balance-sheet-v2', templateUrl: './balance-sheet-v2.component.html', }) export class BalanceSheetV2Component implements OnInit { public kGrid: KGridHelper = new KGridHelper(); public FromDate = null; public ToDate: Date = null; public _incomeStatement: IncomeStatementViewModel[]; public loading = false; public geting = false; public searchEvent = new Subject(); public searchSubcription: Subscription = null; public selectedAccount: any; public BS: any; state: DataStateChangeEvent; public GrossIncome = 0; public GrossRevneu = 0; public GrossEarnings = 0; public EquityAndCap = 0; public Liabilities = 0; public isIncomeHidden = false; constructor(public _accountService: AccountService, public _notificationService: NotificationService, public _reportingServices: ReportingService, public _authenticationService: AuthenticationService ) { } ngOnInit() { } getReport() { this.getBalanceSheetv2(); } getBalanceSheetv2() { this._reportingServices .getBalanceSheetv1({ ToDate: new Date(this.ToDate) }) .subscribe((res: IncomeStatementViewModel[]) => { console.log(res); this.loading = true; this.geting = true; this._incomeStatement = []; this._incomeStatement = res; this.EquityAndCap = res[2].Total; this.Liabilities = res[1].Total; this.loading = false; this.geting = false; }, (err) => { console.log(err); }); let todate = this.ToDate; let formdate = new Date(); formdate.setFullYear(this.ToDate.getFullYear() - 30); this._reportingServices .getIncomeStatement({ FromDate: formdate, ToDate: new Date(todate) }) .subscribe((res: any[]) => { this.kGrid.data = []; this.kGrid.data = res; console.log(this.kGrid.data); ; this.kGrid.gridView = { data: this.kGrid.data, total: this.kGrid.totalRecords }; this.kGrid.loading = false; }, (err) => { console.log(err); }); } public ClearFilter() { this.kGrid.fromDate = null; this.kGrid.toDate = null; } BePositiveNigga(num) { return Math.abs(num); } }