Merge branch 'release/7.4' into dev

pull/6827/head
Jens Ulferts 7 years ago
commit 033be9f436
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 8
      app/controllers/cost_reports_controller.rb
  2. 11
      app/models/cost_query/filter/cost_type_id.rb

@ -197,10 +197,10 @@ class CostReportsController < ApplicationController
# Determine the active cost type, if it is not labor or money, and add a hidden filter to the query
# sets the @cost_type -> this is used to select the proper units for display
def set_cost_type
if @query
@query.filter :cost_type_id, operator: '=', value: @unit_id.to_s, display: false
@cost_type = CostType.find(@unit_id) if @unit_id > 0
end
return unless @query
@query.filter :cost_type_id, operator: '=', value: @unit_id.to_s, display: false
@cost_type = CostType.find(@unit_id) if @unit_id > 0
end
# set the @cost_types -> this is used to determine which tabs to display

@ -38,6 +38,17 @@ class CostQuery::Filter::CostTypeId < Report::Filter::Base
@display
end
def field
# prevent setting an extra cost type constraint
# WHERE cost_type_id IN (...)
# when money value is requested
if values == ["0"]
[]
else
super
end
end
def self.available_values(*)
[[::I18n.t(:caption_labor), -1]] + CostType.order('name').pluck(:name, :id)
end

Loading…
Cancel
Save