mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: cashflow statement meta.
This commit is contained in:
@@ -6,12 +6,15 @@ import FinancialSheet from '../FinancialSheet';
|
||||
import {
|
||||
ICashFlowStatementService,
|
||||
ICashFlowStatementQuery,
|
||||
ICashFlowStatement,
|
||||
ICashFlowStatementDOO,
|
||||
IAccountTransaction,
|
||||
ICashFlowStatementMeta
|
||||
} from 'interfaces';
|
||||
import CashFlowStatement from './CashFlow';
|
||||
import Ledger from 'services/Accounting/Ledger';
|
||||
import CashFlowRepository from './CashFlowRepository';
|
||||
import InventoryService from 'services/Inventory/Inventory';
|
||||
import { parseBoolean } from 'utils';
|
||||
|
||||
@Service()
|
||||
export default class CashFlowStatementService
|
||||
@@ -24,6 +27,9 @@ export default class CashFlowStatementService
|
||||
@Inject()
|
||||
cashFlowRepo: CashFlowRepository;
|
||||
|
||||
@Inject()
|
||||
inventoryService: InventoryService;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -82,15 +88,12 @@ export default class CashFlowStatementService
|
||||
* Retrieve the cash flow sheet statement.
|
||||
* @param {number} tenantId
|
||||
* @param {ICashFlowStatementQuery} query
|
||||
* @returns {Promise<ICashFlowStatement>}
|
||||
* @returns {Promise<ICashFlowStatementDOO>}
|
||||
*/
|
||||
public async cashFlow(
|
||||
tenantId: number,
|
||||
query: ICashFlowStatementQuery
|
||||
): Promise<{
|
||||
data: ICashFlowStatement;
|
||||
query: ICashFlowStatementQuery;
|
||||
}> {
|
||||
): Promise<ICashFlowStatementDOO> {
|
||||
// Retrieve all accounts on the storage.
|
||||
const accounts = await this.cashFlowRepo.cashFlowAccounts(tenantId);
|
||||
|
||||
@@ -120,7 +123,6 @@ export default class CashFlowStatementService
|
||||
tenantId,
|
||||
filter
|
||||
);
|
||||
|
||||
// Transformes the transactions to ledgers.
|
||||
const ledger = Ledger.fromTransactions(transactions);
|
||||
const cashLedger = Ledger.fromTransactions(cashAtBeginningTransactions);
|
||||
@@ -139,6 +141,34 @@ export default class CashFlowStatementService
|
||||
return {
|
||||
data: cashFlowInstance.reportData(),
|
||||
query: filter,
|
||||
meta: this.reportMetadata(tenantId),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the balance sheet meta.
|
||||
* @param {number} tenantId -
|
||||
* @returns {ICashFlowStatementMeta}
|
||||
*/
|
||||
private reportMetadata(tenantId: number): ICashFlowStatementMeta {
|
||||
const settings = this.tenancy.settings(tenantId);
|
||||
|
||||
const isCostComputeRunning = this.inventoryService
|
||||
.isItemsCostComputeRunning(tenantId);
|
||||
|
||||
const organizationName = settings.get({
|
||||
group: 'organization',
|
||||
key: 'name',
|
||||
});
|
||||
const baseCurrency = settings.get({
|
||||
group: 'organization',
|
||||
key: 'base_currency',
|
||||
});
|
||||
|
||||
return {
|
||||
isCostComputeRunning: parseBoolean(isCostComputeRunning, false),
|
||||
organizationName,
|
||||
baseCurrency
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
ITableRow,
|
||||
ITableColumn,
|
||||
ICashFlowStatementQuery,
|
||||
IDateRange
|
||||
IDateRange,
|
||||
ICashFlowStatementDOO
|
||||
} from 'interfaces';
|
||||
import { dateRangeFromToCollection, tableRowMapper } from 'utils';
|
||||
import { mapValuesDeep } from 'utils/deepdash';
|
||||
@@ -28,20 +29,14 @@ const DISPLAY_COLUMNS_BY = {
|
||||
|
||||
|
||||
export default class CashFlowTable implements ICashFlowTable {
|
||||
private report: {
|
||||
data: ICashFlowStatement;
|
||||
query: ICashFlowStatementQuery;
|
||||
};
|
||||
private report: ICashFlowStatementDOO;
|
||||
private dateRangeSet: IDateRange[];
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {ICashFlowStatement} reportStatement
|
||||
*/
|
||||
constructor(reportStatement: {
|
||||
data: ICashFlowStatement;
|
||||
query: ICashFlowStatementQuery;
|
||||
}) {
|
||||
constructor(reportStatement: ICashFlowStatementDOO) {
|
||||
this.report = reportStatement;
|
||||
this.dateRangeSet = [];
|
||||
this.initDateRangeCollection();
|
||||
|
||||
Reference in New Issue
Block a user