mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: add Bad-debt & cancel bad-bebt.
This commit is contained in:
@@ -45,7 +45,7 @@ export default function DialogsContainer() {
|
||||
<ReceiptPdfPreviewDialog dialogName={'receipt-pdf-preview'} />
|
||||
<MoneyInDialog dialogName={'money-in'} />
|
||||
<MoneyOutDialog dialogName={'money-out'} />
|
||||
<BadDebtDialog dialogName={'invoice-bad-debt'} />
|
||||
<BadDebtDialog dialogName={'write-off-bad-debt'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* bad debt alert.
|
||||
* Cancel bad debt alert.
|
||||
*/
|
||||
function BadDebtAlert({
|
||||
function CancelBadDebtAlert({
|
||||
name,
|
||||
|
||||
// #withAlertStoreConnect
|
||||
@@ -23,7 +23,7 @@ function BadDebtAlert({
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
}) {
|
||||
// handle cancel alert.
|
||||
// handle cancel alert.
|
||||
const handleCancel = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
@@ -35,7 +35,7 @@ function BadDebtAlert({
|
||||
cancelBadDebtMutate(invoiceId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('the_invoice_has_been_deleted_successfully'),
|
||||
message: intl.get('badDebt_canceled_write_off_success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
@@ -48,7 +48,7 @@ function BadDebtAlert({
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'badDebt.label_cancel_bad_debt'} />}
|
||||
confirmButtonText={<T id={'save'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancel}
|
||||
@@ -56,10 +56,13 @@ function BadDebtAlert({
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<T id={'are_sure_to_cancel_this_invoice'} />
|
||||
<T id={'badDebt_are_sure_to_write_off_this_invoice'} />
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withAlertStoreConnect(), withAlertActions)(BadDebtAlert);
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(CancelBadDebtAlert);
|
||||
@@ -50,7 +50,7 @@ function BadDebtForm({
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {
|
||||
AppToaster.show({
|
||||
message: intl.get('badDebt_success_message'),
|
||||
message: intl.get('badDebt_writte_off_success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(dialogName);
|
||||
|
||||
@@ -38,11 +38,11 @@ export default function BillDrawerDetails() {
|
||||
id={'landed_cost'}
|
||||
panel={<LocatedLandedCostTable />}
|
||||
/>
|
||||
<Tab
|
||||
{/* <Tab
|
||||
title={intl.get('payment_transactions')}
|
||||
id={'payment_transactions'}
|
||||
// panel={}
|
||||
/>
|
||||
/> */}
|
||||
</DrawerMainTabs>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
NavbarGroup,
|
||||
Classes,
|
||||
NavbarDivider,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
Intent,
|
||||
MenuItem,
|
||||
Menu,
|
||||
} from '@blueprintjs/core';
|
||||
import { If, Icon, FormattedMessage as T } from 'components';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
function BadDebtMenuItem({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
}) {
|
||||
// Invoice detail drawer context.
|
||||
const { invoiceId, invoice } = useInvoiceDetailDrawerContext();
|
||||
|
||||
const handleBadDebtInvoiceDialog = () => {
|
||||
openDialog('invoice-bad-debt', { invoiceId });
|
||||
};
|
||||
|
||||
const handleBadDebtInvoiceAlert = () => {
|
||||
openAlert('bad-debt', { invoiceId });
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<If condition={invoice.is_writtenoff}>
|
||||
<MenuItem
|
||||
text={<T id={'badDebt.label_cancel_bad_debt'} />}
|
||||
onClick={handleBadDebtInvoiceAlert}
|
||||
/>
|
||||
</If>
|
||||
<MenuItem
|
||||
text={
|
||||
<T id={'badDebt.label'} onClick={handleBadDebtInvoiceDialog} />
|
||||
}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
canOutsideClickClose={false}
|
||||
usePortal={false}
|
||||
modifiers={{
|
||||
offset: { offset: '0, 4' },
|
||||
}}
|
||||
>
|
||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
export default compose(withDialogActions, withAlertsActions)(BadDebtMenuItem);
|
||||
@@ -30,11 +30,11 @@ export default function InvoiceDetail() {
|
||||
id={'journal_entries'}
|
||||
panel={<JournalEntriesTable transactions={transactions} />}
|
||||
/>
|
||||
<Tab
|
||||
{/* <Tab
|
||||
title={intl.get('payment_transactions')}
|
||||
id={'payment_transactions'}
|
||||
// panel={}
|
||||
/>
|
||||
/> */}
|
||||
</DrawerMainTabs>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
import BadDebtMenuItem from './BadDebtMenuItem';
|
||||
import { BadDebtMenuItem } from './utils';
|
||||
|
||||
/**
|
||||
* Invoice details action bar.
|
||||
@@ -71,12 +71,15 @@ function InvoiceDetailActionsBar({
|
||||
const handleQuickPaymentInvoice = () => {
|
||||
openDialog('quick-payment-receive', { invoiceId });
|
||||
};
|
||||
const handleBadDebtInvoiceDialog = () => () => {
|
||||
openDialog('invoice-bad-debt', { invoiceId });
|
||||
|
||||
// Handle write-off invoice.
|
||||
const handleBadDebtInvoice = () => {
|
||||
openDialog('write-off-bad-debt', { invoiceId });
|
||||
};
|
||||
|
||||
const handleBadDebtInvoiceAlert = () => {
|
||||
openAlert('bad-debt', { invoiceId });
|
||||
// Handle cancele write-off invoice.
|
||||
const handleCancelBadDebtInvoice = () => {
|
||||
openAlert('cancel-bad-debt', { invoiceId });
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -112,7 +115,11 @@ function InvoiceDetailActionsBar({
|
||||
onClick={handleDeleteInvoice}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<BadDebtMenuItem />
|
||||
<BadDebtMenuItem
|
||||
invoice={invoice}
|
||||
onAlert={handleCancelBadDebtInvoice}
|
||||
onDialog={handleBadDebtInvoice}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
MenuItem,
|
||||
Menu,
|
||||
} from '@blueprintjs/core';
|
||||
import { If, Icon, FormattedMessage as T, Choose } from 'components';
|
||||
import { FormatNumberCell } from '../../../components';
|
||||
|
||||
/**
|
||||
@@ -48,3 +58,34 @@ export const useInvoiceReadonlyEntriesColumns = () =>
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
export const BadDebtMenuItem = ({ invoice, onDialog, onAlert }) => {
|
||||
return (
|
||||
<Popover
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
modifiers={{
|
||||
offset: { offset: '0, 4' },
|
||||
}}
|
||||
content={
|
||||
<Menu>
|
||||
<Choose>
|
||||
<Choose.When condition={!invoice.is_writtenoff}>
|
||||
<MenuItem text={<T id={'badDebt.label'} />} onClick={onDialog} />
|
||||
</Choose.When>
|
||||
<Choose.When condition={invoice.is_writtenoff}>
|
||||
<MenuItem
|
||||
onClick={onAlert}
|
||||
text={<T id={'badDebt.label_cancel_bad_debt'} />}
|
||||
/>
|
||||
</Choose.When>
|
||||
</Choose>
|
||||
</Menu>
|
||||
}
|
||||
position={Position.BOTTOM}
|
||||
>
|
||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ const columnsMapper = (data, index, column) => ({
|
||||
id: column.key,
|
||||
key: column.key,
|
||||
Header: column.label,
|
||||
Cell: CellForceWidth,
|
||||
// Cell: CellForceWidth,
|
||||
accessor: `cells[${index}].value`,
|
||||
forceWidthAccess: `cells[0].value`,
|
||||
className: column.key,
|
||||
|
||||
@@ -7,8 +7,8 @@ const InvoiceDeliverAlert = React.lazy(() =>
|
||||
import('../../Alerts/Invoices/InvoiceDeliverAlert'),
|
||||
);
|
||||
|
||||
const BadDebtAlert = React.lazy(() =>
|
||||
import('../../Alerts/Invoices/BadDebtAlert'),
|
||||
const CancelBadDebtAlert = React.lazy(() =>
|
||||
import('../../Alerts/Invoices/CancelBadDebtAlert'),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -17,5 +17,5 @@ const BadDebtAlert = React.lazy(() =>
|
||||
export default [
|
||||
{ name: 'invoice-delete', component: InvoiceDeleteAlert },
|
||||
{ name: 'invoice-deliver', component: InvoiceDeliverAlert },
|
||||
{ name: 'bad-debt', component: BadDebtAlert },
|
||||
{ name: 'cancel-bad-debt', component: CancelBadDebtAlert },
|
||||
];
|
||||
|
||||
@@ -9,6 +9,7 @@ import t from './types';
|
||||
const commonInvalidateQueries = (queryClient) => {
|
||||
// Invalidate invoices.
|
||||
queryClient.invalidateQueries(t.SALE_INVOICES);
|
||||
queryClient.invalidateQueries(t.SALE_INVOICE);
|
||||
|
||||
// Invalidate customers.
|
||||
queryClient.invalidateQueries(t.CUSTOMERS);
|
||||
|
||||
@@ -1435,5 +1435,11 @@
|
||||
"cash_flow_transaction.balance_in_bigcapital": "الرصيد في Bigcapital",
|
||||
"badDebt.label_written_off_amount": "المبلغ المشطوب",
|
||||
"badDebt.label": "الديون المعدومة",
|
||||
"badDebt_the_seller_can_charge_the_amount_of_an_invoice": "يمكن للبائع تحميل مبلغ الفاتورة على حساب مصروفات الديون المعدومة عندما يكون من المؤكد أن الفاتورة لن يتم دفعها."
|
||||
"badDebt.label_cancel_bad_debt": "إلغاء الديون المعدومة",
|
||||
"badDebt_the_seller_can_charge_the_amount_of_an_invoice": "يمكن للبائع تحميل مبلغ الفاتورة على حساب مصروفات الديون المعدومة عندما يكون من المؤكد أن الفاتورة لن يتم دفعها.",
|
||||
"badDebt_writte_off_success_message":"تم شطب فاتورة البيع المقدمة بنجاح.",
|
||||
"badDebt_canceled_write_off_success_message":"تم إلغاء شطب فاتورة البيع المقدمة بنجاح.",
|
||||
"badDebt_are_sure_to_write_off_this_invoice": "هل أنت متأكد أنك تريد شطب هذه الفاتورة؟ "
|
||||
|
||||
|
||||
}
|
||||
@@ -1425,10 +1425,8 @@
|
||||
"badDebt.label": "Bad debt",
|
||||
"badDebt.label_cancel_bad_debt": "Cancel bad debt",
|
||||
"badDebt_the_seller_can_charge_the_amount_of_an_invoice": "The seller can charge the amount of an invoice to the bad debt expense account when it is certain that the invoice will not be paid.",
|
||||
"badDebt_success_message":"The given sale invoice has been writte-off successfully.",
|
||||
"are_sure_to_cancel_this_invoice": "Are you sure you want to cancel this invoice?",
|
||||
|
||||
"payment_transactions": "Payment transactions"
|
||||
|
||||
|
||||
"badDebt_writte_off_success_message":"The given sale invoice has been writte-off successfully.",
|
||||
"badDebt_canceled_write_off_success_message":"The given sale invoice has been canceled write-off successfully.",
|
||||
"badDebt_are_sure_to_write_off_this_invoice": "Are you sure you want to write off this invoice?"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user