diff --git a/app/controllers/report_controller/reports/editor.rb b/app/controllers/report_controller/reports/editor.rb index 267cb249373..17baaca3a53 100644 --- a/app/controllers/report_controller/reports/editor.rb +++ b/app/controllers/report_controller/reports/editor.rb @@ -25,6 +25,10 @@ def chargeback_allocated_methods Hash[CHAREGEBACK_ALLOCATED_METHODS.map { |x| _(x) }] end + def default_chargeback_allocated_method + chargeback_allocated_methods.keys.first + end + def miq_report_new assert_privileges("miq_report_new") @_params.delete :id # incase add button was pressed from report show screen. @@ -524,7 +528,7 @@ def gfv_model @edit[:new][:cb_groupby] ||= "date" # Default to Date grouping @edit[:new][:tz] = session[:user_tz] @edit[:new][:cb_include_metrics] = true if @edit[:new][:model] == 'ChargebackVm' - @edit[:new][:method_for_allocated_metrics] = DEFAULT_CHARGEBACK_ALLOCATED_METHOD + @edit[:new][:method_for_allocated_metrics] = default_chargeback_allocated_method end reset_report_col_fields build_edit_screen @@ -619,7 +623,7 @@ def gfv_chargeback elsif params.key?(:cb_include_metrics) @edit[:new][:cb_include_metrics] = params[:cb_include_metrics] == 'true' elsif params.key?(:method_for_allocated_metrics) - @edit[:new][:method_for_allocated_metrics] = params[:method_for_allocated_metrics].try(:to_sym) || DEFAULT_CHARGEBACK_ALLOCATED_METHOD + @edit[:new][:method_for_allocated_metrics] = params[:method_for_allocated_metrics].try(:to_sym) || default_chargeback_allocated_method elsif params.key?(:cb_owner_id) @edit[:new][:cb_owner_id] = params[:cb_owner_id].blank? ? nil : params[:cb_owner_id] elsif params.key?(:cb_tenant_id) @@ -1306,7 +1310,7 @@ def set_form_vars # @edit[:new][:cb_include_metrics] = nil - it means YES (YES is default value for new and legacy reports) @edit[:new][:cb_include_metrics] = options[:include_metrics].nil? || options[:include_metrics] - @edit[:new][:method_for_allocated_metrics] = options[:method_for_allocated_metrics].try(:to_sym) || DEFAULT_CHARGEBACK_ALLOCATED_METHOD + @edit[:new][:method_for_allocated_metrics] = options[:method_for_allocated_metrics].try(:to_sym) || default_chargeback_allocated_method @edit[:new][:cb_groupby_tag] = options[:groupby_tag] if options.key?(:groupby_tag) @edit[:new][:cb_model] = Chargeback.report_cb_model(@rpt.db) @edit[:new][:cb_interval] = options[:interval] diff --git a/app/helpers/ui_constants.rb b/app/helpers/ui_constants.rb index e1081980d47..811714749b4 100644 --- a/app/helpers/ui_constants.rb +++ b/app/helpers/ui_constants.rb @@ -499,7 +499,6 @@ module UiConstants CHAREGEBACK_ALLOCATED_METHODS = {} CHAREGEBACK_ALLOCATED_METHODS[:max] = N_('Maximum') CHAREGEBACK_ALLOCATED_METHODS[:avg] = N_('Average') - DEFAULT_CHARGEBACK_ALLOCATED_METHOD = CHAREGEBACK_ALLOCATED_METHODS.keys.first end # Make these constants globally available