mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix(financial-statement): BIG-405 reports filter from/to dates out of the range.
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { HTMLSelect, FormGroup, Intent, Position } from '@blueprintjs/core';
|
import { HTMLSelect, FormGroup, Intent, Position } from '@blueprintjs/core';
|
||||||
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
|
|
||||||
import { Row, Col, Hint } from '@/components';
|
import { Row, Col, Hint } from '@/components';
|
||||||
import { momentFormatter, parseDateRangeQuery } from '@/utils';
|
import { momentFormatter, parseDateRangeQuery } from '@/utils';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
|
||||||
import { dateRangeOptions } from './constants';
|
import { dateRangeOptions } from './constants';
|
||||||
|
|
||||||
|
const FINANCIAL_REPORT_MAX_DATE = moment().add(5, 'years').toDate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Financial statement - Date range select.
|
* Financial statement - Date range select.
|
||||||
@@ -19,10 +21,7 @@ export default function FinancialStatementDateRange() {
|
|||||||
<Row>
|
<Row>
|
||||||
<Col xs={4}>
|
<Col xs={4}>
|
||||||
<FastField name={'date_range'}>
|
<FastField name={'date_range'}>
|
||||||
{({
|
{({ form: { setFieldValue }, field: { value } }) => (
|
||||||
form: { setFieldValue },
|
|
||||||
field: { value },
|
|
||||||
}) => (
|
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={intl.get('report_date_range')}
|
label={intl.get('report_date_range')}
|
||||||
labelInfo={<Hint />}
|
labelInfo={<Hint />}
|
||||||
@@ -40,8 +39,14 @@ export default function FinancialStatementDateRange() {
|
|||||||
const dateRange = parseDateRangeQuery(newValue);
|
const dateRange = parseDateRangeQuery(newValue);
|
||||||
|
|
||||||
if (dateRange) {
|
if (dateRange) {
|
||||||
setFieldValue('fromDate', moment(dateRange.fromDate).toDate());
|
setFieldValue(
|
||||||
setFieldValue('toDate', moment(dateRange.toDate).toDate());
|
'fromDate',
|
||||||
|
moment(dateRange.fromDate).toDate(),
|
||||||
|
);
|
||||||
|
setFieldValue(
|
||||||
|
'toDate',
|
||||||
|
moment(dateRange.toDate).toDate(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFieldValue('dateRange', newValue);
|
setFieldValue('dateRange', newValue);
|
||||||
@@ -78,6 +83,7 @@ export default function FinancialStatementDateRange() {
|
|||||||
canClearSelection={false}
|
canClearSelection={false}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
fill={true}
|
fill={true}
|
||||||
|
maxDate={FINANCIAL_REPORT_MAX_DATE}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
@@ -109,6 +115,7 @@ export default function FinancialStatementDateRange() {
|
|||||||
fill={true}
|
fill={true}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
intent={error && Intent.DANGER}
|
intent={error && Intent.DANGER}
|
||||||
|
maxDate={FINANCIAL_REPORT_MAX_DATE}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user