mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix: financial statements.
This commit is contained in:
@@ -12,7 +12,6 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import SettingsConnect from 'connectors/Settings.connect';
|
||||
|
||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||
import withJournal from './withJournal';
|
||||
import withJournalActions from './withJournalActions';
|
||||
|
||||
|
||||
@@ -23,9 +22,6 @@ function Journal({
|
||||
// #withDashboard
|
||||
changePageTitle,
|
||||
|
||||
// #withJournal
|
||||
journalSheetLoading,
|
||||
|
||||
// #withPreferences
|
||||
organizationSettings,
|
||||
}) {
|
||||
@@ -34,13 +30,15 @@ function Journal({
|
||||
to_date: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
basis: 'accural'
|
||||
});
|
||||
const [refetch, setRefetch] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
changePageTitle('Journal Sheet');
|
||||
}, []);
|
||||
|
||||
const fetchHook = useQuery(['journal', filter],
|
||||
(key, query) => { requestFetchJournalSheet(query); });
|
||||
(key, query) => { requestFetchJournalSheet(query); },
|
||||
{ manual: true });
|
||||
|
||||
// Handle financial statement filter change.
|
||||
const handleFilterSubmit = useCallback((filter) => {
|
||||
@@ -50,6 +48,7 @@ function Journal({
|
||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||
};
|
||||
setFilter(_filter);
|
||||
setRefetch(true);
|
||||
}, [fetchHook]);
|
||||
|
||||
const handlePrintClick = useCallback(() => {
|
||||
@@ -61,13 +60,20 @@ function Journal({
|
||||
}, []);
|
||||
|
||||
const handleFetchData = useCallback(({ sortBy, pageIndex, pageSize }) => {
|
||||
fetchHook.refetch();
|
||||
}, [fetchHook]);
|
||||
setRefetch(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (refetch) {
|
||||
fetchHook.refetch({ force: true });
|
||||
setRefetch(false);
|
||||
}
|
||||
}, [refetch, fetchHook])
|
||||
|
||||
return (
|
||||
<DashboardInsider>
|
||||
<JournalActionsBar
|
||||
onFilterChanged={() => {}}
|
||||
onSubmitFilter={handleFilterSubmit}
|
||||
onPrintClick={handlePrintClick}
|
||||
onExportClick={handleExportClick} />
|
||||
|
||||
@@ -81,7 +87,6 @@ function Journal({
|
||||
<JournalTable
|
||||
companyName={organizationSettings.name}
|
||||
journalQuery={filter}
|
||||
loading={journalSheetLoading}
|
||||
onFetchData={handleFetchData} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,8 +98,5 @@ function Journal({
|
||||
export default compose(
|
||||
withDashboard,
|
||||
withJournalActions,
|
||||
withJournal(({ journalSheetLoading }) => ({
|
||||
journalSheetLoading,
|
||||
})),
|
||||
SettingsConnect,
|
||||
)(Journal);
|
||||
@@ -5,9 +5,10 @@ import {
|
||||
Intent,
|
||||
} from '@blueprintjs/core';
|
||||
import moment from 'moment';
|
||||
import {useFormik} from 'formik';
|
||||
import {useIntl} from 'react-intl';
|
||||
import { useFormik } from 'formik';
|
||||
import { useIntl } from 'react-intl';
|
||||
import * as Yup from 'yup';
|
||||
|
||||
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
||||
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ import withJournal from './withJournal';
|
||||
function JournalSheetTable({
|
||||
// #withJournal
|
||||
journalSheetTableRows,
|
||||
journalSheetLoading,
|
||||
journalSheetQuery,
|
||||
|
||||
// #ownProps
|
||||
onFetchData,
|
||||
loading,
|
||||
companyName,
|
||||
}) {
|
||||
const rowTypeFilter = (rowType, value, types) => {
|
||||
@@ -86,9 +87,10 @@ function JournalSheetTable({
|
||||
<FinancialSheet
|
||||
companyName={companyName}
|
||||
sheetType={'Journal Sheet'}
|
||||
date={new Date()}
|
||||
fromDate={journalSheetQuery.from_date}
|
||||
toDate={journalSheetQuery.to_date}
|
||||
name="journal"
|
||||
loading={loading}>
|
||||
loading={journalSheetLoading}>
|
||||
|
||||
<DataTable
|
||||
className="bigcapital-datatable--financial-report"
|
||||
@@ -106,7 +108,10 @@ function JournalSheetTable({
|
||||
const mapStateToProps = (state, props) => {
|
||||
const { journalQuery } = props;
|
||||
return {
|
||||
journalIndex: getFinancialSheetIndexByQuery(state.financialStatements.journal.sheets, journalQuery)
|
||||
journalIndex: getFinancialSheetIndexByQuery(
|
||||
state.financialStatements.journal.sheets,
|
||||
journalQuery,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,7 +119,9 @@ const withJournalTable = connect(mapStateToProps);
|
||||
|
||||
export default compose(
|
||||
withJournalTable,
|
||||
withJournal(({ journalSheetTableRows }) => ({
|
||||
journalSheetTableRows
|
||||
withJournal(({ journalSheetTableRows, journalSheetLoading, journalSheetQuery }) => ({
|
||||
journalSheetTableRows,
|
||||
journalSheetLoading,
|
||||
journalSheetQuery,
|
||||
})),
|
||||
)(JournalSheetTable);
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
getFinancialSheetIndexByQuery,
|
||||
getFinancialSheet,
|
||||
getFinancialSheetTableRows,
|
||||
getFinancialSheetQuery,
|
||||
} from 'store/financialStatement/financialStatements.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
@@ -10,8 +11,18 @@ export default (mapState) => {
|
||||
const { journalIndex } = props;
|
||||
|
||||
const mapped = {
|
||||
journalSheet: getFinancialSheet(state.financialStatements.journal.sheets, journalIndex),
|
||||
journalSheetTableRows: getFinancialSheetTableRows(state.financialStatements.journal.sheets, journalIndex),
|
||||
journalSheet: getFinancialSheet(
|
||||
state.financialStatements.journal.sheets,
|
||||
journalIndex
|
||||
),
|
||||
journalSheetTableRows: getFinancialSheetTableRows(
|
||||
state.financialStatements.journal.sheets,
|
||||
journalIndex
|
||||
),
|
||||
journalSheetQuery: getFinancialSheetQuery(
|
||||
state.financialStatements.journal.sheets,
|
||||
journalIndex,
|
||||
),
|
||||
journalSheetLoading: state.financialStatements.journal.loading,
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
|
||||
Reference in New Issue
Block a user