Filters zero_nil setting and computing fixed
This commit is contained in:
parent
08ac719566
commit
cfe225c014
@ -35,7 +35,8 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td style="padding-top:4px;">
|
<td style="padding-top:4px;">
|
||||||
<%= label_tag do %>
|
<%= label_tag do %>
|
||||||
<%= check_box_tag 'formula[zero_nil]', session[:i_filters][:formula][:zero_nil] %>
|
<%= hidden_field_tag 'formula[zero_nil]', 0 %>
|
||||||
|
<%= check_box_tag 'formula[zero_nil]', 1, @formula_q.formula.zero_nil %>
|
||||||
<%= t 'quantities.form.zero_nil' %>
|
<%= t 'quantities.form.zero_nil' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td style="padding-top:4px;">
|
<td style="padding-top:4px;">
|
||||||
<%= label_tag do %>
|
<%= label_tag do %>
|
||||||
<%= check_box_tag 'formula[zero_nil]', session[:m_filters][:formula][:zero_nil] %>
|
<%= hidden_field_tag 'formula[zero_nil]', 0 %>
|
||||||
|
<%= check_box_tag 'formula[zero_nil]', 1, @formula_q.formula.zero_nil %>
|
||||||
<%= t 'quantities.form.zero_nil' %>
|
<%= t 'quantities.form.zero_nil' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
@ -86,7 +86,11 @@ module BodyTracking
|
|||||||
if deps.empty?
|
if deps.empty?
|
||||||
output_ids = items.select { |i| subitems[q.name][i.id].nil? }.map(&:id)
|
output_ids = items.select { |i| subitems[q.name][i.id].nil? }.map(&:id)
|
||||||
input_q = q.formula.quantities
|
input_q = q.formula.quantities
|
||||||
inputs = input_q.map { |i_q| [i_q, completed_q[i_q.name].values_at(*output_ids)] }
|
inputs = input_q.map do |i_q|
|
||||||
|
values = completed_q[i_q.name].values_at(*output_ids)
|
||||||
|
values.map! { |v, u| [v || BigDecimal(0), u] } if q.formula.zero_nil
|
||||||
|
[i_q, values]
|
||||||
|
end
|
||||||
begin
|
begin
|
||||||
calculated = q.formula.calculate(inputs.to_h)
|
calculated = q.formula.calculate(inputs.to_h)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
Reference in New Issue
Block a user