diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb
index 3a921a0d9..65a6deac5 100644
--- a/app/controllers/officing/results_controller.rb
+++ b/app/controllers/officing/results_controller.rb
@@ -28,6 +28,7 @@ class Officing::ResultsController < Officing::BaseController
where(date: index_params[:date])
@whites = ::Poll::WhiteResult.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date]).sum(:amount)
@nulls = ::Poll::NullResult.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date]).sum(:amount)
+ @total = ::Poll::TotalResult.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date]).sum(:amount)
end
end
@@ -70,6 +71,7 @@ class Officing::ResultsController < Officing::BaseController
build_white_results
build_null_results
+ build_total_results
end
def build_white_results
@@ -96,6 +98,18 @@ class Officing::ResultsController < Officing::BaseController
end
end
+ def build_total_results
+ if results_params[:total].present?
+ total_result = ::Poll::TotalResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
+ date: results_params[:date])
+ total_result.officer_assignment_id = @officer_assignment.id
+ total_result.amount = results_params[:total].to_i
+ total_result.author = current_user
+ total_result.origin = 'booth'
+ @results << total_result
+ end
+ end
+
def go_back_to_new(alert = nil)
params[:d] = results_params[:date]
params[:oa] = results_params[:officer_assignment_id]
@@ -132,7 +146,7 @@ class Officing::ResultsController < Officing::BaseController
end
def results_params
- params.permit(:officer_assignment_id, :date, :questions, :whites, :nulls)
+ params.permit(:officer_assignment_id, :date, :questions, :whites, :nulls, :total)
end
def index_params
diff --git a/app/views/admin/poll/results/index.html.erb b/app/views/admin/poll/results/index.html.erb
index 9d3a6abef..64a93aa10 100644
--- a/app/views/admin/poll/results/index.html.erb
+++ b/app/views/admin/poll/results/index.html.erb
@@ -14,11 +14,13 @@
| <%= t("admin.results.index.table_whites") %> |
<%= t("admin.results.index.table_nulls") %> |
+ <%= t("admin.results.index.table_total") %> |
| <%= @poll.white_results.sum(:amount) %> |
<%= @poll.null_results.sum(:amount) %> |
+ <%= @poll.total_results.sum(:amount) %> |
@@ -47,4 +49,4 @@
<% end %>
<% end %>
-
\ No newline at end of file
+
diff --git a/app/views/officing/results/index.html.erb b/app/views/officing/results/index.html.erb
index 70da6d8d3..3b14e3c97 100644
--- a/app/views/officing/results/index.html.erb
+++ b/app/views/officing/results/index.html.erb
@@ -16,12 +16,14 @@
| <%= t("officing.results.index.table_whites") %> |
<%= t("officing.results.index.table_nulls") %> |
+ <%= t("officing.results.index.table_total") %> |
| <%= @whites %> |
<%= @nulls %> |
+ <%= @total %> |
@@ -54,4 +56,4 @@
<%= t("officing.results.index.no_results") %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/officing/results/new.html.erb b/app/views/officing/results/new.html.erb
index 74af8af10..fa5f449fb 100644
--- a/app/views/officing/results/new.html.erb
+++ b/app/views/officing/results/new.html.erb
@@ -47,6 +47,11 @@
<%= t("officing.results.new.ballots_null") %>
<%= text_field_tag :nulls, params[:nulls].presence, placeholder: "0" %>
+
+
+
<%= t("officing.results.new.ballots_total") %>
+ <%= text_field_tag :total, params[:total].presence, placeholder: "0" %>
+
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index 3f1b12189..91b493ffa 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -612,6 +612,7 @@ en:
no_results: "There are no results"
table_whites: "Blank ballots"
table_nulls: "Invalid ballots"
+ table_total: "Total ballots"
table_answer: Answer
table_votes: Votes
booths:
diff --git a/config/locales/en/officing.yml b/config/locales/en/officing.yml
index 6dc0d976b..72b3812ea 100644
--- a/config/locales/en/officing.yml
+++ b/config/locales/en/officing.yml
@@ -31,6 +31,7 @@ en:
select_date: "Select date"
ballots_white: "Blank ballots"
ballots_null: "Invalid ballots"
+ ballots_total: "Total ballots"
submit: "Save"
results_list: "Your results"
see_results: "See results"
@@ -41,6 +42,7 @@ en:
table_votes: Votes
table_whites: "Blank ballots"
table_nulls: "Invalid ballots"
+ table_total: "Total ballots"
residence:
flash:
create: "Document verified with Census"
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index 9872baa0d..2db094999 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -612,6 +612,7 @@ es:
no_results: "No hay resultados"
table_whites: Papeletas en blanco
table_nulls: Papeletas nulas
+ table_total: Papeletas totales
table_answer: Respuesta
table_votes: Votos
booths:
diff --git a/config/locales/es/officing.yml b/config/locales/es/officing.yml
index f7d070eb3..81dd70492 100644
--- a/config/locales/es/officing.yml
+++ b/config/locales/es/officing.yml
@@ -31,6 +31,7 @@ es:
select_date: "Elige día"
ballots_white: "Papeletas en blanco"
ballots_null: "Papeletas nulas"
+ ballots_total: "Papeletas totales"
submit: "Guardar"
results_list: "Tus resultados"
see_results: "Ver resultados"
@@ -41,6 +42,7 @@ es:
table_votes: Votos
table_whites: Papeletas en blanco
table_nulls: Papeletas nulas
+ table_total: Papeletas totales
residence:
flash:
create: "Documento verificado con el Padrón"
diff --git a/spec/features/officing/results_spec.rb b/spec/features/officing/results_spec.rb
index 1de3f4bdb..676ac7d68 100644
--- a/spec/features/officing/results_spec.rb
+++ b/spec/features/officing/results_spec.rb
@@ -65,6 +65,7 @@ feature 'Officing Results' do
fill_in "whites", with: '66'
fill_in "nulls", with: '77'
+ fill_in "total", with: '88'
click_button 'Save'
@@ -101,6 +102,7 @@ feature 'Officing Results' do
fill_in "questions[#{@question_1.id}][1]", with: '200'
fill_in "whites", with: '6'
fill_in "nulls", with: '7'
+ fill_in "total", with: '8'
click_button 'Save'
@@ -113,6 +115,7 @@ feature 'Officing Results' do
expect(page).to_not have_content('7777')
within("#white_results") { expect(page).to have_content('6') }
within("#null_results") { expect(page).to have_content('7') }
+ within("#total_results") { expect(page).to have_content('8') }
within("#question_#{@question_1.id}_0_result") { expect(page).to have_content('5555') }
within("#question_#{@question_1.id}_1_result") { expect(page).to have_content('200') }
end
@@ -134,6 +137,11 @@ feature 'Officing Results' do
booth_assignment: @officer_assignment.booth_assignment,
date: @poll.ends_at,
amount: 44)
+ total_result = create(:poll_total_result,
+ officer_assignment: @officer_assignment,
+ booth_assignment: @officer_assignment.booth_assignment,
+ date: @poll.ends_at,
+ amount: 66)
visit officing_poll_results_path(@poll,
date: I18n.l(@poll.ends_at.to_date),
@@ -154,6 +162,7 @@ feature 'Officing Results' do
within('#white_results') { expect(page).to have_content('21') }
within('#null_results') { expect(page).to have_content('44') }
+ within('#total_results') { expect(page).to have_content('66') }
end
-end
\ No newline at end of file
+end