fix: financial reports.

This commit is contained in:
a.bouhuolia
2022-02-13 13:21:59 +02:00
parent b1f07d281f
commit 2986b537d0
13 changed files with 90 additions and 48 deletions

View File

@@ -15,6 +15,7 @@ import {
CashFlowStatementAlerts,
} from './components';
import { getDefaultCashFlowSheetQuery } from './utils';
import { compose } from 'utils';
/**
@@ -26,13 +27,8 @@ function CashFlowStatement({
}) {
// filter
const [filter, setFilter] = useState({
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
toDate: moment().endOf('year').format('YYYY-MM-DD'),
basis: 'cash',
displayColumnsType: 'total',
filterByOption: 'with-transactions',
...getDefaultCashFlowSheetQuery(),
});
// Handle refetch cash flow after filter change.
const handleFilterSubmit = (filter) => {
const _filter = {
@@ -42,7 +38,6 @@ function CashFlowStatement({
};
setFilter({ ..._filter });
};
// Handle format number submit.
const handleNumberFormatSubmit = (values) => {
setFilter({

View File

@@ -12,6 +12,7 @@ import CashFlowStatementGeneralPanel from './CashFlowStatementGeneralPanel';
import withCashFlowStatement from './withCashFlowStatement';
import withCashFlowStatementActions from './withCashFlowStatementActions';
import { getDefaultCashFlowSheetQuery } from './utils';
import { compose, transformToForm } from 'utils';
/**
@@ -29,10 +30,7 @@ function CashFlowStatementHeader({
toggleCashFlowStatementFilterDrawer,
}) {
// Filter form default values.
const defaultValues = {
fromDate: moment().toDate(),
toDate: moment().toDate(),
};
const defaultValues = getDefaultCashFlowSheetQuery();
// Initial form values.
const initialValues = transformToForm({

View File

@@ -0,0 +1,14 @@
import moment from 'moment';
/**
* Retrieves the default cashflow sheet query.
*/
export const getDefaultCashFlowSheetQuery = () => {
return {
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
toDate: moment().endOf('year').format('YYYY-MM-DD'),
basis: 'cash',
displayColumnsType: 'total',
filterByOption: 'with-transactions',
};
};