Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into feature/GEPAFINBE-126

This commit is contained in:
piyushkag
2025-02-17 15:41:41 +05:30
12 changed files with 139 additions and 54 deletions

View File

@@ -1083,7 +1083,7 @@ public class ApplicationAmendmentRequestDao {
List<ApplicationAmendmentRequestResponse> response = new ArrayList<>(); List<ApplicationAmendmentRequestResponse> response = new ArrayList<>();
if (applicationAmendmentRequestEntity != null) { if (applicationAmendmentRequestEntity != null) {
response = applicationAmendmentRequestEntity.stream() response = applicationAmendmentRequestEntity.stream()
.map(entity -> convertEntityToResponse(entity, false)) .map(entity -> convertEntityToResponse(entity, true))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
return response; return response;

View File

@@ -516,7 +516,6 @@ public class ApplicationDao {
.filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue())) .filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue()))
.findFirst() .findFirst()
.ifPresent(setting -> { .ifPresent(setting -> {
Object fieldValue = applicationFormFieldRequestBean.getFieldValue(); Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
if(fieldValue!=null) { if(fieldValue!=null) {
try { try {
@@ -1133,20 +1132,28 @@ public class ApplicationDao {
// mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null); // mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null);
// mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null); // mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null);
// mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null); // mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null);
if(validator.isProductionProfileActivated()) { // if(Boolean.TRUE.equals(hub.getUniqueUuid().equals(defaultHubUuid))) {
emailLogRequest.setRecipientEmails(carloEmail); // if (validator.isProductionProfileActivated()) {
// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null); // emailLogRequest.setRecipientEmails(carloEmail);
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail),emailLogRequest); //// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
} // emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail),emailLogRequest);
emailLogRequest.setRecipientEmails(hub.getEmail()); // }
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(hub.getEmail()),emailLogRequest); // List<String> listDefaultSystemReceiverEmail = Arrays.stream(defaultSystemReceiverEmail.split(","))
List<String> listDefaultSystemReceiverEmail = Arrays.stream(defaultSystemReceiverEmail.split(",")) // .map(String::trim)
// .filter(email -> !email.isEmpty())
// .toList();
//
// emailLogRequest.setRecipientEmails(defaultSystemReceiverEmail);
// emailNotificationDao.sendMail(hub.getId(), subject, body, listDefaultSystemReceiverEmail, emailLogRequest);
// }
List<String> hubEmails = Arrays.stream(hub.getEmail().split(","))
.map(String::trim) .map(String::trim)
.filter(email -> !email.isEmpty()) .filter(email -> !email.isEmpty())
.toList(); .toList();
emailLogRequest.setRecipientEmails(defaultSystemReceiverEmail); emailLogRequest.setRecipientEmails(hub.getEmail());
emailNotificationDao.sendMail(hub.getId(), subject, body, listDefaultSystemReceiverEmail,emailLogRequest); emailNotificationDao.sendMail(hub.getId(), subject, body,hubEmails,emailLogRequest);
emailLogRequest.setRecipientEmails(rinaldoEmail); emailLogRequest.setRecipientEmails(rinaldoEmail);
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail),emailLogRequest); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail),emailLogRequest);
} }

View File

@@ -153,7 +153,7 @@ public class ApplicationEvaluationDao {
Long hubId = application.getHubId(); Long hubId = application.getHubId();
HubEntity hub = hubService.valdateHub(hubId); HubEntity hub = hubService.valdateHub(hubId);
Long initialDays = (hub != null) ? hub.getEvaluationExpirationDays() : 0L; Long initialDays = (hub != null) ? hub.getEvaluationExpirationDays() : 30L;
entity.setApplicationId(application.getId()); entity.setApplicationId(application.getId());
entity.setAssignedApplicationsEntity(assignedApplications); entity.setAssignedApplicationsEntity(assignedApplications);
@@ -165,10 +165,10 @@ public class ApplicationEvaluationDao {
entity.setMotivation(req.getMotivation()); entity.setMotivation(req.getMotivation());
entity.setIsDeleted(false); entity.setIsDeleted(false);
entity.setInitialDays(initialDays); entity.setInitialDays(initialDays);
entity.setRemainingDays(30L); entity.setRemainingDays(initialDays);
entity.setSuspendedDays(0L); entity.setSuspendedDays(0L);
entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
entity.setEndDate(DateTimeUtil.DateServerToUTC(application.getSubmissionDate().plusDays(30))); entity.setEndDate(DateTimeUtil.DateServerToUTC(application.getSubmissionDate().plusDays(initialDays)));
entity.setEvaluationVersion(application.getEvaluationVersion()); entity.setEvaluationVersion(application.getEvaluationVersion());
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()); entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
return entity; return entity;

View File

@@ -122,10 +122,40 @@ public class CompanyDao {
userWithCompanyEntity.setPec(companyRequest.getPec()); userWithCompanyEntity.setPec(companyRequest.getPec());
userWithCompanyEntity.setContactName(companyRequest.getContactName()); userWithCompanyEntity.setContactName(companyRequest.getContactName());
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail()); userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) );
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity); UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity);
/** This code is responsible for adding a version history log for the "adding user with company" operation. **/ /** This code is responsible for adding a version history log for the "adding user with company" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build()); loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build());
if (StringUtils.isEmpty(companyEntity.getJson())) {
companyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()));
Map<String, Object> vatCheckResponse = companyRequest.getVatCheckResponse();
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
if (data != null) {
if (data.containsKey("dettaglio")) {
Map<String, Object> dettaglio = (Map<String, Object>) data.get("dettaglio");
if (dettaglio != null) {
if (dettaglio.containsKey("codice_ateco")) {
Object codiceAtecoObj = dettaglio.get("codice_ateco");
String codiceAteco = (codiceAtecoObj != null) ? codiceAtecoObj.toString() : null;
if (codiceAteco != null) {
companyEntity.setCodiceAteco(codiceAteco);
}
}
}
}
}
companyEntity = companyRepository.save(companyEntity);
/** This code is responsible for adding a version history log for "updating company json field" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder()
.request(request)
.actionType(VersionActionTypeEnum.INSERT)
.oldData(null)
.newData(companyEntity)
.build());
}
return userWithCompany; return userWithCompany;
} }
@@ -143,6 +173,7 @@ public class CompanyDao {
entity.setNumberOfEmployees(request.getNumberOfEmployees()); entity.setNumberOfEmployees(request.getNumberOfEmployees());
entity.setAnnualRevenue(request.getAnnualRevenue()); entity.setAnnualRevenue(request.getAnnualRevenue());
entity.setHub(userEntity.getHub()); entity.setHub(userEntity.getHub());
entity.setJson(Utils.convertMapIntoJsonString(request.getVatCheckResponse()));
if (request.getVatCheckResponse() != null) { if (request.getVatCheckResponse() != null) {
Map<String, Object> vatCheckResponse = request.getVatCheckResponse(); Map<String, Object> vatCheckResponse = request.getVatCheckResponse();
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data"); Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
@@ -226,10 +257,10 @@ public class CompanyDao {
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId); UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
//cloned entity for old data //cloned entity for old data
UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity); UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity);
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) { // if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null; // String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
setIfUpdated(userWithCompanyEntity::getJson, userWithCompanyEntity::setJson, responseJson); // setIfUpdated(companyEntity::getJson, companyEntity::setJson, responseJson);
} // }
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec()); setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec());
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail()); setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail());
setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName()); setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName());

View File

@@ -59,4 +59,7 @@ public class CompanyEntity extends BaseEntity{
@Column(name = "CODICE_ATECO") @Column(name = "CODICE_ATECO")
private String codiceAteco; private String codiceAteco;
@Column(name = "JSON")
private String json;
} }

View File

@@ -35,9 +35,6 @@ public class UserWithCompanyEntity extends BaseEntity{
@Column(name = "EMAIL") @Column(name = "EMAIL")
private String email; private String email;
@Column(name = "JSON")
private String json;
@Column(name = "IS_DELETED") @Column(name = "IS_DELETED")
private Boolean isDeleted = false; private Boolean isDeleted = false;

View File

@@ -160,7 +160,7 @@ public class FieldValidator {
public FieldValidator validateCustomTableValidation(String value, String customRule, String fieldId, ContentResponseBean contentResponseBean) { public FieldValidator validateCustomTableValidation(String value, String customRule, String fieldId, ContentResponseBean contentResponseBean) {
if (customRule == null || value == null) { if (customRule == null ) {
return this; // No custom rule to validate return this; // No custom rule to validate
} }
@@ -168,6 +168,7 @@ public class FieldValidator {
case GepafinConstant.NON_EMPTY_TABLES: case GepafinConstant.NON_EMPTY_TABLES:
try { try {
checkTableValidation(value, fieldId, contentResponseBean, errors); checkTableValidation(value, fieldId, contentResponseBean, errors);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -186,6 +187,7 @@ public class FieldValidator {
.findFirst() // Get the first matching result .findFirst() // Get the first matching result
.orElse(null); // Default to null if no match .orElse(null); // Default to null if no match
if (tableType!=null){ if (tableType!=null){
try { try {
Object object = PdfUtils.extractRows(value);; Object object = PdfUtils.extractRows(value);;
@@ -224,31 +226,47 @@ public class FieldValidator {
return; return;
} }
for (int rowIndex = 0; rowIndex < fieldValueList.size(); rowIndex++) { // for (int rowIndex = 0; rowIndex < fieldValueList.size(); rowIndex++) {
Map<String, Object> field = fieldValueList.get(rowIndex); // Map<String, Object> field = fieldValueList.get(rowIndex);
//
// boolean hasSingleNonNullPredefinedFalse = false;
//
// for (Map.Entry<String, Boolean> entry : stateFieldMap.entrySet()) {
// String stateKey = entry.getKey();
// Boolean isPredefinedFalse = Boolean.FALSE.equals(entry.getValue());
//
// if (isPredefinedFalse) {
// Object fieldValue = field.get(stateKey);
// if (fieldValue != null && !StringUtils.isEmpty(fieldValue.toString())) {
// hasSingleNonNullPredefinedFalse = true;
// break;
// }
// }
// }
//
// if (!hasSingleNonNullPredefinedFalse) {
// errors.add(MessageFormat.format(
// Translator.toLocale(GepafinConstant.VALIDATION_IN_TABLE),
// fieldId));
// break;
// }
//
// }
boolean hasSingleNonNullPredefinedFalse = false;
for (Map.Entry<String, Boolean> entry : stateFieldMap.entrySet()) { boolean hasAtLeastOneNonEmptyPredefinedFalse = fieldValueList.stream()
String stateKey = entry.getKey(); .anyMatch(field -> stateFieldMap.entrySet().stream()
Boolean isPredefinedFalse = Boolean.FALSE.equals(entry.getValue()); .filter(entry -> Boolean.FALSE.equals(entry.getValue())) // Check only predefined: false fields
.anyMatch(entry -> {
if (isPredefinedFalse) { Object fieldValue = field.get(entry.getKey());
Object fieldValue = field.get(stateKey); return fieldValue != null && !StringUtils.isEmpty(fieldValue.toString());
if (fieldValue != null && !StringUtils.isEmpty(fieldValue.toString())) { })
hasSingleNonNullPredefinedFalse = true; );
break;
}
}
}
if (!hasSingleNonNullPredefinedFalse) {
errors.add(MessageFormat.format(
Translator.toLocale(GepafinConstant.VALIDATION_IN_TABLE),
fieldId));
break;
}
if (!hasAtLeastOneNonEmptyPredefinedFalse) {
errors.add(MessageFormat.format(
Translator.toLocale(GepafinConstant.VALIDATION_IN_TABLE),
fieldId));
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -61,7 +61,7 @@ public class UserActionAspect {
handleSuccessResponse((ResponseEntity<?>) result, storedUserActionId == null ? userActionId : storedUserActionId); handleSuccessResponse((ResponseEntity<?>) result, storedUserActionId == null ? userActionId : storedUserActionId);
} }
} catch (Exception ex) { } catch (Exception ex) {
log.error("Exception occurred: ", ex); // log.error("Exception occurred: ", ex);
handleError(ex, getUserActionIdFromRequest(request)); handleError(ex, getUserActionIdFromRequest(request));
throw ex; throw ex;
} finally { } finally {

View File

@@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Response<Object> handleCustomValidationException(final CustomValidationException ex) { public Response<Object> handleCustomValidationException(final CustomValidationException ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return new Response<>(null, ex.getStatus(), ex.getMessage()); return new Response<>(null, ex.getStatus(), ex.getMessage());
} }
@@ -45,14 +45,14 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Response<Object> handleValidationException(final ValidationException ex) { public Response<Object> handleValidationException(final ValidationException ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return new Response<>(ex.getErrors(), ex.getStatus(), ex.getMessage()); return new Response<>(ex.getErrors(), ex.getStatus(), ex.getMessage());
} }
@ExceptionHandler(ResourceNotFoundException.class) @ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) { public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return ResponseEntity.status(HttpStatus.NOT_FOUND) return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, ex.getStatus(), ex.getMessage())); .body(new Response<>(null, ex.getStatus(), ex.getMessage()));
} }
@@ -71,7 +71,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Response<Object> handleInvalidTokenException(final Throwable ex) { public Response<Object> handleInvalidTokenException(final Throwable ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return new Response<>(ex.getMessage(), Status.UNAUTHORIZED, Translator.toLocale("invalid_signature")); return new Response<>(ex.getMessage(), Status.UNAUTHORIZED, Translator.toLocale("invalid_signature"));
} }
@@ -80,7 +80,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Response<Object> unauthorizedAccessException(final Throwable ex) { public Response<Object> unauthorizedAccessException(final Throwable ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return new Response<>(null, Status.UNAUTHORIZED, ex.getMessage()); return new Response<>(null, Status.UNAUTHORIZED, ex.getMessage());
} }
@@ -115,7 +115,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
public Response<Object> handleUnAuthorizedException(final Throwable ex) { public Response<Object> handleUnAuthorizedException(final Throwable ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
log.error(ex.getLocalizedMessage(), ex); // log.error(ex.getLocalizedMessage(), ex);
return new Response<>(null, Status.VALIDATION_ERROR, Translator.toLocale("invalid_login")); return new Response<>(null, Status.VALIDATION_ERROR, Translator.toLocale("invalid_login"));
} }

View File

@@ -37,4 +37,4 @@ spring.rabbitmq.host=172.18.0.5
spring.rabbitmq.port=61613 spring.rabbitmq.port=61613
spring.rabbitmq.username=guest spring.rabbitmq.username=guest
spring.rabbitmq.password=guest spring.rabbitmq.password=guest
spring.rabbitmq.virtual-host=/ spring.rabbitmq.virtual-host=/

View File

@@ -2380,6 +2380,17 @@
path="db/dump/update_system_email_template_application_rejected_04_02_2025.sql"/> path="db/dump/update_system_email_template_application_rejected_04_02_2025.sql"/>
</changeSet> </changeSet>
<changeSet id="14-02-2025_PK_124000" author="Piyush Kag">
<addColumn tableName="COMPANY">
<column name="JSON" type="TEXT"/>
</addColumn>
<sqlFile dbms="postgresql"
path="db/dump/insert_json_column_in_company_data_06_02_2025.sql"/>
<dropColumn tableName="USER_WITH_COMPANY" columnName="JSON"/>
</changeSet>
<changeSet id="06-02-2025_NK_155519" author="Nisha Kashyap"> <changeSet id="06-02-2025_NK_155519" author="Nisha Kashyap">
<addColumn tableName="call"> <addColumn tableName="call">
<column name="number_of_check" type="numeric"></column> <column name="number_of_check" type="numeric"></column>

View File

@@ -0,0 +1,18 @@
UPDATE COMPANY C
SET JSON = (
SELECT U.JSON
FROM USER_WITH_COMPANY U
WHERE U.COMPANY_ID = C.ID
AND U.IS_DELETED = false
AND U.JSON IS NOT NULL
AND U.JSON <> ''
ORDER BY U.ID ASC
LIMIT 1
)
WHERE EXISTS (
SELECT 1 FROM USER_WITH_COMPANY U
WHERE U.COMPANY_ID = C.ID
AND U.IS_DELETED = false
AND U.JSON IS NOT NULL
AND U.JSON <> ''
);