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

Truncate employer name after 35 characters #5455

Merged
merged 4 commits into from
Jan 28, 2025
Merged

Conversation

mmazanec22
Copy link
Contributor

Link to pivotal/JIRA issue

https://github.com/newjersey/affordability-pm/issues/275

Is PM acceptance required? (delete one)

  • No - merge after code review approval

What was done?

Truncate the employer name to avoid bundle failures

How to test?

  • Use the Zeus two w2s profile
  • Edit the UI box 14 data to be under the threshold but add up to more than max (try 90 in both boxes)

Copy link

Heroku app: https://gyr-review-app-5455-afe71c96318b.herokuapp.com/
View logs: heroku logs --app gyr-review-app-5455 (optionally add --tail)

@@ -21,7 +21,7 @@ def document
xml.Body do
column_a = w2.box14_ui_wf_swf&.positive? ? w2.box14_ui_wf_swf : w2.box14_ui_hc_wd

xml.EmployerName w2.employer_name
xml.EmployerName w2.employer_name[0...35]
Copy link
Member

Choose a reason for hiding this comment

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

I recommend using sanitize_for_xml(w2.employer_name, 35) because that method will

  • ensure no excess spaces (only single spaces allowed in most (all?) xml strings)
  • trim a trailing space if the truncation lands after a space (trailing whitespace can also cause a validation error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thank you!

@amanifarooque
Copy link

@mmazanec22 seeing XML errors now generating for the w2 > businessline1 field

the IRS is doing validations on employer name for w2s, that limit is 70 characters, so we should never receive an employer name longer than that limit

182:0: ERROR: Element '{http://www.irs.gov/efile}BusinessNameLine1Txt': [facet 'pattern'] The value 'Wharton State Forest, the best place to mountain bike in New Jersey' is not accepted by the pattern '(([A-Za-z0-9#\-\(\)]|&|') ?)*([A-Za-z0-9#\-\(\)]|&|')'.

expect(body.at('EmployerName').text).to eq(w2.employer_name)
expect(body.at('EmployerName').text).to eq(w2.employer_name[0...35])
if w2.employer_name == long_employer_name
expect(body.at('EmployerName').text.length).to eq(35)
Copy link
Contributor

Choose a reason for hiding this comment

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

[pebble] putting expectations inside an if feels off to me, since there's an outside chance the test is only passing because the expectation isn't being tested. I think the expectation on line 28 is probably enough on its own, but if you feel there needs to be more then you could test explicitly the two expected names outside of the .each?

Copy link
Contributor

@mluedke2 mluedke2 left a comment

Choose a reason for hiding this comment

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

two pebbles and a dust but otherwise looks great to me!

@mmazanec22
Copy link
Contributor Author

@mluedke2 I'm going to address your comments in a fast follow since this is an urgent PR to fix bundle failures

@mmazanec22 mmazanec22 merged commit 879d1f8 into main Jan 28, 2025
7 checks passed
@mmazanec22 mmazanec22 deleted the nj-275-employer-name-bug branch January 28, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants