Discern customer tasks and active tasks
This commit is contained in:
parent
856d22b617
commit
2e5985b32b
26
stoptime.rb
26
stoptime.rb
|
@ -895,18 +895,22 @@ module StopTime::Controllers
|
||||||
# {Views#overview}.
|
# {Views#overview}.
|
||||||
def get
|
def get
|
||||||
@tasks = {}
|
@tasks = {}
|
||||||
@tasks_summary = {}
|
|
||||||
@task_count = 0
|
@task_count = 0
|
||||||
|
@active_tasks = {}
|
||||||
|
@active_tasks_summary = {}
|
||||||
Customer.all.each do |customer|
|
Customer.all.each do |customer|
|
||||||
tasks = customer.active_tasks
|
tasks = customer.unbilled_tasks
|
||||||
@tasks[customer] = 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
|
@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
|
end
|
||||||
render :overview
|
render :overview
|
||||||
end
|
end
|
||||||
|
@ -1789,7 +1793,7 @@ module StopTime::Views
|
||||||
col.task
|
col.task
|
||||||
col.hours
|
col.hours
|
||||||
col.amount
|
col.amount
|
||||||
@tasks[customer].each do |task|
|
@active_tasks[customer].each do |task|
|
||||||
tr do
|
tr do
|
||||||
summary = task.summary
|
summary = task.summary
|
||||||
td do
|
td do
|
||||||
|
@ -1803,8 +1807,8 @@ module StopTime::Views
|
||||||
end
|
end
|
||||||
tr do
|
tr do
|
||||||
td { b "Total" }
|
td { b "Total" }
|
||||||
td.text_right { "%.2fh" % @tasks_summary[customer][0] }
|
td.text_right { "%.2fh" % @active_tasks_summary[customer][0] }
|
||||||
td.text_right { "€ %.2f" % @tasks_summary[customer][1] }
|
td.text_right { "€ %.2f" % @active_tasks_summary[customer][1] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue