MAPC / massbuilds

Crowdsourcing authoritative info on recent & ongoing developments in Massachusetts.
https://www.massbuilds.com/
2 stars 2 forks source link

Unit style percentages can exceed 100% #306

Open atomtay opened 4 years ago

atomtay commented 4 years ago

Describe the bug Users can input more units via Unit Styles than present in Unit Types, and there are no validation checks to prevent this. As a result, it is possible to input impossible values ("200% of units in this development are studios")

Steps to reproduce Walk us through how you revealed the bug.

  1. Go to 'Create a development'
  2. Scroll to "development type" and select Residential
  3. Enter 1 in each of the four Unit Type fields
  4. Enter 5 into one of the three Unit Style fields
  5. See that the percentage for that field is 125% (5 units out of 4)

Expected behavior The percentages for Unit Styles should add up to 100%, and users should not be able to write in more units in the Unit Styles than they have in the above Unit Types section.

Screenshots Example of what should be an invalid input: invalid state

Example of what could be a valid input: valid state

Desktop (please complete the following information):

Additional context The denominator should always be the number of units dictated in the Unit Type section. The numerator (the total number of units accounted for in Unit Styles) should not be able to exceed this for the math to work out.