mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: transaction by refernce.
This commit is contained in:
@@ -4,11 +4,14 @@ import intl from 'react-intl-universal';
|
|||||||
|
|
||||||
import LocatedLandedCostTable from './LocatedLandedCostTable';
|
import LocatedLandedCostTable from './LocatedLandedCostTable';
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import { useBillDrawerContext } from './BillDrawerProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bill view details.
|
* Bill view details.
|
||||||
*/
|
*/
|
||||||
export default function BillDrawerDetails() {
|
export default function BillDrawerDetails() {
|
||||||
|
const { data } = useBillDrawerContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="view-detail-drawer">
|
<div className="view-detail-drawer">
|
||||||
<Tabs animate={true} large={true} defaultSelectedTabId="landed_cost">
|
<Tabs animate={true} large={true} defaultSelectedTabId="landed_cost">
|
||||||
@@ -16,7 +19,7 @@ export default function BillDrawerDetails() {
|
|||||||
<Tab
|
<Tab
|
||||||
title={intl.get('journal_entries')}
|
title={intl.get('journal_entries')}
|
||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable />}
|
panel={<JournalEntriesTable transactions={data} />}
|
||||||
/>
|
/>
|
||||||
<Tab
|
<Tab
|
||||||
title={intl.get('located_landed_cost')}
|
title={intl.get('located_landed_cost')}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
import { useBillLocatedLandedCost } from 'hooks/query';
|
import { useBillLocatedLandedCost } from 'hooks/query';
|
||||||
|
import { useTransactionsByReference } from 'hooks/query';
|
||||||
|
|
||||||
const BillDrawerContext = React.createContext();
|
const BillDrawerContext = React.createContext();
|
||||||
|
|
||||||
@@ -9,6 +10,16 @@ const BillDrawerContext = React.createContext();
|
|||||||
* Bill drawer provider.
|
* Bill drawer provider.
|
||||||
*/
|
*/
|
||||||
function BillDrawerProvider({ billId, ...props }) {
|
function BillDrawerProvider({ billId, ...props }) {
|
||||||
|
|
||||||
|
// Handle fetch transaction by reference.
|
||||||
|
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
|
||||||
|
{
|
||||||
|
reference_id: billId,
|
||||||
|
reference_type: 'Bill',
|
||||||
|
},
|
||||||
|
{ enabled: !!billId },
|
||||||
|
);
|
||||||
|
|
||||||
// Handle fetch bill located landed cost transaction.
|
// Handle fetch bill located landed cost transaction.
|
||||||
const { isLoading: isLandedCostLoading, data: transactions } =
|
const { isLoading: isLandedCostLoading, data: transactions } =
|
||||||
useBillLocatedLandedCost(billId, {
|
useBillLocatedLandedCost(billId, {
|
||||||
@@ -19,10 +30,11 @@ function BillDrawerProvider({ billId, ...props }) {
|
|||||||
const provider = {
|
const provider = {
|
||||||
transactions,
|
transactions,
|
||||||
billId,
|
billId,
|
||||||
|
data,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider loading={isLandedCostLoading}>
|
<DashboardInsider loading={isLandedCostLoading || isTransactionLoading}>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="bill-drawer"
|
name="bill-drawer"
|
||||||
title={intl.get('bill_details')}
|
title={intl.get('bill_details')}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import { Tabs, Tab } from '@blueprintjs/core';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice view detail.
|
* Invoice view detail.
|
||||||
*/
|
*/
|
||||||
export default function InvoiceDetail() {
|
export default function InvoiceDetail() {
|
||||||
|
const { data } = useInvoiceDetailDrawerContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="view-detail-drawer">
|
<div className="view-detail-drawer">
|
||||||
<Tabs
|
<Tabs
|
||||||
@@ -20,7 +23,7 @@ export default function InvoiceDetail() {
|
|||||||
<Tab
|
<Tab
|
||||||
title={intl.get('journal_entries')}
|
title={intl.get('journal_entries')}
|
||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable journal={[]} />}
|
panel={<JournalEntriesTable transactions={data} />}
|
||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,16 +1,29 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useTransactionsByReference } from 'hooks/query';
|
||||||
|
|
||||||
const InvoiceDetailDrawerContext = React.createContext();
|
const InvoiceDetailDrawerContext = React.createContext();
|
||||||
/**
|
/**
|
||||||
* Invoice detail provider.
|
* Invoice detail provider.
|
||||||
*/
|
*/
|
||||||
function InvoiceDetailDrawerProvider({ invoiceId, ...props }) {
|
function InvoiceDetailDrawerProvider({ invoiceId, ...props }) {
|
||||||
|
|
||||||
|
// Handle fetch transaction by reference.
|
||||||
|
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
|
||||||
|
{
|
||||||
|
reference_id: invoiceId,
|
||||||
|
reference_type: 'SaleInvoice',
|
||||||
|
},
|
||||||
|
{ enabled: !!invoiceId },
|
||||||
|
);
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {};
|
const provider = {
|
||||||
|
data,
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider loading={isTransactionLoading}>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="invoice-detail-drawer"
|
name="invoice-detail-drawer"
|
||||||
title={intl.get('invoice_details')}
|
title={intl.get('invoice_details')}
|
||||||
|
|||||||
@@ -1,14 +1,30 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useTransactionsByReference } from 'hooks/query';
|
||||||
|
|
||||||
const PaymentMadeDetailContext = React.createContext();
|
const PaymentMadeDetailContext = React.createContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payment made detail provider.
|
||||||
|
*/
|
||||||
function PaymentMadeDetailProvider({ paymentMadeId, ...props }) {
|
function PaymentMadeDetailProvider({ paymentMadeId, ...props }) {
|
||||||
|
|
||||||
|
// Handle fetch transaction by reference.
|
||||||
|
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
|
||||||
|
{
|
||||||
|
reference_id: paymentMadeId,
|
||||||
|
reference_type: 'paymentMade',
|
||||||
|
},
|
||||||
|
{ enabled: !!paymentMadeId },
|
||||||
|
);
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {};
|
const provider = {
|
||||||
|
data,
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider loading={isTransactionLoading}>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="payment-made-detail-drawer"
|
name="payment-made-detail-drawer"
|
||||||
title={intl.get('payment_made_details')}
|
title={intl.get('payment_made_details')}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import { Tabs, Tab } from '@blueprintjs/core';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* payment receive view detail.
|
* payment receive view detail.
|
||||||
*/
|
*/
|
||||||
export default function PaymentReceiveDetail() {
|
export default function PaymentReceiveDetail() {
|
||||||
|
const { data } = usePaymentReceiveDetailContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="view-detail-drawer">
|
<div className="view-detail-drawer">
|
||||||
<Tabs animate={true} large={true} defaultSelectedTabId="journal_entries">
|
<Tabs animate={true} large={true} defaultSelectedTabId="journal_entries">
|
||||||
@@ -15,7 +18,7 @@ export default function PaymentReceiveDetail() {
|
|||||||
<Tab
|
<Tab
|
||||||
title={intl.get('journal_entries')}
|
title={intl.get('journal_entries')}
|
||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable journal={[]} />}
|
panel={<JournalEntriesTable transactions={data} />}
|
||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,17 +1,29 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useTransactionsByReference } from 'hooks/query';
|
||||||
|
|
||||||
const PaymentReceiveDetailContext = React.createContext();
|
const PaymentReceiveDetailContext = React.createContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment receive detail provider.
|
* Payment receive detail provider.
|
||||||
*/
|
*/
|
||||||
function PaymentReceiveDetailProvider({ paymentReceiveId, ...props }) {
|
function PaymentReceiveDetailProvider({ paymentReceiveId, ...props }) {
|
||||||
|
|
||||||
|
// Handle fetch transaction by reference.
|
||||||
|
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
|
||||||
|
{
|
||||||
|
reference_id: paymentReceiveId,
|
||||||
|
reference_type: 'paymentReceive',
|
||||||
|
},
|
||||||
|
{ enabled: !!paymentReceiveId },
|
||||||
|
);
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {};
|
const provider = { data };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider loading={isTransactionLoading}>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="payment-receive-detail-drawer"
|
name="payment-receive-detail-drawer"
|
||||||
title={intl.get('payment_receive_details')}
|
title={intl.get('payment_receive_details')}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import { Tabs, Tab } from '@blueprintjs/core';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||||
|
import { useReceiptDetailDrawerContext } from './ReceiptDetailDrawerProvider';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receipt view detail.
|
* Receipt view detail.
|
||||||
*/
|
*/
|
||||||
export default function ReceiptDetail() {
|
export default function ReceiptDetail() {
|
||||||
|
const { data } = useReceiptDetailDrawerContext();
|
||||||
return (
|
return (
|
||||||
<div className="view-detail-drawer">
|
<div className="view-detail-drawer">
|
||||||
<Tabs animate={true} large={true} defaultSelectedTabId="journal_entries">
|
<Tabs animate={true} large={true} defaultSelectedTabId="journal_entries">
|
||||||
@@ -15,7 +18,7 @@ export default function ReceiptDetail() {
|
|||||||
<Tab
|
<Tab
|
||||||
title={intl.get('journal_entries')}
|
title={intl.get('journal_entries')}
|
||||||
id={'journal_entries'}
|
id={'journal_entries'}
|
||||||
panel={<JournalEntriesTable journal={[]} />}
|
panel={<JournalEntriesTable transactions={data} />}
|
||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,18 +1,31 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useTransactionsByReference } from 'hooks/query';
|
||||||
|
|
||||||
|
// useTransactionsByReference
|
||||||
const ReceiptDetailDrawerContext = React.createContext();
|
const ReceiptDetailDrawerContext = React.createContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receipt detail provider.
|
* Receipt detail provider.
|
||||||
*/
|
*/
|
||||||
function ReceiptDetailDrawerProvider({ receiptId, ...props }) {
|
function ReceiptDetailDrawerProvider({ receiptId, ...props }) {
|
||||||
|
// Handle fetch transaction by reference.
|
||||||
|
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
|
||||||
|
{
|
||||||
|
reference_id: receiptId,
|
||||||
|
reference_type: 'SaleReceipt',
|
||||||
|
},
|
||||||
|
{ enabled: !!receiptId },
|
||||||
|
);
|
||||||
|
|
||||||
//provider.
|
//provider.
|
||||||
const provider = {};
|
const provider = {
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider loading={isTransactionLoading}>
|
||||||
<DrawerHeaderContent
|
<DrawerHeaderContent
|
||||||
name="receipt-detail-drawer"
|
name="receipt-detail-drawer"
|
||||||
title={intl.get('receipt_details')}
|
title={intl.get('receipt_details')}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import moment from 'moment';
|
|||||||
/**
|
/**
|
||||||
* Journal entries table.
|
* Journal entries table.
|
||||||
*/
|
*/
|
||||||
export default function JournalEntriesTable({ journal }) {
|
export default function JournalEntriesTable({ transactions }) {
|
||||||
const columns = React.useMemo(
|
const columns = React.useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -17,22 +17,22 @@ export default function JournalEntriesTable({ journal }) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('account_name'),
|
Header: intl.get('account_name'),
|
||||||
accessor: 'account_name',
|
accessor: 'accountName',
|
||||||
width: 150,
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('contact'),
|
Header: intl.get('contact'),
|
||||||
accessor: 'contact',
|
accessor: 'contactTypeFormatted',
|
||||||
width: 150,
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('credit'),
|
Header: intl.get('credit'),
|
||||||
accessor: 'credit',
|
accessor: ({ credit }) => credit.formattedAmount,
|
||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('debit'),
|
Header: intl.get('debit'),
|
||||||
accessor: 'debit',
|
accessor: ({ debit }) => debit.formattedAmount,
|
||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -43,7 +43,7 @@ export default function JournalEntriesTable({ journal }) {
|
|||||||
<Card>
|
<Card>
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={journal}
|
data={transactions}
|
||||||
className={'datatable--journal-entries'}
|
className={'datatable--journal-entries'}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -466,3 +466,22 @@ export function useInventoryItemDetailsReport(query, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve transactions by reference report.
|
||||||
|
*/
|
||||||
|
export function useTransactionsByReference(query, props) {
|
||||||
|
return useRequestQuery(
|
||||||
|
[t.TRANSACTIONS_BY_REFERENCE, query],
|
||||||
|
{
|
||||||
|
method: 'get',
|
||||||
|
url: `/financial_statements/transactions-by-reference`,
|
||||||
|
params: query,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
select: (res) => res.data.data,
|
||||||
|
defaultData: {},
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const FINANCIAL_REPORTS = {
|
|||||||
INVENTORY_VALUATION: 'INVENTORY_VALUATION',
|
INVENTORY_VALUATION: 'INVENTORY_VALUATION',
|
||||||
CASH_FLOW_STATEMENT: 'CASH_FLOW_STATEMENT',
|
CASH_FLOW_STATEMENT: 'CASH_FLOW_STATEMENT',
|
||||||
INVENTORY_ITEM_DETAILS: 'INVENTORY_ITEM_DETAILS',
|
INVENTORY_ITEM_DETAILS: 'INVENTORY_ITEM_DETAILS',
|
||||||
|
TRANSACTIONS_BY_REFERENCE: 'TRANSACTIONS_BY_REFERENCE',
|
||||||
};
|
};
|
||||||
|
|
||||||
const BILLS = {
|
const BILLS = {
|
||||||
|
|||||||
Reference in New Issue
Block a user