diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb
index 64e67c6ca..2c9755d6a 100644
--- a/app/controllers/admin/poll/booth_assignments_controller.rb
+++ b/app/controllers/admin/poll/booth_assignments_controller.rb
@@ -24,7 +24,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
def show
@poll = ::Poll.find(params[:poll_id])
- @booth_assignment = @poll.booth_assignments.includes(:recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
+ @booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end
diff --git a/app/controllers/officing/final_recounts_controller.rb b/app/controllers/officing/final_recounts_controller.rb
index 56b0c600e..bbfa13c95 100644
--- a/app/controllers/officing/final_recounts_controller.rb
+++ b/app/controllers/officing/final_recounts_controller.rb
@@ -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).
diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb
index 5ace7ab5f..842eaee63 100644
--- a/app/helpers/officing_helper.rb
+++ b/app/helpers/officing_helper.rb
@@ -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
\ No newline at end of file
diff --git a/app/helpers/poll_final_recounts_helper.rb b/app/helpers/poll_final_recounts_helper.rb
new file mode 100644
index 000000000..e196cb65b
--- /dev/null
+++ b/app/helpers/poll_final_recounts_helper.rb
@@ -0,0 +1,7 @@
+module PollFinalRecountsHelper
+
+ def final_recount_for_date(final_recounts, date)
+ final_recounts.select {|f| f.date == date}.first
+ end
+
+end
\ No newline at end of file
diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb
index 1246e8f98..95ce54341 100644
--- a/app/helpers/poll_recounts_helper.rb
+++ b/app/helpers/poll_recounts_helper.rb
@@ -1,7 +1,7 @@
module PollRecountsHelper
def recount_for_date(recounts, date)
- recounts.select {|r| r.date.to_date == date}.first
+ recounts.select {|r| r.date == date}.first
end
end
\ No newline at end of file
diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb
index 2652ee2bb..7ce61791a 100644
--- a/app/views/admin/poll/booth_assignments/show.html.erb
+++ b/app/views/admin/poll/booth_assignments/show.html.erb
@@ -55,26 +55,30 @@
| <%= t("admin.poll_booth_assignments.show.date") %> |
<%= t("admin.poll_booth_assignments.show.count_by_officer") %> |
+ <%= t("admin.poll_booth_assignments.show.count_final") %> |
<%= t("admin.poll_booth_assignments.show.count_by_system") %> |
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
<% recount = recount_for_date(@booth_assignment.recounts, voting_date) %>
+ <% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %>
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
- <% if recount.present? %>
-
- | <%= l voting_date %> |
- <%= recount.count %> |
- <%= system_count %> |
-
- <% else %>
-
- | <%= l voting_date %> |
+
+ | <%= l voting_date %> |
+ <% if recount.present? %>
+
+ <%= recount.count %> |
+ <% else %>
- |
- <%= system_count %> |
-
- <% end %>
+ <% end %>
+ <% if final_recount.present? %>
+ <%= final_recount.count %> |
+ <% else %>
+ - |
+ <% end %>
+ <%= system_count %> |
+
<% end %>
diff --git a/app/views/officing/final_recounts/new.html.erb b/app/views/officing/final_recounts/new.html.erb
index 42518cfd9..e67ea509a 100644
--- a/app/views/officing/final_recounts/new.html.erb
+++ b/app/views/officing/final_recounts/new.html.erb
@@ -52,6 +52,8 @@
<%= t("officing.final_recounts.new.date") %> |
<%= t("officing.final_recounts.new.booth") %> |
<%= t("officing.final_recounts.new.count") %> |
+ <%= "Recuento diario anterior" %> |
+ <%= "Recuento del sistema" %> |
<% @final_recounts.each do |final_recount| %>
@@ -65,6 +67,12 @@
<%= final_recount.count %>
|
+
+ <%= recount_to_compare_with_final_recount final_recount %>
+ |
+
+ <%= system_recount_to_compare_with_final_recount final_recount %>
+ |
<% end %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 7db4d2d48..b5ac39456 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -288,6 +288,7 @@ en:
no_recounts: "There are not daily recounts of this booth yet"
date: "Date"
count_by_officer: "Votes (by officer)"
+ count_final: "Final recount"
count_by_system: "Votes (automatic)"
polls:
index:
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index abe65bd60..d1b485231 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -288,6 +288,7 @@ es:
no_recounts: "No hay recuentos diarios de esta urna"
date: "Fecha"
count_by_officer: "Votos (presidente de mesa)"
+ count_final: "Recuento final"
count_by_system: "Votos (automático)"
polls:
index:
diff --git a/config/locales/officing.en.yml b/config/locales/officing.en.yml
index c82d3f740..607346e6b 100644
--- a/config/locales/officing.en.yml
+++ b/config/locales/officing.en.yml
@@ -46,8 +46,8 @@ en:
date: "Date"
select_booth: "Select booth"
select_date: "Select date"
- count: "Vote count"
- count_placeholder: "Vote count"
+ count: "Final vote count"
+ count_placeholder: "Final vote count"
submit: Save
final_recount_list: "Your final recounts"
residence:
diff --git a/config/locales/officing.es.yml b/config/locales/officing.es.yml
index df91b79ed..c9cf97544 100644
--- a/config/locales/officing.es.yml
+++ b/config/locales/officing.es.yml
@@ -46,8 +46,8 @@ es:
date: "Día"
select_booth: "Elige urna"
select_date: "Elige día"
- count: "Número de votos"
- count_placeholder: "Número de votos"
+ count: "Recuento final"
+ count_placeholder: "Número final de votos"
submit: "Guardar"
final_recount_list: "Tus recuentos finales"
residence:
diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb
index 14a8ba1e1..3dc255104 100644
--- a/spec/features/admin/poll/booth_assigments_spec.rb
+++ b/spec/features/admin/poll/booth_assigments_spec.rb
@@ -90,11 +90,12 @@ feature 'Admin booths assignments' do
end
scenario 'Lists all recounts for the booth assignment' do
- poll = create(:poll)
+ poll = create(:poll, starts_at: 2.weeks.ago, ends_at: 1.week.ago)
booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer_assignment_1 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.starts_at)
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at)
+ final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at)
recount_1 = create(:poll_recount,
booth_assignment: booth_assignment,
@@ -105,7 +106,12 @@ feature 'Admin booths assignments' do
booth_assignment: booth_assignment,
officer_assignment: officer_assignment_2,
date: officer_assignment_2.date,
- count: 1)
+ count: 78)
+ final_recount = create(:poll_final_recount,
+ booth_assignment: booth_assignment,
+ officer_assignment: final_officer_assignment,
+ date: final_officer_assignment.date,
+ count: 5678)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
other_recount = create(:poll_recount, booth_assignment: booth_assignment_2, count: 100)
@@ -119,14 +125,18 @@ feature 'Admin booths assignments' do
within('#recounts_list') do
expect(page).to_not have_content other_recount.count
- within("#recount_#{recount_1.id}") do
+ within("#recounting_#{recount_1.date.strftime('%Y%m%d')}") do
expect(page).to have_content recount_1.count
end
- within("#recount_#{recount_2.id}") do
+ within("#recounting_#{recount_2.date.strftime('%Y%m%d')}") do
expect(page).to have_content recount_2.count
end
+ within("#recounting_#{final_recount.date.strftime('%Y%m%d')}") do
+ expect(page).to have_content final_recount.count
+ end
+
end
end
@@ -147,8 +157,8 @@ feature 'Admin booths assignments' do
click_link 'Recounts'
within('#recounts_list') do
- expect(page).to have_css("#recount_#{recount.id}.count-error")
- within("#recount_#{recount.id}") do
+ expect(page).to have_css("#recounting_#{recount.date.strftime('%Y%m%d')} td.count-error")
+ within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
expect(page).to have_content recount.count
expect(page).to have_content 0
end
@@ -161,7 +171,7 @@ feature 'Admin booths assignments' do
within('#recounts_list') do
expect(page).to_not have_css('.count-error')
- within("#recount_#{recount.id}") do
+ within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
expect(page).to have_content(recount.count)
end
end
diff --git a/spec/features/officing/final_recount_spec.rb b/spec/features/officing/final_recount_spec.rb
index 770561bb7..ffb7c38f4 100644
--- a/spec/features/officing/final_recount_spec.rb
+++ b/spec/features/officing/final_recount_spec.rb
@@ -63,7 +63,7 @@ feature 'Officing Final Recount' do
end
end
- scenario 'Edit recount' do
+ scenario 'Edit final recount' do
final_recount = create(:poll_final_recount,
officer_assignment: @officer_assignment,
booth_assignment: @officer_assignment.booth_assignment,
@@ -97,4 +97,38 @@ feature 'Officing Final Recount' do
end
expect(page).to_not have_content('100')
end
+
+ scenario 'Show daily, final and system recounts to compare' do
+ voting_officer_assignment = create(:poll_officer_assignment, date: 7.days.ago)
+ poll = voting_officer_assignment.booth_assignment.poll
+ poll.update(ends_at: 1.day.ago)
+ daily_recount = create(:poll_recount,
+ officer_assignment: voting_officer_assignment,
+ booth_assignment: voting_officer_assignment.booth_assignment,
+ date: voting_officer_assignment.date,
+ count: 500)
+ final_officer_assignment = create(:poll_officer_assignment, :final,
+ booth_assignment: voting_officer_assignment.booth_assignment,
+ date: poll.ends_at + 1.day,
+ officer: @poll_officer)
+ final_recount = create(:poll_final_recount,
+ officer_assignment: final_officer_assignment,
+ booth_assignment: final_officer_assignment.booth_assignment,
+ date: daily_recount.date,
+ count: 100)
+ 33.times { create(:poll_voter, :valid_document,
+ poll: poll,
+ booth_assignment: final_officer_assignment.booth_assignment,
+ created_at: daily_recount.date) }
+
+ visit new_officing_poll_final_recount_path(poll)
+ within("#poll_final_recount_#{final_recount.id}") do
+ expect(page).to have_content(I18n.l(final_recount.date.to_date, format: :long))
+ expect(page).to have_content(final_officer_assignment.booth_assignment.booth.name)
+ expect(page).to have_content('500')
+ expect(page).to have_content('100')
+ expect(page).to have_content('33')
+ end
+
+ end
end
\ No newline at end of file