mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
WIP transactions by vendors report.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import { tableMapper, tableRowMapper } from 'utils';
|
||||
import {
|
||||
ITransactionsByContactsContact,
|
||||
ITableRow,
|
||||
} from 'interfaces';
|
||||
|
||||
enum ROW_TYPE {
|
||||
OPENING_BALANCE = 'OPENING_BALANCE',
|
||||
CLOSING_BALANCE = 'CLOSING_BALANCE',
|
||||
TRANSACTION = 'TRANSACTION',
|
||||
CUSTOMER = 'CUSTOMER',
|
||||
}
|
||||
|
||||
export default class TransactionsByContactsTableRows {
|
||||
/**
|
||||
* Retrieve the table rows of contact transactions.
|
||||
* @param {ITransactionsByCustomersCustomer} contact
|
||||
* @returns {ITableRow[]}
|
||||
*/
|
||||
protected contactTransactions(
|
||||
contact: ITransactionsByContactsContact
|
||||
): ITableRow[] {
|
||||
const columns = [
|
||||
{ key: 'date', accessor: 'date' },
|
||||
{ key: 'account', accessor: 'account.name' },
|
||||
{ key: 'referenceType', accessor: 'referenceType' },
|
||||
{ key: 'transactionType', accessor: 'transactionType' },
|
||||
{ key: 'credit', accessor: 'credit.formattedAmount' },
|
||||
{ key: 'debit', accessor: 'debit.formattedAmount' },
|
||||
];
|
||||
return tableMapper(contact.transactions, columns, {
|
||||
rowTypes: [ROW_TYPE.TRANSACTION],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the table row of contact opening balance.
|
||||
* @param {ITransactionsByCustomersCustomer} contact
|
||||
* @returns {ITableRow}
|
||||
*/
|
||||
protected contactOpeningBalance(
|
||||
contact: ITransactionsByContactsContact
|
||||
): ITableRow {
|
||||
const columns = [
|
||||
{ key: 'openingBalanceLabel', value: 'Opening balance' },
|
||||
{
|
||||
key: 'openingBalanceValue',
|
||||
accessor: 'openingBalance.formattedAmount',
|
||||
},
|
||||
];
|
||||
return tableRowMapper(contact, columns, {
|
||||
rowTypes: [ROW_TYPE.OPENING_BALANCE],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the table row of contact closing balance.
|
||||
* @param {ITransactionsByCustomersCustomer} contact -
|
||||
* @returns {ITableRow}
|
||||
*/
|
||||
protected contactClosingBalance(
|
||||
contact: ITransactionsByContactsContact
|
||||
): ITableRow {
|
||||
const columns = [
|
||||
{ key: 'openingBalanceLabel', value: 'Closing balance' },
|
||||
{
|
||||
key: 'openingBalanceValue',
|
||||
accessor: 'closingBalance.formattedAmount',
|
||||
},
|
||||
];
|
||||
return tableRowMapper(contact, columns, {
|
||||
rowTypes: [ROW_TYPE.CLOSING_BALANCE],
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user