mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix(server): Handle the delete error when the matched transaction
This commit is contained in:
@@ -11,6 +11,7 @@ import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { useDeleteExpense } from '@/hooks/query';
|
||||
import { compose } from '@/utils';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
import { handleDeleteErrors } from './_utils';
|
||||
|
||||
/**
|
||||
* Expense delete alert.
|
||||
@@ -51,16 +52,7 @@ function ExpenseDeleteAlert({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
if (
|
||||
errors.find((e) => e.type === 'EXPENSE_HAS_ASSOCIATED_LANDED_COST')
|
||||
) {
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: intl.get(
|
||||
'couldn_t_delete_expense_transaction_has_associated_located_landed_cost_transaction',
|
||||
),
|
||||
});
|
||||
}
|
||||
handleDeleteErrors(errors);
|
||||
},
|
||||
)
|
||||
.finally(() => {
|
||||
|
||||
20
packages/webapp/src/containers/Alerts/Expenses/_utils.ts
Normal file
20
packages/webapp/src/containers/Alerts/Expenses/_utils.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import { AppToaster } from '@/components';
|
||||
|
||||
export const handleDeleteErrors = (errors: any) => {
|
||||
if (errors.find((e: any) => e.type === 'EXPENSE_HAS_ASSOCIATED_LANDED_COST')) {
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: intl.get(
|
||||
'couldn_t_delete_expense_transaction_has_associated_located_landed_cost_transaction',
|
||||
),
|
||||
});
|
||||
}
|
||||
if (errors.find((e: any) => e.type === 'CANNOT_DELETE_TRANSACTION_MATCHED')) {
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: 'Cannot delete a transaction matched with a bank transaction.',
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user