adds all recounts to offering final recounts list

so poll officers can compare
This commit is contained in:
Juanjo Bazán
2017-01-30 20:16:02 +01:00
parent 0b013139ad
commit 70d00a9768
6 changed files with 57 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ class Officing::FinalRecountsController < Officing::BaseController
def new
@officer_assignments = ::Poll::OfficerAssignment.
includes(:final_recounts, booth_assignment: :booth).
includes(:final_recounts, booth_assignment: [:booth]).
joins(:booth_assignment).
final.
where(id: current_user.poll_officer.officer_assignment_ids).

View File

@@ -16,4 +16,13 @@ module OfficingHelper
options_for_select(options)
end
def recount_to_compare_with_final_recount(final_recount)
recount = final_recount.booth_assignment.recounts.select {|r| r.date == final_recount.date}.first
recount.present? ? recount.count : "-"
end
def system_recount_to_compare_with_final_recount(final_recount)
final_recount.booth_assignment.voters.select {|v| v.created_at.to_date == final_recount.date}.size
end
end

View File

@@ -52,6 +52,8 @@
<th><%= t("officing.final_recounts.new.date") %></th>
<th><%= t("officing.final_recounts.new.booth") %></th>
<th><%= t("officing.final_recounts.new.count") %></th>
<th><%= "Recuento diario anterior" %></th>
<th><%= "Recuento del sistema" %></th>
</thead>
<tbody>
<% @final_recounts.each do |final_recount| %>
@@ -65,6 +67,12 @@
<td>
<strong><%= final_recount.count %></strong>
</td>
<td>
<strong><%= recount_to_compare_with_final_recount final_recount %></strong>
</td>
<td>
<strong><%= system_recount_to_compare_with_final_recount final_recount %></strong>
</td>
</tr>
<% end %>
</tbody>