|
|
|
|
@@ -1130,8 +1130,12 @@ public class ApplicationAmendmentRequestDao {
|
|
|
|
|
public ApplicationAmendmentRequestResponse closeAmendmentRequest(Long id, CloseAmendmentRequest closeAmendmentRequest) {
|
|
|
|
|
|
|
|
|
|
log.info("Closing application amendement with ID: {}", id);
|
|
|
|
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validatApplicationAmendmentRequestByListStatus(id,List.of(ApplicationAmendmentRequestEnum.AWAITING.getValue(),ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue()));
|
|
|
|
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
|
|
|
|
//cloned entity for old data and versioning
|
|
|
|
|
if(Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()))
|
|
|
|
|
|| Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue()))) {
|
|
|
|
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_APPROPIATE_STATUS));
|
|
|
|
|
}
|
|
|
|
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
|
|
|
|
List<ApplicationAmendmentRequestEntity> amendmentRequestList = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
|
|
|
|
existingApplicationAmendment.getApplicationEvaluationEntity().getId()
|
|
|
|
|
@@ -1215,7 +1219,11 @@ public class ApplicationAmendmentRequestDao {
|
|
|
|
|
|
|
|
|
|
public ApplicationAmendmentRequestResponse extendResponseDays(Long id, Long newResponseDays) {
|
|
|
|
|
log.info("Extending response days for Application Amendment ID: {}, Additional Days: {}", id, newResponseDays);
|
|
|
|
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validatApplicationAmendmentRequestByStatus(id,ApplicationAmendmentRequestEnum.EXPIRED.getValue());
|
|
|
|
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validateApplicationAmendmentRequest(id);
|
|
|
|
|
if(Boolean.TRUE.equals(applicationAmendmentRequestEntity.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()))
|
|
|
|
|
|| Boolean.TRUE.equals(applicationAmendmentRequestEntity.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue()))) {
|
|
|
|
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_APPROPIATE_STATUS));
|
|
|
|
|
}
|
|
|
|
|
log.info("Extending response days for Application Amendment ID: {}, Additional Days: {}", id, newResponseDays);
|
|
|
|
|
|
|
|
|
|
if (newResponseDays != null && newResponseDays > 0) {
|
|
|
|
|
@@ -1777,14 +1785,14 @@ public class ApplicationAmendmentRequestDao {
|
|
|
|
|
amendment.setEmailSendResponse(mergedResponses);
|
|
|
|
|
applicationAmendmentRequestRepository.save(amendment);
|
|
|
|
|
}
|
|
|
|
|
public ApplicationAmendmentRequestEntity validatApplicationAmendmentRequestByListStatus(Long id,List<String> status) {
|
|
|
|
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalseAndStatusIn(id, status);
|
|
|
|
|
if (applicationAmendmentRequestEntity == null) {
|
|
|
|
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
|
|
|
|
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
|
|
|
|
|
}
|
|
|
|
|
return applicationAmendmentRequestEntity;
|
|
|
|
|
}
|
|
|
|
|
// public ApplicationAmendmentRequestEntity validatApplicationAmendmentRequestByListStatus(Long id,List<String> status) {
|
|
|
|
|
// ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id, status);
|
|
|
|
|
// if (applicationAmendmentRequestEntity == null) {
|
|
|
|
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
|
|
|
|
// Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
|
|
|
|
|
// }
|
|
|
|
|
// return applicationAmendmentRequestEntity;
|
|
|
|
|
// }
|
|
|
|
|
public long calculateSuspendedDays(List<ApplicationAmendmentRequestEntity> amendments) {
|
|
|
|
|
List<Pair<LocalDateTime, LocalDateTime>> periods = amendments.stream()
|
|
|
|
|
.filter(amendmentRequest -> amendmentRequest.getStartDate() != null)
|
|
|
|
|
|