Skip to content

Commit

Permalink
pay frequency type issue resolved (#591)
Browse files Browse the repository at this point in the history
* pay frequency type issue resolved

* resolved test failures

* changes per Sree feedback

---------

Co-authored-by: Ana Medrano Fernandez <amedrano@codeforamerica.org@Anas-MacBook-Pro-2.local>
  • Loading branch information
analoo and Ana Medrano Fernandez committed Feb 1, 2024
1 parent fba12ea commit 2414264
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.ladocuploader.app.data.enums;

import java.util.HashMap;
import java.util.Map;
import lombok.Getter;

@Getter
public enum PayFrequencyType {
EVERY_WEEK("Every week", "job-pay-period.every-week"),
EVERY_TWO_WEEKS("Every 2 weeks", "job-pay-period.every-two-weeks"),
TWICE_A_MONTH("Twice a month", "job-pay-period.twice-a-month"),
EVERY_MONTH("Every month", "job-pay-period.every-month"),
VARIES("It varies", "job-pay-period.it-varies");

private final String value;
private final String labelSrc;

static private final Map<String, PayFrequencyType> MAP_BY_VALUE = new HashMap<>();

static {
for (PayFrequencyType type : PayFrequencyType.values()) {
MAP_BY_VALUE.put(type.value, type);
}
}

PayFrequencyType(String value, String labelSrc) {
this.value = value;
this.labelSrc = labelSrc;
}

public static String getLabelSrcFromValue(String value) {
PayFrequencyType expenseType = (PayFrequencyType) MAP_BY_VALUE.get(value);
return expenseType != null ? expenseType.labelSrc : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ public static ArrayList<HashMap<String, Object>> getHouseholdIncomeReviewItems(S
item.put("jobName", job.get("employerName"));
item.put("isApplicant", name.equals(applicantFullName));
// TODO: handle income types - hourly vs. non hourly
var payPeriod = job.getOrDefault("jobPaidByHour", "false").equals("true") ? "Hourly, " + job.get("hoursPerWeek").toString() + " hours per week" : job.getOrDefault("payPeriod", "It varies").toString();
var payPeriod = job.getOrDefault("jobPaidByHour", "false").equals("true") ? "Hourly" : job.get("payPeriod").toString();
var hoursPerWeek = job.getOrDefault("hoursPerWeek", "").toString();
item.put("payPeriod", payPeriod);
item.put("hoursPerWeek", hoursPerWeek);

// TODO: add wage amount and not future income
var payAmount = job.getOrDefault("jobPaidByHour", "false").equals("true") ? job.get("hourlyWage").toString() : job.get("payPeriodAmount").toString();
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ income-confirmation.header=Got it! You're almost done with the income section.
income-confirmation.subtext=Do you want to add another job for your household?

job-pay-period.title=Pay period
job-pay-period-self.header=How often do you get paid?
job-pay-period-household.header=How often does {0} get paid?
job-pay-period-self.header=How often do you get paid?
job-pay-period-household.header=How often does {0} get paid?
job-pay-period.every-week=Every week
job-pay-period.every-two-weeks=Every 2 weeks
job-pay-period.twice-a-month=Twice a month
Expand All @@ -803,6 +803,7 @@ income-list.monthly-income=Your monthly household income
income-list.continue=I'm done adding jobs
income-list.box-title=Your monthly household income
income-list.total-income=Total monthly household income
income-list.hourly-statement=Hourly, {0} hours per week
income-list.total-monthly-pay=Total monthly household income
income-list.no-jobs-added=No jobs added
income-list.thats-you=(that's you!)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ income-list.monthly-income=Ingresos mensuales del hogar
income-list.continue=He terminado de agregar los trabajos
income-list.box-title=Ingresos mensuales del hogar
income-list.total-income=Total de ingresos mensuales del hogar
income-list.hourly-statement=Por hora, {0} horas por semana
income-list.total-monthly-pay=Total de ingresos mensuales del hogar
income-list.no-jobs-added=No se agregaron trabajos
income-list.thats-you=(¡Usted!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
th:text="${incomeItem.jobName.toUpperCase()}"></div>
</strong>
<div><strong th:text="${incomeItem.income}"></strong></div>
<div><span th:text="${incomeItem.payPeriod}"></span></div>
<div><span th:text="${incomeItem.payPeriod == 'Hourly' ? #messages.msgWithParams('income-list.hourly-statement', incomeItem.hoursPerWeek) : #messages.msg(T(org.ladocuploader.app.data.enums.PayFrequencyType).getLabelSrcFromValue(incomeItem.payPeriod))}"></span></div>
</div>

<div class="subflow-list__item-actions">
Expand Down
17 changes: 11 additions & 6 deletions src/main/resources/templates/laDigitalAssister/jobPayAmount.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html th:lang="${#locale.language}" xmlns:th="http://www.thymeleaf.org">
<th:block th:with="messageVariant=${fieldData.getOrDefault('payPeriod', 'It varies') == 'It varies' ? 'variable' : 'fixed'}">
<th:block
th:with="messageVariant=${fieldData.getOrDefault('payPeriod', 'It varies') == 'It varies' ? 'variable' : 'fixed'}">
<head th:replace="~{fragments/head :: head(title=#{job-pay-amount.title})}"></head>
<body>
<div class="page-wrapper">
Expand All @@ -11,20 +12,24 @@
<main id="content" role="main" class="form-card spacing-above-35">
<p class="grey-text" th:text="${fieldData.get('employerName')}"></p>
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=${messageVariant == 'fixed' ? #messages.msgWithParams('job-pay-amount.fixed.header', fieldData.getOrDefault('payPeriod', 'in the last 30 days').toLowerCase()) : #messages.msg('job-pay-amount.variable.header')}, subtext=#{job-pay-amount.subtext})}"/>
<th:block th:replace="~{fragments/form :: form(action=${formAction}, content=~{::content})}">
th:with="labelValue=${#messages.msg(T(org.ladocuploader.app.data.enums.PayFrequencyType).getLabelSrcFromValue(fieldData.get('payPeriod'))).toLowerCase()}">
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=${messageVariant == 'fixed' ? #messages.msgWithParams('job-pay-amount.fixed.header', labelValue) : #messages.msg('job-pay-amount.variable.header')}, subtext=#{job-pay-amount.subtext})}"/>
</th:block>
<th:block
th:replace="~{fragments/form :: form(action=${formAction}, content=~{::content})}">
<th:block th:ref="content">
<div class="form-card__content">
<th:block
th:replace="~{fragments/inputs/money :: money(inputName='payPeriodAmount',
th:replace="~{fragments/inputs/money :: money(inputName='payPeriodAmount',
ariaLabel='header')}"/>

</div>
<div class="form-card__footer">


<th:block th:replace="~{fragments/inputs/submitButton :: submitButton(
text=#{general.inputs.continue})}" />
text=#{general.inputs.continue})}"/>

</div>
</th:block>
Expand All @@ -33,7 +38,7 @@
</div>
</section>
</div>
<th:block th:replace="~{fragments/footer :: footer}" />
<th:block th:replace="~{fragments/footer :: footer}"/>
</body>
</th:block>
</html>
31 changes: 12 additions & 19 deletions src/main/resources/templates/laDigitalAssister/jobPayPeriod.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,27 @@
<p class="grey-text" th:text="${fieldData.get('employerName')}"></p>
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=${hhMemberUUID == 'you' ? #messages.msg('job-pay-period-self.header') : #messages.msgWithParams('job-pay-period-household.header', householdMemberName)})}"/>
<th:block th:replace="~{fragments/form :: form(action=${formAction}, content=~{::content})}">
<th:block
th:replace="~{fragments/form :: form(action=${formAction}, content=~{::content})}">
<th:block th:ref="content">
<div class="form-card__content">
<th:block th:replace="~{fragments/inputs/radioFieldset ::
radioFieldset(inputName='payPeriod',
ariaLabel='header',
content=~{::radioContent})}">
<th:block th:ref="radioContent">
<!-- Copy the below input if you want to add more -->
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod',value=#{job-pay-period.every-week}, label=#{job-pay-period.every-week})}"/>
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod',value=#{job-pay-period.every-two-weeks}, label=#{job-pay-period.every-two-weeks})}"/>
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod',value=#{job-pay-period.twice-a-month}, label=#{job-pay-period.twice-a-month})}"/>
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod',value=#{job-pay-period.every-month}, label=#{job-pay-period.every-month})}"/>
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod',value=#{job-pay-period.it-varies}, label=#{job-pay-period.it-varies})}"/>
</th:block>
</th:block>
<th:block th:ref="radioContent">
<th:block
th:each="payPeriod : ${T(org.ladocuploader.app.data.enums.PayFrequencyType).values()}">
<th:block
th:replace="~{fragments/inputs/radio :: radio(inputName='payPeriod', value=${payPeriod.getValue()}, label=#{${payPeriod.getLabelSrc()}})}"/>
</th:block>
</th:block>
</th:block>

</div>
<div class="form-card__footer">


<th:block th:replace="~{fragments/inputs/submitButton :: submitButton(
text=#{general.inputs.continue})}" />
text=#{general.inputs.continue})}"/>

</div>
</th:block>
Expand All @@ -50,7 +43,7 @@
</div>
</section>
</div>
<th:block th:replace="~{fragments/footer :: footer}" />
<th:block th:replace="~{fragments/footer :: footer}"/>
</body>
</th:block>
</html>

0 comments on commit 2414264

Please sign in to comment.