Skip to content

Commit

Permalink
use null safe comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
lkemperman-cfa committed Oct 17, 2023
1 parent 58c7b35 commit 0b09c81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/main/java/org/ladocuploader/app/utils/IncomeCalculator.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.ladocuploader.app.utils;

import formflow.library.data.Submission;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Slf4j
public class IncomeCalculator {
Submission submission;
public IncomeCalculator(Submission submission) {
Expand All @@ -27,19 +30,21 @@ public static double futureIncomeForJob(Map<String, Object> job) throws NumberFo
if (job.getOrDefault("jobPaidByHour", "false").toString().equals("true")) {
var hoursPerWeek = Double.parseDouble(job.get("hoursPerWeek").toString());
var hourlyWage = Double.parseDouble(job.get("hourlyWage").toString());
log.info("Returning hourly wage");
return hoursPerWeek * hourlyWage * (52.0 / 12);
} else {
var payPeriod = job.getOrDefault("payPeriod", "It varies");
var payPeriod = job.getOrDefault("payPeriod", "It varies").toString();
var payPeriodAmount = Double.parseDouble(job.get("payPeriodAmount").toString());
if (payPeriod == "Every week"){
if (Objects.equals(payPeriod, "Every week")){
return payPeriodAmount * (52.0 / 12);
} else if (payPeriod == "Every 2 weeks"){
} else if (Objects.equals(payPeriod, "Every 2 weeks")){
return (payPeriodAmount * ((52.0 / 2) / 12));
} else if (payPeriod == "Twice a month"){
} else if (Objects.equals(payPeriod, "Twice a month")){
return payPeriodAmount * 2;
} else if (payPeriod == "Every month"){
} else if (Objects.equals(payPeriod, "Every month")){
return payPeriodAmount;
}
log.info("Using 30D estimate");
// based on 30D estimate
return payPeriodAmount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
th:replace="'fragments/cardHeader' :: cardHeader(header=#{income-by-job.header}, subtext=#{income-by-job.subheader})"/>

<th:block th:replace="~{fragments/continueButton :: continue}" />
<span class="text--small spacing-below-0">
<a th:href="'/flow/' + ${flow} + '/householdAnnualIncome'" th:text="#{income-by-job.enter-directly}"></a>
</span>
<!-- <span class="text&#45;&#45;small spacing-below-0">-->
<!-- <a th:href="'/flow/' + ${flow} + '/householdAnnualIncome'" th:text="#{income-by-job.enter-directly}"></a>-->
<!-- </span>-->
</main>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>

<div class="subflow-list__item-actions">
<a th:href="'/flow/laDigitalAssister/' + ${iterationStartScreen} + '/' + ${incomeItem.uuid} + '/edit'"
<a th:href="'/flow/laDigitalAssister/householdEmployerName/' + ${incomeItem.uuid} + '/edit'"
th:text="#{income-list.edit-job}"
class="subflow-edit"
th:id="'edit-iteration-' + ${incomeItem.uuid}">
Expand Down

0 comments on commit 0b09c81

Please sign in to comment.