Merge pull request #207 from Kitzanos/feature/GEPAFINBE-153

GEPAFINBE-153 (Beneficiary: create stats page )
This commit is contained in:
Rinaldo
2025-02-10 11:36:26 +01:00
committed by GitHub
14 changed files with 325 additions and 55 deletions

View File

@@ -408,6 +408,19 @@ public class GepafinConstant {
public static final String ASSIGNED_APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "assigned.application.status.updated.successfully"; public static final String ASSIGNED_APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "assigned.application.status.updated.successfully";
public static final String REQUIRED_REQUESTED_AMOUNT_MSG = "validation.required.requested.amount"; public static final String REQUIRED_REQUESTED_AMOUNT_MSG = "validation.required.requested.amount";
public static final String REQUESTED_VS_APPROVED_AMOUNTS="requestedVsApprovedAmount";
public static final String MONTH="month";
public static final String TOTAL_REQUESTED="totalRequested";
public static final String TOTAL_APPROVED="totalApproved";
public static final String NUMBER_OF_APPLICATION="numberOfApplication";
public static final String COMPANY_ID_NOT_NULL_MSG = "company.id.not.null";
public static final String USER_WITH_COMPANY="userWithCompany";
public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount"; public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount";
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns"; public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";

View File

@@ -1419,6 +1419,9 @@ public class ApplicationDao {
public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(UserEntity userEntity, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) { public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(UserEntity userEntity, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) {
Integer pageNo = null; Integer pageNo = null;
Integer pageLimit = null; Integer pageLimit = null;
UserWithCompanyEntity userWithCompany= userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId).orElse(null);
if (applicationPageableRequestBean.getGlobalFilters() != null) { if (applicationPageableRequestBean.getGlobalFilters() != null) {
pageNo = applicationPageableRequestBean.getGlobalFilters().getPage(); pageNo = applicationPageableRequestBean.getGlobalFilters().getPage();
pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit(); pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit();
@@ -1429,7 +1432,7 @@ public class ApplicationDao {
if (pageNo == null || pageNo <= 0) { if (pageNo == null || pageNo <= 0) {
pageNo = GepafinConstant.DEFAULT_PAGE; pageNo = GepafinConstant.DEFAULT_PAGE;
} }
Specification<ApplicationEntity> spec = search(callId, companyId, applicationPageableRequestBean, userEntity); Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompany.getId(), applicationPageableRequestBean, userEntity);
Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit)); Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
// Prepare the response // Prepare the response
@@ -1452,10 +1455,10 @@ public class ApplicationDao {
return pageableResponseBean; return pageableResponseBean;
} }
public Specification<ApplicationEntity> search(Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean, UserEntity userEntity) { public Specification<ApplicationEntity> search(Long callId, Long companyId, Long userWithCompanyId, ApplicationPageableRequestBean applicationPageableRequestBean, UserEntity userEntity) {
return (root, query, criteriaBuilder) -> { return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = getPredicates(applicationPageableRequestBean, criteriaBuilder, root, callId, companyId, userEntity); List<Predicate> predicates = getPredicates(applicationPageableRequestBean, criteriaBuilder, root, callId,companyId, userWithCompanyId, userEntity);
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true); SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
if (applicationPageableRequestBean.getGlobalFilters() != null if (applicationPageableRequestBean.getGlobalFilters() != null
@@ -1479,13 +1482,15 @@ public class ApplicationDao {
private List<Predicate> getPredicates(ApplicationPageableRequestBean applicationPageableRequestBean, private List<Predicate> getPredicates(ApplicationPageableRequestBean applicationPageableRequestBean,
CriteriaBuilder criteriaBuilder, Root<ApplicationEntity> root, Long callId, Long companyId, UserEntity userEntity) { CriteriaBuilder criteriaBuilder, Root<ApplicationEntity> root, Long callId,Long companyId, Long userWithCompanyId, UserEntity userEntity) {
Integer year = null; Integer year = null;
String search = null; String search = null;
Integer daysRange = null;
if (applicationPageableRequestBean.getGlobalFilters() != null) { if (applicationPageableRequestBean.getGlobalFilters() != null) {
year = applicationPageableRequestBean.getGlobalFilters().getYear(); year = applicationPageableRequestBean.getGlobalFilters().getYear();
search = applicationPageableRequestBean.getGlobalFilters().getSearch(); search = applicationPageableRequestBean.getGlobalFilters().getSearch();
daysRange = applicationPageableRequestBean.getDaysRange();
} }
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
@@ -1527,16 +1532,24 @@ public class ApplicationDao {
} }
// Optional companyId filter // Optional companyId filter
if (userWithCompanyId != null) {
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_WITH_COMPANY).get(GepafinConstant.ID), userWithCompanyId));
}
if (companyId != null) { if (companyId != null) {
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.COMPANY_ID), companyId)); predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.COMPANY_ID), companyId));
} }
if (daysRange != null && daysRange >= 0) {
LocalDateTime today = LocalDateTime.now();
LocalDateTime pastDate = today.minusDays(daysRange);
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
}
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED))); predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId())); predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId()));
return predicates; return predicates;
} }
public void checkCallEndDate(CallEntity call) { public void checkCallEndDate(CallEntity call) {
LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now());

View File

@@ -198,6 +198,7 @@ public class DashboardDao {
return stats; return stats;
} }
// public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){ // public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
// Pageable pageable = PageRequest.of(0, 20); // Get the first 20 records // Pageable pageable = PageRequest.of(0, 20); // Get the first 20 records
// List<String> roles=List.of(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue(),RoleStatusEnum.ROLE_GEPAFIN_OPERATOR.getValue(),RoleStatusEnum.ROLE_INSTRUCTOR_MANAGER.getValue()); // List<String> roles=List.of(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue(),RoleStatusEnum.ROLE_GEPAFIN_OPERATOR.getValue(),RoleStatusEnum.ROLE_INSTRUCTOR_MANAGER.getValue());
@@ -268,6 +269,7 @@ public class DashboardDao {
responseBean.setNumberOfDueApplication(dueApplications); responseBean.setNumberOfDueApplication(dueApplications);
} }
} }
private AmendmentWidgetResponseBean initializeAmendmentResponseBean() { private AmendmentWidgetResponseBean initializeAmendmentResponseBean() {
return AmendmentWidgetResponseBean.builder() return AmendmentWidgetResponseBean.builder()
.totalAmendments(0L) .totalAmendments(0L)
@@ -289,6 +291,7 @@ public class DashboardDao {
calculateAverageResponseDays(applicationIds, amendmentWidgetResponseBean, hubId); calculateAverageResponseDays(applicationIds, amendmentWidgetResponseBean, hubId);
return amendmentWidgetResponseBean; return amendmentWidgetResponseBean;
} }
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId, Long userId) { public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId, Long userId) {
if (userId != null) { if (userId != null) {
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userId); return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userId);
@@ -359,6 +362,7 @@ public class DashboardDao {
responseBean.setAverageResponseDays(BigDecimal.ZERO); responseBean.setAverageResponseDays(BigDecimal.ZERO);
} }
} }
public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(UserEntity userEntity) { public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(UserEntity userEntity) {
Long userId = userEntity.getId(); Long userId = userEntity.getId();
Long hubId = userEntity.getHub().getId(); Long hubId = userEntity.getHub().getId();
@@ -409,7 +413,109 @@ public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(
return response; return response;
} }
public static List<String> getStatusList() {
return List.of(
ApplicationStatusTypeEnum.SUBMIT.getValue(),
ApplicationStatusTypeEnum.EVALUATION.getValue(),
ApplicationStatusTypeEnum.APPROVED.getValue(),
ApplicationStatusTypeEnum.REJECTED.getValue(),
ApplicationStatusTypeEnum.SOCCORSO.getValue(),
ApplicationStatusTypeEnum.APPOINTMENT.getValue(),
ApplicationStatusTypeEnum.NDG.getValue(),
ApplicationStatusTypeEnum.ADMISSIBLE.getValue()
);
}
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(UserEntity userEntity, CompanyEntity company) {
BeneficiaryStatisticsResponseBean widgetResponseBean = initializeBeneficiaryStatisticsBean();
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(userEntity.getId(), company.getId());
Long hubId = userEntity.getHub().getId();
List<String> statusList = getStatusList();
Long submittedApplication = applicationRepository.countSubmittedApplicationsByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId(), statusList);
Long approvedApplication = getApplicationCountByStatus(hubId, userEntity.getId(), userWithCompanyEntity.getId(), ApplicationStatusTypeEnum.APPROVED);
BigDecimal successRate = getSuccessRate(hubId, userEntity.getId(), userWithCompanyEntity.getId());
BigDecimal totalAmountRequested = applicationRepository.sumAmountRequestedByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId());
updateApplicationWidget(widgetResponseBean.getApplicationWidget(), submittedApplication, approvedApplication, successRate, totalAmountRequested);
Map<String, Object> widgetBars = getApplicationStatistics(userEntity, userWithCompanyEntity.getId());
widgetResponseBean.setApplicationWidgetBars(widgetBars);
return widgetResponseBean;
}
private BeneficiaryStatisticsResponseBean initializeBeneficiaryStatisticsBean() {
return BeneficiaryStatisticsResponseBean.builder()
.applicationWidget(ApplicationWidget.builder()
.submittedApplication(0L)
.approvedApplication(0L)
.successRate(BigDecimal.ZERO)
.totalAmountFinanced(BigDecimal.ZERO)
.build())
.build();
}
private Long getApplicationCountByStatus(Long hubId, Long userId, Long userWithCompanyId, ApplicationStatusTypeEnum status) {
return applicationRepository.countSubmittedApplicationsByHubIdAndUserIdAndStatus(hubId, userId, userWithCompanyId, status.getValue());
}
private BigDecimal getSuccessRate(Long hubId, Long userId, Long userWithCompanyId) {
return applicationRepository.findSuccessRateByHubIdAndUserIdAndUserWithCompanyId(hubId, userId, userWithCompanyId);
}
private void updateApplicationWidget(ApplicationWidget applicationWidget, Long submittedApplication, Long approvedApplication, BigDecimal successRate, BigDecimal totalAmountRequested) {
applicationWidget.setSubmittedApplication(submittedApplication != null ? submittedApplication : 0L);
applicationWidget.setApprovedApplication(approvedApplication != null ? approvedApplication : 0L);
applicationWidget.setSuccessRate(successRate != null ? successRate : BigDecimal.ZERO);
applicationWidget.setTotalAmountFinanced(totalAmountRequested != null ? totalAmountRequested : BigDecimal.ZERO);
}
public Map<String, Object> getApplicationStatistics(UserEntity requestedUser, Long userWithCompanyId) {
Map<String, Object> stats = new HashMap<>();
Map<String, Long> statusData = new HashMap<>();
for (ApplicationStatusTypeEnum status : ApplicationStatusTypeEnum.values()) {
statusData.put(status.name(), 0L);
}
// Get applications per status
List<Object[]> applicationsByStatus = applicationRepository.findApplicationsByStatusAndUserIdAndUserWithCompanyId(
requestedUser.getHub().getId(),
requestedUser.getId(),
userWithCompanyId
);
applicationsByStatus.forEach(result -> {
String status = (String) result[0];
Long count = (Long) result[1];
statusData.put(status, count);
});
List<Map<String, Object>> statusList = statusData.entrySet().stream().map(entry -> {
Map<String, Object> statusMap = new HashMap<>();
statusMap.put(GepafinConstant.STATUS, entry.getKey());
statusMap.put(GepafinConstant.NUMBER_OF_APPLICATION, entry.getValue());
return statusMap;
}).collect(Collectors.toList());
stats.put(GepafinConstant.APPLICATION_PER_STATUS, statusList);
// Requested VS Approved Amounts
List<Object[]> requestedVsApprovedAmounts = applicationRepository.findRequestedVsApprovedAmountsPerMonth(
requestedUser.getHub().getId(),
requestedUser.getId(),
userWithCompanyId
);
stats.put(GepafinConstant.REQUESTED_VS_APPROVED_AMOUNTS, requestedVsApprovedAmounts.stream().map(result -> {
Map<String, Object> data = new HashMap<>();
data.put(GepafinConstant.MONTH, result[0]);
data.put(GepafinConstant.TOTAL_REQUESTED, result[1]);
data.put(GepafinConstant.TOTAL_APPROVED, result[2]);
return data;
}).toList());
return stats;
}
private PreInstructorWidgetResponseBean initializeDashboardPreInstructorResponseBean() { private PreInstructorWidgetResponseBean initializeDashboardPreInstructorResponseBean() {
return PreInstructorWidgetResponseBean.builder() return PreInstructorWidgetResponseBean.builder()
.assignedApplication(ApplicationToConsider.builder() .assignedApplication(ApplicationToConsider.builder()

View File

@@ -149,6 +149,7 @@ public enum UserActionContextEnum {
GET_AMENDMENT_DETAILS("GET_AMENDMENT_DETAILS"), GET_AMENDMENT_DETAILS("GET_AMENDMENT_DETAILS"),
GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR("GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR"), GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR("GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR"),
GET_APPLICATION_DETAILS_FOR_EVALUATION("GET_APPLICATION_DETAILS_FOR_EVALUATION"), GET_APPLICATION_DETAILS_FOR_EVALUATION("GET_APPLICATION_DETAILS_FOR_EVALUATION"),
GET_STATISTICS_PAGE_FOR_BENEFICIARY("GET_STATISTICS_PAGE_FOR_BENEFICIARY"),
/** Evaluation criteria action context **/ /** Evaluation criteria action context **/
GET_EVALUATION_CRITERIA("GET_EVALUATION_CRITERIA"), GET_EVALUATION_CRITERIA("GET_EVALUATION_CRITERIA"),

View File

@@ -10,5 +10,7 @@ public class ApplicationPageableRequestBean {
private GlobalFilters globalFilters; private GlobalFilters globalFilters;
private Integer daysRange;
private List<ApplicationStatusTypeEnum> status; private List<ApplicationStatusTypeEnum> status;
} }

View File

@@ -0,0 +1,19 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
@Data
@Builder
public class ApplicationWidget {
private Long submittedApplication;
private BigDecimal successRate;
private Long approvedApplication;
private BigDecimal totalAmountFinanced;
}

View File

@@ -0,0 +1,17 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Map;
@Data
@Builder
public class BeneficiaryStatisticsResponseBean {
private ApplicationWidget applicationWidget;
private Map<String, Object> applicationWidgetBars;
}

View File

@@ -94,5 +94,68 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
@Query("SELECT a.id FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.isDeleted = false") @Query("SELECT a.id FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.isDeleted = false")
List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId); List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId);
@Query("SELECT CASE WHEN COUNT(CASE WHEN a.submissionDate IS NOT NULL THEN 1 ELSE NULL END) > 0 THEN " +
"CAST((SUM(CASE WHEN a.status = 'APPROVED' THEN 1 ELSE 0 END) * 100.0) / " +
"COUNT(CASE WHEN a.submissionDate IS NOT NULL THEN 1 ELSE NULL END) AS BigDecimal) " +
"ELSE CAST(0 AS BigDecimal) END " +
"FROM ApplicationEntity a " +
"WHERE a.hubId = :hubId AND a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId " +
"AND a.isDeleted = false")
BigDecimal findSuccessRateByHubIdAndUserIdAndUserWithCompanyId(
@Param("hubId") Long hubId,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId);
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId AND a.call.hub.id = :hubId GROUP BY a.status")
List<Object[]> findApplicationsByStatusAndUserIdAndUserWithCompanyId(@Param("hubId") Long hubId,
@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("SELECT COUNT(a) FROM ApplicationEntity a " +
"WHERE a.hubId = :hubId " +
"AND a.userId = :userId " +
"AND a.userWithCompany.id = :userWithCompanyId " +
"AND a.isDeleted = false " +
"AND a.status IN :statusList " +
"AND a.submissionDate IS NOT NULL")
Long countSubmittedApplicationsByHubIdAndUserId(
@Param("hubId") Long hubId,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId,
@Param("statusList") List<String> statusList
);
@Query("SELECT COUNT(a) FROM ApplicationEntity a " +
"WHERE a.hubId = :hubId " +
"AND a.userId = :userId " +
"AND a.userWithCompany.id = :userWithCompanyId " +
"AND a.status = :status " +
"AND a.isDeleted = false")
Long countSubmittedApplicationsByHubIdAndUserIdAndStatus(
@Param("hubId") Long hubId,
@Param("userId") Long userId,
@Param("userWithCompanyId") Long userWithCompanyId,
@Param("status") String status);
@Query("SELECT SUM(a.amountAccepted) FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.userId = :userId AND a.status = 'APPROVED' AND a.userWithCompany.id = :userWithCompanyId AND a.isDeleted = false")
BigDecimal sumAmountRequestedByHubIdAndUserId(@Param("hubId") Long hubId, @Param("userId") Long userId, @Param("userWithCompanyId") Long userWithCompanyId);
} }

View File

@@ -18,4 +18,6 @@ public interface DashboardService {
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request,Long userId); public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request,Long userId);
public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(HttpServletRequest request); public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(HttpServletRequest request);
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(HttpServletRequest request,Long companyId);
} }

View File

@@ -57,4 +57,11 @@ public class DashboardServiceImpl implements DashboardService {
UserEntity userEntity = validator.validateUser(request); UserEntity userEntity = validator.validateUser(request);
return dashboardDao.getApplicationDetailsForEvaluation(userEntity); return dashboardDao.getApplicationDetailsForEvaluation(userEntity);
} }
@Override
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(HttpServletRequest request, Long companyId) {
UserEntity userEntity = validator.validateUser(request);
CompanyEntity company = validator.validateUserWithCompany(request, companyId);
return dashboardDao.getStatisticsPageForBeneficiary(userEntity,company);
}
} }

View File

@@ -95,7 +95,7 @@ public interface DashboardApi {
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')") @PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')")
ResponseEntity<Response<AssignedApplicationWidgetResponseBean>> getApplicationDetailsForEvaluation(HttpServletRequest request); ResponseEntity<Response<AssignedApplicationWidgetResponseBean>> getApplicationDetailsForEvaluation(HttpServletRequest request);
@Operation(summary = "Api to get dashboard widget for pre instructor", @Operation(summary = "Api to get Statistics page for beneficiary",
responses = { responses = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -105,10 +105,25 @@ public interface DashboardApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/beneficiary/statistic/company/{companyId}",
produces = { "application/json" })
ResponseEntity<Response<BeneficiaryStatisticsResponseBean>> getStatisticsPageForBeneficiary(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable(value = "companyId", required = true) Long companyId);
@Operation(summary = "Api to get dashboard widget for pre instructor",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/instructor/amendment", @GetMapping(value = "/instructor/amendment",
produces = { "application/json" }) produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')") @PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')")
ResponseEntity<Response<PreInstructorWidgetResponseBean>> getDashboardWidgetForPreInstructor(HttpServletRequest request, @Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId); ResponseEntity<Response<PreInstructorWidgetResponseBean>> getDashboardWidgetForPreInstructor(HttpServletRequest request, @Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId);
} }

View File

@@ -93,6 +93,15 @@ public class DashboardApiController implements DashboardApi {
return ResponseEntity.status(HttpStatus.CREATED) return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(widgetResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY))); .body(new Response<>(widgetResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY)));
} }
@Override
public ResponseEntity<Response<BeneficiaryStatisticsResponseBean>> getStatisticsPageForBeneficiary(HttpServletRequest request, Long companyId) {
/** This code is responsible for creating user action logs for the "Get statistics page for beneficiary" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_STATISTICS_PAGE_FOR_BENEFICIARY).build());
BeneficiaryStatisticsResponseBean widgetResponseBean= dashboardService.getStatisticsPageForBeneficiary(request, companyId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(widgetResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY)));
}
} }

View File

@@ -368,6 +368,7 @@ either.applicationId.or.assignedApplicationId.must.be.provided=Either applicatio
assigned.application.status.updated.successfully=Assigned application status updated successfully. assigned.application.status.updated.successfully=Assigned application status updated successfully.
validation.required.requested.amount=The Requested Amount configuration should be mandatory. validation.required.requested.amount=The Requested Amount configuration should be mandatory.
company.id.not.null=Company ID cannot be null.
formula.amount.not.matches.requested.amount= The {0} does not matches to calculated amount. formula.amount.not.matches.requested.amount= The {0} does not matches to calculated amount.

View File

@@ -359,5 +359,7 @@ either.applicationId.or.assignedApplicationId.must.be.provided = "<22> necessario
assigned.application.status.updated.successfully=Stato dell'applicazione assegnata aggiornato con successo. assigned.application.status.updated.successfully=Stato dell'applicazione assegnata aggiornato con successo.
validation.required.requested.amount=La configurazione dell'importo richiesto <20> obbligatoria. validation.required.requested.amount=La configurazione dell'importo richiesto <20> obbligatoria.
company.id.not.null=L'ID dell'azienda non pu? essere nullo.
formula.amount.not.matches.requested.amount=Il {0} non corrisponde all'importo calcolato. formula.amount.not.matches.requested.amount=Il {0} non corrisponde all'importo calcolato.