mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: invoice payment transactions.
This commit is contained in:
@@ -6,6 +6,7 @@ import clsx from 'classnames';
|
|||||||
import { DrawerMainTabs } from 'components';
|
import { DrawerMainTabs } from 'components';
|
||||||
|
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import InvoicePaymentTransactionsTable from './InvoicePaymentTransactionsTable';
|
||||||
import InvoiceDetailTab from './InvoiceDetailTab';
|
import InvoiceDetailTab from './InvoiceDetailTab';
|
||||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||||
|
|
||||||
@@ -30,11 +31,11 @@ export default function InvoiceDetail() {
|
|||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable transactions={transactions} />}
|
panel={<JournalEntriesTable transactions={transactions} />}
|
||||||
/>
|
/>
|
||||||
{/* <Tab
|
<Tab
|
||||||
title={intl.get('payment_transactions')}
|
title={intl.get('payment_transactions')}
|
||||||
id={'payment_transactions'}
|
id={'payment_transactions'}
|
||||||
// panel={}
|
panel={<InvoicePaymentTransactionsTable />}
|
||||||
/> */}
|
/>
|
||||||
</DrawerMainTabs>
|
</DrawerMainTabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||||
import { useTransactionsByReference, useInvoice } from 'hooks/query';
|
import {
|
||||||
|
useTransactionsByReference,
|
||||||
|
useInvoice,
|
||||||
|
useInvoicePaymentTransactions,
|
||||||
|
} from 'hooks/query';
|
||||||
|
|
||||||
const InvoiceDetailDrawerContext = React.createContext();
|
const InvoiceDetailDrawerContext = React.createContext();
|
||||||
/**
|
/**
|
||||||
@@ -25,14 +29,30 @@ function InvoiceDetailDrawerProvider({ invoiceId, ...props }) {
|
|||||||
enabled: !!invoiceId,
|
enabled: !!invoiceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fetch invoice payment transactions.
|
||||||
|
const {
|
||||||
|
data: paymentTransactions,
|
||||||
|
isFetching: isPaymentTransactionFetching,
|
||||||
|
isLoading: isPaymentTransactionLoading,
|
||||||
|
} = useInvoicePaymentTransactions(invoiceId, {
|
||||||
|
enabled: !!invoiceId,
|
||||||
|
});
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
transactions,
|
transactions,
|
||||||
|
paymentTransactions,
|
||||||
|
isPaymentTransactionLoading,
|
||||||
|
isPaymentTransactionFetching,
|
||||||
invoiceId,
|
invoiceId,
|
||||||
invoice,
|
invoice,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<DrawerLoading loading={isTransactionLoading || isInvoiceLoading}>
|
<DrawerLoading
|
||||||
|
loading={
|
||||||
|
isTransactionLoading || isInvoiceLoading || isPaymentTransactionLoading
|
||||||
|
}
|
||||||
|
>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="invoice-detail-drawer"
|
name="invoice-detail-drawer"
|
||||||
title={intl.get('invoice_details')}
|
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,
|
MenuItem,
|
||||||
Menu,
|
Menu,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { Icon, FormattedMessage as T, Choose } from 'components';
|
import clsx from 'classnames';
|
||||||
import { FormatNumberCell } from '../../../components';
|
import { CLASSES } from '../../../common/classes';
|
||||||
|
import {
|
||||||
|
Icon,
|
||||||
|
FormattedMessage as T,
|
||||||
|
Choose,
|
||||||
|
FormatDateCell,
|
||||||
|
FormatNumberCell,
|
||||||
|
} from '../../../components';
|
||||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,3 +106,49 @@ export const BadDebtMenuItem = ({
|
|||||||
</Popover>
|
</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.
|
// 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 invoices payment transactions.
|
||||||
|
client.invalidateQueries(t.SALE_INVOICE_PAYMENT_TRANSACTIONS);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transform payment receives.
|
// Transform payment receives.
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const BILLS = {
|
|||||||
BILLS: 'BILLS',
|
BILLS: 'BILLS',
|
||||||
BILL: 'BILL',
|
BILL: 'BILL',
|
||||||
BILLS_DUE: 'BILLS_DUE',
|
BILLS_DUE: 'BILLS_DUE',
|
||||||
|
BILLS_PAYMENT_TRANSACTIONS: 'BILLS_PAYMENT_TRANSACTIONS',
|
||||||
};
|
};
|
||||||
|
|
||||||
const VENDORS = {
|
const VENDORS = {
|
||||||
@@ -95,6 +96,7 @@ const SALE_INVOICES = {
|
|||||||
NOTIFY_SALE_INVOICE_BY_SMS: 'NOTIFY_SALE_INVOICE_BY_SMS',
|
NOTIFY_SALE_INVOICE_BY_SMS: 'NOTIFY_SALE_INVOICE_BY_SMS',
|
||||||
BAD_DEBT: 'BAD_DEBT',
|
BAD_DEBT: 'BAD_DEBT',
|
||||||
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
|
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
|
||||||
|
SALE_INVOICE_PAYMENT_TRANSACTIONS: 'SALE_INVOICE_PAYMENT_TRANSACTIONS',
|
||||||
};
|
};
|
||||||
|
|
||||||
const USERS = {
|
const USERS = {
|
||||||
|
|||||||
@@ -1480,5 +1480,6 @@
|
|||||||
"sms_notification.payment_details.type": "شكر علي عملية الدفع",
|
"sms_notification.payment_details.type": "شكر علي عملية الدفع",
|
||||||
"sms_notification.receipt_details.type": "تفاصيل إيصال البيع",
|
"sms_notification.receipt_details.type": "تفاصيل إيصال البيع",
|
||||||
"personal": "المحمول",
|
"personal": "المحمول",
|
||||||
"list.create":"إضافة {value}"
|
"list.create":"إضافة {value}",
|
||||||
|
"payment_transactions":"معاملات الدفع"
|
||||||
}
|
}
|
||||||
@@ -1467,5 +1467,6 @@
|
|||||||
"sms_notification.payment_details.type": "Payment receive thank you.",
|
"sms_notification.payment_details.type": "Payment receive thank you.",
|
||||||
"sms_notification.receipt_details.type": "Sale receipt details",
|
"sms_notification.receipt_details.type": "Sale receipt details",
|
||||||
"personal": "Personal",
|
"personal": "Personal",
|
||||||
"list.create":"Create {value}"
|
"list.create":"Create {value}",
|
||||||
|
"payment_transactions":"Payment transactions"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user