Skip to content

Commit ebb3d67

Browse files
authored
ORV2-3151 ORV2-3379 ORV2-3380 Remove date range limit for Payment and Refund Summary report (#1821)
1 parent 9ca51d7 commit ebb3d67

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

frontend/src/features/idir/reporting/forms/PaymentAndRefundDetail.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export const PaymentAndRefundDetail = () => {
249249
</Stack>
250250
)}
251251
<Stack direction="row" spacing={3}>
252-
<ReportDateTimePickers />
252+
<ReportDateTimePickers enableDateRangeValidation={true}/>
253253
</Stack>
254254
<br />
255255
<Stack direction="row">

frontend/src/features/idir/reporting/forms/subcomponents/ReportDateTimePickers.tsx

+22-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ import duration from "dayjs/plugin/duration";
66
import { useFormContext } from "react-hook-form";
77

88
import { useCallback, useEffect } from "react";
9-
import { RequiredOrNull } from "../../../../../common/types/common";
9+
import { Optional, RequiredOrNull } from "../../../../../common/types/common";
1010
import { PaymentAndRefundSummaryFormData } from "../../types/types";
1111

1212
dayjs.extend(duration);
1313
const THIRTY_ONE_DAYS = 31;
1414
const roundingBuffer = dayjs.duration(1, "hour").asDays();
1515

16+
/**
17+
* The props used by the ReportDateTimePickers component.
18+
*/
19+
export type ReportDateTimePickersProps = {
20+
enableDateRangeValidation?: Optional<boolean>;
21+
};
22+
1623
/**
1724
* The date time pickers for reports.
1825
*/
19-
export const ReportDateTimePickers = () => {
26+
export const ReportDateTimePickers = ({
27+
enableDateRangeValidation = false,
28+
}: ReportDateTimePickersProps) => {
2029
const { setValue, watch, setError, formState, clearErrors } =
2130
useFormContext<PaymentAndRefundSummaryFormData>();
2231
const { errors } = formState;
@@ -42,8 +51,10 @@ export const ReportDateTimePickers = () => {
4251
}, [fromDateTime, toDateTime]);
4352

4453
useEffect(() => {
45-
validateToDateTime();
46-
}, [fromDateTime, toDateTime]);
54+
if (enableDateRangeValidation) {
55+
validateToDateTime();
56+
}
57+
}, [fromDateTime, toDateTime, enableDateRangeValidation]);
4758

4859
return (
4960
<>
@@ -114,8 +125,14 @@ export const ReportDateTimePickers = () => {
114125
* The reports API account for a rounding value which allows this buffer.
115126
*
116127
* Hence the decision to add 1 minute to 30 days, to make life easier for user.
128+
*
129+
* Note: Date range validation is not applicable for Summary Reports.
117130
*/
118-
maxDateTime={fromDateTime.add(THIRTY_ONE_DAYS, "days").add(1, "minute")}
131+
maxDateTime={
132+
enableDateRangeValidation
133+
? fromDateTime.add(THIRTY_ONE_DAYS, "days").add(1, "minute")
134+
: undefined
135+
}
119136
views={["year", "month", "day", "hours", "minutes"]}
120137
slotProps={{
121138
textField: {

vehicles/src/modules/permit-application-payment/payment/dto/request/create-payment-summary-report.dto.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,8 @@ export class CreatePaymentSummaryReportDto {
2929
@ApiProperty({
3030
example: '2023-10-27T23:26:51.170Z',
3131
description:
32-
'Include records in the report till the given date and time.' +
33-
'The difference between fromDateTime and toDateTime must not be' +
34-
' more than 31 days.',
32+
'Include records in the report till the given date and time.'
3533
})
3634
@IsDateString()
37-
@IsDateTimeAfter<CreatePaymentSummaryReportDto>('fromDateTime', {
38-
difference: {
39-
maxDiff: 31,
40-
unit: 'days',
41-
},
42-
rounding: {
43-
maxDiff: 1,
44-
unit: 'hour',
45-
},
46-
})
4735
toDateTime: string;
4836
}

0 commit comments

Comments
 (0)