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