mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: financial reports meta
This commit is contained in:
@@ -69,6 +69,7 @@ export class TransactionsByVendorApplication {
|
||||
* Retrieves the transactions by vendor in XLSX format.
|
||||
* @param {number} tenantId
|
||||
* @param {ITransactionsByVendorsFilter} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public xlsx(
|
||||
tenantId: number,
|
||||
|
||||
@@ -12,6 +12,7 @@ import TransactionsByVendor from './TransactionsByVendor';
|
||||
import Ledger from '@/services/Accounting/Ledger';
|
||||
import TransactionsByVendorRepository from './TransactionsByVendorRepository';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { TransactionsByVendorMeta } from './TransactionsByVendorMeta';
|
||||
|
||||
export class TransactionsByVendorsInjectable
|
||||
implements ITransactionsByVendorsService
|
||||
@@ -22,6 +23,9 @@ export class TransactionsByVendorsInjectable
|
||||
@Inject()
|
||||
private reportRepository: TransactionsByVendorRepository;
|
||||
|
||||
@Inject()
|
||||
private transactionsByVendorMeta: TransactionsByVendorMeta;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IVendorBalanceSummaryQuery}
|
||||
@@ -165,10 +169,12 @@ export class TransactionsByVendorsInjectable
|
||||
tenant.metadata.baseCurrency,
|
||||
i18n
|
||||
);
|
||||
const meta = await this.transactionsByVendorMeta.meta(tenantId, filter);
|
||||
|
||||
return {
|
||||
data: reportInstance.reportData(),
|
||||
query: filter,
|
||||
meta: {},
|
||||
meta,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import moment from 'moment';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { FinancialSheetMeta } from '../FinancialSheetMeta';
|
||||
import {
|
||||
ITransactionsByVendorMeta,
|
||||
ITransactionsByVendorsFilter,
|
||||
} from '@/interfaces';
|
||||
|
||||
@Service()
|
||||
export class TransactionsByVendorMeta {
|
||||
@Inject()
|
||||
private financialSheetMeta: FinancialSheetMeta;
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by vendor meta.
|
||||
* @param {number} tenantId -
|
||||
* @returns {Promise<ITransactionsByVendorMeta>}
|
||||
*/
|
||||
public async meta(
|
||||
tenantId: number,
|
||||
query: ITransactionsByVendorsFilter
|
||||
): Promise<ITransactionsByVendorMeta> {
|
||||
const commonMeta = await this.financialSheetMeta.meta(tenantId);
|
||||
const formattedToDate = moment(query.toDate).format('YYYY/MM/DD');
|
||||
const formattedFromDate = moment(query.fromDate).format('YYYY/MM/DD');
|
||||
const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`;
|
||||
|
||||
return {
|
||||
...commonMeta,
|
||||
sheetName: 'Transactions By Vendor',
|
||||
formattedFromDate,
|
||||
formattedToDate,
|
||||
formattedDateRange,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,12 @@ export class TransactionsByVendorsPdf {
|
||||
query: ITransactionsByVendorsFilter
|
||||
): Promise<Buffer> {
|
||||
const table = await this.transactionsByVendorTable.table(tenantId, query);
|
||||
const sheetName = 'Transactions By Vendors';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
table.meta.sheetName,
|
||||
table.meta.formattedDateRange
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ export class TransactionsByVendorsTable extends TransactionsByContactsTableRows
|
||||
accessor: 'closingBalance.formattedAmount',
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
...tableRowMapper(vendor, columns, { rowTypes: [ROW_TYPE.VENDOR] }),
|
||||
children: R.pipe(
|
||||
@@ -82,6 +81,14 @@ export class TransactionsByVendorsTable extends TransactionsByContactsTableRows
|
||||
* @returns {ITableColumn[]}
|
||||
*/
|
||||
public tableColumns = (): ITableColumn[] => {
|
||||
return [];
|
||||
return [
|
||||
{ key: 'vendor_name', label: 'Vendor name' },
|
||||
{ key: 'account_name', label: 'Account Name' },
|
||||
{ key: 'ref_type', label: 'Reference Type' },
|
||||
{ key: 'transaction_type', label: 'Transaction Type' },
|
||||
{ key: 'credit', label: 'Credit' },
|
||||
{ key: 'debit', label: 'Debit' },
|
||||
{ key: 'running_balance', label: 'Running Balance' },
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user