Discern customer tasks and active tasks

This commit is contained in:
Paul van Tilburg 2014-11-08 12:06:19 +01:00
parent 856d22b617
commit 2e5985b32b
1 changed files with 15 additions and 11 deletions

View File

@ -895,18 +895,22 @@ module StopTime::Controllers
# {Views#overview}.
def get
@tasks = {}
@tasks_summary = {}
@task_count = 0
@active_tasks = {}
@active_tasks_summary = {}
Customer.all.each do |customer|
tasks = customer.active_tasks
tasks = customer.unbilled_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
active_tasks = customer.active_tasks
@active_tasks[customer] = active_tasks
@active_tasks_summary[customer] =
active_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
end
render :overview
end
@ -1789,7 +1793,7 @@ module StopTime::Views
col.task
col.hours
col.amount
@tasks[customer].each do |task|
@active_tasks[customer].each do |task|
tr do
summary = task.summary
td do
@ -1803,8 +1807,8 @@ module StopTime::Views
end
tr do
td { b "Total" }
td.text_right { "%.2fh" % @tasks_summary[customer][0] }
td.text_right { "€ %.2f" % @tasks_summary[customer][1] }
td.text_right { "%.2fh" % @active_tasks_summary[customer][0] }
td.text_right { "€ %.2f" % @active_tasks_summary[customer][1] }
end
end
end