From 35462ed0ddc64f88fee34e0ec3fb800757a482e2 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 1 Nov 2014 17:47:13 +0100 Subject: [PATCH] Show a total of unbilled time and earned money (excl. VAT) per customer --- stoptime.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 063dbae..379bb70 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -759,10 +759,17 @@ module StopTime::Controllers # Views#overview. def get @tasks = {} + @tasks_summary = {} @task_count = 0 Customer.all.each do |customer| tasks = customer.active_tasks @tasks[customer] = tasks + @tasks_summary[customer] = tasks.inject([0.0, 0.0]) do |summ, task| + task_summ = task.summary + summ[0] += task_summ[0] + summ[1] += task_summ[2] + summ + end @task_count += tasks.count end render :overview @@ -1614,6 +1621,11 @@ module StopTime::Views td.text_right { "€ %.2f" % summary[2] } end end + tr do + td { b "Total" } + td.text_right { "%.2fh" % @tasks_summary[customer][0] } + td.text_right { "€ %.2f" % @tasks_summary[customer][1] } + end end end end