From 326ce77e8c08e56c0add87416335b195ab18df79 Mon Sep 17 00:00:00 2001 From: rajesh Date: Fri, 14 Nov 2025 18:53:25 +0530 Subject: [PATCH] Done ticket GEPAFINBE-6147 & contract document issue --- .../constants/GepafinConstant.java | 1 + .../dao/ApplicationAmendmentRequestDao.java | 28 ++++++++++++------- .../tendermanagement/dao/ApplicationDao.java | 2 +- ...ApplicationAmendmentRequestRepository.java | 2 +- src/main/resources/message_en.properties | 3 ++ src/main/resources/message_it.properties | 2 ++ 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 452ecb50..cf544480 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -633,6 +633,7 @@ public class GepafinConstant { public static final String SUBJECT_AND_BODY_REQUIRED="subject.body.required"; public static final String MAIL_SENT_SUCCESSFULLY="mail.send.successfully"; public static final String EMAIL_LOG_FETCHED="email.log.fetched"; + public static final String APPLICATION_AMENDMENT_APPROPIATE_STATUS="amendment.appropiate.status"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java index b41f4621..d8243429 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java @@ -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 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 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 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 amendments) { List> periods = amendments.stream() .filter(amendmentRequest -> amendmentRequest.getStartDate() != null) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index bfc0e4d5..d193c953 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -1688,7 +1688,7 @@ public class ApplicationDao { for (DocumentEntity contractDocument : contractDocuments) { ApplicationContractEntity applicationContractEntity=applicationContractRepository.findByIdAndIsDeletedFalse(contractDocument.getSourceId()); String contractFolder = "CONTRACT/"; - String contractS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CONTRACT, callId, applicationId, 0L,contractDocument.getSourceId(),applicationContractEntity.getApplicationId()); + String contractS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CONTRACT, callId, applicationId, 0L,0L,applicationContractEntity.getId()); String fileName = Utils.extractFileName(contractDocument.getFilePath()); addDocumentToZip(zos, contractS3Folder, contractDocument.getFilePath(), contractFolder + fileName); } diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java index 3b0de711..dc03dd43 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java @@ -59,7 +59,7 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository findAmendmentsDueForExpiration(LocalDateTime currentTime); diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index a2aeca61..825dbc63 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -425,3 +425,6 @@ application.contract.already.exist=Application contract already exist for this a application.not.approved=Application is not approved. subject.body.required=Subject and body is required to create contract. mail.send.successfully=Mail sent succesfully. +email.log.fetched=Email log fetched successfully. +amendment.appropiate.status=Application amendment is not in appropiate status for this operation. + diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 8507f202..0b059428 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -416,3 +416,5 @@ application.contract.already.exist=Il contratto di applicazione esiste gi application.not.approved=La domanda non è stata approvata. subject.body.required=Per creare un contratto sono necessari oggetto e corpo. mail.send.successfully=Email inviata con successo. +email.log.fetched=Registro email recuperato correttamente. +amendment.appropiate.status=L'emendamento dell'applicazione non è in stato appropriato per questa operazione.