RED-7694 - Check if startDate is before endDate for license before overwriting... #152

Merged
andrei.isvoran.ext merged 1 commits from RED-7687 into master 2023-10-03 09:50:13 +02:00
2 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.iqser.red.service.persistence.management.v1.processor.service;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
@ -37,7 +38,7 @@ public class LicenseReportService {
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.");
}

View File

@ -26,6 +26,12 @@ public class LicenseReportRequest {
return startDate;
}
public boolean isStartDateBeforeEndDate() {
var endDate = this.endDate == null ? Instant.now() : this.endDate;
return getStartDate().isBefore(endDate);
}
public Instant getEndDate() {