mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
WIP financial statements.
This commit is contained in:
@@ -28,11 +28,19 @@ export const fetchBalanceSheet = ({ query }) => {
|
||||
|
||||
export const fetchTrialBalanceSheet = ({ query }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.TRIAL_BALANCE_SHEET_LOADING,
|
||||
loading: true,
|
||||
});
|
||||
ApiService.get('/financial_statements/trial_balance_sheet', { params: query }).then((response) => {
|
||||
dispatch({
|
||||
type: t.TRAIL_BALANCE_STATEMENT_SET,
|
||||
data: response.data,
|
||||
});
|
||||
dispatch({
|
||||
type: t.TRIAL_BALANCE_SHEET_LOADING,
|
||||
loading: false,
|
||||
});
|
||||
resolve(response.data);
|
||||
}).catch((error) => { reject(error); })
|
||||
})
|
||||
|
||||
@@ -2,13 +2,16 @@ import { createReducer } from '@reduxjs/toolkit';
|
||||
import t from 'store/types';
|
||||
import {
|
||||
getBalanceSheetIndexByQuery,
|
||||
getTrialBalanceSheetIndex,
|
||||
getFinancialSheetIndexByQuery,
|
||||
// getFinancialSheetIndexByQuery,
|
||||
} from './financialStatements.selectors';
|
||||
|
||||
const initialState = {
|
||||
balanceSheets: [],
|
||||
trialBalanceSheets: [],
|
||||
trialBalance: {
|
||||
sheets: [],
|
||||
loading: false,
|
||||
},
|
||||
generalLedger: [],
|
||||
journalSheets: [],
|
||||
};
|
||||
@@ -30,19 +33,22 @@ export default createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.TRAIL_BALANCE_STATEMENT_SET]: (state, action) => {
|
||||
const index = getTrialBalanceSheetIndex(state.trialBalanceSheets, action.query);
|
||||
|
||||
const index = getFinancialSheetIndexByQuery(state.trialBalance.sheets, action.query);
|
||||
const trailBalanceSheet = {
|
||||
accounts: action.data.accounts,
|
||||
query: action.data.query,
|
||||
};
|
||||
if (index !== -1) {
|
||||
state.trialBalanceSheets[index] = trailBalanceSheet;
|
||||
state.trialBalance.sheets[index] = trailBalanceSheet;
|
||||
} else {
|
||||
state.trailBalanceSheet.push(trailBalanceSheet);
|
||||
state.trialBalance.sheets.push(trailBalanceSheet);
|
||||
}
|
||||
},
|
||||
|
||||
[t.TRIAL_BALANCE_SHEET_LOADING]: (state, action) => {
|
||||
state.trialBalance.loading = !!action.loading;
|
||||
},
|
||||
|
||||
[t.JOURNAL_SHEET_SET]: (state, action) => {
|
||||
const index = getFinancialSheetIndexByQuery(state.journalSheets, action.query);
|
||||
console.log(index, 'INDEX');
|
||||
|
||||
@@ -4,5 +4,6 @@ export default {
|
||||
GENERAL_LEDGER_STATEMENT_SET: 'GENERAL_LEDGER_STATEMENT_SET',
|
||||
BALANCE_SHEET_STATEMENT_SET: 'BALANCE_SHEET_STATEMENT_SET',
|
||||
TRAIL_BALANCE_STATEMENT_SET: 'TRAIL_BALANCE_STATEMENT_SET',
|
||||
TRIAL_BALANCE_SHEET_LOADING: 'TRIAL_BALANCE_SHEET_LOADING',
|
||||
JOURNAL_SHEET_SET: 'JOURNAL_SHEET_SET',
|
||||
}
|
||||
Reference in New Issue
Block a user