mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: bill payment transactions.
This commit is contained in:
@@ -8,6 +8,7 @@ import { DrawerMainTabs } from 'components';
|
|||||||
import BillDetailTab from './BillDetailTab';
|
import BillDetailTab from './BillDetailTab';
|
||||||
import LocatedLandedCostTable from './LocatedLandedCostTable';
|
import LocatedLandedCostTable from './LocatedLandedCostTable';
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import BillPaymentTransactionTable from './BillPaymentTransactionTable';
|
||||||
import { useBillDrawerContext } from './BillDrawerProvider';
|
import { useBillDrawerContext } from './BillDrawerProvider';
|
||||||
|
|
||||||
import BillDrawerCls from 'style/components/Drawers/BillDrawer.module.scss';
|
import BillDrawerCls from 'style/components/Drawers/BillDrawer.module.scss';
|
||||||
@@ -33,16 +34,16 @@ export default function BillDrawerDetails() {
|
|||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable transactions={transactions} />}
|
panel={<JournalEntriesTable transactions={transactions} />}
|
||||||
/>
|
/>
|
||||||
|
<Tab
|
||||||
|
title={intl.get('payment_transactions')}
|
||||||
|
id={'payment_transactions'}
|
||||||
|
panel={<BillPaymentTransactionTable />}
|
||||||
|
/>
|
||||||
<Tab
|
<Tab
|
||||||
title={intl.get('located_landed_cost')}
|
title={intl.get('located_landed_cost')}
|
||||||
id={'landed_cost'}
|
id={'landed_cost'}
|
||||||
panel={<LocatedLandedCostTable />}
|
panel={<LocatedLandedCostTable />}
|
||||||
/>
|
/>
|
||||||
{/* <Tab
|
|
||||||
title={intl.get('payment_transactions')}
|
|
||||||
id={'payment_transactions'}
|
|
||||||
// panel={}
|
|
||||||
/> */}
|
|
||||||
</DrawerMainTabs>
|
</DrawerMainTabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
useBill,
|
useBill,
|
||||||
useTransactionsByReference,
|
useTransactionsByReference,
|
||||||
useBillLocatedLandedCost,
|
useBillLocatedLandedCost,
|
||||||
|
useBillPaymentTransactions,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
|
|
||||||
const BillDrawerContext = React.createContext();
|
const BillDrawerContext = React.createContext();
|
||||||
@@ -33,15 +34,31 @@ function BillDrawerProvider({ billId, ...props }) {
|
|||||||
enabled: !!billId,
|
enabled: !!billId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle fetch bill payment transaction.
|
||||||
|
const {
|
||||||
|
isLoading: isPaymentTransactionsLoading,
|
||||||
|
isFetching: isPaymentTransactionFetching,
|
||||||
|
data: paymentTransactions,
|
||||||
|
} = useBillPaymentTransactions(billId, {
|
||||||
|
enabled: !!billId,
|
||||||
|
});
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
transactions,
|
transactions,
|
||||||
billId,
|
billId,
|
||||||
data,
|
data,
|
||||||
bill,
|
bill,
|
||||||
|
paymentTransactions,
|
||||||
|
isPaymentTransactionsLoading,
|
||||||
|
isPaymentTransactionFetching,
|
||||||
};
|
};
|
||||||
|
|
||||||
const loading = isLandedCostLoading || isTransactionLoading || isBillLoading;
|
const loading =
|
||||||
|
isLandedCostLoading ||
|
||||||
|
isTransactionLoading ||
|
||||||
|
isPaymentTransactionsLoading ||
|
||||||
|
isBillLoading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerLoading loading={loading}>
|
<DrawerLoading loading={loading}>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { DataTable, Card } from 'components';
|
||||||
|
|
||||||
|
import { useBillPaymentTransactionsColumns } from './utils';
|
||||||
|
import { useBillDrawerContext } from './BillDrawerProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bill payment transactions datatable.
|
||||||
|
*/
|
||||||
|
export default function BillPaymentTransactionTable() {
|
||||||
|
const columns = useBillPaymentTransactionsColumns();
|
||||||
|
|
||||||
|
const {
|
||||||
|
paymentTransactions,
|
||||||
|
isPaymentTransactionsLoading,
|
||||||
|
isPaymentTransactionFetching,
|
||||||
|
} = useBillDrawerContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<DataTable
|
||||||
|
columns={columns}
|
||||||
|
data={paymentTransactions}
|
||||||
|
loading={isPaymentTransactionsLoading}
|
||||||
|
headerLoading={isPaymentTransactionsLoading}
|
||||||
|
progressBarLoading={isPaymentTransactionFetching}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
import { FormatNumberCell } from '../../../components';
|
import clsx from 'classnames';
|
||||||
|
import { CLASSES } from '../../../common/classes';
|
||||||
|
import { FormatNumberCell, FormatDateCell } from '../../../components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve bill readonly details entries table columns.
|
* Retrieve bill readonly details entries table columns.
|
||||||
*/
|
*/
|
||||||
export const useBillReadonlyEntriesTableColumns = () =>
|
export const useBillReadonlyEntriesTableColumns = () =>
|
||||||
React.useMemo(
|
React.useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
Header: intl.get('product_and_service'),
|
Header: intl.get('product_and_service'),
|
||||||
accessor: 'item.name',
|
accessor: 'item.name',
|
||||||
width: 150,
|
width: 150,
|
||||||
className: 'item',
|
className: 'item',
|
||||||
disableSortBy: true
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('description'),
|
Header: intl.get('description'),
|
||||||
accessor: 'description',
|
accessor: 'description',
|
||||||
className: 'description',
|
className: 'description',
|
||||||
disableSortBy: true
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('quantity'),
|
Header: intl.get('quantity'),
|
||||||
@@ -28,7 +30,7 @@ React.useMemo(
|
|||||||
Cell: FormatNumberCell,
|
Cell: FormatNumberCell,
|
||||||
width: 100,
|
width: 100,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
disableSortBy: true
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('rate'),
|
Header: intl.get('rate'),
|
||||||
@@ -36,7 +38,7 @@ React.useMemo(
|
|||||||
Cell: FormatNumberCell,
|
Cell: FormatNumberCell,
|
||||||
width: 100,
|
width: 100,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
disableSortBy: true
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('amount'),
|
Header: intl.get('amount'),
|
||||||
@@ -44,8 +46,54 @@ React.useMemo(
|
|||||||
Cell: FormatNumberCell,
|
Cell: FormatNumberCell,
|
||||||
width: 100,
|
width: 100,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
disableSortBy: true
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve bill payment transactions table columns.
|
||||||
|
*/
|
||||||
|
export const useBillPaymentTransactionsColumns = () => {
|
||||||
|
return React.useMemo(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
id: 'date',
|
||||||
|
Header: intl.get('payment_date'),
|
||||||
|
accessor: 'date',
|
||||||
|
Cell: FormatDateCell,
|
||||||
|
width: 110,
|
||||||
|
className: 'date',
|
||||||
|
textOverview: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'amount',
|
||||||
|
Header: intl.get('amount'),
|
||||||
|
accessor: 'amount',
|
||||||
|
// accessor: 'formatted_amount',
|
||||||
|
align: 'right',
|
||||||
|
width: 100,
|
||||||
|
className: clsx(CLASSES.FONT_BOLD),
|
||||||
|
textOverview: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'payment_number',
|
||||||
|
Header: intl.get('payment_no'),
|
||||||
|
accessor: 'payment_number',
|
||||||
|
width: 100,
|
||||||
|
className: 'payment_number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'reference',
|
||||||
|
Header: intl.get('reference_no'),
|
||||||
|
accessor: 'reference',
|
||||||
|
width: 90,
|
||||||
|
className: 'reference',
|
||||||
|
clickable: true,
|
||||||
|
textOverview: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -178,3 +178,18 @@ export function useRefreshBills() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useBillPaymentTransactions(id, props) {
|
||||||
|
return useRequestQuery(
|
||||||
|
[t.BILLS_PAYMENT_TRANSACTIONS, id],
|
||||||
|
{
|
||||||
|
method: 'get',
|
||||||
|
url: `purchases/bills/${id}/payment-transactions`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
select: (res) => res.data.data,
|
||||||
|
defaultData: [],
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ const commonInvalidateQueries = (client) => {
|
|||||||
// Invalidate the cashflow transactions.
|
// Invalidate the cashflow transactions.
|
||||||
client.invalidateQueries(t.CASH_FLOW_TRANSACTIONS);
|
client.invalidateQueries(t.CASH_FLOW_TRANSACTIONS);
|
||||||
client.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
client.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||||
|
|
||||||
|
// Invalidate bills payment transactions.
|
||||||
|
client.invalidateQueries(t.BILLS_PAYMENT_TRANSACTIONS);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user