mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
fix: financial statements.
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Menu, MenuItem, MenuDivider} from '@blueprintjs/core';
|
import {Menu, MenuItem, MenuDivider} from '@blueprintjs/core';
|
||||||
import {useHistory} from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import preferencesMenu from 'config/preferencesMenu';
|
import preferencesMenu from 'config/preferencesMenu';
|
||||||
|
|
||||||
export default function PreferencesSidebar() {
|
export default function PreferencesSidebar() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const items = preferencesMenu.map((item) => (
|
const items = preferencesMenu.map((item) => (
|
||||||
(item.divider) ?
|
(item.divider) ?
|
||||||
<MenuDivider title={item.title} /> :
|
<MenuDivider
|
||||||
|
title={item.title} /> :
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
active={(item.href && item.href === location.pathname)}
|
||||||
text={item.text}
|
text={item.text}
|
||||||
label={item.label}
|
label={item.label}
|
||||||
disabled={item.disabled}
|
disabled={item.disabled}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import BalanceSheetTable from './BalanceSheetTable';
|
|||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import BalanceSheetActionsBar from './BalanceSheetActionsBar';
|
import BalanceSheetActionsBar from './BalanceSheetActionsBar';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
|
||||||
|
|
||||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withBalanceSheetActions from './withBalanceSheetActions';
|
import withBalanceSheetActions from './withBalanceSheetActions';
|
||||||
import withBalanceSheetDetail from './withBalanceSheetDetail';
|
import withBalanceSheetDetail from './withBalanceSheetDetail';
|
||||||
|
|
||||||
@@ -40,14 +40,16 @@ function BalanceSheet({
|
|||||||
display_columns_by: '',
|
display_columns_by: '',
|
||||||
none_zero: false,
|
none_zero: false,
|
||||||
});
|
});
|
||||||
|
const [refetch, setRefetch] = useState(false);
|
||||||
|
|
||||||
const fetchHook = useQuery(['balance-sheet', filter],
|
const fetchHook = useQuery(['balance-sheet', filter],
|
||||||
(key, query) => { fetchBalanceSheet({ ...query }); });
|
(key, query) => fetchBalanceSheet({ ...query }),
|
||||||
|
{ manual: true });
|
||||||
|
|
||||||
// Handle fetch the data of balance sheet.
|
// Handle fetch the data of balance sheet.
|
||||||
const handleFetchData = useCallback(() => {
|
const handleFetchData = useCallback(() => {
|
||||||
fetchHook.refetch();
|
setRefetch(true);
|
||||||
}, [fetchHook]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle('Balance Sheet');
|
changePageTitle('Balance Sheet');
|
||||||
@@ -61,8 +63,17 @@ function BalanceSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter({ ..._filter });
|
setFilter({ ..._filter });
|
||||||
|
setRefetch(true);
|
||||||
}, [setFilter]);
|
}, [setFilter]);
|
||||||
|
|
||||||
|
// Refetch sheet effect.
|
||||||
|
useEffect(() => {
|
||||||
|
if (refetch) {
|
||||||
|
fetchHook.refetch({ force: true });
|
||||||
|
setRefetch(false);
|
||||||
|
}
|
||||||
|
}, [refetch])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
<BalanceSheetActionsBar />
|
<BalanceSheetActionsBar />
|
||||||
@@ -92,6 +103,5 @@ export default compose(
|
|||||||
withBalanceSheetDetail(({ balanceSheetLoading }) => ({
|
withBalanceSheetDetail(({ balanceSheetLoading }) => ({
|
||||||
balanceSheetLoading,
|
balanceSheetLoading,
|
||||||
})),
|
})),
|
||||||
// BalanceSheetConnect,
|
withSettings,
|
||||||
SettingsConnect,
|
|
||||||
)(BalanceSheet);
|
)(BalanceSheet);
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import FilterDropdown from 'components/FilterDropdown';
|
import FilterDropdown from 'components/FilterDropdown';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import FinancialStatementDateRange from 'containers/FinancialStatements/Financia
|
|||||||
import SelectDisplayColumnsBy from '../SelectDisplayColumnsBy';
|
import SelectDisplayColumnsBy from '../SelectDisplayColumnsBy';
|
||||||
import RadiosAccountingBasis from '../RadiosAccountingBasis';
|
import RadiosAccountingBasis from '../RadiosAccountingBasis';
|
||||||
|
|
||||||
|
|
||||||
export default function BalanceSheetHeader({
|
export default function BalanceSheetHeader({
|
||||||
onSubmitFilter,
|
onSubmitFilter,
|
||||||
pageFilter,
|
pageFilter,
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ function BalanceSheetTable({
|
|||||||
data={balanceSheetAccounts}
|
data={balanceSheetAccounts}
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
expanded={expandedRows}
|
expanded={expandedRows}
|
||||||
expandSubRows={true}
|
expandSubRows={true} />
|
||||||
noInitialFetch={true} />
|
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
fetchBalanceSheet,
|
fetchBalanceSheet,
|
||||||
} from 'store/financialStatement/financialStatements.actions';
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
fetchBalanceSheet: (query = {}) => dispatch(fetchBalanceSheet({ query })),
|
fetchBalanceSheet: (query = {}) => dispatch(fetchBalanceSheet({ query })),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,33 @@
|
|||||||
import React, { useEffect, useCallback, useState, useMemo } from 'react';
|
import React, { useEffect, useCallback, useState, useMemo } from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import GeneralLedgerTable from 'containers/FinancialStatements/GeneralLedger/GeneralLedgerTable';
|
import GeneralLedgerTable from 'containers/FinancialStatements/GeneralLedger/GeneralLedgerTable';
|
||||||
import useAsync from 'hooks/async';
|
import { useQuery } from 'react-query';
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
|
||||||
import GeneralLedgerConnect from 'connectors/GeneralLedgerSheet.connect';
|
|
||||||
import GeneralLedgerHeader from './GeneralLedgerHeader';
|
import GeneralLedgerHeader from './GeneralLedgerHeader';
|
||||||
|
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
|
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider'
|
import DashboardInsider from 'components/Dashboard/DashboardInsider'
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import GeneralLedgerActionsBar from './GeneralLedgerActionsBar';
|
import GeneralLedgerActionsBar from './GeneralLedgerActionsBar';
|
||||||
import AccountsConnect from 'connectors/Accounts.connector';
|
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import withGeneralLedgerActions from './withGeneralLedgerActions';
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||||
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
|
|
||||||
|
|
||||||
function GeneralLedger({
|
function GeneralLedger({
|
||||||
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
getGeneralLedgerSheetIndex,
|
|
||||||
getGeneralLedgerSheet,
|
// #withGeneralLedgerActions
|
||||||
fetchGeneralLedger,
|
fetchGeneralLedger,
|
||||||
generalLedgerSheetLoading,
|
|
||||||
|
// #withAccountsActions
|
||||||
requestFetchAccounts,
|
requestFetchAccounts,
|
||||||
|
|
||||||
|
// #withSettings
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
@@ -27,34 +36,32 @@ function GeneralLedger({
|
|||||||
basis: 'accural',
|
basis: 'accural',
|
||||||
none_zero: true,
|
none_zero: true,
|
||||||
});
|
});
|
||||||
|
const [refetch, setRefetch] = useState(false);
|
||||||
|
|
||||||
// Change page title of the dashboard.
|
// Change page title of the dashboard.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle('General Ledger');
|
changePageTitle('General Ledger');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchHook = useAsync(() => {
|
const fetchAccounts = useQuery(['accounts-list'],
|
||||||
return Promise.all([
|
() => requestFetchAccounts());
|
||||||
requestFetchAccounts(),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
const fetchSheet = useAsync((query = filter) => {
|
const fetchSheet = useQuery(['general-ledger', filter],
|
||||||
return Promise.all([
|
(key, query) => fetchGeneralLedger(query),
|
||||||
fetchGeneralLedger(query),
|
{ manual: true });
|
||||||
]);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
const generalLedgerSheetIndex = useMemo(() =>
|
// Refetch general ledger sheet effect.
|
||||||
getGeneralLedgerSheetIndex(filter),
|
useEffect(() => {
|
||||||
[getGeneralLedgerSheetIndex, filter]);
|
if (refetch) {
|
||||||
|
fetchSheet.refetch({ force: true });
|
||||||
const generalLedgerSheet = useMemo(() =>
|
setRefetch(false);
|
||||||
getGeneralLedgerSheet(generalLedgerSheetIndex),
|
}
|
||||||
[generalLedgerSheetIndex, getGeneralLedgerSheet])
|
}, [fetchSheet, refetch]);
|
||||||
|
|
||||||
// Handle fetch data of trial balance table.
|
// Handle fetch data of trial balance table.
|
||||||
const handleFetchData = useCallback(() => { fetchSheet.execute() }, [fetchSheet]);
|
const handleFetchData = useCallback(() => {
|
||||||
|
setRefetch(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Handle financial statement filter change.
|
// Handle financial statement filter change.
|
||||||
const handleFilterSubmit = useCallback((filter) => {
|
const handleFilterSubmit = useCallback((filter) => {
|
||||||
@@ -64,14 +71,15 @@ function GeneralLedger({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(parsedFilter);
|
setFilter(parsedFilter);
|
||||||
fetchSheet.execute(parsedFilter);
|
setRefetch(true);
|
||||||
}, [setFilter, fetchSheet]);
|
}, [setFilter]);
|
||||||
|
|
||||||
const handleFilterChanged = () => {};
|
const handleFilterChanged = () => {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
<GeneralLedgerActionsBar onFilterChanged={handleFilterChanged} />
|
<GeneralLedgerActionsBar
|
||||||
|
onFilterChanged={handleFilterChanged} />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<div class="financial-statement financial-statement--general-ledger">
|
<div class="financial-statement financial-statement--general-ledger">
|
||||||
@@ -82,11 +90,7 @@ function GeneralLedger({
|
|||||||
<div class="financial-statement__table">
|
<div class="financial-statement__table">
|
||||||
<GeneralLedgerTable
|
<GeneralLedgerTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
loading={generalLedgerSheetLoading}
|
generalLedgerQuery={filter}
|
||||||
data={[
|
|
||||||
... (generalLedgerSheet) ?
|
|
||||||
generalLedgerSheet.tableRows : [],
|
|
||||||
]}
|
|
||||||
onFetchData={handleFetchData} />
|
onFetchData={handleFetchData} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -96,8 +100,8 @@ function GeneralLedger({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DashboardConnect,
|
withGeneralLedgerActions,
|
||||||
AccountsConnect,
|
withDashboard,
|
||||||
GeneralLedgerConnect,
|
withAccountsActions,
|
||||||
SettingsConnect,
|
withSettings,
|
||||||
)(GeneralLedger);
|
)(GeneralLedger);
|
||||||
@@ -15,10 +15,12 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import FilterDropdown from 'components/FilterDropdown';
|
import FilterDropdown from 'components/FilterDropdown';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General ledger actions bar.
|
||||||
|
*/
|
||||||
export default function GeneralLedgerActionsBar({
|
export default function GeneralLedgerActionsBar({
|
||||||
|
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const filterDropdown = FilterDropdown({
|
const filterDropdown = FilterDropdown({
|
||||||
fields: [],
|
fields: [],
|
||||||
onFilterChange: (filterConditions) => {
|
onFilterChange: (filterConditions) => {
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
import React, {useEffect, useState, useCallback, useMemo} from 'react';
|
import React, {useEffect, useState, useCallback, useMemo} from 'react';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import {
|
||||||
|
defaultExpanderReducer,
|
||||||
|
compose
|
||||||
|
} from 'utils';
|
||||||
|
|
||||||
import FinancialSheet from 'components/FinancialSheet';
|
import FinancialSheet from 'components/FinancialSheet';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import Money from 'components/Money';
|
import Money from 'components/Money';
|
||||||
import moment from 'moment';
|
|
||||||
import {
|
import {
|
||||||
defaultExpanderReducer,
|
getFinancialSheetIndexByQuery,
|
||||||
} from 'utils';
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
import withGeneralLedger from './withGeneralLedger';
|
||||||
|
|
||||||
|
|
||||||
const ROW_TYPE = {
|
const ROW_TYPE = {
|
||||||
@@ -13,13 +21,15 @@ const ROW_TYPE = {
|
|||||||
OPENING_BALANCE: 'opening_balance',
|
OPENING_BALANCE: 'opening_balance',
|
||||||
ACCOUNT: 'account_name',
|
ACCOUNT: 'account_name',
|
||||||
TRANSACTION: 'transaction',
|
TRANSACTION: 'transaction',
|
||||||
}
|
};
|
||||||
|
|
||||||
export default function GeneralLedgerTable({
|
function GeneralLedgerTable({
|
||||||
companyName,
|
companyName,
|
||||||
onFetchData,
|
onFetchData,
|
||||||
loading,
|
|
||||||
data,
|
generalLedgerSheetLoading,
|
||||||
|
generalLedgerTableRows,
|
||||||
|
generalLedgerQuery,
|
||||||
}) {
|
}) {
|
||||||
// Account name column accessor.
|
// Account name column accessor.
|
||||||
const accountNameAccessor = useCallback((row) => {
|
const accountNameAccessor = useCallback((row) => {
|
||||||
@@ -141,20 +151,23 @@ export default function GeneralLedgerTable({
|
|||||||
}, [onFetchData]);
|
}, [onFetchData]);
|
||||||
|
|
||||||
// Default expanded rows of general ledger table.
|
// Default expanded rows of general ledger table.
|
||||||
const expandedRows = useMemo(() => defaultExpanderReducer(data, 1), [data]);
|
const expandedRows = useMemo(
|
||||||
|
() => defaultExpanderReducer(generalLedgerTableRows, 1),
|
||||||
|
[generalLedgerTableRows]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FinancialSheet
|
<FinancialSheet
|
||||||
companyName={companyName}
|
companyName={companyName}
|
||||||
sheetType={'General Ledger Sheet'}
|
sheetType={'General Ledger Sheet'}
|
||||||
date={new Date()}
|
fromDate={generalLedgerQuery.from_date}
|
||||||
|
toDate={generalLedgerQuery.to_date}
|
||||||
name="general-ledger"
|
name="general-ledger"
|
||||||
loading={loading}>
|
loading={generalLedgerSheetLoading}>
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
className="bigcapital-datatable--financial-report"
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={data}
|
data={generalLedgerTableRows}
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
expanded={expandedRows}
|
expanded={expandedRows}
|
||||||
virtualizedRows={true}
|
virtualizedRows={true}
|
||||||
@@ -162,4 +175,30 @@ export default function GeneralLedgerTable({
|
|||||||
fixedSizeHeight={1000} />
|
fixedSizeHeight={1000} />
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { generalLedgerQuery } = props;
|
||||||
|
|
||||||
|
return {
|
||||||
|
generalLedgerIndex: getFinancialSheetIndexByQuery(
|
||||||
|
state.financialStatements.generalLedger.sheets,
|
||||||
|
generalLedgerQuery,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const withGeneralLedgerTable = connect(mapStateToProps);
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withGeneralLedgerTable,
|
||||||
|
withGeneralLedger(({
|
||||||
|
generalLedgerTableRows,
|
||||||
|
generalLedgerSheetLoading,
|
||||||
|
generalLedgerQuery,
|
||||||
|
}) => ({
|
||||||
|
generalLedgerTableRows,
|
||||||
|
generalLedgerSheetLoading,
|
||||||
|
generalLedgerQuery
|
||||||
|
})),
|
||||||
|
)(GeneralLedgerTable);
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
getFinancialSheet,
|
||||||
|
getFinancialSheetQuery,
|
||||||
|
getFinancialSheetTableRows,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { generalLedgerIndex } = props;
|
||||||
|
|
||||||
|
const mapped = {
|
||||||
|
generalLedgerSheet: getFinancialSheet(
|
||||||
|
state.financialStatements.generalLedger.sheets,
|
||||||
|
generalLedgerIndex,
|
||||||
|
),
|
||||||
|
generalLedgerTableRows: getFinancialSheetTableRows(
|
||||||
|
state.financialStatements.generalLedger.sheets,
|
||||||
|
generalLedgerIndex,
|
||||||
|
),
|
||||||
|
generalLedgerQuery: getFinancialSheetQuery(
|
||||||
|
state.financialStatements.generalLedger.sheets,
|
||||||
|
generalLedgerIndex,
|
||||||
|
),
|
||||||
|
generalLedgerSheetLoading: state.financialStatements.generalLedger.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
fetchGeneralLedger,
|
||||||
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
fetchGeneralLedger: (query = {}) => dispatch(fetchGeneralLedger({ query })),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -12,7 +12,6 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
|||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
|
||||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
import withJournal from './withJournal';
|
|
||||||
import withJournalActions from './withJournalActions';
|
import withJournalActions from './withJournalActions';
|
||||||
|
|
||||||
|
|
||||||
@@ -23,9 +22,6 @@ function Journal({
|
|||||||
// #withDashboard
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|
||||||
// #withJournal
|
|
||||||
journalSheetLoading,
|
|
||||||
|
|
||||||
// #withPreferences
|
// #withPreferences
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
}) {
|
}) {
|
||||||
@@ -34,13 +30,15 @@ function Journal({
|
|||||||
to_date: moment().endOf('year').format('YYYY-MM-DD'),
|
to_date: moment().endOf('year').format('YYYY-MM-DD'),
|
||||||
basis: 'accural'
|
basis: 'accural'
|
||||||
});
|
});
|
||||||
|
const [refetch, setRefetch] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle('Journal Sheet');
|
changePageTitle('Journal Sheet');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchHook = useQuery(['journal', filter],
|
const fetchHook = useQuery(['journal', filter],
|
||||||
(key, query) => { requestFetchJournalSheet(query); });
|
(key, query) => { requestFetchJournalSheet(query); },
|
||||||
|
{ manual: true });
|
||||||
|
|
||||||
// Handle financial statement filter change.
|
// Handle financial statement filter change.
|
||||||
const handleFilterSubmit = useCallback((filter) => {
|
const handleFilterSubmit = useCallback((filter) => {
|
||||||
@@ -50,6 +48,7 @@ function Journal({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(_filter);
|
setFilter(_filter);
|
||||||
|
setRefetch(true);
|
||||||
}, [fetchHook]);
|
}, [fetchHook]);
|
||||||
|
|
||||||
const handlePrintClick = useCallback(() => {
|
const handlePrintClick = useCallback(() => {
|
||||||
@@ -61,13 +60,20 @@ function Journal({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleFetchData = useCallback(({ sortBy, pageIndex, pageSize }) => {
|
const handleFetchData = useCallback(({ sortBy, pageIndex, pageSize }) => {
|
||||||
fetchHook.refetch();
|
setRefetch(true);
|
||||||
}, [fetchHook]);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (refetch) {
|
||||||
|
fetchHook.refetch({ force: true });
|
||||||
|
setRefetch(false);
|
||||||
|
}
|
||||||
|
}, [refetch, fetchHook])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
<JournalActionsBar
|
<JournalActionsBar
|
||||||
onFilterChanged={() => {}}
|
onSubmitFilter={handleFilterSubmit}
|
||||||
onPrintClick={handlePrintClick}
|
onPrintClick={handlePrintClick}
|
||||||
onExportClick={handleExportClick} />
|
onExportClick={handleExportClick} />
|
||||||
|
|
||||||
@@ -81,7 +87,6 @@ function Journal({
|
|||||||
<JournalTable
|
<JournalTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
journalQuery={filter}
|
journalQuery={filter}
|
||||||
loading={journalSheetLoading}
|
|
||||||
onFetchData={handleFetchData} />
|
onFetchData={handleFetchData} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -93,8 +98,5 @@ function Journal({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withDashboard,
|
withDashboard,
|
||||||
withJournalActions,
|
withJournalActions,
|
||||||
withJournal(({ journalSheetLoading }) => ({
|
|
||||||
journalSheetLoading,
|
|
||||||
})),
|
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(Journal);
|
)(Journal);
|
||||||
@@ -5,9 +5,10 @@ import {
|
|||||||
Intent,
|
Intent,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {useFormik} from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import {useIntl} from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
||||||
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ import withJournal from './withJournal';
|
|||||||
function JournalSheetTable({
|
function JournalSheetTable({
|
||||||
// #withJournal
|
// #withJournal
|
||||||
journalSheetTableRows,
|
journalSheetTableRows,
|
||||||
|
journalSheetLoading,
|
||||||
|
journalSheetQuery,
|
||||||
|
|
||||||
// #ownProps
|
// #ownProps
|
||||||
onFetchData,
|
onFetchData,
|
||||||
loading,
|
|
||||||
companyName,
|
companyName,
|
||||||
}) {
|
}) {
|
||||||
const rowTypeFilter = (rowType, value, types) => {
|
const rowTypeFilter = (rowType, value, types) => {
|
||||||
@@ -86,9 +87,10 @@ function JournalSheetTable({
|
|||||||
<FinancialSheet
|
<FinancialSheet
|
||||||
companyName={companyName}
|
companyName={companyName}
|
||||||
sheetType={'Journal Sheet'}
|
sheetType={'Journal Sheet'}
|
||||||
date={new Date()}
|
fromDate={journalSheetQuery.from_date}
|
||||||
|
toDate={journalSheetQuery.to_date}
|
||||||
name="journal"
|
name="journal"
|
||||||
loading={loading}>
|
loading={journalSheetLoading}>
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
className="bigcapital-datatable--financial-report"
|
||||||
@@ -106,7 +108,10 @@ function JournalSheetTable({
|
|||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const { journalQuery } = props;
|
const { journalQuery } = props;
|
||||||
return {
|
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(
|
export default compose(
|
||||||
withJournalTable,
|
withJournalTable,
|
||||||
withJournal(({ journalSheetTableRows }) => ({
|
withJournal(({ journalSheetTableRows, journalSheetLoading, journalSheetQuery }) => ({
|
||||||
journalSheetTableRows
|
journalSheetTableRows,
|
||||||
|
journalSheetLoading,
|
||||||
|
journalSheetQuery,
|
||||||
})),
|
})),
|
||||||
)(JournalSheetTable);
|
)(JournalSheetTable);
|
||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
getFinancialSheetIndexByQuery,
|
getFinancialSheetIndexByQuery,
|
||||||
getFinancialSheet,
|
getFinancialSheet,
|
||||||
getFinancialSheetTableRows,
|
getFinancialSheetTableRows,
|
||||||
|
getFinancialSheetQuery,
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
@@ -10,8 +11,18 @@ export default (mapState) => {
|
|||||||
const { journalIndex } = props;
|
const { journalIndex } = props;
|
||||||
|
|
||||||
const mapped = {
|
const mapped = {
|
||||||
journalSheet: getFinancialSheet(state.financialStatements.journal.sheets, journalIndex),
|
journalSheet: getFinancialSheet(
|
||||||
journalSheetTableRows: getFinancialSheetTableRows(state.financialStatements.journal.sheets, journalIndex),
|
state.financialStatements.journal.sheets,
|
||||||
|
journalIndex
|
||||||
|
),
|
||||||
|
journalSheetTableRows: getFinancialSheetTableRows(
|
||||||
|
state.financialStatements.journal.sheets,
|
||||||
|
journalIndex
|
||||||
|
),
|
||||||
|
journalSheetQuery: getFinancialSheetQuery(
|
||||||
|
state.financialStatements.journal.sheets,
|
||||||
|
journalIndex,
|
||||||
|
),
|
||||||
journalSheetLoading: state.financialStatements.journal.loading,
|
journalSheetLoading: state.financialStatements.journal.loading,
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ function ProfitLossSheet({
|
|||||||
from_date: moment().startOf('year').format('YYYY-MM-DD'),
|
from_date: moment().startOf('year').format('YYYY-MM-DD'),
|
||||||
to_date: moment().endOf('year').format('YYYY-MM-DD'),
|
to_date: moment().endOf('year').format('YYYY-MM-DD'),
|
||||||
});
|
});
|
||||||
|
const [refetch, setRefetch] = useState(false);
|
||||||
|
|
||||||
// Change page title of the dashboard.
|
// Change page title of the dashboard.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -42,7 +43,8 @@ function ProfitLossSheet({
|
|||||||
|
|
||||||
// Fetches profit/loss sheet.
|
// Fetches profit/loss sheet.
|
||||||
const fetchHook = useQuery(['profit-loss', filter],
|
const fetchHook = useQuery(['profit-loss', filter],
|
||||||
(key, query) => { fetchProfitLossSheet(query); });
|
(key, query) => fetchProfitLossSheet(query),
|
||||||
|
{ manual: true });
|
||||||
|
|
||||||
// Handle submit filter.
|
// Handle submit filter.
|
||||||
const handleSubmitFilter = useCallback((filter) => {
|
const handleSubmitFilter = useCallback((filter) => {
|
||||||
@@ -52,13 +54,21 @@ function ProfitLossSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(_filter);
|
setFilter(_filter);
|
||||||
|
setRefetch(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Handle fetch data of profit/loss sheet table.
|
// Handle fetch data of profit/loss sheet table.
|
||||||
const handleFetchData = useCallback(() => {
|
const handleFetchData = useCallback(() => {
|
||||||
fetchHook.refetch();
|
setRefetch(true);
|
||||||
}, [fetchHook]);
|
}, [fetchHook]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (refetch) {
|
||||||
|
fetchHook.refetch({ force: true });
|
||||||
|
setRefetch(false);
|
||||||
|
}
|
||||||
|
}, [fetchHook, refetch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
<ProfitLossActionsBar />
|
<ProfitLossActionsBar />
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ function ProfitLossSheetTable({
|
|||||||
<FinancialSheet
|
<FinancialSheet
|
||||||
companyName={companyName}
|
companyName={companyName}
|
||||||
sheetType={'Profit/Loss Sheet'}
|
sheetType={'Profit/Loss Sheet'}
|
||||||
date={new Date()}
|
fromDate={profitLossQuery.from_date}
|
||||||
|
toDate={profitLossQuery.to_date}
|
||||||
name="profit-loss-sheet"
|
name="profit-loss-sheet"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
basis={profitLossQuery.basis}>
|
basis={profitLossQuery.basis}>
|
||||||
@@ -133,8 +134,7 @@ function ProfitLossSheetTable({
|
|||||||
data={profitLossTableRows}
|
data={profitLossTableRows}
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
expanded={expandedRows}
|
expanded={expandedRows}
|
||||||
rowClassNames={rowClassNames}
|
rowClassNames={rowClassNames} />
|
||||||
noInitialFetch={true} />
|
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
|||||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
import withTrialBalanceActions from './withTrialBalanceActions';
|
import withTrialBalanceActions from './withTrialBalanceActions';
|
||||||
import withTrialBalance from './withTrialBalance';
|
import withTrialBalance from './withTrialBalance';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
|
|
||||||
|
|
||||||
function TrialBalanceSheet({
|
function TrialBalanceSheet({
|
||||||
@@ -35,13 +35,15 @@ function TrialBalanceSheet({
|
|||||||
basis: 'accural',
|
basis: 'accural',
|
||||||
none_zero: false,
|
none_zero: false,
|
||||||
});
|
});
|
||||||
|
const [refetch, setRefetch] = useState(false);
|
||||||
|
|
||||||
const fetchHook = useQuery(['trial-balance', filter],
|
const fetchHook = useQuery(['trial-balance', filter],
|
||||||
(key, query) => { fetchTrialBalanceSheet(query); });
|
(key, query) => fetchTrialBalanceSheet(query),
|
||||||
|
{ manual: true });
|
||||||
|
|
||||||
// handle fetch data of trial balance table.
|
// handle fetch data of trial balance table.
|
||||||
const handleFetchData = useCallback(() => {
|
const handleFetchData = useCallback(() => {
|
||||||
fetchHook.refetch()
|
setRefetch(true);
|
||||||
}, [fetchHook]);
|
}, [fetchHook]);
|
||||||
|
|
||||||
// Change page title of the dashboard.
|
// Change page title of the dashboard.
|
||||||
@@ -56,7 +58,16 @@ function TrialBalanceSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(parsedFilter);
|
setFilter(parsedFilter);
|
||||||
}, [setFilter]);
|
setRefetch(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Refetch sheet effect.
|
||||||
|
useEffect(() => {
|
||||||
|
if (refetch) {
|
||||||
|
fetchHook.refetch({ force: true });
|
||||||
|
setRefetch(false);
|
||||||
|
}
|
||||||
|
}, [fetchHook]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
@@ -87,5 +98,5 @@ export default compose(
|
|||||||
withTrialBalance(({ trialBalanceSheetLoading }) => ({
|
withTrialBalance(({ trialBalanceSheetLoading }) => ({
|
||||||
trialBalanceSheetLoading,
|
trialBalanceSheetLoading,
|
||||||
})),
|
})),
|
||||||
SettingsConnect,
|
withSettings,
|
||||||
)(TrialBalanceSheet);
|
)(TrialBalanceSheet);
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, {useState, useCallback, useMemo} from 'react';
|
import React, {useState, useCallback, useMemo} from 'react';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import {Row, Col} from 'react-grid-system';
|
import {Row, Col} from 'react-grid-system';
|
||||||
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
} from "@blueprintjs/core";
|
} from "@blueprintjs/core";
|
||||||
@@ -9,6 +8,7 @@ import moment from 'moment';
|
|||||||
import {useIntl} from 'react-intl';
|
import {useIntl} from 'react-intl';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
|
|
||||||
|
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
||||||
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ function TrialBalanceSheetTable({
|
|||||||
|
|
||||||
// #withTrialBalanceTable
|
// #withTrialBalanceTable
|
||||||
trialBalanceIndex,
|
trialBalanceIndex,
|
||||||
|
trialBalanceQuery,
|
||||||
|
|
||||||
onFetchData,
|
onFetchData,
|
||||||
loading,
|
loading,
|
||||||
@@ -102,7 +103,8 @@ function TrialBalanceSheetTable({
|
|||||||
<FinancialSheet
|
<FinancialSheet
|
||||||
companyName={companyName}
|
companyName={companyName}
|
||||||
sheetType={'Trial Balance Sheet'}
|
sheetType={'Trial Balance Sheet'}
|
||||||
date={new Date()}
|
fromDate={trialBalanceQuery.from_date}
|
||||||
|
toDate={trialBalanceQuery.to_date}
|
||||||
name="trial-balance"
|
name="trial-balance"
|
||||||
loading={loading}>
|
loading={loading}>
|
||||||
|
|
||||||
@@ -119,7 +121,10 @@ function TrialBalanceSheetTable({
|
|||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const { trialBalanceQuery } = props;
|
const { trialBalanceQuery } = props;
|
||||||
return {
|
return {
|
||||||
trialBalanceIndex: getFinancialSheetIndexByQuery(state.financialStatements.trialBalance.sheets, trialBalanceQuery),
|
trialBalanceIndex: getFinancialSheetIndexByQuery(
|
||||||
|
state.financialStatements.trialBalance.sheets,
|
||||||
|
trialBalanceQuery,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,14 @@ export default (mapState) => {
|
|||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const { trialBalanceIndex } = props;
|
const { trialBalanceIndex } = props;
|
||||||
const mapped = {
|
const mapped = {
|
||||||
trialBalanceAccounts: getFinancialSheetAccounts(state.financialStatements.trialBalance.sheets, trialBalanceIndex),
|
trialBalanceAccounts: getFinancialSheetAccounts(
|
||||||
trialBalanceQuery: getFinancialSheetQuery(state.financialStatements.trialBalance.sheets, trialBalanceIndex),
|
state.financialStatements.trialBalance.sheets,
|
||||||
|
trialBalanceIndex
|
||||||
|
),
|
||||||
|
trialBalanceQuery: getFinancialSheetQuery(
|
||||||
|
state.financialStatements.trialBalance.sheets,
|
||||||
|
trialBalanceIndex
|
||||||
|
),
|
||||||
trialBalanceSheetLoading: state.financialStatements.trialBalance.loading,
|
trialBalanceSheetLoading: state.financialStatements.trialBalance.loading,
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
MenuDivider,
|
MenuDivider,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Tag
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { snakeCase } from 'lodash';
|
import { snakeCase } from 'lodash';
|
||||||
|
|
||||||
@@ -138,9 +139,11 @@ function UsersListPreferences({
|
|||||||
{
|
{
|
||||||
id: 'active',
|
id: 'active',
|
||||||
Header: 'Status',
|
Header: 'Status',
|
||||||
accessor: (user) =>
|
accessor: (user) => user.active ?
|
||||||
user.active ? <span>Active</span> : <span>Inactivate</span>,
|
<Tag intent={Intent.SUCCESS} minimal={true}>Active</Tag> :
|
||||||
|
<Tag intent={Intent.WARNING} minimal={true}>Inactivate</Tag>,
|
||||||
width: 50,
|
width: 50,
|
||||||
|
className: 'status',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
|
|||||||
@@ -91,8 +91,14 @@
|
|||||||
.#{$ns}-menu-item {
|
.#{$ns}-menu-item {
|
||||||
padding: 10px 18px;
|
padding: 10px 18px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: 300;
|
font-weight: 400;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&.#{$ns}-active{
|
||||||
|
background-color: #ebf1f5;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,3 +116,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Users/Roles List.
|
||||||
|
// ---------------------------------
|
||||||
|
.preferences__inside-content--users-roles{
|
||||||
|
.bigcapital-datatable{
|
||||||
|
.td.status{
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user