RED-7687 - Check if startDate is before endDate for license before overwriting the endDate if it's in the future.
This commit is contained in:
parent
b706a71ec1
commit
ad20a1f9f5
@ -1,5 +1,6 @@
|
|||||||
package com.iqser.red.service.persistence.management.v1.processor.service;
|
package com.iqser.red.service.persistence.management.v1.processor.service;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@ -37,7 +38,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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,12 @@ 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() {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user