mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-10 09:52:00 +00:00
feat: invoice payment transactions.
This commit is contained in:
@@ -6,6 +6,7 @@ import clsx from 'classnames';
|
||||
import { DrawerMainTabs } from 'components';
|
||||
|
||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||
import InvoicePaymentTransactionsTable from './InvoicePaymentTransactionsTable';
|
||||
import InvoiceDetailTab from './InvoiceDetailTab';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
@@ -30,11 +31,11 @@ export default function InvoiceDetail() {
|
||||
id={'journal_entries'}
|
||||
panel={<JournalEntriesTable transactions={transactions} />}
|
||||
/>
|
||||
{/* <Tab
|
||||
<Tab
|
||||
title={intl.get('payment_transactions')}
|
||||
id={'payment_transactions'}
|
||||
// panel={}
|
||||
/> */}
|
||||
panel={<InvoicePaymentTransactionsTable />}
|
||||
/>
|
||||
</DrawerMainTabs>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||
import { useTransactionsByReference, useInvoice } from 'hooks/query';
|
||||
import {
|
||||
useTransactionsByReference,
|
||||
useInvoice,
|
||||
useInvoicePaymentTransactions,
|
||||
} from 'hooks/query';
|
||||
|
||||
const InvoiceDetailDrawerContext = React.createContext();
|
||||
/**
|
||||
@@ -25,14 +29,30 @@ function InvoiceDetailDrawerProvider({ invoiceId, ...props }) {
|
||||
enabled: !!invoiceId,
|
||||
});
|
||||
|
||||
// Fetch invoice payment transactions.
|
||||
const {
|
||||
data: paymentTransactions,
|
||||
isFetching: isPaymentTransactionFetching,
|
||||
isLoading: isPaymentTransactionLoading,
|
||||
} = useInvoicePaymentTransactions(invoiceId, {
|
||||
enabled: !!invoiceId,
|
||||
});
|
||||
|
||||
//provider.
|
||||
const provider = {
|
||||
transactions,
|
||||
paymentTransactions,
|
||||
isPaymentTransactionLoading,
|
||||
isPaymentTransactionFetching,
|
||||
invoiceId,
|
||||
invoice,
|
||||
};
|
||||
return (
|
||||
<DrawerLoading loading={isTransactionLoading || isInvoiceLoading}>
|
||||
<DrawerLoading
|
||||
loading={
|
||||
isTransactionLoading || isInvoiceLoading || isPaymentTransactionLoading
|
||||
}
|
||||
>
|
||||
<DrawerHeaderContent
|
||||
name="invoice-detail-drawer"
|
||||
title={intl.get('invoice_details')}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import { DataTable, Card } from 'components';
|
||||
|
||||
import { useInvoicePaymentTransactionsColumns } from './utils';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
/**
|
||||
* Invoice payment transactions datatable.
|
||||
*/
|
||||
export default function InvoicePaymentTransactionsTable() {
|
||||
const columns = useInvoicePaymentTransactionsColumns();
|
||||
const {
|
||||
paymentTransactions,
|
||||
isPaymentTransactionLoading,
|
||||
isPaymentTransactionFetching,
|
||||
} = useInvoiceDetailDrawerContext();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={paymentTransactions}
|
||||
loading={isPaymentTransactionLoading}
|
||||
headerLoading={isPaymentTransactionLoading}
|
||||
progressBarLoading={isPaymentTransactionFetching}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -8,8 +8,15 @@ import {
|
||||
MenuItem,
|
||||
Menu,
|
||||
} from '@blueprintjs/core';
|
||||
import { Icon, FormattedMessage as T, Choose } from 'components';
|
||||
import { FormatNumberCell } from '../../../components';
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../common/classes';
|
||||
import {
|
||||
Icon,
|
||||
FormattedMessage as T,
|
||||
Choose,
|
||||
FormatDateCell,
|
||||
FormatNumberCell,
|
||||
} from '../../../components';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
/**
|
||||
@@ -99,3 +106,49 @@ export const BadDebtMenuItem = ({
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve invoice payment transactions table columns.
|
||||
*/
|
||||
export const useInvoicePaymentTransactionsColumns = () => {
|
||||
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: 120,
|
||||
className: clsx(CLASSES.FONT_BOLD),
|
||||
textOverview: true,
|
||||
},
|
||||
{
|
||||
id: 'payment_receive_no.',
|
||||
Header: intl.get('payment_no'),
|
||||
accessor: 'payment_receive_no',
|
||||
width: 100,
|
||||
className: 'payment_receive_no',
|
||||
},
|
||||
{
|
||||
id: 'reference_no',
|
||||
Header: intl.get('reference_no'),
|
||||
accessor: 'reference_no',
|
||||
width: 90,
|
||||
className: 'reference_no',
|
||||
clickable: true,
|
||||
textOverview: true,
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
};
|
||||
|
||||
@@ -269,3 +269,18 @@ export function useInvoiceSMSDetail(invoiceId, query, props) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function useInvoicePaymentTransactions(invoiceId, props) {
|
||||
return useRequestQuery(
|
||||
[t.SALE_INVOICE_PAYMENT_TRANSACTIONS, invoiceId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/invoices/${invoiceId}/payment-transactions`,
|
||||
},
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
defaultData: [],
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ const commonInvalidateQueries = (client) => {
|
||||
// Invalidate the cashflow transactions.
|
||||
client.invalidateQueries(t.CASH_FLOW_TRANSACTIONS);
|
||||
client.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||
|
||||
// Invalidate invoices payment transactions.
|
||||
client.invalidateQueries(t.SALE_INVOICE_PAYMENT_TRANSACTIONS);
|
||||
};
|
||||
|
||||
// Transform payment receives.
|
||||
|
||||
@@ -30,6 +30,7 @@ const BILLS = {
|
||||
BILLS: 'BILLS',
|
||||
BILL: 'BILL',
|
||||
BILLS_DUE: 'BILLS_DUE',
|
||||
BILLS_PAYMENT_TRANSACTIONS: 'BILLS_PAYMENT_TRANSACTIONS',
|
||||
};
|
||||
|
||||
const VENDORS = {
|
||||
@@ -95,6 +96,7 @@ const SALE_INVOICES = {
|
||||
NOTIFY_SALE_INVOICE_BY_SMS: 'NOTIFY_SALE_INVOICE_BY_SMS',
|
||||
BAD_DEBT: 'BAD_DEBT',
|
||||
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
|
||||
SALE_INVOICE_PAYMENT_TRANSACTIONS: 'SALE_INVOICE_PAYMENT_TRANSACTIONS',
|
||||
};
|
||||
|
||||
const USERS = {
|
||||
|
||||
@@ -1480,5 +1480,6 @@
|
||||
"sms_notification.payment_details.type": "شكر علي عملية الدفع",
|
||||
"sms_notification.receipt_details.type": "تفاصيل إيصال البيع",
|
||||
"personal": "المحمول",
|
||||
"list.create":"إضافة {value}"
|
||||
"list.create":"إضافة {value}",
|
||||
"payment_transactions":"معاملات الدفع"
|
||||
}
|
||||
@@ -1467,5 +1467,6 @@
|
||||
"sms_notification.payment_details.type": "Payment receive thank you.",
|
||||
"sms_notification.receipt_details.type": "Sale receipt details",
|
||||
"personal": "Personal",
|
||||
"list.create":"Create {value}"
|
||||
"list.create":"Create {value}",
|
||||
"payment_transactions":"Payment transactions"
|
||||
}
|
||||
Reference in New Issue
Block a user