Fixed call date and time check issue

This commit is contained in:
rajesh
2025-04-01 11:42:19 +05:30
parent e46e595b94
commit ed62ed2791
3 changed files with 29 additions and 16 deletions

View File

@@ -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<ContentResponseBean> contentResponseBeans, ApplicationFormFieldRequestBean applicationFormFieldRequestBean,FieldValidator fieldValidator) {

View File

@@ -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()))) {

View File

@@ -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;
@@ -28,6 +29,16 @@ public class DateTimeUtil {
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();
c.add(Calendar.MONTH, -month);