diff app/models/.svn/text-base/version.rb.svn-base @ 23:ca82a3468d27 cannam

* Merge SVN update from default
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 24 Sep 2010 14:17:42 +0100
parents 40f7cfd4df19
children af80e5618e9b
line wrap: on
line diff
--- a/app/models/.svn/text-base/version.rb.svn-base	Thu Sep 23 16:19:06 2010 +0100
+++ b/app/models/.svn/text-base/version.rb.svn-base	Fri Sep 24 14:17:42 2010 +0100
@@ -73,6 +73,18 @@
   def completed?
     effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
   end
+
+  def behind_schedule?
+    if completed_pourcent == 100
+      return false
+    elsif due_date && fixed_issues.present? && fixed_issues.minimum('start_date') # TODO: should use #start_date but that method is wrong...
+      start_date = fixed_issues.minimum('start_date')
+      done_date = start_date + ((due_date - start_date+1)* completed_pourcent/100).floor
+      return done_date <= Date.today
+    else
+      false # No issues so it's not late
+    end
+  end
   
   # Returns the completion percentage of this version based on the amount of open/closed issues
   # and the time spent on the open issues.
@@ -123,6 +135,10 @@
   end
   
   def to_s; name end
+
+  def to_s_with_project
+    "#{project} - #{name}"
+  end
   
   # Versions are sorted by effective_date and "Project Name - Version name"
   # Those with no effective_date are at the end, sorted by "Project Name - Version name"