Skip to content

Commit

Permalink
Add action for clearing money amount if less then 100.
Browse files Browse the repository at this point in the history
Also changes an equal to equalsIgnoreCase.
If a user enters a money on hand amount, but then goes back
and decides they have less than 100 on hand, we will clear
out the amount they entered so it doesn't affect calculations.
  • Loading branch information
bseeger committed May 24, 2024
1 parent 56ed1a3 commit 704aacc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void run(Submission submission) {

BigDecimal moneyOnHandAmount = convertToBigDecimal(
inputData.getOrDefault("expeditedMoneyOnHandAmount", "0").toString());

BigDecimal householdIncomeAmount = convertToBigDecimal(
inputData.getOrDefault("householdIncomeLast30Days", "0").toString());
if (!isApplyingForExpeditedSnap) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.mdbenefits.app.submission.actions;

import formflow.library.config.submission.Action;
import formflow.library.data.FormSubmission;
import formflow.library.data.Submission;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MaybeClearMoneyOnHandAmount implements Action {

/**
* This action will clear out the expeditedMoneyOnHandAmount field, if the householdMoneyOnHandLessThan100 is equal to "true";
* This is useful in the case that the user goes forward and enters an amount and then goes back and indicates that they have
* less than the money on hand threshold.
*
* @param formSubmission the data being submitted.
* @param submission submission object the action is associated with, not null
*/
@Override
public void run(FormSubmission formSubmission, Submission submission) {
boolean isMoneyOnHandLessThan100 = ((String) formSubmission.getFormData()
.get("householdMoneyOnHandLessThan100")).equalsIgnoreCase("true");

if (isMoneyOnHandLessThan100) {
formSubmission.getFormData().put("expeditedMoneyOnHandAmount", "0");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BigDecimal totalUtilitiesExpenses() {
Map<String, Object> inputData = submission.getInputData();

expenses.forEach(val -> {
if (!val.equals("None")) {
if (!val.equalsIgnoreCase("None")) {
String inputFieldName = HomeExpensesType.getEnumByName(val).getInputFieldName();
expenseAmounts.add(
new BigDecimal(inputData.getOrDefault(inputFieldName, "0").toString())
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/flows-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ flow:
nextScreens:
- name: expeditedSnapMoneyOnHand
expeditedSnapMoneyOnHand:
onPostAction: MaybeClearMoneyOnHandAmount
beforeSaveAction: CheckExpeditedSnapEligibility
nextScreens:
- name: expeditedSnapQualificationNotice
Expand Down Expand Up @@ -270,6 +271,7 @@ flow:
condition: IsApplyingForSnap
- name: householdMedicalExpenses
householdMoneyOnHand:
onPostAction: MaybeClearMoneyOnHandAmount
beforeSaveAction: CheckExpeditedSnapEligibility
nextScreens:
- name: householdMoneyOnHandAmount
Expand Down

0 comments on commit 704aacc

Please sign in to comment.