Resolves #4677 - Require Business Name for Vendors #4704
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4677
Description
This PR makes
business_name
mandatory when creating or updating a Vendor through the Community | Vendors form and the Purchases | New Vendor form. Previously the validations ensured that at least acontact_name
orbusiness_name
was entered, but the dropdown to select a vendor looks a little funky without abusiness_name
.This change prevents further vendors from being created with empty business names, but we still need to handle the existing cases of this. Since we know that either a
business_name
orcontact_name
was required, we run a migration to backfill thebusiness_name
from thecontact_name
for any vendor instance that is missing one.I added the validation on
business_name
to the Vendor model and while that alone works correctly with specs, it didn't look the nicest displayed on the form submission because:a) it shows the error on
contact_name
which doesn't make as much sense now thatbusiness_name
is always requiredb) it shows the error on
business_name
from theprovideable
validation in addition to the error onbusiness_name
from the vendor validationI originally wanted to avoid modifying Provideable, but it felt like the logic to handle exclusively from Vendor was messier than it would be to just add a check in provideable to skip those validations when the model is vendor so that we can use the vendor specific validations instead.
Type of change
I wasn't 100% sure which of these to choose - I don't think I'd call this a breaking change, but existing functionality would be expected to accept an empty business name when contact is supplied, so this change is different than expectations.
How Has This Been Tested?
Screenshots