mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: add transactions locking query.
This commit is contained in:
@@ -32,3 +32,4 @@ export * from './cashflowAccounts';
|
||||
export * from './roles';
|
||||
export * from './creditNote';
|
||||
export * from './vendorCredit';
|
||||
export * from './transactionsLocking';
|
||||
|
||||
87
src/hooks/query/transactionsLocking.js
Normal file
87
src/hooks/query/transactionsLocking.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import { transformPagination } from 'utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useRequestPdf } from '../utils';
|
||||
import t from './types';
|
||||
|
||||
// Common invalidate queries.
|
||||
const commonInvalidateQueries = (queryClient) => {
|
||||
// Invalidate customers.
|
||||
queryClient.invalidateQueries(t.TRANSACTIONS_LOCKING);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a locking transactions.
|
||||
*/
|
||||
export function useCreateLockingTransactoin(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.put('transactions-locking/lock', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create cancle locking transactions
|
||||
*/
|
||||
export function useCancelLockingTransaction(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.put('transactions-locking/cancel-lock', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a unlocking partial transactions.
|
||||
*/
|
||||
export function useCreateUnlockingPartialTransactions(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
return useMutation(
|
||||
(values) => apiRequest.put('transactions-locking/unlock-partial', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create cancle unlocking partial transactions.
|
||||
*/
|
||||
export function useCancelUnlockingPartialTransactions(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
return useMutation(
|
||||
(values) =>
|
||||
apiRequest.put('transactions-locking/cancel-unlock-partial', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ const CREDIT_NOTES = {
|
||||
const VENDOR_CREDIT_NOTES = {
|
||||
VENDOR_CREDITS: 'VENDOR_CREDITS',
|
||||
VENDOR_CREDIT: 'VENDOR_CREDIT',
|
||||
REFUND_VENDOR_CREDIT: 'REFUND_VENDOR_CREDIT',
|
||||
REFUND_VENDOR_CREDIT: 'REFUND_VENDOR_CREDIT',
|
||||
RECONCILE_VENDOR_CREDIT: 'RECONCILE_VENDOR_CREDIT',
|
||||
RECONCILE_VENDOR_CREDITS: 'RECONCILE_VENDOR_CREDITS',
|
||||
};
|
||||
@@ -178,6 +178,10 @@ const CASH_FLOW_ACCOUNTS = {
|
||||
'CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY',
|
||||
};
|
||||
|
||||
const TARNSACTIONS_LOCKING = {
|
||||
TRANSACTIONS_LOCKING: 'TRANSACTIONS_LOCKING',
|
||||
};
|
||||
|
||||
export default {
|
||||
...ACCOUNTS,
|
||||
...BILLS,
|
||||
@@ -204,4 +208,5 @@ export default {
|
||||
...ROLES,
|
||||
...CREDIT_NOTES,
|
||||
...VENDOR_CREDIT_NOTES,
|
||||
...TARNSACTIONS_LOCKING,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user