diff --git a/config/locales/en.yml b/config/locales/en.yml index 1aee3bfa2c..ef9dfe332d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2827,6 +2827,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using order_management: reports: + base: + date_end_before_start_error: "must be after start" + parameter_not_allowed_error: "You are not authorized to use one or more selected filters for this report." enterprise_fee_summaries: filters: date_range: "Date Range" @@ -2836,8 +2839,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using none: "None" select_and_search: "Select filters and click on GENERATE REPORT to access your data." enterprise_fee_summary: - date_end_before_start_error: "must be after start" - parameter_not_allowed_error: "You are not authorized to use one or more selected filters for this report." fee_calculated_on_transfer_through_all: "All" fee_calculated_on_transfer_through_entire_orders: "Entire Orders through %{distributor}" tax_category_various: "Various" diff --git a/engines/order_management/app/services/order_management/reports/bulk_coop/parameters.rb b/engines/order_management/app/services/order_management/reports/bulk_coop/parameters.rb index 16ed31a744..5fe2b0e5fb 100644 --- a/engines/order_management/app/services/order_management/reports/bulk_coop/parameters.rb +++ b/engines/order_management/app/services/order_management/reports/bulk_coop/parameters.rb @@ -16,11 +16,6 @@ module OrderManagement validate :require_valid_datetime_range - def self.date_end_before_start_error_message - i18n_scope = "order_management.reports.enterprise_fee_summary" - I18n.t("date_end_before_start_error", scope: i18n_scope) - end - def initialize(attributes = {}) self.distributor_ids = [] @@ -34,13 +29,6 @@ module OrderManagement protected - def require_valid_datetime_range - return if start_at.blank? || end_at.blank? - - error_message = self.class.date_end_before_start_error_message - errors.add(:end_at, error_message) unless start_at < end_at - end - # Remove the blank strings that Rails multiple selects add by default to # make sure that blank lists are still submitted to the server as arrays # instead of nil. diff --git a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/parameters.rb b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/parameters.rb index cc12d9be1f..938feeea75 100644 --- a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/parameters.rb +++ b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/parameters.rb @@ -19,11 +19,6 @@ module OrderManagement validate :require_valid_datetime_range - def self.date_end_before_start_error_message - i18n_scope = "order_management.reports.enterprise_fee_summary" - I18n.t("date_end_before_start_error", scope: i18n_scope) - end - def initialize(attributes = {}) self.distributor_ids = [] self.producer_ids = [] @@ -42,13 +37,6 @@ module OrderManagement protected - def require_valid_datetime_range - return if start_at.blank? || end_at.blank? - - error_message = self.class.date_end_before_start_error_message - errors.add(:end_at, error_message) unless start_at < end_at - end - # Remove the blank strings that Rails multiple selects add by default to # make sure that blank lists are still submitted to the server as arrays # instead of nil. diff --git a/engines/order_management/app/services/reports/parameters/base.rb b/engines/order_management/app/services/reports/parameters/base.rb index 8debc06b1d..c25a2e9969 100644 --- a/engines/order_management/app/services/reports/parameters/base.rb +++ b/engines/order_management/app/services/reports/parameters/base.rb @@ -12,8 +12,22 @@ module Reports end end + def self.date_end_before_start_error_message + i18n_scope = "order_management.reports.base" + I18n.t("date_end_before_start_error", scope: i18n_scope) + end + # The parameters are never persisted. def to_key; end + + protected + + def require_valid_datetime_range + return if start_at.blank? || end_at.blank? + + error_message = self.class.date_end_before_start_error_message + errors.add(:end_at, error_message) unless start_at < end_at + end end end end