Updated code

This commit is contained in:
nisha
2025-01-13 13:00:04 +05:30
parent 3b8246987e
commit b4877b588c
16 changed files with 110 additions and 55 deletions

View File

@@ -424,6 +424,10 @@ public class ApplicationDao {
if(applicationEntity.getProtocol() != null) {
responseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}
responseBean.setAmountAccepted(applicationEntity.getAmountAccepted());
responseBean.setAmountRequested(applicationEntity.getAmountRequested());
responseBean.setDateAccepted(applicationEntity.getDateAccepted());
responseBean.setDateRejected(applicationEntity.getDateRejected());
return responseBean;
}
@@ -443,6 +447,10 @@ public class ApplicationDao {
response.setCallId(entity.getCall().getId());
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
response.setAmountAccepted(entity.getAmountAccepted());
response.setAmountRequested(entity.getAmountRequested());
response.setDateAccepted(entity.getDateAccepted());
response.setDateRejected(entity.getDateRejected());
if(entity.getProtocol() != null) {
response.setProtocolNumber(entity.getProtocol().getProtocolNumber());
}
@@ -481,22 +489,31 @@ public class ApplicationDao {
List<Long> newDocumentIds = validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
for (ContentResponseBean contentResponseBean:contentResponseBeans){
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("numberinput"))) {
List<SettingResponseBean> settingResponseBeans=contentResponseBean.getSettings();
for(SettingResponseBean settingResponseBean:settingResponseBeans){
if(settingResponseBean.getName().equals("isRequestedAmount")){
Object value=settingResponseBean.getValue();
if (value instanceof Boolean) {
if(Boolean.TRUE.equals(value))
{
applicationFormEntity.getApplication().setAmountRequested((BigDecimal) applicationFormFieldRequestBean.getFieldValue());
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.stream()
.filter(content -> "numberinput".equals(content.getName()))
.map(ContentResponseBean::getSettings)
.flatMap(List::stream)
.filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue()))
.findFirst()
.ifPresent(setting -> {
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
if(fieldValue!=null) {
if (fieldValue instanceof String) {
try {
BigDecimal amountRequested = new BigDecimal((String) fieldValue);
applicationFormEntity.getApplication().setAmountRequested(amountRequested);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e);
}
} else {
throw new IllegalArgumentException("Field value is not a String: " + fieldValue);
}
}
}
}
}}
});
ApplicationFormFieldEntity oldApplicationFormFieldData = null;
if (applicationFormFieldEntities == null || applicationFormFieldEntities.isEmpty()) {
@@ -827,6 +844,10 @@ public class ApplicationDao {
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getName());
applicationGetResponseBean.setCompanyId(applicationEntity.getCompanyId());
applicationGetResponseBean.setAmountAccepted(applicationEntity.getAmountAccepted());
applicationGetResponseBean.setAmountRequested(applicationEntity.getAmountRequested());
applicationGetResponseBean.setDateAccepted(applicationEntity.getDateAccepted());
applicationGetResponseBean.setDateRejected(applicationEntity.getDateRejected());
if(applicationEntity.getProtocol() != null) {
applicationGetResponseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}

View File

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
@@ -582,6 +583,10 @@ public class ApplicationEvaluationDao {
CompanyEntity company = companyService.validateCompany(application.getCompanyId());
response.setCompanyName(company.getCompanyName());
}
response.setAmountAccepted(application.getAmountAccepted());
response.setAmountRequested(application.getAmountRequested());
response.setDateAccepted(application.getDateAccepted());
response.setDateRejected(application.getDateRejected());
}
@@ -613,11 +618,15 @@ public class ApplicationEvaluationDao {
entity.setIsDeleted(false);
setIfUpdated(entity::getNote, entity::setNote, req.getNote());
setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation());
application.setAmountAccepted(req.getAmountAccepted());
if(Boolean.TRUE.equals(req.getApplicationStatus().equals(ApplicationStatusForEvaluation.APPROVED)) && (req.getAmountAccepted()==null || req.getAmountAccepted().compareTo(BigDecimal.ZERO) < 0)){
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.AMOUNT_ACCEPTED_REQUIRED_WHILE_APPROVING_APPLICATION));
}
if (req.getAmountAccepted() != null && req.getAmountAccepted().compareTo(BigDecimal.ZERO) > 0) {
application.setAmountAccepted(req.getAmountAccepted());
}
actionType = VersionActionTypeEnum.UPDATE;
} else {
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
ApplicationEntity application = applicationService.validateApplication(assignedApplicationsEntity.getApplication().getId());
entity = convertToEntity(user, req, assignedApplicationId);
actionType = VersionActionTypeEnum.INSERT;

View File

@@ -63,7 +63,6 @@ public class DashboardDao {
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
Map<String, Object> widgetBars =getStatistics(requestedUserEntity);
widgetResponseBean.setWidgetBars(widgetBars);
widgetResponseBean.setUserActionWidgetList(getUserAction(requestedUserEntity));
return widgetResponseBean;
}
@@ -97,14 +96,14 @@ public class DashboardDao {
private void setAmountRequested(Widget1 widget1, UserEntity requestedUserEntity) {
BigDecimal amountRequested = applicationRepository.findTotalAmountRequestedOfApplication(requestedUserEntity.getHub().getId());
if (amountRequested != null) {
widget1.setAmountRequested(amountRequested);
widget1.setTotalAmountRequested(amountRequested);
}
}
private void setAmountAccepted(Widget1 widget1, UserEntity requestedUserEntity) {
BigDecimal amountAccepted = applicationRepository.findTotalAmountAcceptedOfApplication(requestedUserEntity.getHub().getId());
if (amountAccepted != null) {
widget1.setAmountAccepted(amountAccepted);
widget1.setTotalAmountAccepted(amountAccepted);
}
}
@@ -194,12 +193,12 @@ public class DashboardDao {
return stats;
}
public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
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());
Page<UserActionEntity> userActionEntities=userActionsRepository.findActionsByRoleNamesAndHubId(roles,requestedUserEntity.getHub().getId(),pageable);
return userActionEntities;
}
// public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
// 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());
// Page<UserActionEntity> userActionEntities=userActionsRepository.findActionsByRoleNamesAndHubId(roles,requestedUserEntity.getHub().getId(),pageable);
// return userActionEntities;
// }
public ApplicationWidgetResponseBean getApplicationDetails(UserEntity userEntity) {
ApplicationWidgetResponseBean applicationWidgetResponseBean = initializeResponseBean();

View File

@@ -309,6 +309,10 @@ public class FlowFormDao {
if(applicationEntity.getProtocol() != null) {
nextOrPreviousFormResponse.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}
nextOrPreviousFormResponse.setAmountAccepted(applicationEntity.getAmountAccepted());
nextOrPreviousFormResponse.setAmountRequested(applicationEntity.getAmountRequested());
nextOrPreviousFormResponse.setDateAccepted(applicationEntity.getDateAccepted());
nextOrPreviousFormResponse.setDateRejected(applicationEntity.getDateRejected());
return nextOrPreviousFormResponse;
}