mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: Credit note.
This commit is contained in:
14
src/store/CreditNotes/creditNotes.actions.js
Normal file
14
src/store/CreditNotes/creditNotes.actions.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export const setCreditNotesTableState = (queries) => {
|
||||
return {
|
||||
type: t.CREDIT_NOTE_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const resetCreditNotesTableState = () => {
|
||||
return {
|
||||
type: t.CREDIT_NOTE_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
34
src/store/CreditNotes/creditNotes.reducer.js
Normal file
34
src/store/CreditNotes/creditNotes.reducer.js
Normal file
@@ -0,0 +1,34 @@
|
||||
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 = {
|
||||
pageSize: 20,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:CreditNotes';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('CREDIT_NOTES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
30
src/store/CreditNotes/creditNotes.selector.js
Normal file
30
src/store/CreditNotes/creditNotes.selector.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './creditNotes.reducer';
|
||||
|
||||
const creditNotesTableStateSelector = (state) =>
|
||||
state.creditNotes?.tableState;
|
||||
|
||||
/**
|
||||
* Retrieve credit note table state.
|
||||
*/
|
||||
export const getCreditNoteTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
creditNotesTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve Credit note table state.
|
||||
*/
|
||||
export const isCreditNoteTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(creditNotesTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
4
src/store/CreditNotes/creditNotes.type.js
Normal file
4
src/store/CreditNotes/creditNotes.type.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
CREDIT_NOTE_TABLE_STATE_SET: 'CREDIT_NOTE/TABLES_STATE_SET',
|
||||
CREDIT_NOTE_TABLE_STATE_RESET: 'CREDIT_NOTE/TABLE_STATE/RESET',
|
||||
};
|
||||
@@ -31,6 +31,7 @@ import paymentMades from './PaymentMades/paymentMades.reducer';
|
||||
import organizations from './organizations/organizations.reducers';
|
||||
import subscriptions from './subscription/subscription.reducer';
|
||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.reducer';
|
||||
import creditNotes from './CreditNotes/creditNotes.reducer'
|
||||
import plans from './plans/plans.reducer';
|
||||
|
||||
const appReducer = combineReducers({
|
||||
@@ -63,6 +64,7 @@ const appReducer = combineReducers({
|
||||
paymentReceives,
|
||||
paymentMades,
|
||||
inventoryAdjustments,
|
||||
creditNotes,
|
||||
plans
|
||||
});
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import paymentMades from './PaymentMades/paymentMades.type';
|
||||
import organizations from './organizations/organizations.types';
|
||||
import subscription from './subscription/subscription.types';
|
||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.type';
|
||||
import creditNotes from './CreditNotes/creditNotes.type'
|
||||
import plans from './plans/plans.types';
|
||||
|
||||
export default {
|
||||
@@ -61,5 +62,6 @@ export default {
|
||||
...organizations,
|
||||
...subscription,
|
||||
...inventoryAdjustments,
|
||||
...plans
|
||||
...creditNotes,
|
||||
...plans,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user