mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
Merge branch 'develop' of https://github.com/bigcapitalhq/client into develop
This commit is contained in:
@@ -1,30 +1,22 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Card, FormattedMessage as T } from 'components';
|
||||
import { Card } from 'components';
|
||||
import { ItemManuTransaction } from './utils';
|
||||
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
||||
import ItemPaymentTransactionContent from './ItemPaymentTransactionContent';
|
||||
|
||||
export const ItemPaymentTransactions = () => {
|
||||
const { value } = useItemDetailDrawerContext();
|
||||
const { value, setValue } = useItemDetailDrawerContext();
|
||||
|
||||
// handle item change.
|
||||
const handleItemChange = (item) => {
|
||||
setValue(item);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<ItemManuTransactions>
|
||||
<T id={'item.drawer_transactions_by'} />
|
||||
<ItemManuTransaction />
|
||||
</ItemManuTransactions>
|
||||
<ItemManuTransaction onChange={handleItemChange} />
|
||||
<ItemPaymentTransactionContent tansactionType={value} />
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
const ItemManuTransactions = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #727983;
|
||||
.bp3-button {
|
||||
padding-left: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -7,19 +7,20 @@ import {
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
} from '@blueprintjs/core';
|
||||
import styled from 'styled-components';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
||||
import transactions from '../../../../common/itemPaymentTranactionsOption';
|
||||
|
||||
export const ItemManuTransaction = () => {
|
||||
export const ItemManuTransaction = ({ onChange }) => {
|
||||
const { value, setValue } = useItemDetailDrawerContext();
|
||||
|
||||
// const handleClickItem = (item) => {
|
||||
// onChange && onChange(item);
|
||||
// };
|
||||
const handleClickItem = (item) => {
|
||||
onChange && onChange(item);
|
||||
};
|
||||
|
||||
const content = transactions.map(({ name, label }) => (
|
||||
<MenuItem onClick={() => setValue(name)} text={label} />
|
||||
<MenuItem onClick={() => handleClickItem(name)} text={label} />
|
||||
));
|
||||
|
||||
return (
|
||||
@@ -32,7 +33,28 @@ export const ItemManuTransaction = () => {
|
||||
}}
|
||||
content={<Menu>{content}</Menu>}
|
||||
>
|
||||
<Button minimal={true} text={<T id={value} />} rightIcon={'caret-down'} />
|
||||
<ItemSwitchButton
|
||||
minimal={true}
|
||||
text={<T id={'item.drawer_transactions_by'} />}
|
||||
rightIcon={'caret-down'}
|
||||
>
|
||||
<ItemSwitchText>
|
||||
<T id={value} />
|
||||
</ItemSwitchText>
|
||||
</ItemSwitchButton>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
const ItemSwitchButton = styled(Button)`
|
||||
.bp3-button-text {
|
||||
display: flex;
|
||||
color: #727983;
|
||||
}
|
||||
`;
|
||||
|
||||
const ItemSwitchText = styled.span`
|
||||
font-weight: 600;
|
||||
color: #33304a;
|
||||
padding-left: 3px;
|
||||
`;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import { DrawerBody } from 'components';
|
||||
|
||||
import 'style/components/Drawers/ViewDetail/ViewDetail.scss';
|
||||
|
||||
import PaymentMadeDetails from './PaymentMadeDetails';
|
||||
import { PaymentMadeDetailProvider } from './PaymentMadeDetailProvider';
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import clsx from 'classnames';
|
||||
import { defaultTo } from 'lodash';
|
||||
|
||||
import { DetailsMenu, DetailItem, FormatDate } from 'components';
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
FormatDate,
|
||||
DetailsMenu,
|
||||
DetailItem,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
ButtonLink,
|
||||
} from 'components';
|
||||
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
|
||||
|
||||
import PaymentDrawerCls from './PaymentMadeDrawer.module.scss';
|
||||
|
||||
/**
|
||||
* Payment made - detail panel - header.
|
||||
*/
|
||||
@@ -15,39 +21,53 @@ export default function PaymentMadeDetailHeader() {
|
||||
const { paymentMade } = usePaymentMadeDetailContext();
|
||||
|
||||
return (
|
||||
<div className={clsx(PaymentDrawerCls.detail_panel_header)}>
|
||||
<DetailsMenu>
|
||||
<DetailItem label={intl.get('amount')}>
|
||||
<h3 class="big-number" children={paymentMade.formatted_amount} />
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('payment_made.details.payment_number')}
|
||||
children={defaultTo(paymentMade.payment_number, '-')}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('customer_name')}
|
||||
children={paymentMade.vendor?.display_name}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('payment_account')}
|
||||
children={paymentMade.payment_account?.name}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('payment_date')}
|
||||
children={<FormatDate value={paymentMade.payment_date} />}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
<CommercialDocHeader>
|
||||
<CommercialDocTopHeader>
|
||||
<DetailsMenu>
|
||||
<DetailItem label={intl.get('amount')}>
|
||||
<h3 class="big-number">{paymentMade.formatted_amount}</h3>
|
||||
</DetailItem>
|
||||
</DetailsMenu>
|
||||
</CommercialDocTopHeader>
|
||||
|
||||
<DetailsMenu direction={'horizantal'} minLabelSize={'160px'}>
|
||||
<DetailItem
|
||||
label={intl.get('description')}
|
||||
children={defaultTo(paymentMade.statement, '-')}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('created_at')}
|
||||
children={<FormatDate value={paymentMade.created_at} />}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
</div>
|
||||
<Row>
|
||||
<Col xs={6}>
|
||||
<DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>
|
||||
<DetailItem
|
||||
label={intl.get('payment_made.details.payment_number')}
|
||||
children={defaultTo(paymentMade.payment_number, '-')}
|
||||
/>
|
||||
<DetailItem label={intl.get('vendor_name')}>
|
||||
<ButtonLink>{paymentMade.vendor?.display_name}</ButtonLink>
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('payment_account')}
|
||||
children={paymentMade.payment_account?.name}
|
||||
/>
|
||||
|
||||
<DetailItem
|
||||
label={intl.get('payment_date')}
|
||||
children={<FormatDate value={paymentMade.payment_date} />}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
</Col>
|
||||
<Col xs={6}>
|
||||
<DetailsMenu
|
||||
textAlign={'right'}
|
||||
direction={'horizantal'}
|
||||
minLabelSize={'180px'}
|
||||
>
|
||||
<DetailItem
|
||||
label={intl.get('description')}
|
||||
children={defaultTo(paymentMade.statement, '-')}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('created_at')}
|
||||
children={<FormatDate value={paymentMade.created_at} />}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
</Col>
|
||||
</Row>
|
||||
</CommercialDocHeader>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,26 +20,14 @@ function PaymentMadeDetailProvider({ paymentMadeId, ...props }) {
|
||||
enabled: !!paymentMadeId,
|
||||
},
|
||||
);
|
||||
// Handle fetch transaction by reference.
|
||||
const {
|
||||
data: { transactions },
|
||||
isLoading: isTransactionLoading,
|
||||
} = useTransactionsByReference(
|
||||
{
|
||||
reference_id: paymentMadeId,
|
||||
reference_type: 'BillPayment',
|
||||
},
|
||||
{ enabled: !!paymentMadeId },
|
||||
);
|
||||
|
||||
//provider.
|
||||
const provider = {
|
||||
transactions,
|
||||
paymentMadeId,
|
||||
paymentMade,
|
||||
};
|
||||
|
||||
const loading = isTransactionLoading || isPaymentMadeLoading;
|
||||
const loading = isPaymentMadeLoading;
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={loading}>
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
import React from 'react';
|
||||
import clsx from 'classnames';
|
||||
|
||||
import { Card } from 'components';
|
||||
import { CommercialDocBox } from 'components';
|
||||
|
||||
import PaymentMadeDetailActionsBar from './PaymentMadeDetailActionsBar';
|
||||
import PaymentMadeDetailHeader from './PaymentMadeDetailHeader';
|
||||
import PaymentMadeDetailTable from './PaymentMadeDetailTable';
|
||||
import PaymentMadeDetailFooter from './PaymentMadeDetailFooter';
|
||||
|
||||
import PaymentDrawerCls from './PaymentMadeDrawer.module.scss';
|
||||
|
||||
/**
|
||||
* Payment made detail tab.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function PaymentMadeDetailTab() {
|
||||
return (
|
||||
<div className={clsx(PaymentDrawerCls.detail_panel)}>
|
||||
<PaymentMadeDetailActionsBar />
|
||||
|
||||
<Card>
|
||||
<PaymentMadeDetailHeader />
|
||||
<PaymentMadeDetailTable />
|
||||
<PaymentMadeDetailFooter />
|
||||
</Card>
|
||||
</div>
|
||||
<CommercialDocBox>
|
||||
<PaymentMadeDetailHeader />
|
||||
<PaymentMadeDetailTable />
|
||||
<PaymentMadeDetailFooter />
|
||||
</CommercialDocBox>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React from 'react';
|
||||
import clsx from 'classnames';
|
||||
|
||||
import { CommercialDocEntriesTable } from 'components';
|
||||
|
||||
import { usePaymentMadeEntriesColumns } from './utils';
|
||||
import { DataTable } from 'components';
|
||||
|
||||
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
|
||||
|
||||
import PaymentDrawerCls from './PaymentMadeDrawer.module.scss';
|
||||
import { TableStyle } from 'common';
|
||||
|
||||
/**
|
||||
* Payment made read-only details table.
|
||||
@@ -19,12 +18,10 @@ export default function PaymentMadeDetailTable() {
|
||||
const { paymentMade } = usePaymentMadeDetailContext();
|
||||
|
||||
return (
|
||||
<div className={clsx(PaymentDrawerCls.detail_panel_table)}>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={paymentMade.entries}
|
||||
className={'table-constrant'}
|
||||
/>
|
||||
</div>
|
||||
<CommercialDocEntriesTable
|
||||
columns={columns}
|
||||
data={paymentMade.entries}
|
||||
styleName={TableStyle.Constrant}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,35 +1,47 @@
|
||||
import React from 'react';
|
||||
import { Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import clsx from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DrawerMainTabs } from 'components';
|
||||
import PaymentMadeDetailTab from './PaymentMadeDetailTab';
|
||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
|
||||
|
||||
import PaymentDrawerCls from './PaymentMadeDrawer.module.scss';
|
||||
import PaymentMadeDetailActionsBar from './PaymentMadeDetailActionsBar';
|
||||
import PaymentMadeDetailTab from './PaymentMadeDetailTab';
|
||||
import PaymentMadeGLEntriesPanel from './PaymentMadeGLEntriesPanel';
|
||||
|
||||
/**
|
||||
* Payment made - view detail.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function PaymentMadeDetails() {
|
||||
const { transactions } = usePaymentMadeDetailContext();
|
||||
|
||||
function PaymentMadeDetailsTabs() {
|
||||
return (
|
||||
<div className={clsx(PaymentDrawerCls.root)}>
|
||||
<DrawerMainTabs defaultSelectedTabId="details">
|
||||
<Tab
|
||||
id={'details'}
|
||||
title={intl.get('details')}
|
||||
panel={<PaymentMadeDetailTab />}
|
||||
/>
|
||||
<Tab
|
||||
id={'journal_entries'}
|
||||
title={intl.get('journal_entries')}
|
||||
panel={<JournalEntriesTable transactions={transactions} />}
|
||||
/>
|
||||
</DrawerMainTabs>
|
||||
</div>
|
||||
<DrawerMainTabs defaultSelectedTabId="details">
|
||||
<Tab
|
||||
id={'details'}
|
||||
title={intl.get('details')}
|
||||
panel={<PaymentMadeDetailTab />}
|
||||
/>
|
||||
<Tab
|
||||
id={'journal_entries'}
|
||||
title={intl.get('journal_entries')}
|
||||
panel={<PaymentMadeGLEntriesPanel />}
|
||||
/>
|
||||
</DrawerMainTabs>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment made view detail.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function PaymentMadeDetail() {
|
||||
return (
|
||||
<PaymentMadeDetailsRoot>
|
||||
<PaymentMadeDetailActionsBar />
|
||||
<PaymentMadeDetailsTabs />
|
||||
</PaymentMadeDetailsRoot>
|
||||
);
|
||||
}
|
||||
|
||||
const PaymentMadeDetailsRoot = styled.div``;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Card } from 'components';
|
||||
import JournalEntriesTable, {
|
||||
AmountDisplayedBaseCurrencyMessage,
|
||||
} from '../../JournalEntriesTable/JournalEntriesTable';
|
||||
|
||||
import { useTransactionsByReference } from 'hooks/query';
|
||||
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
|
||||
|
||||
/**
|
||||
* Payment made GL entries table panel.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function PaymentMadeGLEntriesPanel() {
|
||||
const { paymentMadeId } = usePaymentMadeDetailContext();
|
||||
|
||||
// Handle fetch transaction by reference.
|
||||
const {
|
||||
data: { transactions },
|
||||
isLoading: isTransactionLoading,
|
||||
} = useTransactionsByReference(
|
||||
{
|
||||
reference_id: paymentMadeId,
|
||||
reference_type: 'BillPayment',
|
||||
},
|
||||
{ enabled: !!paymentMadeId },
|
||||
);
|
||||
|
||||
return (
|
||||
<PaymentMadeGLEntriesRoot>
|
||||
<AmountDisplayedBaseCurrencyMessage />
|
||||
<JournalEntriesTable
|
||||
loading={isTransactionLoading}
|
||||
transactions={transactions}
|
||||
/>
|
||||
</PaymentMadeGLEntriesRoot>
|
||||
);
|
||||
}
|
||||
|
||||
const PaymentMadeGLEntriesRoot = styled(Card)``;
|
||||
Reference in New Issue
Block a user