mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat: financial reports meta
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import moment from 'moment';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { FinancialSheetMeta } from '../FinancialSheetMeta';
|
||||
import {
|
||||
ITransactionsByCustomersFilter,
|
||||
ITransactionsByCustomersMeta,
|
||||
} from '@/interfaces';
|
||||
|
||||
@Service()
|
||||
export class TransactionsByCustomersMeta {
|
||||
@Inject()
|
||||
private financialSheetMeta: FinancialSheetMeta;
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by customers meta.
|
||||
* @param {number} tenantId -
|
||||
* @returns {IBalanceSheetMeta}
|
||||
*/
|
||||
public async meta(
|
||||
tenantId: number,
|
||||
query: ITransactionsByCustomersFilter
|
||||
): Promise<ITransactionsByCustomersMeta> {
|
||||
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 Customers',
|
||||
formattedFromDate,
|
||||
formattedToDate,
|
||||
formattedDateRange,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export class TransactionsByCustomersPdf {
|
||||
/**
|
||||
* Retrieves the transactions by customers in PDF format.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {IBalanceSheetQuery} query - Balance sheet query.
|
||||
* @param {ITransactionsByCustomersFilter} query - Balance sheet query.
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
@@ -24,13 +24,11 @@ export class TransactionsByCustomersPdf {
|
||||
tenantId,
|
||||
query
|
||||
);
|
||||
const sheetName = 'Transactions By Customers';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
table.meta.sheetName,
|
||||
table.meta.formattedDateRange
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import TransactionsByCustomers from './TransactionsByCustomers';
|
||||
import Ledger from '@/services/Accounting/Ledger';
|
||||
import TransactionsByCustomersRepository from './TransactionsByCustomersRepository';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { TransactionsByCustomersMeta } from './TransactionsByCustomersMeta';
|
||||
|
||||
export class TransactionsByCustomersSheet
|
||||
implements ITransactionsByCustomersService
|
||||
@@ -22,6 +23,9 @@ export class TransactionsByCustomersSheet
|
||||
@Inject()
|
||||
private reportRepository: TransactionsByCustomersRepository;
|
||||
|
||||
@Inject()
|
||||
private transactionsByCustomersMeta: TransactionsByCustomersMeta;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {ICustomerBalanceSummaryQuery}
|
||||
@@ -160,10 +164,12 @@ export class TransactionsByCustomersSheet
|
||||
i18n
|
||||
);
|
||||
|
||||
const meta = await this.transactionsByCustomersMeta.meta(tenantId, filter);
|
||||
|
||||
return {
|
||||
data: reportInstance.reportData(),
|
||||
query: filter,
|
||||
meta: {},
|
||||
meta,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as R from 'ramda';
|
||||
import { tableRowMapper } from 'utils';
|
||||
import { ITransactionsByCustomersCustomer, ITableRow, ITableColumn } from '@/interfaces';
|
||||
import {
|
||||
ITransactionsByCustomersCustomer,
|
||||
ITableRow,
|
||||
ITableColumn,
|
||||
} from '@/interfaces';
|
||||
import TransactionsByContactsTableRows from '../TransactionsByContact/TransactionsByContactTableRows';
|
||||
|
||||
enum ROW_TYPE {
|
||||
@@ -78,6 +82,14 @@ export class TransactionsByCustomersTable extends TransactionsByContactsTableRow
|
||||
* @returns {ITableColumn[]}
|
||||
*/
|
||||
public tableColumns = (): ITableColumn[] => {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
{ key: 'customer_name', label: 'Customer 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' },
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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