Merge pull request #172 from Kitzanos/request-amount-issue-prod

Cherry-pick (Fixed isRequested amount issue)
This commit is contained in:
Rinaldo
2025-01-22 08:04:53 +01:00
committed by GitHub

View File

@@ -496,24 +496,21 @@ public class ApplicationDao {
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.stream() contentResponseBeans.stream()
.filter(content -> "numberinput".equals(content.getName())) .filter(content -> "numberinput".equals(content.getName()) && content.getId().toString().equals(applicationFormFieldRequestBean.getFieldId()))
.map(ContentResponseBean::getSettings) .map(ContentResponseBean::getSettings)
.flatMap(List::stream) .flatMap(List::stream)
.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) {
if (fieldValue instanceof String) {
try { try {
BigDecimal amountRequested = new BigDecimal((String) fieldValue); BigDecimal amountRequested = new BigDecimal(fieldValue.toString());
applicationFormEntity.getApplication().setAmountRequested(amountRequested); applicationFormEntity.getApplication().setAmountRequested(amountRequested);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e); throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e);
} }
} else {
throw new IllegalArgumentException("Field value is not a String: " + fieldValue);
}
} }
}); });