mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: add ability credit & vendor & item transactions.
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import React from 'react';
|
||||
import { Intent, MenuItem, Menu } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormatDateCell, Icon } from 'components';
|
||||
import { Can, FormatDateCell, Icon } from 'components';
|
||||
import { safeCallback } from 'utils';
|
||||
import {
|
||||
VendorCreditAction,
|
||||
AbilitySubject,
|
||||
} from '../../../../common/abilityOption';
|
||||
|
||||
/**
|
||||
* Actions menu.
|
||||
@@ -10,12 +14,14 @@ import { safeCallback } from 'utils';
|
||||
export function ActionsMenu({ payload: { onDelete }, row: { original } }) {
|
||||
return (
|
||||
<Menu>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
<Can I={VendorCreditAction.Delete} a={AbilitySubject.VendorCredit}>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
</Can>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, MenuItem, Menu } from '@blueprintjs/core';
|
||||
import { FormatDateCell, Icon } from 'components';
|
||||
import { Can, FormatDateCell, Icon } from 'components';
|
||||
import { safeCallback } from 'utils';
|
||||
import {
|
||||
VendorCreditAction,
|
||||
AbilitySubject,
|
||||
} from '../../../../common/abilityOption';
|
||||
|
||||
/**
|
||||
* Actions menu.
|
||||
@@ -10,12 +14,14 @@ import { safeCallback } from 'utils';
|
||||
export function ActionsMenu({ payload: { onDelete }, row: { original } }) {
|
||||
return (
|
||||
<Menu>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
<Can I={VendorCreditAction.Delete} a={AbilitySubject.VendorCredit}>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
</Can>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,16 @@ import { Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DrawerMainTabs } from 'components';
|
||||
import { Can, DrawerMainTabs } from 'components';
|
||||
import VendorCreditDetailActionsBar from './VendorCreditDetailActionsBar';
|
||||
import VendorCreditDetailPanel from './VendorCreditDetailPanel';
|
||||
import RefundVendorCreditTransactionsTable from './RefundVendorCreditTransactions/RefundVendorCreditTransactionsTable';
|
||||
import ReconcileVendorCreditTransactionsTable from './ReconcileVendorCreditTransactions/ReconcileVendorCreditTransactionsTable';
|
||||
import { VendorCreditGLEntriesTable } from './JournalEntriesTransactions/JournalEntriesTransactionsTable';
|
||||
import {
|
||||
VendorCreditAction,
|
||||
AbilitySubject,
|
||||
} from '../../../common/abilityOption';
|
||||
|
||||
/**
|
||||
* Vendor credit view detail.
|
||||
@@ -40,16 +44,18 @@ function VendorCreditDetailsTabs() {
|
||||
id={'journal_entries'}
|
||||
panel={<VendorCreditGLEntriesTable />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('vendor_credit.drawer.label_refund_transactions')}
|
||||
id={'refund_transactions'}
|
||||
panel={<RefundVendorCreditTransactionsTable />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('vendor_credit.drawer.label_bills_reconciled')}
|
||||
id={'reconcile_transactions'}
|
||||
panel={<ReconcileVendorCreditTransactionsTable />}
|
||||
/>
|
||||
{/* <Can I={VendorCreditAction.View} a={AbilitySubject.VendorCredit}> */}
|
||||
<Tab
|
||||
title={intl.get('vendor_credit.drawer.label_refund_transactions')}
|
||||
id={'refund_transactions'}
|
||||
panel={<RefundVendorCreditTransactionsTable />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('vendor_credit.drawer.label_bills_reconciled')}
|
||||
id={'reconcile_transactions'}
|
||||
panel={<ReconcileVendorCreditTransactionsTable />}
|
||||
/>
|
||||
{/* </Can> */}
|
||||
</DrawerMainTabs>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||
import { useVendorCreditDetailDrawerContext } from './VendorCreditDetailDrawerProvider';
|
||||
import { VendorCreditMenuItem } from './utils';
|
||||
|
||||
import {
|
||||
VendorCreditAction,
|
||||
AbilitySubject,
|
||||
} from '../../../common/abilityOption';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
@@ -59,43 +62,45 @@ function VendorCreditDetailActionsBar({
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'vendor_credits.label.edit_vendor_credit'} />}
|
||||
onClick={handleEditVendorCredit}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<If condition={!vendorCredit.is_closed && !vendorCredit.is_draft}>
|
||||
<Can I={VendorCreditAction.Edit} a={AbilitySubject.VendorCredit}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="arrow-downward" iconSize={18} />}
|
||||
text={<T id={'refund'} />}
|
||||
onClick={handleRefundVendorCredit}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'vendor_credits.label.edit_vendor_credit'} />}
|
||||
onClick={handleEditVendorCredit}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
</If>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleDeleteVendorCredit}
|
||||
/>
|
||||
<If
|
||||
condition={
|
||||
!vendorCredit.is_closed &&
|
||||
!vendorCredit.is_draft
|
||||
// vendorCredit.is_published
|
||||
}
|
||||
>
|
||||
<NavbarDivider />
|
||||
<VendorCreditMenuItem
|
||||
payload={{
|
||||
onReconcile: handleReconcileVendorCredit,
|
||||
}}
|
||||
</Can>
|
||||
<Can I={VendorCreditAction.Refund} a={AbilitySubject.VendorCredit}>
|
||||
<If condition={!vendorCredit.is_closed && !vendorCredit.is_draft}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="arrow-downward" iconSize={18} />}
|
||||
text={<T id={'refund'} />}
|
||||
onClick={handleRefundVendorCredit}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
</If>
|
||||
</Can>
|
||||
<Can I={VendorCreditAction.Delete} a={AbilitySubject.VendorCredit}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleDeleteVendorCredit}
|
||||
/>
|
||||
</If>
|
||||
</Can>
|
||||
<Can I={VendorCreditAction.Edit} a={AbilitySubject.VendorCredit}>
|
||||
<If condition={!vendorCredit.is_closed && !vendorCredit.is_draft}>
|
||||
<NavbarDivider />
|
||||
<VendorCreditMenuItem
|
||||
payload={{
|
||||
onReconcile: handleReconcileVendorCredit,
|
||||
}}
|
||||
/>
|
||||
</If>
|
||||
</Can>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user