feat: add specific cashflow account transactions.

This commit is contained in:
elforjani13
2021-10-27 19:29:32 +02:00
parent f378275673
commit b0f1584b04
3 changed files with 16 additions and 21 deletions

View File

@@ -12,7 +12,7 @@ import {
const AccountTransactionsContext = React.createContext(); const AccountTransactionsContext = React.createContext();
function flattenInfinityPages(data) { function flattenInfinityPages(data) {
return flatten(map(data.pages, (page) => page.cashflow_transactions)); return flatten(map(data.pages, (page) => page.transactions));
} }
/** /**
@@ -30,9 +30,10 @@ function AccountTransactionsProvider({ query, ...props }) {
isSuccess: isCashflowTransactionsSuccess, isSuccess: isCashflowTransactionsSuccess,
fetchNextPage: fetchNextTransactionsPage, fetchNextPage: fetchNextTransactionsPage,
isFetchingNextPage, isFetchingNextPage,
hasNextPage hasNextPage,
} = useAccountTransactionsInfinity(accountId, { } = useAccountTransactionsInfinity(accountId, {
page_size: 50, page_size: 50,
account_id: accountId,
}); });
// Memorized the cashflow account transactions. // Memorized the cashflow account transactions.

View File

@@ -49,7 +49,7 @@ export function useAccountTransactionsColumns() {
{ {
id: 'type', id: 'type',
Header: intl.get('type'), Header: intl.get('type'),
accessor: 'reference_type_formatted', accessor: 'formatted_transaction_type',
className: 'type', className: 'type',
width: 140, width: 140,
textOverview: true, textOverview: true,
@@ -89,12 +89,21 @@ export function useAccountTransactionsColumns() {
{ {
id: 'running_balance', id: 'running_balance',
Header: intl.get('cash_flow.label.running_balance'), Header: intl.get('cash_flow.label.running_balance'),
accessor: 'running_balance', accessor: 'formatted_running_balance',
className: 'running_balance', className: 'running_balance',
width: 150, width: 150,
textOverview: true, textOverview: true,
align: 'right', align: 'right',
}, },
{
id: 'balance',
Header: intl.get('balance'),
accessor: 'formatted_balance',
className: 'balance',
width: 150,
textOverview: true,
align: 'right',
},
], ],
[], [],
); );

View File

@@ -38,21 +38,6 @@ export function useCashflowAccounts(query, props) {
); );
} }
/**
* Retrieve account transactions list.
*/
export function useCashflowTransactions(accountId, props) {
return useRequestQuery(
[t.CASH_FLOW_TRANSACTIONS, accountId],
{ method: 'get', url: `cashflow/account/${accountId}/transactions` },
{
select: (res) => res.data.cashflow_transactions,
defaultData: [],
...props,
},
);
}
/** /**
* Create Money in owner contribution . * Create Money in owner contribution .
*/ */
@@ -123,7 +108,7 @@ export function useAccountTransactionsInfinity(
const response = await apiRequest.http({ const response = await apiRequest.http({
...axios, ...axios,
method: 'get', method: 'get',
url: `/api/cashflow/account/${accountId}/transactions`, url: `/api/financial_statements/cashflow-account-transactions`,
params: { page: pageParam, ...query }, params: { page: pageParam, ...query },
}); });
return response.data; return response.data;