mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
Merge branch 'develop' of https://github.com/bigcapitalhq/client into develop
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
Col,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
VendorDrawerLink,
|
||||
} from 'components';
|
||||
|
||||
import { useBillDrawerContext } from './BillDrawerProvider';
|
||||
@@ -45,7 +46,9 @@ export default function BillDetailHeader() {
|
||||
<FormatDate value={bill.due_date} />
|
||||
</DetailItem>
|
||||
<DetailItem label={intl.get('vendor_name')}>
|
||||
<ButtonLink>{bill.vendor?.display_name}</ButtonLink>
|
||||
<VendorDrawerLink vendorId={bill.vendor_id}>
|
||||
{bill.vendor?.display_name}
|
||||
</VendorDrawerLink>
|
||||
</DetailItem>
|
||||
<DetailItem label={intl.get('bill.details.bill_number')}>
|
||||
{defaultTo(bill.bill_number, '-')}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../common/classes';
|
||||
import { Can, FormatDateCell, Icon } from '../../../../components';
|
||||
@@ -27,6 +27,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={PaymentMadeAction.Delete} a={AbilitySubject.PaymentMade}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
ButtonLink,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
CustomerDrawerLink,
|
||||
} from 'components';
|
||||
import { useCreditNoteDetailDrawerContext } from './CreditNoteDetailDrawerProvider';
|
||||
|
||||
@@ -48,7 +49,9 @@ export default function CreditNoteDetailHeader() {
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem label={intl.get('customer_name')}>
|
||||
<ButtonLink>{creditNote.customer?.display_name}</ButtonLink>
|
||||
<CustomerDrawerLink customerId={creditNote.customer_id}>
|
||||
{creditNote.customer?.display_name}
|
||||
</CustomerDrawerLink>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Row,
|
||||
Col,
|
||||
ButtonLink,
|
||||
CustomerDrawerLink,
|
||||
} from 'components';
|
||||
import { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider';
|
||||
import { EstimateDetailsStatus } from './components';
|
||||
@@ -46,7 +47,9 @@ export default function EstimateDetailHeader() {
|
||||
/>
|
||||
|
||||
<DetailItem label={intl.get('customer_name')}>
|
||||
<ButtonLink>{estimate.customer?.display_name}</ButtonLink>
|
||||
<CustomerDrawerLink customerId={estimate.customer_id}>
|
||||
{estimate.customer?.display_name}
|
||||
</CustomerDrawerLink>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
FormatDate,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
CustomerDrawerLink,
|
||||
} from 'components';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
import { InvoiceDetailsStatus } from './utils';
|
||||
@@ -50,9 +51,9 @@ export default function InvoiceDetailHeader() {
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem label={intl.get('customer_name')}>
|
||||
<ButtonLink onClick={handleCustomerLinkClick}>
|
||||
<CustomerDrawerLink customerId={invoice.customer_id}>
|
||||
{invoice.customer?.display_name}
|
||||
</ButtonLink>
|
||||
</CustomerDrawerLink>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem label={intl.get('invoice.details.invoice_no')}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../common/classes';
|
||||
import { FormatDateCell, Icon, Can } from '../../../../components';
|
||||
@@ -27,6 +27,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={PaymentReceiveAction.Delete} a={AbilitySubject.PaymentReceive}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../../common/classes';
|
||||
@@ -28,6 +28,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={BillAction.Delete} a={AbilitySubject.Bill}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../../common/classes';
|
||||
@@ -28,6 +28,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={SaleEstimateAction.Delete} a={AbilitySubject.Estimate}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../../common/classes';
|
||||
@@ -28,6 +28,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={SaleInvoiceAction.Delete} a={AbilitySubject.Invoice}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../../common/classes';
|
||||
@@ -28,6 +28,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</Can>
|
||||
<Can I={SaleReceiptAction.Edit} a={AbilitySubject.Receipt}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('invoice_transactions.action.delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
ButtonLink,
|
||||
VendorDrawerLink,
|
||||
} from 'components';
|
||||
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
|
||||
|
||||
@@ -38,7 +39,9 @@ export default function PaymentMadeDetailHeader() {
|
||||
children={defaultTo(paymentMade.payment_number, '-')}
|
||||
/>
|
||||
<DetailItem label={intl.get('vendor_name')}>
|
||||
<ButtonLink>{paymentMade.vendor?.display_name}</ButtonLink>
|
||||
<VendorDrawerLink vendorId={paymentMade.vendor_id}>
|
||||
{paymentMade.vendor?.display_name}
|
||||
</VendorDrawerLink>
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('payment_account')}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
ButtonLink,
|
||||
CustomerDrawerLink,
|
||||
} from 'components';
|
||||
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
|
||||
|
||||
@@ -38,7 +39,9 @@ export default function PaymentReceiveDetailHeader() {
|
||||
children={defaultTo(paymentReceive.payment_receive_no, '-')}
|
||||
/>
|
||||
<DetailItem label={intl.get('customer_name')}>
|
||||
<ButtonLink>{paymentReceive.customer?.display_name}</ButtonLink>
|
||||
<CustomerDrawerLink customerId={paymentReceive.customer_id}>
|
||||
{paymentReceive.customer?.display_name}
|
||||
</CustomerDrawerLink>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
|
||||
@@ -5,6 +5,7 @@ import styled from 'styled-components';
|
||||
|
||||
import {
|
||||
ButtonLink,
|
||||
CustomerDrawerLink,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
} from 'components';
|
||||
@@ -41,7 +42,9 @@ export default function ReceiptDetailHeader() {
|
||||
children={defaultTo(receipt.receipt_number, '-')}
|
||||
/>
|
||||
<DetailItem label={intl.get('customer_name')}>
|
||||
<ButtonLink>{receipt.customer?.display_name} </ButtonLink>
|
||||
<CustomerDrawerLink customerId={receipt.customer_id}>
|
||||
{receipt.customer?.display_name}
|
||||
</CustomerDrawerLink>
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('receipt_date')}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DrawerMainTabs } from 'components';
|
||||
import RefundCreditNoteDetailTab from './RefundCreditNoteDetailTab';
|
||||
import RefundCreditNoteDetailActionsBar from './RefundCreditNoteDetailActionsBar';
|
||||
|
||||
/**
|
||||
* Refund credit note detail.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function RefundCreditNoteDetail() {
|
||||
return (
|
||||
<RefundCreditNoteDetailRoot>
|
||||
<RefundCreditNoteDetailActionsBar />
|
||||
<RefundCreditNoteDetailTabs />
|
||||
</RefundCreditNoteDetailRoot>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund credit note detail tabs.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function RefundCreditNoteDetailTabs() {
|
||||
return (
|
||||
<DrawerMainTabs>
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<RefundCreditNoteDetailTab />}
|
||||
/>
|
||||
</DrawerMainTabs>
|
||||
);
|
||||
}
|
||||
|
||||
const RefundCreditNoteDetailRoot = styled.div``;
|
||||
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import { Button, NavbarGroup, Classes, Intent } from '@blueprintjs/core';
|
||||
|
||||
import { useRefundCreditNoteDrawerContext } from './RefundCreditNoteDrawerProvider';
|
||||
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import { Icon, DrawerActionsBar, FormattedMessage as T, Can } from 'components';
|
||||
import {
|
||||
CreditNoteAction,
|
||||
AbilitySubject,
|
||||
} from '../../../common/abilityOption';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Refund credit note actions bar.
|
||||
*/
|
||||
function RefundCreditNoteDetailActionsBar({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
}) {
|
||||
const { refundTransactionId } = useRefundCreditNoteDrawerContext();
|
||||
|
||||
// Handle delete refund credit.
|
||||
const handleDeleteRefundCreditNote = () => {
|
||||
openAlert('refund-credit-delete', { creditNoteId: refundTransactionId });
|
||||
};
|
||||
|
||||
return (
|
||||
<Can I={CreditNoteAction.Delete} a={AbilitySubject.CreditNote}>
|
||||
<DrawerActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleDeleteRefundCreditNote}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DrawerActionsBar>
|
||||
</Can>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withAlertsActions)(RefundCreditNoteDetailActionsBar);
|
||||
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { defaultTo } from 'lodash';
|
||||
|
||||
import {
|
||||
CommercialDocHeader,
|
||||
FormatDate,
|
||||
DetailsMenu,
|
||||
DetailItem,
|
||||
} from 'components';
|
||||
|
||||
import { useRefundCreditNoteDrawerContext } from './RefundCreditNoteDrawerProvider';
|
||||
|
||||
export default function RefundCreditNoteDetailHeader() {
|
||||
const { refundCreditTransaction } = useRefundCreditNoteDrawerContext();
|
||||
|
||||
return (
|
||||
<CommercialDocHeader>
|
||||
<DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>
|
||||
<DetailItem
|
||||
label={intl.get('date')}
|
||||
children={
|
||||
<FormatDate value={refundCreditTransaction.formatted_date} />
|
||||
}
|
||||
/>
|
||||
<DetailItem label={intl.get('refund_credit.drawer.label.amount')}>
|
||||
<strong>{refundCreditTransaction.formtted_amount}</strong>
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('refund_credit.drawer.label.credit_note_no')}
|
||||
children={refundCreditTransaction.credit_note?.credit_note_number}
|
||||
/>
|
||||
|
||||
<DetailItem
|
||||
label={intl.get('refund_credit.drawer.label.withdrawal_account')}
|
||||
children={refundCreditTransaction.from_account.name}
|
||||
/>
|
||||
<DetailItem label={intl.get('refund_credit.drawer.label.reference_no')}>
|
||||
{defaultTo(refundCreditTransaction.reference_no, '—')}
|
||||
</DetailItem>
|
||||
<DetailItem label={intl.get('refund_credit.drawer.label.description')}>
|
||||
{defaultTo(refundCreditTransaction.description, '—')}
|
||||
</DetailItem>
|
||||
</DetailsMenu>
|
||||
</CommercialDocHeader>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
|
||||
import { CommercialDocBox } from 'components';
|
||||
import RefundCreditNoteDetailHeader from './RefundCreditNoteDetailHeader';
|
||||
|
||||
/**
|
||||
* Refund credit note detail tab.
|
||||
* @returns
|
||||
*/
|
||||
export default function RefundCreditNoteDetailTab() {
|
||||
return (
|
||||
<CommercialDocBox>
|
||||
<RefundCreditNoteDetailHeader />
|
||||
</CommercialDocBox>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { DrawerBody } from 'components';
|
||||
|
||||
import RefundCreditNoteDetail from './RefundCreditNoteDetail';
|
||||
import { RefundCreditNoteDrawerProvider } from './RefundCreditNoteDrawerProvider';
|
||||
|
||||
/**
|
||||
* Refund credit note drawer content.
|
||||
*/
|
||||
export default function RefundCreditNoteDrawerContent({ refundTransactionId }) {
|
||||
return (
|
||||
<RefundCreditNoteDrawerProvider refundTransactionId={refundTransactionId}>
|
||||
<DrawerBody>
|
||||
<RefundCreditNoteDetail />
|
||||
</DrawerBody>
|
||||
</RefundCreditNoteDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||
import { useRefundCreditTransaction } from 'hooks/query';
|
||||
|
||||
const RefundCreditNoteDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Refund credit note drawer provider.
|
||||
*/
|
||||
function RefundCreditNoteDrawerProvider({ refundTransactionId, ...props }) {
|
||||
// Handle fetch refund credit note transaction.
|
||||
const {
|
||||
data: refundCreditTransaction,
|
||||
isLoading: isRefundCreditTransaction,
|
||||
} = useRefundCreditTransaction(refundTransactionId, {
|
||||
enabled: !!refundTransactionId,
|
||||
});
|
||||
|
||||
// provider
|
||||
const provider = {
|
||||
refundTransactionId,
|
||||
refundCreditTransaction,
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={isRefundCreditTransaction}>
|
||||
<DrawerHeaderContent
|
||||
name="refund-credit-detail-drawer"
|
||||
title={intl.get('refund_credit.drawer.title')}
|
||||
/>
|
||||
<RefundCreditNoteDrawerContext.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useRefundCreditNoteDrawerContext = () =>
|
||||
React.useContext(RefundCreditNoteDrawerContext);
|
||||
|
||||
export { RefundCreditNoteDrawerProvider, useRefundCreditNoteDrawerContext };
|
||||
37
src/containers/Drawers/RefundCreditNoteDetailDrawer/index.js
Normal file
37
src/containers/Drawers/RefundCreditNoteDetailDrawer/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const RefundCreditNoteDrawerContent = React.lazy(() =>
|
||||
import('./RefundCreditNoteDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Refund credit note detail.
|
||||
* @returns
|
||||
*/
|
||||
function RefundCreditNoteDetailDrawer({
|
||||
name,
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload: { refundTransactionId },
|
||||
}) {
|
||||
return (
|
||||
<Drawer
|
||||
isOpen={isOpen}
|
||||
name={name}
|
||||
style={{ minWidth: '700px', maxWidth: '750px' }}
|
||||
size={'65%'}
|
||||
>
|
||||
<DrawerSuspense>
|
||||
<RefundCreditNoteDrawerContent
|
||||
refundTransactionId={refundTransactionId}
|
||||
/>
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
export default compose(withDrawers())(RefundCreditNoteDetailDrawer);
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DrawerMainTabs } from 'components';
|
||||
import RefundVendorCreditDetailTab from './RefundVendorCreditDetailTab'
|
||||
import RefundVendorCreditDetailActionsBar from './RefundVendorCreditDetailActionsBar';
|
||||
|
||||
/**
|
||||
* Refund vendor credit detail.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export default function RefundVendorCreditDetail() {
|
||||
return (
|
||||
<RefundVendorCreditDetailRoot>
|
||||
<RefundVendorCreditDetailActionsBar />
|
||||
<RefundVendorCreditDetailTabs />
|
||||
</RefundVendorCreditDetailRoot>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund vendor credit detail tabs.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function RefundVendorCreditDetailTabs() {
|
||||
return (
|
||||
<DrawerMainTabs>
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<RefundVendorCreditDetailTab />}
|
||||
/>
|
||||
</DrawerMainTabs>
|
||||
);
|
||||
}
|
||||
|
||||
const RefundVendorCreditDetailRoot = styled.div``;
|
||||
@@ -0,0 +1,45 @@
|
||||
import React from 'react';
|
||||
import { Button, NavbarGroup, Classes, Intent } from '@blueprintjs/core';
|
||||
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import { useRefundVendorCreditNoteDrawerContext } from './RefundVendorCreditDrawerProvider';
|
||||
import { Icon, DrawerActionsBar, FormattedMessage as T, Can } from 'components';
|
||||
import {
|
||||
VendorCreditAction,
|
||||
AbilitySubject,
|
||||
} from '../../../common/abilityOption';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Refund vendor credit actions bar.
|
||||
*/
|
||||
function RefundVendorCreditDetailActionsBar({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
}) {
|
||||
const { refundTransactionId } = useRefundVendorCreditNoteDrawerContext();
|
||||
|
||||
// Handle delete refund vendor credit.
|
||||
const handleDeleteRefundVendorCredit = () => {
|
||||
openAlert('refund-vendor-delete', { vendorCreditId: refundTransactionId });
|
||||
};
|
||||
|
||||
return (
|
||||
<Can I={VendorCreditAction.Delete} a={AbilitySubject.VendorCredit}>
|
||||
<DrawerActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleDeleteRefundVendorCredit}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DrawerActionsBar>
|
||||
</Can>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withAlertsActions)(RefundVendorCreditDetailActionsBar);
|
||||
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { defaultTo } from 'lodash';
|
||||
|
||||
import {
|
||||
CommercialDocHeader,
|
||||
FormatDate,
|
||||
DetailsMenu,
|
||||
DetailItem,
|
||||
} from 'components';
|
||||
|
||||
import { useRefundVendorCreditNoteDrawerContext } from './RefundVendorCreditDrawerProvider';
|
||||
|
||||
export default function RefundVendorCreditDetailHeader() {
|
||||
const { refundVendorTransaction } = useRefundVendorCreditNoteDrawerContext();
|
||||
|
||||
return (
|
||||
<CommercialDocHeader>
|
||||
<DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>
|
||||
<DetailItem
|
||||
label={intl.get('date')}
|
||||
children={
|
||||
<FormatDate value={refundVendorTransaction.formatted_date} />
|
||||
}
|
||||
/>
|
||||
<DetailItem label={intl.get('refund_vendor_credit.drawer.label.amount')}>
|
||||
<strong>{refundVendorTransaction.formtted_amount}</strong>
|
||||
</DetailItem>
|
||||
<DetailItem
|
||||
label={intl.get('refund_vendor_credit.drawer.label.vendor_credit_no')}
|
||||
children={refundVendorTransaction.vendor_credit?.vendor_credit_number}
|
||||
/>
|
||||
|
||||
<DetailItem
|
||||
label={intl.get('refund_vendor_credit.drawer.label.deposit_account')}
|
||||
children={refundVendorTransaction.deposit_account.name}
|
||||
/>
|
||||
<DetailItem label={intl.get('refund_vendor_credit.drawer.label.reference_no')}>
|
||||
{defaultTo(refundVendorTransaction.reference_no, '—')}
|
||||
</DetailItem>
|
||||
<DetailItem label={intl.get('refund_vendor_credit.drawer.label.description')}>
|
||||
{defaultTo(refundVendorTransaction.description, '—')}
|
||||
</DetailItem>
|
||||
</DetailsMenu>
|
||||
</CommercialDocHeader>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
|
||||
import { CommercialDocBox } from 'components';
|
||||
import RefundVendorCreditDetailHeader from './RefundVendorCreditDetailHeader';
|
||||
|
||||
/**
|
||||
* Refund vendor credit detail tab.
|
||||
*/
|
||||
export default function RefundVendorCreditDetailTab() {
|
||||
return (
|
||||
<CommercialDocBox>
|
||||
<RefundVendorCreditDetailHeader />
|
||||
</CommercialDocBox>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { DrawerBody } from 'components';
|
||||
|
||||
import RefundVendorCreditDetail from './RefundVendorCreditDetail';
|
||||
import { RefundVendorCreditDrawerProvider } from './RefundVendorCreditDrawerProvider';
|
||||
|
||||
/**
|
||||
* Refund vendor credit drawer content.
|
||||
* @returns
|
||||
*/
|
||||
export default function RefundVendorCreditDrawerContent({
|
||||
refundTransactionId,
|
||||
}) {
|
||||
return (
|
||||
<RefundVendorCreditDrawerProvider refundTransactionId={refundTransactionId}>
|
||||
<DrawerBody>
|
||||
<RefundVendorCreditDetail />
|
||||
</DrawerBody>
|
||||
</RefundVendorCreditDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||
import { useRefundVendorCreditTransaction } from 'hooks/query';
|
||||
|
||||
const RefundVendorCreditDrawerContent = React.createContext();
|
||||
|
||||
/**
|
||||
* Refund vendor credit drawer provider.
|
||||
*/
|
||||
function RefundVendorCreditDrawerProvider({ refundTransactionId, ...props }) {
|
||||
// Handle fetch refund credit note transaction.
|
||||
const {
|
||||
data: refundVendorTransaction,
|
||||
isLoading: isRefundVendorTransaction,
|
||||
} = useRefundVendorCreditTransaction(refundTransactionId, {
|
||||
enabled: !!refundTransactionId,
|
||||
});
|
||||
|
||||
// provider
|
||||
const provider = {
|
||||
refundTransactionId,
|
||||
refundVendorTransaction,
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={isRefundVendorTransaction}>
|
||||
<DrawerHeaderContent
|
||||
name="refund-vendor-detail-drawer"
|
||||
title={intl.get('refund_vendor_credit.drawer.title')}
|
||||
/>
|
||||
<RefundVendorCreditDrawerContent.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useRefundVendorCreditNoteDrawerContext = () =>
|
||||
React.useContext(RefundVendorCreditDrawerContent);
|
||||
|
||||
export {
|
||||
RefundVendorCreditDrawerProvider,
|
||||
useRefundVendorCreditNoteDrawerContext,
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const RefundVendorCreditDrawerContent = React.lazy(() =>
|
||||
import('./RefundVendorCreditDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Refund credit note detail.
|
||||
* @returns
|
||||
*/
|
||||
function RefundCreditNoteDetailDrawer({
|
||||
name,
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload: { refundTransactionId },
|
||||
}) {
|
||||
return (
|
||||
<Drawer
|
||||
isOpen={isOpen}
|
||||
name={name}
|
||||
style={{ minWidth: '700px', maxWidth: '750px' }}
|
||||
size={'65%'}
|
||||
>
|
||||
<DrawerSuspense>
|
||||
<RefundVendorCreditDrawerContent
|
||||
refundTransactionId={refundTransactionId}
|
||||
/>
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(RefundCreditNoteDetailDrawer);
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
ButtonLink,
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
VendorDrawerLink,
|
||||
} from 'components';
|
||||
import { useVendorCreditDetailDrawerContext } from './VendorCreditDetailDrawerProvider';
|
||||
import { VendorCreditDetailsStatus } from './utils';
|
||||
@@ -44,7 +45,9 @@ export default function VendorCreditDetailHeader() {
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem label={intl.get('vendor_name')}>
|
||||
<ButtonLink>{vendorCredit.vendor?.display_name}</ButtonLink>
|
||||
<VendorDrawerLink vendorId={vendorCredit.vendor_id}>
|
||||
{vendorCredit.vendor?.display_name}
|
||||
</VendorDrawerLink>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
|
||||
Reference in New Issue
Block a user