Merge pull request #326 from Kitzanos/call-end-date-fix-prod

Cherry-pick (Fixed call end date issue)
This commit is contained in:
Rinaldo
2025-07-11 10:02:02 +02:00
committed by GitHub
4 changed files with 42 additions and 13 deletions

View File

@@ -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";
}

View File

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

View File

@@ -411,3 +411,5 @@ user.action.id.not.found = User Action id not found.
ndg.not.found=NDG not found.
email.pec.cannot.null=Email pec is required.
user.request.completed=User request completed successfully.
end.date.greater.than.now=End date must be greater than the current date and time.

View File

@@ -402,3 +402,5 @@ user.action.id.not.found = ID azione utente non trovato.
ndg.not.found=NDG non trovato.
email.pec.cannot.null=L'indirizzo email pec è obbligatorio.
user.request.completed=Richiesta utente completata con successo.
end.date.greater.than.now=La data di fine deve essere successiva alla data e all'ora correnti.