RED-7694 - Backport Fix invalid date period
This commit is contained in:
parent
fe84f2ef04
commit
9e5bd8cfef
@ -36,10 +36,15 @@ public class LicenseReportRequest {
|
|||||||
return startDate;
|
return startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStartDateBeforeEndDate() {
|
||||||
|
|
||||||
|
var endDate = this.endDate == null ? Instant.now() : this.endDate;
|
||||||
|
return getStartDate().isBefore(endDate);
|
||||||
|
}
|
||||||
|
|
||||||
public Instant getEndDate() {
|
public Instant getEndDate() {
|
||||||
|
|
||||||
if (endDate == null) {
|
if (endDate == null || endDate.isAfter(Instant.now())) {
|
||||||
endDate = Instant.now();
|
endDate = Instant.now();
|
||||||
}
|
}
|
||||||
return endDate;
|
return endDate;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class LicenseReportService {
|
|||||||
|
|
||||||
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
|
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
|
||||||
|
|
||||||
if (licenseReportRequest.getEndDate().isBefore(licenseReportRequest.getStartDate())) {
|
if (!licenseReportRequest.isStartDateBeforeEndDate()) {
|
||||||
throw new BadRequestException("Invalid date period: End date is before start date.");
|
throw new BadRequestException("Invalid date period: End date is before start date.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user