Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate dob #186989077 #4463

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0b3dc8f
Reordered options, bolded text
tofarr Mar 28, 2024
30f9d2e
Bolded text, reordered options
tofarr Mar 28, 2024
2344e73
Merge branch 'main' into nyc-county-warning-#187296817
tofarr Apr 1, 2024
2174fcb
County warning
tofarr Apr 1, 2024
0f83818
I18n fixes
tofarr Apr 1, 2024
ff4649f
I18n Fixes
tofarr Apr 1, 2024
c2be6b9
I18n Spec fixes
tofarr Apr 1, 2024
36bd35e
Using rails script tag
tofarr Apr 1, 2024
b73f5a4
Updated names for clarity
tofarr Apr 2, 2024
f3eb6b6
Style update
tofarr Apr 4, 2024
30ea2d1
Select warning component
tofarr Apr 4, 2024
1a90540
Integration with form builder
tofarr Apr 4, 2024
5048db2
Clearer name
tofarr Apr 4, 2024
71a73b6
Renamed for clarity
tofarr Apr 4, 2024
69095cb
More progressive enhancement
tofarr Apr 4, 2024
0e2df98
Controller page cleanup
tofarr Apr 4, 2024
f0267d7
More cleanup
tofarr Apr 4, 2024
f50c21f
Added a little flair
tofarr Apr 4, 2024
3965c5a
Fix copypasta
tofarr Apr 4, 2024
22c1bda
Permitted fix
tofarr Apr 4, 2024
7fd7ebb
Fixed headers
tofarr Apr 4, 2024
5da8deb
Updates
tofarr Apr 4, 2024
32220c5
Fixed copy
tofarr Apr 4, 2024
ed4134d
Merge branch 'main' into nyc-county-warning-#187296817
tofarr Apr 5, 2024
9ccefb0
Merge branch 'main' into nyc-county-warning-#187296817
tofarr Apr 5, 2024
026d496
Spec fixes
tofarr Apr 5, 2024
2c883b9
Using content_tag instead of raw html
tofarr Apr 5, 2024
675f51b
Fix spec
tofarr Apr 5, 2024
a1cd39d
Spec fix
tofarr Apr 5, 2024
72591cb
Annotation updates
tofarr Apr 5, 2024
526125e
Merge branch 'main' into nyc-county-warning-#187296817
tofarr Apr 8, 2024
30ba970
WIP
tofarr Apr 8, 2024
50d7a25
WIP
tofarr Apr 8, 2024
8127931
WIP
tofarr Apr 8, 2024
75c1902
Merge branch 'nyc-county-warning-#187296817' into dependent-birth-yea…
tofarr Apr 8, 2024
13a0600
WIP
tofarr Apr 8, 2024
590471f
Dependend birth year warning #186829970
tofarr Apr 8, 2024
bf6068b
WIP
tofarr Apr 9, 2024
a1c3984
Merge branch 'main' into dependent-birth-year-warning-#186829970
tofarr Apr 9, 2024
60c5a94
WIP
tofarr Apr 9, 2024
5ac1e19
WIP
tofarr Apr 9, 2024
7bca00f
WIP
tofarr Apr 9, 2024
9032403
WIP
tofarr Apr 9, 2024
43991a7
WIP
tofarr Apr 9, 2024
679da8e
WIP
tofarr Apr 9, 2024
c2aaabb
Merge branch 'main' into validate-dob-#186989077
tofarr Apr 9, 2024
125333f
WIP
tofarr Apr 9, 2024
ec2f9e8
WIP
tofarr Apr 9, 2024
2c3d3a3
Extract variable
tofarr Apr 17, 2024
3f18580
Merge branch 'main' into validate-dob-#186989077
tofarr Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/state_file/questions/name_dob_controller.rb
Expand Up @@ -4,6 +4,10 @@ class NameDobController < AuthenticatedQuestionsController
include ReturnToReviewConcern

def edit
@filing_year = Rails.configuration.statefile_current_tax_year
@sixty_five_years_ago = MultiTenantService.statefile.end_of_current_tax_year.years_ago(65)
@primary_over_65 = current_intake.direct_file_data.node.at("Primary65OrOlderInd")&.content == "X"
@spouse_over_65 = current_intake.direct_file_data.node.at("Spouse65OrOlderInd")&.content == "X"
if current_intake.state_file_analytics.name_dob_first_visit_at.nil?
current_intake.state_file_analytics.update!(name_dob_first_visit_at: DateTime.now)
end
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/vita_min_form_builder.rb
Expand Up @@ -375,6 +375,17 @@ def continue(value = I18n.t("general.continue"))
submit(value, class: "button button--primary button--wide")
end

def warning_for_date(object_name, min_date, max_date, year, msg)
@template.content_tag(:div, msg,
class: "warning warning-for-date",
"data-warning-for-date": object_name,
style: "display:none",
"data-min-date": min_date && min_date.strftime("%Y-%m-%d"),
"data-max-date": max_date && max_date.strftime("%Y-%m-%d"),
"data-required-year": year
)
end

def warning_for_select(element_id, permitted_values, msg)
@template.content_tag(:div, msg,
class: "warning warning-for-select",
Expand Down
40 changes: 40 additions & 0 deletions app/javascript/components/WarningForDateComponent.js
@@ -0,0 +1,40 @@

export default function WarningForDateComponent() {
const warningElements = document.querySelectorAll("[data-warning-for-date]");
warningElements.forEach((warningElement) => {
let { maxDate, minDate, warningForDate, requiredYear } = warningElement.dataset;
maxDate = new Date(maxDate);
minDate = new Date(minDate);
const fields = ["year", "month", "day"].map((f) => {
return document.querySelector(`[name="${warningForDate.replace("year", f)}"]`);
});

function show(){
if (requiredYear) {
const selectedYear = fields[0].value;
return selectedYear && selectedYear !== requiredYear;
}
const date = new Date(...fields.map((s) => {
return parseInt(s.value);
}))
if (!date.getTime()) {
return false;
}
if (minDate.getTime() && date.getTime() < minDate.getTime()) {
return true;
}
if (maxDate.getTime() && date.getTime() > maxDate.getTime()) {
return true;
}
return false;
}
function render(){
$(warningElement)[show() ? "show" : "hide"]("slow");
}

fields.forEach((f) => {
f.addEventListener("change", render);
})
render();
});
}
2 changes: 2 additions & 0 deletions app/javascript/listeners/index.js
Expand Up @@ -17,6 +17,7 @@ import { initServiceComparisonComponent } from "../lib/service_comparison_compon
import { fetchEfileStateCounts } from "../lib/fetch_efile_state_counts";
import { fetchStateFileEfileStateCounts } from "../lib/fetch_statefile_efile_state_counts";
import ClientMenuComponent from "../components/ClientMenuComponent";
import WarningForDateComponent from "../components/WarningForDateComponent";
import WarningForSelectComponent from "../components/WarningForSelectComponent";
import MixpanelEventTracking from "../lib/mixpanel_event_tracking";
import IntercomBehavior from "../lib/intercom_behavior";
Expand All @@ -28,6 +29,7 @@ const Listeners = (function(){
MixpanelEventTracking.listenForTrackedClicks();
const { controllerAction } = document.querySelector("#mixpanelData")?.dataset || {};
ClientMenuComponent();
WarningForDateComponent();
WarningForSelectComponent();

documentSubmittingIndicator.init(); // extend styling on honeyCrisp's default ajax upload functionality.
Expand Down
25 changes: 25 additions & 0 deletions app/views/state_file/questions/name_dob/edit.html.erb
Expand Up @@ -21,6 +21,13 @@
t(".suffix"),
suffix_options_for_state_select,
prompt: t('general.select_prompt'), include_blank: true) %>
<div class="form-group">
<% if @primary_over_65 %>
<%= f.warning_for_date("#{f.object_name}[primary_birth_date_year]", nil, @sixty_five_years_ago, nil, t(".primary_dob_over_65_warning", filing_year: @filing_year)) %>
<% else %>
<%= f.warning_for_date("#{f.object_name}[primary_birth_date_year]", @sixty_five_years_ago, nil, nil, t(".primary_dob_under_65_warning", filing_year: @filing_year)) %>
<% end %>
</div>
<div class="date-select">
<%= f.cfa_date_select(:primary_birth_date,
t('.your_dob'),
Expand Down Expand Up @@ -48,6 +55,13 @@
suffix_options_for_state_select,
prompt: t('general.select_prompt'), include_blank: true) %>
<% if f.object.ask_spouse_dob? %>
<div class="form-group">
<% if @spouse_over_65 %>
<%= f.warning_for_date("#{f.object_name}[spouse_birth_date_year]", nil, @sixty_five_years_ago, nil, t(".spouse_dob_over_65_warning", filing_year: @filing_year)) %>
<% else %>
<%= f.warning_for_date("#{f.object_name}[spouse_birth_date_year]", @sixty_five_years_ago, nil, nil, t(".spouse_dob_under_65_warning", filing_year: @filing_year)) %>
<% end %>
</div>
<div class="date-select">
<%= f.cfa_date_select(:spouse_birth_date,
t('.spouse_dob'),
Expand Down Expand Up @@ -77,6 +91,17 @@
<%= ff.cfa_input_field(:first_name, t("general.first_name"), classes: ["form-width--long"], options: {disabled: true}) %>
<%= ff.cfa_input_field(:last_name, t("general.last_name"), classes: ["form-width--long"], options: {disabled: true}) %>

<% child_birth_yr = current_intake.direct_file_data.eitc_eligible_dependents[ff.object.ssn]&.at("ChildBirthYr")&.content %>
<% if child_birth_yr.present? && current_intake.state_code == "ny" %>
<div class="form-group">
<%= ff.warning_for_date("#{ff.object_name}[dob_year]", nil, nil, child_birth_yr, t(".dependent_dob_year_warning")) %>
</div>
<% elsif ff.object.ctc_qualifying %>
<div class="form-group">
<%= ff.warning_for_date("#{ff.object_name}[dob_year]", MultiTenantService.statefile.end_of_current_tax_year.years_ago(17), nil, nil, t(".dependent_dob_under_17_warning")) %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting MultiTenantService.statefile.end_of_current_tax_year so that here and @sixty_five_years_ago can both use it and not be inconsistent about extracting a variable for one age and not the other.

</div>
<% end %>

<div class="date-select">
<%= ff.cfa_date_select(:dob,
t('general.date_of_birth'),
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Expand Up @@ -2383,15 +2383,21 @@ en:
welcome_back: Welcome back %{user_name}!
name_dob:
edit:
dependent_dob_under_17_warning: According to your federal return, this person was less than 17 years old at the end of 2023. Please double check their date of birth.
dependent_dob_year_warning: You entered a different birth year for this person on your federal return. Please double check their date of birth.
dependent_months_lived_label: Number of months they lived with you in %{year}
dependent_name_dob: Please tell us your dependent’s date of birth
last_name: Last name
middle_initial: Middle initial
months_helper_born_died: Select 12 months if the dependent was born or died during 2023.
months_helper_description: Count any months the dependent lived in your home, as well as any months the dependent was temporarily absent due to being away at school, in a hospital or medical facility, or away on business or vacation.
months_helper_heading: Which months should I count?
primary_dob_over_65_warning: According to your federal return, you were at least 65 years old at the end of %{filing_year}. Please double check your date of birth.
primary_dob_under_65_warning: According to your federal return, you were less than 65 years old at the end of %{filing_year}. Please double check your date of birth.
primary_name_dob: Your name (as shown on your Social Security card or ITIN letter ending in %{last_four_ssn}) and date of birth
spouse_dob: Your spouse's date of birth
spouse_dob_over_65_warning: According to your federal return, your spouse was at least 65 years old at the end of %{filing_year}. Please double check their date of birth.
spouse_dob_under_65_warning: According to your federal return, your spouse was less than 65 years old at the end of %{filing_year}. Please double check their date of birth.
spouse_name_dob_html: Your <strong>spouse’s</strong> name (as shown on your Social Security card or ITIN letter ending in %{last_four_ssn}) and date of birth
spouse_name_html: Your <strong>spouse’s</strong> name (as shown on your Social Security card or ITIN letter ending in %{last_four_ssn})
suffix: Suffix
Expand Down
6 changes: 6 additions & 0 deletions config/locales/es.yml
Expand Up @@ -2350,15 +2350,21 @@ es:
welcome_back: "¡Bienvenido de nuevo %{user_name}!"
name_dob:
edit:
dependent_dob_under_17_warning: Según su declaración federal, esta persona tenía menos de 17 años a finales de 2023. Verifique nuevamente su fecha de nacimiento.
dependent_dob_year_warning: Ingresó un año de nacimiento diferente para esta persona en su declaración federal. Por favor verifique su fecha de nacimiento.
dependent_months_lived_label: Número de meses que vivió contigo en %{year}
dependent_name_dob: Indícanos la fecha de nacimiento de tu dependiente
last_name: Apellido
middle_initial: Inicial del segundo nombre
months_helper_born_died: Selecciona 12 meses si tu dependiente nació o falleció durante el 2023.
months_helper_description: Deberías contar todos los meses en los que tu dependiente vivió en tu hogar, incluyendo los meses en los que estuvo temporalmente ausente por estar en la escuela, en un hospital o centro médico, o ausente por negocios o vacaciones.
months_helper_heading: "¿Cuáles meses debería contar?"
primary_dob_over_65_warning: Según su declaración federal, tenía al menos 65 años a finales de %{filing_year}. Verifique nuevamente su fecha de nacimiento.
primary_dob_under_65_warning: Según su declaración federal, tenía menos de 65 años a finales de %{filing_year}. Verifique nuevamente su fecha de nacimiento.
primary_name_dob: Tu nombre (como aparece en tu tarjeta de Seguro Social o tu carta del Número de Identificación del Contribuyente (ITIN) que termina en %{last_four_ssn}) y la fecha de nacimiento
spouse_dob: Fecha de nacimiento de tu cónyuge
spouse_dob_over_65_warning: Según su declaración federal, su cónyuge tenía al menos 65 años a finales de %{filing_year}. Verifique nuevamente su fecha de nacimiento.
spouse_dob_under_65_warning: Según su declaración federal, su cónyuge tenía menos de 65 años a finales de %{filing_year}. Verifique dos veces su fecha de nacimiento.
spouse_name_dob_html: El nombre de tu <strong>cónyuge</strong> (como aparece en su tarjeta de Seguro Social o en la carta del Número de Identificación del Contribuyente (ITIN) que termina en %{last_four_ssn}) y la fecha de nacimiento.
spouse_name_html: El nombre de tu <strong>cónyuge</strong> (como aparece en su tarjeta de Seguro Social o en la carta del Número de Identificación del Contribuyente (ITIN) que termina en %{last_four_ssn})
suffix: Sufijo
Expand Down
16 changes: 16 additions & 0 deletions n-desktop-#186632607
mpidcock marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,16 @@
center-on-desktop-#186632607
dependent-birth-year-warning-#186829970
differentiate-mixpanel-events-#185630719
* main
release
required-intake-data-#187270706
required-intake-data-completed-step-#187270706
required-intake-data-part-2-#187270706
revert-for-deploy
staging
submission-search-fix-#187278919
tims-hubris
translations_a24d8971fccee9a494b7267ce7f7deae_es
update-pending-federal-return-path-#187305186
update-pending-federal-return-path-2-#187305186
validate-dob-#186989077