From 18e9aba6b86cfcaa59383269a0c2b27fe50dc272 Mon Sep 17 00:00:00 2001 From: ijdershem-jf Date: Sun, 18 Dec 2022 16:15:54 -0700 Subject: [PATCH] [OFN-9870] Display accurate error message for differing variant_unit_name for same product in import --- app/models/product_import/entry_validator.rb | 7 ++++++- config/locales/en.yml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index e08360113e..06c1311d3a 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -211,7 +211,7 @@ module ProductImport reference_entry = all_entries_for_product(entry).first return if entry.variant_unit_name.to_s == reference_entry.variant_unit_name.to_s - mark_as_not_updatable(entry, "variant_unit_name") + mark_as_values_must_be_same(entry, "variant_unit_name") end def producer_validation(entry) @@ -425,6 +425,11 @@ module ProductImport error: I18n.t("admin.product_import.model.not_updatable")) end + def mark_as_values_must_be_same(entry, attribute) + mark_as_invalid(entry, attribute: attribute, + error: I18n.t("admin.product_import.model.values_must_be_same")) + end + def import_into_inventory? @import_settings.dig(:settings, 'import_into') == 'inventories' end diff --git a/config/locales/en.yml b/config/locales/en.yml index 96153edcd5..839a7fbb5d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -730,6 +730,7 @@ en: not_found: not found in database category_not_found: doesn't match allowed categories. See the correct categories to choose from on the product import page, or check that there's no misspelling. not_updatable: cannot be updated on existing products via product import + values_must_be_same: must be the same for products with the same name blank: can't be blank products_no_permission: you do not have permission to manage products for this enterprise inventory_no_permission: you do not have permission to create inventory for this producer