Skip to content

Commit

Permalink
Update how we write to th job table in PDF.
Browse files Browse the repository at this point in the history
  • Loading branch information
bseeger committed Mar 29, 2024
1 parent eed99ec commit df418a7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,24 @@ private Map<String, SubmissionField> prepareIncome(Submission submission) {
if (income != null) {
int i = 1;
for (Map<String, Object> incomeDetails : income) {
var employeeName = incomeDetails.get("householdMemberJobAdd");
String employeeName = (String) incomeDetails.get("householdMemberJobAdd");
if (employeeName.equals("you")) {
employeeName = inputData.get("firstName") + " " + inputData.get("lastName");
}

var employerName = incomeDetails.get("employerName");
var payFrequency = incomeDetails.get("payPeriod");
var payPeriodAmount = incomeDetails.get("payPeriodAmount");
String employerName = (String) incomeDetails.get("employerName");
String payFrequency = (String) incomeDetails.get("payPeriod");
String payPeriodAmount = (String) incomeDetails.get("payPeriodAmount");
String moneyString = String.format("$%,.0f", Double.valueOf(payPeriodAmount));

fields.put("employeeName" + i,
new SingleField("employeeName" + i, (String) employeeName, null));
new SingleField("employeeName" + i, employeeName, null));
fields.put("employerName" + i,
new SingleField("employerName" + i, (String) employerName, null));
fields.put("employmentRateOfPay" + i,
new SingleField("employmentRateOfPay" + i, "Last 30 Days", null));
new SingleField("employerName" + i, employerName, null));
fields.put("employmentPayPerPeriod" + i,
new SingleField("employmentPayPerPeriod" + i, (String) payPeriodAmount, null));
new SingleField("employmentPayPerPeriod" + i, moneyString, null));
fields.put("employmentPayFreq" + i,
new SingleField("employmentPayFreq" + i, preparePayPeriod((String) payFrequency), null));
new SingleField("employmentPayFreq" + i, preparePayPeriod(payFrequency), null));

i++;
}
Expand Down Expand Up @@ -140,10 +139,10 @@ private Map<String, SubmissionField> prepareMoneyOnHandResources(Submission subm
Map<String, SubmissionField> fields = new HashMap<>();
var moneyOnHandSelected = (List<String>) submission.getInputData().getOrDefault("moneyOnHandTypes[]", emptyList());

if (moneyOnHandSelected.isEmpty()){
if (moneyOnHandSelected.isEmpty()) {
return fields;
}
if(isNoneOfAboveSelection(moneyOnHandSelected)) {
if (isNoneOfAboveSelection(moneyOnHandSelected)) {
fields.put("householdHasResourcesOrAssets", new SingleField("householdHasResourcesOrAssets", "false", null
));
return fields;
Expand All @@ -153,8 +152,9 @@ private Map<String, SubmissionField> prepareMoneyOnHandResources(Submission subm
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));
fields.put("resourcesOrAssetsType" + i,
new SingleField("resourcesOrAssetsType" + i, messagesSource.getMessage(
type.getLabelSrc(), null, Locale.ENGLISH), null));
i++;
}
}
Expand Down
Binary file modified src/main/resources/pdfs/9701.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IncomeDetailsPreparerTest {

private IncomeDetailsPreparer incomePreparer;

final int FIELDS_PER_JOB = 5;
final int FIELDS_PER_JOB = 4;

@BeforeEach
void setup() {
Expand Down Expand Up @@ -109,36 +109,37 @@ public void testAdditionalIncome() {
@Test
public void testPrepareMoneyOnHandResourcesDoesNotAddWhenNONEisPresent() {
Submission submission = new SubmissionTestBuilder()
.withPersonalInfo("Person", "One", "", "", "", "", "", "", "", "")
.with("moneyOnHandTypes[]", List.of(NONE_OF_ABOVE_SELECTION_VALUE))
.build();
.withPersonalInfo("Person", "One", "", "", "", "", "", "", "", "")
.with("moneyOnHandTypes[]", List.of(NONE_OF_ABOVE_SELECTION_VALUE))
.build();

Map<String, SubmissionField> result = incomePreparer.prepareSubmissionFields(submission, null);
assertThat(result.get("householdHasResourcesOrAssets"))
.isEqualTo(new SingleField("householdHasResourcesOrAssets", "false", null));
.isEqualTo(new SingleField("householdHasResourcesOrAssets", "false", null));
}

@Test
public void testPrepareMoneyOnHandResourcesAddsRelevantItems() {
Submission submission = new SubmissionTestBuilder()
.withPersonalInfo("Person", "One", "", "", "", "", "", "", "", "")
.with("moneyOnHandTypes[]", List.of("CHECKING", "SAVINGS", "BONDS"))
.build();
.withPersonalInfo("Person", "One", "", "", "", "", "", "", "", "")
.with("moneyOnHandTypes[]", List.of("CHECKING", "SAVINGS", "BONDS"))
.build();

Map<String, SubmissionField> result = incomePreparer.prepareSubmissionFields(submission, null);

assertThat(withNoJobIncome(result).size()).isEqualTo(4);
assertThat(result.get("householdHasResourcesOrAssets"))
.isEqualTo(new SingleField("householdHasResourcesOrAssets", "true", null));
.isEqualTo(new SingleField("householdHasResourcesOrAssets", "true", null));
assertThat(result.get("resourcesOrAssetsType1"))
.isEqualTo(new SingleField("resourcesOrAssetsType1", "Checking account", null));
.isEqualTo(new SingleField("resourcesOrAssetsType1", "Checking account", null));

assertThat(result.get("resourcesOrAssetsType2"))
.isEqualTo(new SingleField("resourcesOrAssetsType2", "Savings account", null));
.isEqualTo(new SingleField("resourcesOrAssetsType2", "Savings account", null));

assertThat(result.get("resourcesOrAssetsType3"))
.isEqualTo(new SingleField("resourcesOrAssetsType3", "Bonds", null));
.isEqualTo(new SingleField("resourcesOrAssetsType3", "Bonds", null));
}

private void assertJobIncome(Map<String, SubmissionField> results, String expected) {
assertThat(results).containsKey("householdHasEarnedIncome");
var hasIncomeField = (SingleField) results.get("householdHasEarnedIncome");
Expand Down

0 comments on commit df418a7

Please sign in to comment.