import { Component, OnInit } from '@angular/core'; import { AccountService } from '../../accounts/accounts-services'; import { NotificationService } from '../../../_services/notification.service'; import { ReportingService } from '../reporting.service'; import { AuthenticationService } from '../../../_services/authentication.service'; import { KGridHelper } from '../../../_helpers/k-grid.class'; import { PageChangeEvent, DataStateChangeEvent } from '@progress/kendo-angular-grid'; import { State, SortDescriptor, orderBy, process } from '@progress/kendo-data-query'; import { Subject, Subscription } from 'rxjs'; import { LocalService } from '../../../_services/local.service'; @Component({ selector: 'app-income-statement-report', templateUrl: './income-statement-report.component.html' }) export class IncomeStatementReportComponent implements OnInit { public kGrid: KGridHelper = new KGridHelper(); public FromDate = null; public ToDate = null; public _incomeStatement: IncomeStatementViewModel[]; public loading = false; public geting = false; public searchEvent = new Subject(); public searchSubcription: Subscription = null; public selectedAccount: any; state: DataStateChangeEvent; public isIncomeHidden = false; constructor(public _accountService: AccountService, public _notificationService: NotificationService, public _reportingServices: ReportingService, public _authenticationService: AuthenticationService, private _localService: LocalService ) { } ngOnInit() { } getReport() { this.getIncomeStatement(); } HideStatement(item) { } public datab: any[] = [{ text: 'My Documents', items: [ { text: 'Kendo UI Project', items: [ { text: 'about.html' }, { text: 'index.html' }, { text: 'logo.png' } ] }, { text: 'New Web Site', items: [ { text: 'mockup.jpg' }, { text: 'Research.pdf' } ] }, { text: 'Reports', items: [ { text: 'February.pdf' }, { text: 'March.pdf' }, { text: 'April.pdf' } ] } ] }]; // public iconClass({ text, items }: any): any { // return { // 'k-i-file-pdf': is(text, 'pdf'), // 'k-i-folder': items !== undefined, // 'k-i-html': is(text, 'html'), // 'k-i-image': is(text, 'jpg|png'), // 'k-icon': true // }; // } public data: any = []; public GrossIncome = 0; public GrossRevneu = 0; public GrossEarnings = 0; getIncomeStatement() { this.loading = true; this.geting = true; this._reportingServices .getIncomeStatement({ FromDate: new Date(this.FromDate), ToDate: new Date(this.ToDate) }) .subscribe((res: IncomeStatementViewModel[]) => { console.log(res); this._incomeStatement = []; this._incomeStatement = res; this.GrossRevneu = res[0].Total; this.GrossEarnings = res[1].Total; this.GrossIncome = this.BePositiveNigga(this.GrossRevneu) - this.BePositiveNigga(this.GrossEarnings); this.loading = false; this.geting = false; }, (err) => { console.log(err); }); } public ClearFilter() { this.kGrid.fromDate = null; this.kGrid.toDate = null; } BePositiveNigga(num) { return Math.abs(num); } public dataStateChange(state: DataStateChangeEvent): void { this.state = state; this.kGrid.gridView = process(this.kGrid.data, this.state); } public sortChange(sort: SortDescriptor[]): void { if (sort[0].field == 'asd') { return; } this.kGrid.sort = sort; this.sortData(); } private sortData() { this.kGrid.gridView = { data: orderBy(this.kGrid.data, this.kGrid.sort), total: this.kGrid.totalRecords }; } public pageChange(event: PageChangeEvent): void { this.kGrid.skip = event.skip; // this.getEmployeelist(); } private handleError(err: any) { this.kGrid.loading = false; if (err.status == 403) { this._authenticationService.logout(); } } onBinClick(aid: number) { alert(aid); } public changePagesize(value: any) { this.kGrid.pageSize = +value; this.kGrid.skip = 0; // this.getEmployeelist(); } } export class IncomeStatementViewModel { public Id: number; public Name: string; public Count: number; public Head1List: FirstHeadViewModel[]; public Total?: number; } export class FirstHeadViewModel { public Id: number; public Name: string; public Count: number; public Head2List: PreHeadViewModel[]; public Total?: number; } export class PreHeadViewModel { public Id: number; public Name: string; public Count: number; public AccountsHeadList: AccountHeadViewModel[]; public Total?: number; } export class AccountHeadViewModel { public Id: number; public Name: string; public Count: number; public Amount: number; public Total?: number; } export class DataItem { constructor(name?: string, items?: DataItem[]) { this.Name = name; this.Items = items; } public Name: string; public Items?: DataItem[]; }