mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: Bad Debt.
This commit is contained in:
@@ -194,3 +194,38 @@ export function useRefreshInvoices() {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function useCreateBadDebt(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/invoices/${id}/writeoff`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate
|
||||
queryClient.invalidateQueries([t.BAD_DEBT, id]);
|
||||
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function useCancelBadDebt(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/invoices/${id}/writeoff/cancel`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate
|
||||
queryClient.invalidateQueries([t.CANCEL_BAD_DEBT, id]);
|
||||
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ const SALE_INVOICES = {
|
||||
SALE_INVOICES: 'SALE_INVOICES',
|
||||
SALE_INVOICE: 'SALE_INVOICE',
|
||||
SALE_INVOICES_DUE: 'SALE_INVOICES_DUE',
|
||||
BAD_DEBT: 'BAD_DEBT',
|
||||
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
|
||||
};
|
||||
|
||||
const USERS = {
|
||||
@@ -137,7 +139,8 @@ const CASH_FLOW_ACCOUNTS = {
|
||||
CASH_FLOW_ACCOUNTS: 'CASH_FLOW_ACCOUNTS',
|
||||
CASH_FLOW_TRANSACTIONS: 'CASH_FLOW_TRANSACTIONS',
|
||||
CASH_FLOW_TRANSACTION: 'CASH_FLOW_TRANSACTION',
|
||||
CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY: 'CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY'
|
||||
CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY:
|
||||
'CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY',
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user