feat(webapp): categorize the cashflow uncategorized transactions

This commit is contained in:
Ahmed Bouhuolia
2024-03-04 13:41:15 +02:00
parent 0273714a07
commit 9db03350e0
12 changed files with 439 additions and 36 deletions

View File

@@ -104,8 +104,8 @@ export function useDeleteCashflowTransaction(props) {
export function useAccountTransactionsInfinity(
accountId,
query,
axios,
infinityProps,
axios,
) {
const apiRequest = useApiRequest();
@@ -134,6 +134,45 @@ export function useAccountTransactionsInfinity(
);
}
/**
* Retrieve account transactions infinity scrolling.
* @param {number} accountId
* @param {*} axios
* @returns
*/
export function useAccountUncategorizedTransactionsInfinity(
accountId,
query,
infinityProps,
axios,
) {
const apiRequest = useApiRequest();
return useInfiniteQuery(
[t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY, accountId],
async ({ pageParam = 1 }) => {
const response = await apiRequest.http({
...axios,
method: 'get',
url: `/api/cashflow/transactions/${accountId}/uncategorized`,
params: { page: pageParam, ...query },
});
return response.data;
},
{
getPreviousPageParam: (firstPage) => firstPage.pagination.page - 1,
getNextPageParam: (lastPage) => {
const { pagination } = lastPage;
return pagination.total > pagination.page_size * pagination.page
? lastPage.pagination.page + 1
: undefined;
},
...infinityProps,
},
);
}
/**
* Refresh cashflow transactions infinity.
*/

View File

@@ -77,7 +77,7 @@ const SALE_RECEIPTS = {
SALE_RECEIPT: 'SALE_RECEIPT',
SALE_RECEIPT_SMS_DETAIL: 'SALE_RECEIPT_SMS_DETAIL',
NOTIFY_SALE_RECEIPT_BY_SMS: 'NOTIFY_SALE_RECEIPT_BY_SMS',
SALE_RECEIPT_MAIL_OPTIONS: 'SALE_RECEIPT_MAIL_OPTIONS'
SALE_RECEIPT_MAIL_OPTIONS: 'SALE_RECEIPT_MAIL_OPTIONS',
};
const INVENTORY_ADJUSTMENTS = {
@@ -115,7 +115,7 @@ const SALE_INVOICES = {
BAD_DEBT: 'BAD_DEBT',
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
SALE_INVOICE_PAYMENT_TRANSACTIONS: 'SALE_INVOICE_PAYMENT_TRANSACTIONS',
SALE_INVOICE_DEFAULT_OPTIONS: 'SALE_INVOICE_DEFAULT_OPTIONS'
SALE_INVOICE_DEFAULT_OPTIONS: 'SALE_INVOICE_DEFAULT_OPTIONS',
};
const USERS = {
@@ -200,6 +200,8 @@ const CASH_FLOW_ACCOUNTS = {
CASH_FLOW_TRANSACTION: 'CASH_FLOW_TRANSACTION',
CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY:
'CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY',
CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY:
'CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY',
};
const TARNSACTIONS_LOCKING = {