-
Notifications
You must be signed in to change notification settings - Fork 13
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
[FYST-1842] Do not allow clients to update W2 money amount with a nil value #5629
[FYST-1842] Do not allow clients to update W2 money amount with a nil value #5629
Conversation
Heroku app: https://gyr-review-app-5629-aa3928e93377.herokuapp.com/ |
c1a5d1f
to
d33051b
Compare
@@ -26,7 +26,7 @@ | |||
<%= f.vita_min_money_field( | |||
field_name.to_sym, | |||
t(".box14_#{code['name'].downcase}_html"), | |||
options: { value: value || 0 }, | |||
options: { value: value }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed b/c we were pre-filling with 0 and then showing them an error when they saved to "put in 0"
box14_stpickup: 0, | ||
box14_ui_hc_wd: 0, | ||
box14_ui_wf_swf: 0, | ||
w2_index: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a valid
state_file_w2 needs the values at set to non-nil value
…thholding-on-w-2-edit-screen-for-az-and-id-causes-error-on-final-review-page
@@ -70,12 +71,38 @@ class StateFileW2 < ApplicationRecord | |||
validate :validate_tax_amts | |||
validate :state_specific_validation | |||
end | |||
|
|||
validate :validate_nil_tax_amounts, on: :state_file_edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: conversation with @powersurge360 we could do a presence
check here instead; maybe I could've added another block for state_file_edit
form instead of creating a method:
with_options on :state_file_edit do
validates :state_wages_amount, :presence => {message: ->(_object, _data) { I18n.t("state_file.questions.w2.edit.no_money_amount") }},
validates :state_income_tax_amount, :presence => {message: ->(_object, _data) { I18n.t("state_file.questions.w2.edit.no_money_amount") }},
validates :local_wages_and_tips_amount, :presence => {message: ->(_object, _data) { I18n.t("state_file.questions.w2.edit.no_money_amount") }}, if: -> StateFile::StateInformationService.w2_include_local_income_boxes(state_file_intake.state_code) }
validates :local_income_tax_amount, :presence => {message: ->(_object, _data) { I18n.t("state_file.questions.w2.edit.no_money_amount") }}, if: -> StateFile::StateInformationService.w2_include_local_income_boxes(state_file_intake.state_code) }
validates :box14_fli, :presence => {message: ->(_object, _data) { I18n.t("state_file.questions.w2.edit.no_money_amount") }}, if: -> { supported_box14_codes.includes("box14_fli")}
...etc
I think the pros of the pulled out logic is that I know exactly what were doing in the state_file_edit
form only and it's easy to see when the validations run (the if blocks get gnarly toward the end of the lines)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also chatted about using https://api.rubyonrails.org/v7.1/classes/ActiveRecord/Normalization/ClassMethods.html
if we decided to default nil
values to 0.
Something like this?
normalizes :state_wages_amount, with: -> state_wages_amount { state_wages_amount.to_d }
Link to pivotal/JIRA issue
Is PM acceptance required? (delete one)
Reminder: merge main into this branch and get green tests before merging to main
What was done?
nil
into these fieldsvalidates
lines (usingallow_blank: false
) b/c it got too messy (i.e. need to evaluate local boxes & box14 conditional, easier to see in one place, i think)state_file_edit
context (w2 editing screen; not from the income review page), since we believe this page is the source of the error that we're seeing.nil
values -- this was communicated to Tiffany & I'm flagging places where I'm seeing these errors pop up https://codeforamerica.atlassian.net/browse/FYST-18420
-- however, this is not how our money fields work currently across the board (user always has to enter a value to proceed), so we're going to stay ✨ consistent until we determine a better approach for handling. Discussed this with Jey & EricaHow to test?
Screenshots (for visual changes)