WIP transactions by vendors report.

This commit is contained in:
a.bouhuolia
2021-05-06 04:53:33 +02:00
parent c57f2de970
commit 9b5ccf9248
13 changed files with 620 additions and 202 deletions

View File

@@ -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],
});
}
}