Fixed call end date issue
This commit is contained in:
@@ -575,6 +575,8 @@ public class GepafinConstant {
|
||||
public static final String NDG_NOT_FOUND="ndg.not.found";
|
||||
public static final String EMAIL_PEC_REQUIRED="email.pec.cannot.null";
|
||||
public static final String USER_REQUEST_COMPLETED="user.request.completed";
|
||||
public static final String END_DATE_GREATER_THAN_NOW="end.date.greater.than.now";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -628,19 +628,19 @@ public class CallDao {
|
||||
if (dates.size() > 0) {
|
||||
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
|
||||
}
|
||||
if (dates.size() > 1) {
|
||||
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||
|
||||
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
// callRepository.save(callEntity);
|
||||
isEndDateUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (dates.size() > 1) {
|
||||
// LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||
// LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||
//
|
||||
// if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||
//
|
||||
// setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
//// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
//// callRepository.save(callEntity);
|
||||
// isEndDateUpdated = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (updateCallRequest.getEndTime() != null) {
|
||||
LocalTime requestEndTime = DateTimeUtil.parseTime(updateCallRequest.getEndTime());
|
||||
@@ -653,6 +653,29 @@ public class CallDao {
|
||||
isEndTimeUpdated = true;
|
||||
}
|
||||
}
|
||||
if (dates.size() > 1) {
|
||||
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||
|
||||
if (!requestEndDate.equals(storedEndDate)) {
|
||||
// Check if dates are different
|
||||
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
if(callEntity.getStatus().equals(CallStatusEnum.EXPIRED.getValue())) {
|
||||
LocalDateTime newEndDate = LocalDateTime.of(requestEndDate, callEntity.getEndTime());
|
||||
if(newEndDate.isBefore(LocalDateTime.now())){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.END_DATE_GREATER_THAN_NOW));
|
||||
}
|
||||
|
||||
if (requestEndDate.isAfter(LocalDate.now()) || requestEndDate.isEqual(LocalDate.now())) {
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
}
|
||||
}
|
||||
isEndDateUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEndDateUpdated || isEndTimeUpdated) {
|
||||
callRepository.save(callEntity);
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
|
||||
Reference in New Issue
Block a user