feat: cashflow service.

This commit is contained in:
a.bouhuolia
2021-10-24 17:34:00 +02:00
parent fc67d56d45
commit 7dfa280bee
19 changed files with 307 additions and 50 deletions

View File

@@ -0,0 +1,21 @@
import t from 'store/types';
/**
* Sets the cashflow accounts table state.
*/
export const setCashflowAccountsTableState = (queries) => {
return {
type: t.CASHFLOW_ACCOUNTS_TABLE_STATE_SET,
payload: { queries },
};
};
/**
* Resets the cashflow accounts table state.
*/
export const resetCashflowAccountsTableState = () => {
return {
type: t.CASHFLOW_ACCOUNTS_TABLE_STATE_RESET,
};
};

View File

@@ -0,0 +1,31 @@
import { createReducer } from '@reduxjs/toolkit';
import { persistReducer, purgeStoredState } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import { createTableStateReducers } from 'store/tableState.reducer';
import t from 'store/types';
export const defaultTableQuery = {
filterRoles: [],
};
const initialState = {
tableState: defaultTableQuery,
};
const STORAGE_KEY = 'bigcapital:cashflow_accounts';
const CONFIG = {
key: STORAGE_KEY,
whitelist: [],
storage,
};
const reducerInstance = createReducer(initialState, {
...createTableStateReducers('CASHFLOW_ACCOUNTS', defaultTableQuery),
[t.RESET]: () => {
purgeStoredState(CONFIG);
},
});
export default persistReducer(CONFIG, reducerInstance);

View File

@@ -0,0 +1,19 @@
import { paginationLocationQuery } from 'store/selectors';
import { createDeepEqualSelector } from 'utils';
// Accounts table state selector
const cashflowAccountsTableStateSelector = (state, props) =>
state.cashflowAccounts.tableState;
// Get accounts table state marged with location query.
export const getCashflowAccountsTableStateFactory = () =>
createDeepEqualSelector(
paginationLocationQuery,
cashflowAccountsTableStateSelector,
(locationQuery, tableState) => {
return {
...locationQuery,
...tableState,
};
},
);

View File

@@ -0,0 +1,5 @@
export default {
CASHFLOW_ACCOUNTS_TABLE_STATE_SET: 'CASHFLOW_ACCOUNTS/TABLE_STATE_SET',
CASHFLOW_ACCOUNTS_TABLE_STATE_RESET: 'CASHFLOW_ACCOUNTS/TABLE_STATE_RESET',
};

View File

@@ -6,6 +6,7 @@ import authentication from './authentication/authentication.reducer';
import dashboard from './dashboard/dashboard.reducer';
import users from './users/users.reducer';
import accounts from './accounts/accounts.reducer';
import cashflowAccounts from './CashflowAccounts/CashflowAccounts.reducer';
import fields from './customFields/customFields.reducer';
import items from './items/items.reducer';
import views from './customViews/customViews.reducer';
@@ -39,6 +40,7 @@ const appReducer = combineReducers({
dashboard,
users,
accounts,
cashflowAccounts,
manualJournals,
fields,
views,

View File

@@ -1,5 +1,6 @@
import authentication from './authentication/authentication.types';
import accounts from './accounts/accounts.types';
import cashflowAccounts from './CashflowAccounts/CashflowAccounts.types';
import accounting from './manualJournals/manualJournals.types';
import currencies from './currencies/currencies.types';
import customFields from './customFields/customFields.types';
@@ -32,6 +33,7 @@ import plans from './plans/plans.types';
export default {
...authentication,
...accounts,
...cashflowAccounts,
...currencies,
...customFields,
...customViews,