feat: Edit make journal entries.

This commit is contained in:
Ahmed Bouhuolia
2020-04-08 17:50:35 +02:00
parent 8ba96e7343
commit 4920d5f419
16 changed files with 225 additions and 75 deletions

View File

@@ -7,4 +7,27 @@ export const makeJournalEntries = ({ form }) => {
resolve(response);
}).catch((error) => { reject(error); });
});
};
export const fetchManualJournal = ({ id }) => {
return (dispatch) => new Promise((resolve, reject) => {
ApiService.get(`accounting/manual-journals/${id}`).then((response) => {
dispatch({
type: t.MANUAL_JOURNAL_SET,
payload: {
id,
manualJournal: response.data.manual_journal,
}
});
resolve(response);
}).catch((error) => { reject(error); });
});
};
export const editManualJournal = ({ form, id }) => {
return (dispatch) => new Promise((resolve, reject) => {
ApiService.post(`accounting/manual-journals/${id}`, form).then((response) => {
resolve(response);
}).catch((error) => { reject(error); });
});
}

View File

@@ -0,0 +1,19 @@
import t from 'store/types';
import { createReducer } from '@reduxjs/toolkit';
const initialState = {
manualJournals: {},
};
export default createReducer(initialState, {
[t.MANUAL_JOURNAL_SET]: (state, action) => {
const { id, manualJournal } = action.payload;
state.manualJournals[id] = manualJournal;
},
});
export const getManualJournal = (state, id) => {
return state.accounting.manualJournals[id];
}

View File

@@ -2,4 +2,5 @@
export default {
MAKE_JOURNAL_ENTRIES: 'MAKE_JOURNAL_ENTRIES',
MANUAL_JOURNAL_SET: 'MANUAL_JOURNAL_SET',
}

View File

@@ -13,12 +13,14 @@ import resources from './resources/resources.reducer';
import financialStatements from './financialStatement/financialStatements.reducer';
import itemCategories from './itemCategories/itemsCateory.reducer';
import settings from './settings/settings.reducer';
import accounting from './accounting/accounting.reducers';
export default combineReducers({
authentication,
dashboard,
users,
accounts,
accounting,
fields,
views,
expenses,

View File

@@ -1,5 +1,6 @@
import authentication from './authentication/authentication.types';
import accounts from './accounts/accounts.types';
import accounting from './accounting/accounting.types'
import currencies from './currencies/currencies.types';
import customFields from './customFields/customFields.types';
import customViews from './customViews/customViews.types';
@@ -27,5 +28,6 @@ export default {
...users,
...financialStatements,
...itemCategories,
...settings
...settings,
...accounting,
};