Skip to content

Commit

Permalink
Update IncomeDetailsPreparer
Browse files Browse the repository at this point in the history
  • Loading branch information
spokenbird authored and bseeger committed Jun 18, 2024
1 parent 1596cc9 commit c08ff22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio

results.putAll(prepareIncome(submission));
results.putAll(prepareAdditionIncome(submission));
results.putAll(prepareMoneyOnHandResources(submission));
results.putAll(prepareHasMoreThanHundredOnHand(submission));
return results;
}
Expand Down Expand Up @@ -145,38 +144,13 @@ private void writeAdditionalIncomeFields(Submission submission, AdditionalIncome
null
));
}

private Map<String, SubmissionField> prepareMoneyOnHandResources(Submission submission) {
Map<String, SubmissionField> fields = new HashMap<>();
var moneyOnHandSelected = (List<String>) submission.getInputData().getOrDefault("moneyOnHandTypes[]", emptyList());

if (moneyOnHandSelected.isEmpty()) {
return fields;
}
if (isNoneOfAboveSelection(moneyOnHandSelected)) {
fields.put("householdHasResourcesOrAssets", new SingleField("householdHasResourcesOrAssets", "false", null
));
return fields;
} else {
int i = 1;
for (var type : MoneyOnHandType.values()) {
if (moneyOnHandSelected.contains(type.name())) {
fields.put("householdHasResourcesOrAssets", new SingleField("householdHasResourcesOrAssets", "true", null
));
fields.put("resourcesOrAssetsType" + i,
new SingleField("resourcesOrAssetsType" + i, messagesSource.getMessage(
type.getLabelSrc(), null, Locale.ENGLISH), null));
i++;
}
}
}
return fields;
}

private Map<String, SubmissionField> prepareHasMoreThanHundredOnHand(Submission submission) {
Map<String, SubmissionField> fields = new HashMap<>();
if (submission.getInputData().containsKey("expeditedMoneyOnHandAmount")) {
fields.put("householdHasResourcesOrAssets", new SingleField("householdHasResourcesOrAssets", "true", null));
Map<String, Object> inputData = submission.getInputData();
if (inputData.containsKey("expeditedMoneyOnHandAmount")) {
double expeditedMoneyOnHandAmount = Double.parseDouble(inputData.get("expeditedMoneyOnHandAmount").toString());
fields.put("householdHasResourcesOrAssets", new SingleField("householdHasResourcesOrAssets", expeditedMoneyOnHandAmount > 0 ? "true" : "false", null));
}
return fields;
}
Expand Down

This file was deleted.

0 comments on commit c08ff22

Please sign in to comment.