fix: financial statements.

This commit is contained in:
Ahmed Bouhuolia
2020-05-13 02:39:36 +02:00
parent 5ffb54992e
commit 00de156c9f
23 changed files with 276 additions and 104 deletions

View File

@@ -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 />

View File

@@ -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>
);
}