mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
refactor: financial reports to nestjs
This commit is contained in:
35
temp/BalanceSheet/BalanceSheetTableInjectable.ts
Normal file
35
temp/BalanceSheet/BalanceSheetTableInjectable.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { BalanceSheetInjectable } from './BalanceSheetInjectable';
|
||||
import { BalanceSheetTable } from './BalanceSheetTable';
|
||||
import { IBalanceSheetQuery, IBalanceSheetTable } from './BalanceSheet.types';
|
||||
|
||||
@Injectable()
|
||||
export class BalanceSheetTableInjectable {
|
||||
constructor(
|
||||
private readonly balanceSheetService: BalanceSheetInjectable,
|
||||
private readonly i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet in table format.
|
||||
* @param {number} tenantId
|
||||
* @param {number} query
|
||||
* @returns {Promise<IBalanceSheetTable>}
|
||||
*/
|
||||
public async table(filter: IBalanceSheetQuery): Promise<IBalanceSheetTable> {
|
||||
const { data, query, meta } =
|
||||
await this.balanceSheetService.balanceSheet(filter);
|
||||
|
||||
const table = new BalanceSheetTable(data, query, this.i18nService);
|
||||
|
||||
return {
|
||||
table: {
|
||||
columns: table.tableColumns(),
|
||||
rows: table.tableRows(),
|
||||
},
|
||||
query,
|
||||
meta,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user