diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 75fffc97..b63a63fc 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -942,7 +942,7 @@ public class ApplicationDao { throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS)); } if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) { - callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId()); +// callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId()); Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub()); ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity, protocolNumber, userEntity.getHub().getId(),true); applicationEntity.setProtocol(protocolEntity); @@ -1665,19 +1665,21 @@ public class ApplicationDao { public void checkCallEndDate(CallEntity call) { - LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); - - LocalDateTime callEndDateTime = LocalDateTime.of( - call.getEndDate().toLocalDate(), - call.getEndTime() - ); - - if (now.isAfter(callEndDateTime)) { - throw new CustomValidationException( - Status.BAD_REQUEST, - Translator.toLocale(GepafinConstant.CALL_EXPIRED) - ); - } + + callService.validatePublishedCall(call.getId(), call.getHub().getId()); +// LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); +// +// LocalDateTime callEndDateTime = LocalDateTime.of( +// call.getEndDate().toLocalDate(), +// call.getEndTime() +// ); +// +// if (now.isAfter(callEndDateTime)) { +// throw new CustomValidationException( +// Status.BAD_REQUEST, +// Translator.toLocale(GepafinConstant.CALL_EXPIRED) +// ); +// } } public void calculationProcessForFormula(ApplicationFormEntity applicationFormEntity, List contentResponseBeans, ApplicationFormFieldRequestBean applicationFormFieldRequestBean,FieldValidator fieldValidator) { diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java index 86a19a42..7066021f 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java @@ -959,8 +959,8 @@ public class CallDao { Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED)); } - LocalDate currentDate = LocalDate.now(); - LocalTime currentTime = LocalTime.now(); + LocalDate currentDate = DateTimeUtil.LocalDateServerToEurope(LocalDate.now()); + LocalTime currentTime = DateTimeUtil.LocalTimeServerToEurope(LocalTime.now()); if (currentDate.isBefore(callEntity.getStartDate().toLocalDate()) || (currentDate.isEqual(callEntity.getStartDate().toLocalDate()) && currentTime.isBefore(callEntity.getStartTime()))) { diff --git a/src/main/java/net/gepafin/tendermanagement/util/DateTimeUtil.java b/src/main/java/net/gepafin/tendermanagement/util/DateTimeUtil.java index 1a68818f..87f272c4 100644 --- a/src/main/java/net/gepafin/tendermanagement/util/DateTimeUtil.java +++ b/src/main/java/net/gepafin/tendermanagement/util/DateTimeUtil.java @@ -4,6 +4,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationExceptio import net.gepafin.tendermanagement.web.rest.api.errors.Status; import org.springframework.stereotype.Component; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; @@ -27,6 +28,16 @@ public class DateTimeUtil { LocalDateTime localDatetime = ldtZoned.withZoneSameInstant(ZoneId.of("Europe/Rome")).toLocalDateTime(); return localDatetime; } + + public static LocalDate LocalDateServerToEurope(LocalDate systemDate) { + ZonedDateTime zonedDateTime = systemDate.atStartOfDay(ZoneId.systemDefault()); + return zonedDateTime.withZoneSameInstant(ZoneId.of("Europe/Rome")).toLocalDate(); + } + + public static LocalTime LocalTimeServerToEurope(LocalTime systemTime) { + ZonedDateTime zonedDateTime = systemTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()); + return zonedDateTime.withZoneSameInstant(ZoneId.of("Europe/Rome")).toLocalTime(); + } public static LocalDateTime getPreviousMonthDate(int month) { Calendar c = Calendar.getInstance();