Show a total of unbilled time and earned money (excl. VAT) per customer

This commit is contained in:
Paul van Tilburg 2014-11-01 17:47:13 +01:00
parent d1ac6ff979
commit 35462ed0dd
1 changed files with 12 additions and 0 deletions

View File

@ -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