Updated validation logic for start and end dates
This commit is contained in:
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.dao;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -673,6 +674,25 @@ public class CallDao {
|
||||
Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED));
|
||||
}
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
|
||||
if (currentDate.isBefore(callEntity.getStartDate().toLocalDate()) ||
|
||||
(currentDate.isEqual(callEntity.getStartDate().toLocalDate()) && currentTime.isBefore(callEntity.getStartTime()))) {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_STARTED_YET)
|
||||
);
|
||||
}
|
||||
|
||||
if (currentDate.isAfter(callEntity.getEndDate().toLocalDate()) ||
|
||||
(currentDate.isEqual(callEntity.getEndDate().toLocalDate()) && currentTime.isAfter(callEntity.getEndTime()))) {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.CALL_ALREADY_ENDED)
|
||||
);
|
||||
}
|
||||
|
||||
return callEntity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user