diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 8ff0c836..74b4e221 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -636,6 +636,9 @@ public class GepafinConstant { public static final String APPLICATION_AMENDMENT_APPROPIATE_STATUS="amendment.appropiate.status"; public static final String UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION_MSG="upload.company.document.to.application"; public static final String COMPANY_DOCUMENT_NOT_FOUND_WITH_IDS="company.document.not.found.with.ids"; + public static final String REQUIRED_AMOUNT_FIELD_NOT_PROVIDED = "amount.field.not.provided"; + + } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java index d8243429..45b867b2 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java @@ -1859,6 +1859,11 @@ public class ApplicationAmendmentRequestDao { ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity); ApplicationEntity applicationEntity=applicationDao.validateApplication(applicationEvaluationEntity.getApplicationId()); ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity); + if(Boolean.TRUE.equals(applicationAmendmentRequest.getAmendmentDocumentType().equals(AmendmentDocumentTypeEnum.BLUE_TONGUE))) { + if(applicationAmendmentRequest.getBlueTongueField1()==null || applicationAmendmentRequest.getBlueTongueField2()==null){ + throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.REQUIRED_AMOUNT_FIELD_NOT_PROVIDED)); + } + } if(Boolean.FALSE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))) { throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.INVALID_APPLICATION_STATUS)); @@ -1922,6 +1927,8 @@ public class ApplicationAmendmentRequestDao { protocolDao.saveProtocolEntity(protocolEntity); applicationAmendmentRequestEntity.setProtocol(protocolEntity); applicationAmendmentRequestEntity.setAmendmentDocumentType(applicationAmendmentRequest.getAmendmentDocumentType().getValue()); + applicationAmendmentRequestEntity.setBlueTongueField1(applicationAmendmentRequest.getBlueTongueField1()); + applicationAmendmentRequestEntity.setBlueTongueField2(applicationAmendmentRequest.getBlueTongueField2()); ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT); log.info("Amendment request saved with ID={}", applicationAmendment.getId()); @@ -1931,6 +1938,7 @@ public class ApplicationAmendmentRequestDao { ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = convertEntityToResponse(applicationAmendmentRequestEntity,false); if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())){ + log.info("Sending mail for the special amendment for amendment ID = {}", applicationAmendment.getId()); saveEmailSendResponse(emailSendResponse, applicationAmendmentRequestEntity); applicationAmendmentRequestResponse.setEmailSendResponse(responses); } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 4727893f..d5edecb7 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -2653,7 +2653,6 @@ public class ApplicationEvaluationDao { if (criteriaJson != null && applicationEntity.getCall().getThreshold()!=null ){ BigDecimal totalScore = calculateTotalScore(evaluationEntity.getCriteria()); if (totalScore.compareTo(new BigDecimal(applicationEntity.getCall().getThreshold())) >= 0) { - applicationEntity.setStatus(status.getValue()); log.info("Status updated to AWAITING_TECHNICAL_EVALUATION for applicationId: {}", applicationId); } else{ @@ -2661,6 +2660,7 @@ public class ApplicationEvaluationDao { throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.INSUFFICIENT_SCORE_MESSAGE)); } } + applicationEntity.setStatus(status.getValue()); } public BigDecimal calculateTotalScore(String criteriaJson){ diff --git a/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java index 117c3b4a..7cfb73cc 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java @@ -145,7 +145,7 @@ public class EmailNotificationDao { List attachmentRequests =new ArrayList<>(); List urls=new ArrayList<>(); List documentEntities=new ArrayList<>(); - if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED)) { + if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED) || systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE)) { if(Boolean.TRUE.equals(AmendmentDocumentTypeEnum.ALTRE_GARANZIE.getValue().equals(applicationAmendmentRequest.getAmendmentDocumentType()))){ documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY")); }else { @@ -517,7 +517,11 @@ public class EmailNotificationDao { public void sendMailforSpecialAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity,ApplicationEntity applicationEntity) { Map bodyPlaceholders = prepareEmailPlaceholders(applicationEntity, applicationAmendmentRequestEntity); - sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED, bodyPlaceholders, null, + SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum systemEmailTemplatesEntityTypeEnum= SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED; + if(applicationAmendmentRequestEntity.getAmendmentDocumentType().equals(AmendmentDocumentTypeEnum.BLUE_TONGUE.getValue())){ + systemEmailTemplatesEntityTypeEnum= SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE; + } + sendEmail(applicationEntity,systemEmailTemplatesEntityTypeEnum, bodyPlaceholders, null, applicationAmendmentRequestEntity.getId(),null); } public void sendEmailForApplicationContracted(ApplicationEntity applicationEntity,ApplicationContractEntity applicationContractEntity,UserEntity user) { diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java index 1ccd4eed..af7f6f24 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java @@ -5,6 +5,7 @@ import lombok.Data; import org.hibernate.annotations.Where; import net.gepafin.tendermanagement.model.response.EmailSendResponse; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -77,4 +78,10 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity { @Column(name = "AMENDMENT_INITIAL_DOCUMENT") private String amendmentInitialDocument; + @Column(name = "BLUE_TONGUE_FIELD_1") + private BigDecimal blueTongueField1; + + @Column(name = "BLUE_TONGUE_FIELD_2") + private BigDecimal blueTongueField2; + } diff --git a/src/main/java/net/gepafin/tendermanagement/entities/SystemEmailTemplatesEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/SystemEmailTemplatesEntity.java index 0cc3c6fb..4d425442 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/SystemEmailTemplatesEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/SystemEmailTemplatesEntity.java @@ -57,7 +57,8 @@ public class SystemEmailTemplatesEntity extends BaseEntity { INADMISSIBILITY_TEMPLATE("INADMISSIBILITY_NOTIFICATION"), APPLICATION_SUBMISSION_FAILURE_NOTIFICATION("APPLICATION_SUBMISSION_FAILURE_NOTIFICATION"), INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE("INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE"), - SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED"); + SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED"), + SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE("SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE"); private String value; SystemEmailTemplatesEntityTypeEnum(String value) { diff --git a/src/main/java/net/gepafin/tendermanagement/enums/AmendmentDocumentTypeEnum.java b/src/main/java/net/gepafin/tendermanagement/enums/AmendmentDocumentTypeEnum.java index e1e97b63..8dd53ab8 100644 --- a/src/main/java/net/gepafin/tendermanagement/enums/AmendmentDocumentTypeEnum.java +++ b/src/main/java/net/gepafin/tendermanagement/enums/AmendmentDocumentTypeEnum.java @@ -10,7 +10,9 @@ public enum AmendmentDocumentTypeEnum { MCC_START_UP("MCC_START_UP"), - ALTRE_GARANZIE("ALTRE_GARANZIE"); + ALTRE_GARANZIE("ALTRE_GARANZIE"), + + BLUE_TONGUE("BLUE_TONGUE"); private final String value; diff --git a/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java b/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java index fe8d64b2..563e91e0 100644 --- a/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java +++ b/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java @@ -15,6 +15,7 @@ public enum EmailScenarioTypeEnum { APPLICATION_SUBMISSION_FAILURE("APPLICATION_SUBMISSION_FAILURE"), APPLICATION_TECHNICAL_EVALUATION_REJECTED("APPLICATION_TECHNICAL_EVALUATION_REJECTED"), SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED"), + SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE("SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE"), APPLICATION_CONTRACT_CREATED("APPLICATION_CONTRACT_CREATED"); private final String value; diff --git a/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationAmendmentSpecialRequest.java b/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationAmendmentSpecialRequest.java index 3a971a7c..673a5afa 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationAmendmentSpecialRequest.java +++ b/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationAmendmentSpecialRequest.java @@ -13,4 +13,8 @@ public class ApplicationAmendmentSpecialRequest { private AmendmentDocumentTypeEnum amendmentDocumentType; private String pec; + + private BigDecimal blueTongueField1; + + private BigDecimal blueTongueField2; } diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java index dc03dd43..f0f0aca4 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationAmendmentRequestRepository.java @@ -156,4 +156,6 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository statusList); + ApplicationAmendmentRequestEntity findByApplicationIdAndIsDeletedFalseAndAmendmentDocumentTypeAndType(Long applicationId,String amendmentDocumentType, String type); + } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/PecEmailService.java b/src/main/java/net/gepafin/tendermanagement/service/impl/PecEmailService.java index 7f29d522..be6aeb02 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/PecEmailService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/PecEmailService.java @@ -10,14 +10,13 @@ import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.dao.ApplicationDao; import net.gepafin.tendermanagement.dao.EmailLogDao; import net.gepafin.tendermanagement.dao.NotificationDao; +import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; import net.gepafin.tendermanagement.entities.ApplicationEntity; import net.gepafin.tendermanagement.entities.CompanyEntity; import net.gepafin.tendermanagement.entities.EmailLogEntity; -import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum; -import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum; -import net.gepafin.tendermanagement.enums.NotificationTypeEnum; -import net.gepafin.tendermanagement.enums.StatusTypeEnum; +import net.gepafin.tendermanagement.enums.*; import net.gepafin.tendermanagement.model.request.*; +import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository; import net.gepafin.tendermanagement.repositories.EmailLogRepository; import net.gepafin.tendermanagement.service.CompanyService; import net.gepafin.tendermanagement.util.DateTimeUtil; @@ -68,6 +67,9 @@ public class PecEmailService implements EmailService { @Autowired private EmailLogRepository emailLogRepository; + @Autowired + private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository; + @Override public void sendEmail(String subject, String body, List recipientEmails, EmailConfig emailConfig, EmailLogEntity emailLogEntity, Boolean isSendEmail) { @@ -80,7 +82,7 @@ public class PecEmailService implements EmailService { S3DocxProcessor processor = new S3DocxProcessor(s3Client); List urls = Utils.convertJsonStringToList(emailLogEntity.getAttachments(), String.class); - if(emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED.getValue())) { + if(emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED.getValue()) || emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE.getValue()) ) { ApplicationEntity applicationEntity = applicationDao.validateApplication(emailLogEntity.getApplicationId()); CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId()); String amount = Utils.convertToItalianFormat(String.valueOf(applicationEntity.getAmountAccepted())); @@ -88,13 +90,27 @@ public class PecEmailService implements EmailService { if (protocolNumber == null) { protocolNumber = String.valueOf(applicationEntity.getProtocol().getProtocolNumber()); } - replacements = Map.of( - "{call_name}", applicationEntity.getCall().getName(), - "{amount_accepted}", amount, - "{pec}", "bandi.gepafin@legalmail.it", - "{company_name}", company.getCompanyName(), - "{protocol_number}", protocolNumber - ); + + replacements.put("{call_name}", applicationEntity.getCall().getName()); + replacements.put("{amount_accepted}", amount); + replacements.put("{pec}", "bandi.gepafin@legalmail.it"); + replacements.put("{company_name}", company.getCompanyName()); + replacements.put("{protocol_number}", protocolNumber); + + if (emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE.getValue())){ + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalseAndAmendmentDocumentTypeAndType(applicationEntity.getId(), AmendmentDocumentTypeEnum.BLUE_TONGUE.getValue(),ApplicationAmendmentRequestTypeEnum.SPECIAL.getValue()); + if(applicationAmendmentRequestEntity!=null){ + if (applicationAmendmentRequestEntity.getBlueTongueField1() != null) { + replacements.put("{blue_tongue_field_1}", + Utils.convertToItalianFormat(applicationAmendmentRequestEntity.getBlueTongueField1().toString())); + } + + if (applicationAmendmentRequestEntity.getBlueTongueField2() != null) { + replacements.put("{blue_tongue_field_2}", + Utils.convertToItalianFormat(applicationAmendmentRequestEntity.getBlueTongueField2().toString())); + } + } + } } if (urls!=null && Boolean.FALSE.equals(urls.isEmpty())) { Map processedFiles = null; diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index 9c5aa1de..32c8690d 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -3173,4 +3173,25 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/dump/insert_system_email_template_for_special_amendment_blue_tongue_23_02_2026.sql b/src/main/resources/db/dump/insert_system_email_template_for_special_amendment_blue_tongue_23_02_2026.sql new file mode 100644 index 00000000..11bdcc02 --- /dev/null +++ b/src/main/resources/db/dump/insert_system_email_template_for_special_amendment_blue_tongue_23_02_2026.sql @@ -0,0 +1,11 @@ +INSERT INTO gepafin_schema.system_email_template +( template_name, "type", html_content, subject, "json", "system", is_deleted, created_date, updated_date, email_scenario, hub_id) +VALUES( 'Special Amendment Creation Email', 'SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE', ' + +
+

Buongiorno, vi invitiamo a prendere visione del documento allegato con cui vi informiamo dell avvenuta delibera a valere sull Avviso in oggetto.

+

Distinti Saluti,

+

{{email_signature}}

+
+ +', 'Comunicazione esito valutazione tecnica ed economico-finanziaria– Avviso {{call_name}} ', NULL, true, false, '2026-02-22 20:00:00.000', '2026-02-22 20:00:00.000', 'SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE', NULL); \ No newline at end of file diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index 7e930753..d21b41c1 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -428,7 +428,8 @@ 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. upload.company.document.to.application=Uploaded company document to application successfully. -company.document.not.found.with.ids=Company document not found. Missing IDs: {0} +company.document.not.found.with.ids=Company document not found. Missing IDs: {0}. +amount.field.not.provided= Please provide the required amount fields. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index d88b196c..3595be62 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -420,3 +420,4 @@ email.log.fetched=Registro email recuperato correttamente. amendment.appropiate.status=L'emendamento dell'applicazione non � in stato appropriato per questa operazione. upload.company.document.to.application=Documento aziendale caricato correttamente nell'applicazione. company.document.not.found.with.ids=Documento aziendale non trovato. ID mancanti: {0} +amount.field.not.provided= Si prega di fornire i campi obbligatori per l'importo.