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

This commit is contained in:
nisha
2025-03-04 11:33:36 +05:30
6 changed files with 71 additions and 25 deletions

View File

@@ -277,7 +277,8 @@ public class ApplicationDao {
for (ApplicationFormFieldEntity applicationFormFieldEntity : applicationFormFieldEntities) {
Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream()
.filter(contentResponseBean -> "fileupload".equals(contentResponseBean.getName()) &&
.filter(contentResponseBean -> ("fileupload".equals(contentResponseBean.getName()) ||
"fileselect".equals(contentResponseBean.getName())) &&
contentResponseBean.getId().equals(applicationFormFieldEntity.getFieldId()))
.findFirst();
@@ -613,7 +614,7 @@ public class ApplicationDao {
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload"))) {
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload") || contentResponseBean.getName().equals("fileselect"))) {
return;
}
}
@@ -669,7 +670,7 @@ public class ApplicationDao {
// List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
for (ContentResponseBean contentResponseBean:contentResponseBeans){
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload")) || Boolean.TRUE.equals(contentResponseBean.getName().equals("fileselect"))) {
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
if (fieldValueObject instanceof String) {
@@ -1405,7 +1406,7 @@ public class ApplicationDao {
FormEntity formEntity = applicationForm.getForm();
if (formEntity != null) {
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.stream().filter(content -> "fileupload".equals(content.getName())).forEach(content -> {
contentResponseBeans.stream().filter(content -> "fileupload".equals(content.getName()) || "fileselect".equals(content.getName())).forEach(content -> {
Optional<ApplicationFormFieldEntity> formField = applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
content.getId(), applicationForm.getId(), applicationId);
formField.ifPresent(field -> {

View File

@@ -612,11 +612,15 @@ public class CallDao {
}
}
if (isEndDateUpdated || isEndTimeUpdated) {
loggingUtil.logUserAction(UserActionRequest.builder()
.request(request)
.actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPDATE_CALL_END_DATE_AND_TIME)
.build());
/** This code is responsible for adding a version history log for the "update call end date and time" operation **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCallEntity).newData(callEntity).build());
}
// setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());

View File

@@ -8,8 +8,6 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@@ -112,24 +110,31 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId);
@Query("""
SELECT TO_CHAR(a.submissionDate, 'Mon') AS month,
SUM(a.amountRequested) AS totalRequested,
SUM(a.amountAccepted) AS totalApproved
FROM ApplicationEntity a
WHERE a.isDeleted = false
AND a.status = 'APPROVED'
AND a.call.hub.id = :hubId
AND a.userId = :userId
AND a.userWithCompany.id = :userWithCompanyId
GROUP BY TO_CHAR(a.submissionDate, 'Mon'), EXTRACT(YEAR FROM a.submissionDate), EXTRACT(MONTH FROM a.submissionDate)
ORDER BY EXTRACT(YEAR FROM a.submissionDate), EXTRACT(MONTH FROM a.submissionDate)
""")
List<Object[]> findRequestedVsApprovedAmountsPerMonth(
@Param("hubId") Long hubId,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId
);
@Query(value = """
WITH months AS (
SELECT TO_CHAR(generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month'), 'Mon') AS month_label,
EXTRACT(YEAR FROM generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month')) AS year_value,
EXTRACT(MONTH FROM generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month')) AS month_value
)
SELECT m.month_label AS month,
COALESCE(SUM(a.amount_requested), 0) AS totalRequested,
COALESCE(SUM(a.amount_accepted), 0) AS totalApproved
FROM months m
LEFT JOIN {h-schema}application a ON EXTRACT(YEAR FROM a.date_accepted) = m.year_value
AND EXTRACT(MONTH FROM a.date_accepted) = m.month_value
AND a.is_deleted = false
AND a.status = 'APPROVED'
AND a.hub_id = :hubId
AND a.user_id = :userId
AND a.user_with_company_id = :userWithCompanyId
GROUP BY m.month_label, m.year_value, m.month_value
ORDER BY m.year_value, m.month_value
""", nativeQuery = true)
List<Object[]> findRequestedVsApprovedAmountsPerMonth(@Param("hubId") Long hubId,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a " +
"WHERE a.hubId = :hubId " +
@@ -164,4 +169,5 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
);
ApplicationEntity findByIdAndCompanyIdAndIsDeletedFalse(Long id,Long companyId);
}

View File

@@ -25,6 +25,7 @@ import org.springframework.security.authorization.AuthorizationDeniedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.web.servlet.resource.NoResourceFoundException;
@ControllerAdvice
public class GlobalExceptionHandler {
@@ -49,6 +50,7 @@ public class GlobalExceptionHandler {
return new Response<>(ex.getErrors(), ex.getStatus(), ex.getMessage());
}
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) {
log.error(ex.getMessage());
@@ -179,4 +181,13 @@ public class GlobalExceptionHandler {
return Utils.convertIntoJson(exceptionString);
}
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ExceptionHandler(NoResourceFoundException.class)
public ResponseEntity<Response<Void>> handlNoeResourceNotFoundException(NoResourceFoundException ex) {
log.error(ex.getMessage());
// log.error(ex.getLocalizedMessage(), ex);
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Response<>(null, Status.NOT_FOUND, ex.getMessage()));
}
}

View File

@@ -2551,4 +2551,15 @@
</addColumn>
</changeSet>
<changeSet id="03-03-2025_RK_120515" author="Rajesh Khore">
<sql dbms="postgresql">select
setval('gepafin_schema.form_field_id_seq', (select
max(id)+1
from gepafin_schema.form_field), false)
</sql>
<sqlFile dbms="postgresql"
path="db/dump/update_form_field_data_03-03-2025.sql"/>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,13 @@
INSERT INTO FORM_FIELD (SORT_ORDER, NAME, LABEL, DESCRIPTION, SETTINGS, VALIDATORS, CREATED_DATE, UPDATED_DATE)
VALUES
(
23,
'fileselect',
'Caricamento File',
'Per selezionare di documenti o immagini',
'[{name: "label",value: "Seleziona File"},{ name: "isDelegation", value: false }]',
'{"isRequired":false}',
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
);