mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: add journal entries credit & vendor.
This commit is contained in:
@@ -6,6 +6,7 @@ import { DrawerMainTabs } from 'components';
|
||||
import CreditNoteDetailPanel from './CreditNoteDetailPanel';
|
||||
import RefundCreditNoteTransactionsTable from './RefundCreditNoteTransactions/RefundCreditNoteTransactionsTable';
|
||||
import ReconcileCreditNoteTransactionsTable from './ReconcileCreditNoteTransactions/ReconcileCreditNoteTransactionsTable';
|
||||
import JournalEntriesTransactionsTable from './JournalEntriesTransactions/JournalEntriesTransactionsTable';
|
||||
import clsx from 'classnames';
|
||||
|
||||
import CreditNoteDetailCls from '../../../style/components/Drawers/CreditNoteDetails.module.scss';
|
||||
@@ -16,12 +17,17 @@ import CreditNoteDetailCls from '../../../style/components/Drawers/CreditNoteDet
|
||||
export default function CreditNoteDetail() {
|
||||
return (
|
||||
<div className={clsx(CreditNoteDetailCls.root)}>
|
||||
<DrawerMainTabs>
|
||||
<DrawerMainTabs renderActiveTabPanelOnly={true}>
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<CreditNoteDetailPanel />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('journal_entries')}
|
||||
id={'journal_entries'}
|
||||
panel={<JournalEntriesTransactionsTable />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('credit_note.drawer.label_refund_transactions')}
|
||||
id={'refund_transactions'}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import { DataTable, Card } from 'components';
|
||||
|
||||
import { useCreditNoteDetailDrawerContext } from '../CreditNoteDetailDrawerProvider';
|
||||
import { useTransactionsByReference } from 'hooks/query';
|
||||
import { useJournalEntriesTransactionsColumns } from './components';
|
||||
|
||||
/**
|
||||
* Journal entries table.
|
||||
*/
|
||||
export default function JournalEntriesTransactionsTable() {
|
||||
const { creditNoteId } = useCreditNoteDetailDrawerContext();
|
||||
|
||||
const columns = useJournalEntriesTransactionsColumns();
|
||||
|
||||
// Handle fetch transaction by reference.
|
||||
const {
|
||||
data: { transactions },
|
||||
isLoading: isTransactionLoading,
|
||||
} = useTransactionsByReference(
|
||||
{
|
||||
reference_id: creditNoteId,
|
||||
reference_type: 'creditNote',
|
||||
},
|
||||
{ enabled: !!creditNoteId },
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={transactions}
|
||||
loading={isTransactionLoading}
|
||||
className={'datatable--journal-entries'}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormatDateCell, Icon } from '../../../../components';
|
||||
|
||||
import 'style/pages/JournalEntries/List.scss';
|
||||
|
||||
/**
|
||||
* Retrieve journal entries transactions table columns.
|
||||
*/
|
||||
export const useJournalEntriesTransactionsColumns = () => {
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
Header: intl.get('date'),
|
||||
accessor: 'date',
|
||||
accessor: 'formatted_date',
|
||||
Cell: FormatDateCell,
|
||||
width: 140,
|
||||
className: 'date',
|
||||
textOverview: true,
|
||||
},
|
||||
{
|
||||
Header: intl.get('account_name'),
|
||||
accessor: 'account_name',
|
||||
width: 140,
|
||||
className: 'account_name',
|
||||
textOverview: true,
|
||||
},
|
||||
{
|
||||
Header: intl.get('contact'),
|
||||
accessor: 'contactTypeFormatted',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
Header: intl.get('credit'),
|
||||
accessor: ({ credit }) => credit.formatted_amount,
|
||||
width: 100,
|
||||
className: 'credit',
|
||||
},
|
||||
{
|
||||
Header: intl.get('debit'),
|
||||
accessor: ({ debit }) => debit.formatted_amount,
|
||||
width: 100,
|
||||
className: 'debit',
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import { DataTable, Card } from 'components';
|
||||
|
||||
import { useVendorCreditDetailDrawerContext } from '../VendorCreditDetailDrawerProvider';
|
||||
import { useTransactionsByReference } from 'hooks/query';
|
||||
import { useJournalEntriesTransactionsColumns } from './components';
|
||||
|
||||
/**
|
||||
* Journal entries vendor credit transactions table.
|
||||
*/
|
||||
export default function JournalEntriesTransactionsTable() {
|
||||
const { vendorCreditId } = useVendorCreditDetailDrawerContext();
|
||||
|
||||
const columns = useJournalEntriesTransactionsColumns();
|
||||
|
||||
// Handle fetch transaction by reference.
|
||||
const {
|
||||
data: { transactions },
|
||||
isLoading: isTransactionLoading,
|
||||
} = useTransactionsByReference(
|
||||
{
|
||||
reference_id: vendorCreditId,
|
||||
reference_type: 'vendorCredit',
|
||||
},
|
||||
{ enabled: !!vendorCreditId },
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={transactions}
|
||||
loading={isTransactionLoading}
|
||||
className={'datatable--journal-entries'}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormatDateCell } from '../../../../components';
|
||||
|
||||
import 'style/pages/JournalEntries/List.scss';
|
||||
|
||||
/**
|
||||
* Retrieve journal entries transactions table columns.
|
||||
*/
|
||||
export const useJournalEntriesTransactionsColumns = () => {
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
Header: intl.get('date'),
|
||||
accessor: 'date',
|
||||
accessor: 'formatted_date',
|
||||
Cell: FormatDateCell,
|
||||
width: 140,
|
||||
className: 'date',
|
||||
textOverview: true,
|
||||
},
|
||||
{
|
||||
Header: intl.get('account_name'),
|
||||
accessor: 'account_name',
|
||||
width: 140,
|
||||
className: 'account_name',
|
||||
textOverview: true,
|
||||
},
|
||||
{
|
||||
Header: intl.get('contact'),
|
||||
accessor: 'contactTypeFormatted',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
Header: intl.get('credit'),
|
||||
accessor: ({ credit }) => credit.formatted_amount,
|
||||
width: 100,
|
||||
className: 'credit',
|
||||
},
|
||||
{
|
||||
Header: intl.get('debit'),
|
||||
accessor: ({ debit }) => debit.formatted_amount,
|
||||
width: 100,
|
||||
className: 'debit',
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -6,6 +6,7 @@ import { DrawerMainTabs } from 'components';
|
||||
import VendorCreditDetailPanel from './VendorCreditDetailPanel';
|
||||
import RefundVendorCreditTransactionsTable from './RefundVendorCreditTransactions/RefundVendorCreditTransactionsTable';
|
||||
import ReconcileVendorCreditTransactionsTable from './ReconcileVendorCreditTransactions/ReconcileVendorCreditTransactionsTable';
|
||||
import JournalEntriesTransactionsTable from './JournalEntriesTransactions/JournalEntriesTransactionsTable';
|
||||
import clsx from 'classnames';
|
||||
|
||||
import VendorCreditDetailCls from '../../../style/components/Drawers/VendorCreditDetail.module.scss';
|
||||
@@ -16,12 +17,17 @@ import VendorCreditDetailCls from '../../../style/components/Drawers/VendorCredi
|
||||
export default function VendorCreditDetail() {
|
||||
return (
|
||||
<div className={clsx(VendorCreditDetailCls.root)}>
|
||||
<DrawerMainTabs>
|
||||
<DrawerMainTabs renderActiveTabPanelOnly={true}>
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<VendorCreditDetailPanel />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('journal_entries')}
|
||||
id={'journal_entries'}
|
||||
panel={<JournalEntriesTransactionsTable />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('vendor_credit.drawer.label_refund_transactions')}
|
||||
id={'refund_transactions'}
|
||||
|
||||
Reference in New Issue
Block a user