From d1ac6ff9798f352ac96e01f60f4d4c48ae71fcc3 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 1 Nov 2014 17:45:16 +0100 Subject: [PATCH] Show only active tasks in the overview view Active tasks are unbilled tasks that are tasks that are either fixed cost or that have time entries that should be billed. --- stoptime.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index 04873ee..063dbae 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -222,6 +222,12 @@ module StopTime::Models def unbilled_tasks tasks.where("invoice_id IS NULL").order("name ASC") end + + # Returns a list of tasks that are active, i.e. that have not been + # billed and are either fixed cost or have some registered time. + def active_tasks + unbilled_tasks.select { |task| task.fixed_cost? or task.time_entries.present? } + end end # == The task class @@ -755,7 +761,7 @@ module StopTime::Controllers @tasks = {} @task_count = 0 Customer.all.each do |customer| - tasks = customer.unbilled_tasks.sort_by { |t| t.name } + tasks = customer.active_tasks @tasks[customer] = tasks @task_count += tasks.count end