mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix(webapp): cancel the written-off invoice
This commit is contained in:
@@ -32,13 +32,12 @@ function BadDebtForm({
|
|||||||
// #withCurrentOrganization
|
// #withCurrentOrganization
|
||||||
organization: { base_currency },
|
organization: { base_currency },
|
||||||
}) {
|
}) {
|
||||||
const { invoice, dialogName, createBadDebtMutate, cancelBadDebtMutate } =
|
const { invoice, dialogName, createBadDebtMutate } = useBadDebtContext();
|
||||||
useBadDebtContext();
|
|
||||||
|
|
||||||
// Initial form values
|
// Initial form values
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
amount: invoice.due_amount,
|
amount: invoice?.due_amount || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
@@ -67,7 +66,7 @@ function BadDebtForm({
|
|||||||
}
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
createBadDebtMutate([invoice.id, form]).then(onSuccess).catch(onError);
|
createBadDebtMutate([invoice?.id, form]).then(onSuccess).catch(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
FMoneyInputGroup,
|
FMoneyInputGroup,
|
||||||
FTextArea,
|
FTextArea,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
|
FFormGroup,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { useAutofocus } from '@/hooks';
|
import { useAutofocus } from '@/hooks';
|
||||||
@@ -53,7 +54,7 @@ function BadDebtFormFields() {
|
|||||||
fill
|
fill
|
||||||
>
|
>
|
||||||
<ControlGroup>
|
<ControlGroup>
|
||||||
<InputPrependText text={invoice.currency_code} />
|
<InputPrependText text={invoice?.currency_code || ''} />
|
||||||
<FMoneyInputGroup
|
<FMoneyInputGroup
|
||||||
name={'amount'}
|
name={'amount'}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -73,6 +74,7 @@ function BadDebtFormFields() {
|
|||||||
name={'expense_account_id'}
|
name={'expense_account_id'}
|
||||||
items={accounts}
|
items={accounts}
|
||||||
filterByTypes={[ACCOUNT_TYPE.EXPENSE]}
|
filterByTypes={[ACCOUNT_TYPE.EXPENSE]}
|
||||||
|
fill
|
||||||
/>
|
/>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function BadDebtDialog({ dialogName, payload: { invoiceId = null }, isOpen }) {
|
|||||||
name={dialogName}
|
name={dialogName}
|
||||||
title={<T id={'bad_debt.dialog.bad_debt'} />}
|
title={<T id={'bad_debt.dialog.bad_debt'} />}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
canEscapeJeyClose={true}
|
canEscapeKeyClose={true}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
className={'dialog--bad-debt'}
|
className={'dialog--bad-debt'}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ export function useCancelBadDebt(props) {
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
(id) => apiRequest.post(`sale-invoices/${id}/writeoff/cancel`),
|
(id) => apiRequest.post(`sale-invoices/${id}/cancel-writeoff`),
|
||||||
{
|
{
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
// Invalidate
|
// Invalidate
|
||||||
|
|||||||
Reference in New Issue
Block a user