mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
BIG-210 Refund credit & vendor drawer detail.
This commit is contained in:
@@ -16,4 +16,6 @@ export const DRAWERS = {
|
||||
QUICK_CREATE_ITEM: 'quick-create-item',
|
||||
CREDIT_NOTE_DETAIL_DRAWER: 'credit-note-detail-drawer',
|
||||
VENDOR_CREDIT_DETAIL_DRAWER: 'vendor-credit-detail-drawer',
|
||||
REFUND_CREDIT_NOTE_DETAIL_DRAWER:'refund-credit-detail-drawer',
|
||||
REFUND_VENDOR_CREDIT_DETAIL_DRAWER:'refund-vendor-detail-drawer'
|
||||
};
|
||||
|
||||
@@ -19,6 +19,8 @@ import QuickCreateItemDrawer from '../containers/Drawers/QuickCreateItemDrawer';
|
||||
import QuickWriteVendorDrawer from '../containers/Drawers/QuickWriteVendorDrawer';
|
||||
import CreditNoteDetailDrawer from '../containers/Drawers/CreditNoteDetailDrawer';
|
||||
import VendorCreditDetailDrawer from '../containers/Drawers/VendorCreditDetailDrawer';
|
||||
import RefundCreditNoteDetailDrawer from '../containers/Drawers/RefundCreditNoteDetailDrawer';
|
||||
import RefundVendorCreditDetailDrawer from '../containers/Drawers/RefundVendorCreditDetailDrawer';
|
||||
|
||||
import { DRAWERS } from 'common/drawers';
|
||||
|
||||
@@ -51,6 +53,12 @@ export default function DrawersContainer() {
|
||||
<QuickWriteVendorDrawer name={DRAWERS.QUICK_WRITE_VENDOR} />
|
||||
<CreditNoteDetailDrawer name={DRAWERS.CREDIT_NOTE_DETAIL_DRAWER} />
|
||||
<VendorCreditDetailDrawer name={DRAWERS.VENDOR_CREDIT_DETAIL_DRAWER} />
|
||||
<RefundCreditNoteDetailDrawer
|
||||
name={DRAWERS.REFUND_CREDIT_NOTE_DETAIL_DRAWER}
|
||||
/>
|
||||
<RefundVendorCreditDetailDrawer
|
||||
name={DRAWERS.REFUND_VENDOR_CREDIT_DETAIL_DRAWER}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useDeleteRefundCreditNote } from 'hooks/query';
|
||||
|
||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -20,6 +21,9 @@ function RefundCreditNoteDeleteAlert({
|
||||
payload: { creditNoteId },
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { mutateAsync: deleteRefundCreditMutate, isLoading } =
|
||||
useDeleteRefundCreditNote();
|
||||
@@ -37,9 +41,12 @@ function RefundCreditNoteDeleteAlert({
|
||||
message: intl.get('refund_credit_transactions.alert.delete_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeAlert(name);
|
||||
closeDrawer('refund-credit-detail-drawer');
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -65,4 +72,5 @@ function RefundCreditNoteDeleteAlert({
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
)(RefundCreditNoteDeleteAlert);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useDeleteRefundVendorCredit } from 'hooks/query';
|
||||
|
||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -20,6 +21,9 @@ function RefundVendorCreditDeleteAlert({
|
||||
payload: { vendorCreditId },
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { mutateAsync: deleteRefundVendorCreditMutate, isLoading } =
|
||||
useDeleteRefundVendorCredit();
|
||||
@@ -39,9 +43,12 @@ function RefundVendorCreditDeleteAlert({
|
||||
),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeAlert(name);
|
||||
closeDrawer('refund-vendor-detail-drawer');
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -67,4 +74,5 @@ function RefundVendorCreditDeleteAlert({
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
)(RefundVendorCreditDeleteAlert);
|
||||
|
||||
@@ -71,6 +71,14 @@ export const handleCashFlowTransactionType = (reference, openDrawer) => {
|
||||
return openDrawer('payment-made-detail-drawer', {
|
||||
paymentMadeId: reference.reference_id,
|
||||
});
|
||||
case 'RefundCreditNote':
|
||||
return openDrawer('refund-credit-detail-drawer', {
|
||||
refundTransactionId: reference.reference_id,
|
||||
});
|
||||
case 'RefundVendorCredit':
|
||||
return openDrawer('refund-vendor-detail-drawer', {
|
||||
refundTransactionId: reference.reference_id,
|
||||
});
|
||||
|
||||
default:
|
||||
return openDrawer('cashflow-transaction-drawer', {
|
||||
|
||||
@@ -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);
|
||||
@@ -26,6 +26,7 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
|
||||
// Invalidate refund credit
|
||||
queryClient.invalidateQueries(t.REFUND_CREDIT_NOTE);
|
||||
queryClient.invalidateQueries(t.REFUND_CREDIT_NOTE_TRANSACTION);
|
||||
|
||||
// Invalidate reconcile.
|
||||
queryClient.invalidateQueries(t.RECONCILE_CREDIT_NOTE);
|
||||
@@ -35,6 +36,9 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
queryClient.invalidateQueries(t.SALE_INVOICES);
|
||||
queryClient.invalidateQueries(t.SALE_INVOICE);
|
||||
|
||||
// Invalidate cashflow accounts.
|
||||
queryClient.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||
|
||||
// Invalidate financial reports.
|
||||
queryClient.invalidateQueries(t.FINANCIAL_REPORT);
|
||||
};
|
||||
@@ -320,3 +324,20 @@ export function useDeleteReconcileCredit(props) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve refund credit transaction detail.
|
||||
* @param {number} id
|
||||
*
|
||||
*/
|
||||
export function useRefundCreditTransaction(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.REFUND_CREDIT_NOTE_TRANSACTION, id],
|
||||
{ method: 'get', url: `sales/credit_notes/refunds/${id}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.refund_credit,
|
||||
defaultData: {},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ const CREDIT_NOTES = {
|
||||
CREDIT_NOTE: 'CREDIT_NOTE',
|
||||
CREDIT_NOTES: 'CREDIT_NOTES',
|
||||
REFUND_CREDIT_NOTE: 'REFUND_CREDIT_NOTE',
|
||||
REFUND_CREDIT_NOTE_TRANSACTION: 'REFUND_CREDIT_NOTE_TRANSACTION',
|
||||
RECONCILE_CREDIT_NOTE: 'RECONCILE_CREDIT_NOTE',
|
||||
RECONCILE_CREDIT_NOTES: 'RECONCILE_CREDIT_NOTES',
|
||||
};
|
||||
@@ -126,6 +127,7 @@ const VENDOR_CREDIT_NOTES = {
|
||||
VENDOR_CREDITS: 'VENDOR_CREDITS',
|
||||
VENDOR_CREDIT: 'VENDOR_CREDIT',
|
||||
REFUND_VENDOR_CREDIT: 'REFUND_VENDOR_CREDIT',
|
||||
REFUND_VENDOR_CREDIT_TRANSACTION: 'REFUND_VENDOR_CREDIT_TRANSACTION',
|
||||
RECONCILE_VENDOR_CREDIT: 'RECONCILE_VENDOR_CREDIT',
|
||||
RECONCILE_VENDOR_CREDITS: 'RECONCILE_VENDOR_CREDITS',
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
|
||||
// Invalidate refund vendor credit
|
||||
queryClient.invalidateQueries(t.REFUND_VENDOR_CREDIT);
|
||||
queryClient.invalidateQueries(t.REFUND_VENDOR_CREDIT_TRANSACTION);
|
||||
|
||||
// Invalidate reconcile vendor credit.
|
||||
queryClient.invalidateQueries(t.RECONCILE_VENDOR_CREDIT);
|
||||
@@ -35,6 +36,9 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
queryClient.invalidateQueries(t.BILL);
|
||||
queryClient.invalidateQueries(t.BILLS);
|
||||
|
||||
// Invalidate cashflow accounts.
|
||||
queryClient.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||
|
||||
// Invalidate financial reports.
|
||||
queryClient.invalidateQueries(t.FINANCIAL_REPORT);
|
||||
};
|
||||
@@ -333,3 +337,24 @@ export function useDeleteReconcileVendorCredit(props) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve refund vendor transaction detail.
|
||||
* @param {number} id
|
||||
*
|
||||
*/
|
||||
export function useRefundVendorCreditTransaction(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.REFUND_VENDOR_CREDIT_TRANSACTION, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/vendor-credit/refunds/${id}`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
select: (res) => res.data.refund_credit,
|
||||
defaultData: {},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1735,6 +1735,19 @@
|
||||
"permissions.cashflow_account_transactions":"معاملات حسابات التدفقات النقدية",
|
||||
"permissions.more_permissions":"عرض المزيد ",
|
||||
|
||||
"estimate.status.expired": "منتهية الصلاحية"
|
||||
"estimate.status.expired": "منتهية الصلاحية",
|
||||
"refund_credit.drawer.title":" تفاصيل استرجاع الأموال لإشعار الدائن ",
|
||||
"refund_credit.drawer.label.amount":"القيمة",
|
||||
"refund_credit.drawer.label.credit_note_no":"رقم الإشعار",
|
||||
"refund_credit.drawer.label.withdrawal_account":"حساب السحب",
|
||||
"refund_credit.drawer.label.reference_no":"رقم المرجع",
|
||||
"refund_credit.drawer.label.description":"الوصف",
|
||||
"refund_vendor_credit.drawer.title":" تفاصيل استرجاع الأموال لإشعار المدين ",
|
||||
"refund_vendor_credit.drawer.label.amount":"القيمة",
|
||||
"refund_vendor_credit.drawer.label.vendor_credit_no":"رقم الإشعار",
|
||||
"refund_vendor_credit.drawer.label.deposit_account":"حساب إيداع",
|
||||
"refund_vendor_credit.drawer.label.reference_no":"رقم المرجع",
|
||||
"refund_vendor_credit.drawer.label.description":"الوصف"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1722,6 +1722,13 @@
|
||||
"permissions.cashflow_account_transactions":"Cashflow account transactions",
|
||||
"permissions.more_permissions":"More Permissions",
|
||||
|
||||
"estimate.status.expired": "Expired"
|
||||
"estimate.status.expired": "Expired",
|
||||
"refund_credit.drawer.title":"Refund credit note",
|
||||
"refund_credit.drawer.label.amount":"Amount",
|
||||
"refund_credit.drawer.label.credit_note_no":"Credit note number",
|
||||
"refund_credit.drawer.label.withdrawal_account":"Withdrawal account",
|
||||
"refund_credit.drawer.label.reference_no":"Reference number",
|
||||
"refund_credit.drawer.label.description":"Description"
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user