feat: Credit note.

This commit is contained in:
elforjani13
2021-11-29 16:14:22 +02:00
parent 346696f673
commit 0a9798e7a7
37 changed files with 1564 additions and 2 deletions

View 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,
};
};

View 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);

View 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);
});

View 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',
};

View File

@@ -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
});

View File

@@ -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,
};