mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Move the :require_valid_datetime_range method to OrderManagement::Reports::Parameters::Base so it can be reused on multiple reports.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user