Added validation in amendment and change email content

This commit is contained in:
harish
2024-11-05 18:47:43 +05:30
parent dbf1a8735d
commit 472237246c
6 changed files with 87 additions and 16 deletions

View File

@@ -98,7 +98,7 @@ public class ApplicationAmendmentRequestDao {
@Autowired @Autowired
private Validator validator; private Validator validator;
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) { public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId); log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId); ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
Long applicationId = applicationEvaluationEntity.getApplicationId(); Long applicationId = applicationEvaluationEntity.getApplicationId();
@@ -341,7 +341,6 @@ public class ApplicationAmendmentRequestDao {
} }
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) { public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
UserEntity user = validator.validateUser(request);
if(validator.checkIsPreInstructor() && userId == null) { if(validator.checkIsPreInstructor() && userId == null) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG)); throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
} }

View File

@@ -897,12 +897,13 @@ public class ApplicationEvaluationDao {
assignedApplicationsRepository.save(assignedApplicationsEntity); assignedApplicationsRepository.save(assignedApplicationsEntity);
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestRepository.findByApplicationEvaluationIdAndIsDeletedFalse(entity.getId()); ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestRepository.findByApplicationEvaluationIdAndIsDeletedFalse(entity.getId());
if(amendmentRequest!=null){
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) { if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) {
emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(amendmentRequest); emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(amendmentRequest);
} }
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) { if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(amendmentRequest); emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(amendmentRequest);
} }}
return convertToResponse(entity); return convertToResponse(entity);
} }
return null; return null;

View File

@@ -77,9 +77,15 @@ public class EmailNotificationDao {
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId()); UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
List<String> recipientEmails = new ArrayList<>(); List<String> recipientEmails = new ArrayList<>();
if (applicationEntity.getCompany().getEmail() != null) { String companyEmail = applicationEntity.getCompany().getEmail();
recipientEmails.add(applicationEntity.getCompany().getEmail()); String contactEmail = applicationEntity.getCompany().getContactEmail();
if (companyEmail != null && !companyEmail.isEmpty()) {
recipientEmails.add(companyEmail);
} }
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
recipientEmails.add(contactEmail);
}
if (userEntity.getBeneficiary().getEmail() != null) { if (userEntity.getBeneficiary().getEmail() != null) {
recipientEmails.add(userEntity.getBeneficiary().getEmail()); recipientEmails.add(userEntity.getBeneficiary().getEmail());
} }

View File

@@ -39,59 +39,104 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
@Override @Override
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) { public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) {
UserEntity user= validator.validateUser(request); Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationEvaluationId); entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
return applicationAmendmentRequestDao.getApplicationDataForAmendment(applicationEvaluationId);
} }
@Override @Override
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) { public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
UserEntity user= validator.validateUser(request); Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest); return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest);
} }
@Override @Override
public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) { public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
applicationAmendmentRequestDao.deleteById(id); applicationAmendmentRequestDao.deleteById(id);
} }
}
@Override @Override
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) { public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id); return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id);
} }
@Override @Override
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) { public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
UserEntity user = validator.validatePreInstructor(request, userId);
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId); return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
} }
@Override @Override
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) { public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
UserEntity updatedByUser= validator.validateUser(request); ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean); return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
} }
@Override @Override
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId) { public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId) {
return applicationAmendmentRequestDao.validateApplicationAmendmentRequest(applicationAmendmentId); return applicationAmendmentRequestDao.validateApplicationAmendmentRequest(applicationAmendmentId);
} }
@Override @Override
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request, Long beneficiaryId) { public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request, Long beneficiaryId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryId); return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryId);
} }
@Override @Override
public ApplicationAmendmentRequestResponse closeAmendmentRequest(HttpServletRequest request, Long id, CloseAmendmentRequest closeAmendmentRequest) { public ApplicationAmendmentRequestResponse closeAmendmentRequest(HttpServletRequest request, Long id, CloseAmendmentRequest closeAmendmentRequest) {
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.closeAmendmentRequest(id,closeAmendmentRequest); return applicationAmendmentRequestDao.closeAmendmentRequest(id,closeAmendmentRequest);
} }
@Override @Override
public ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays) { public ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays); return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
} }
public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) { public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) {
UserEntity user= validator.validateUser(request); ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
if(amendment!=null) {
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}}
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId); return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId);
} }
@Override @Override

View File

@@ -1716,4 +1716,8 @@
<sqlFile dbms="postgresql" <sqlFile dbms="postgresql"
path="db/dump/update_system_email_template_for_notification_mail_04_11_2024_1.sql"/> path="db/dump/update_system_email_template_for_notification_mail_04_11_2024_1.sql"/>
</changeSet> </changeSet>
<changeSet id="05-11-2024_4" author="Harish Bagora">
<sqlFile dbms="postgresql"
path="db/dump/update_system_email_template_for_notification_mail_05_11_2024_4.sql"/>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -0,0 +1,16 @@
UPDATE gepafin_schema.system_email_template
SET
subject = 'BANDO {{call_name}}- Domanda di concessione di finanziamento agevolato {{company_name}}',
html_content = '<html>
<body style="font-family: Arial, sans-serif; color: #000; line-height: 1.6;">
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
<p>In riferimento alla domanda di concessione di Finanziamento agevolato a valere sul Fondo prestiti
<strong>{{call_name}}</strong> di cui alloggetto, la stessa è stata regolarmente acquisita ed è stata
registrata con Protocollo n. <strong>{{protocol_number}}</strong> del <strong>{{protocol_date}}</strong>
alle <strong>{{protocol_time}}</strong>.</p>
<p>Distinti Saluti,</p>
<p><strong>{{email_signature}}</strong></p>
</div>
</body>
</html>'
WHERE "type" = 'DOCUMENTATION_INTEGRATION_REQUEST' AND "system" = true;