diff --git a/app/models/version.rb b/app/models/version.rb
index e379f4b..59189a9 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -5,12 +5,12 @@
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
@@ -25,11 +25,11 @@ class Version < ActiveRecord::Base
   validates_uniqueness_of :name, :scope => [:project_id]
   validates_length_of :name, :maximum => 60
   validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => 'activerecord_error_not_a_date', :allow_nil => true
-  
+
   def start_date
     effective_date
   end
-  
+
   def due_date
     effective_date
   end
@@ -48,17 +48,18 @@ class Version < ActiveRecord::Base
   def completed?
     effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
   end
-  
+
   def completed_pourcent
     if fixed_issues.count == 0
       0
     elsif open_issues_count == 0
       100
     else
-      (closed_issues_count * 100 + Issue.sum('done_ratio', :include => 'status', :conditions => ["fixed_version_id = ? AND is_closed = ?", id, false]).to_f) / fixed_issues.count
+#      (closed_issues_count * 100 + Issue.sum('done_ratio', :include => 'status', :conditions => ["fixed_version_id = ? AND is_closed = ?", id, false]).to_f) / fixed_issues.count
+      calculate_percent_from_hours
     end
   end
-  
+
   def closed_pourcent
     if fixed_issues.count == 0
       0
@@ -71,7 +72,7 @@ class Version < ActiveRecord::Base
   def overdue?
     effective_date && (effective_date < Date.today) && (open_issues_count > 0)
   end
-  
+
   def open_issues_count
     @open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
   end
@@ -79,16 +80,15 @@ class Version < ActiveRecord::Base
   def closed_issues_count
     @closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
   end
-  
+
   def wiki_page
     if project.wiki && !wiki_page_title.blank?
       @wiki_page ||= project.wiki.find_page(wiki_page_title)
     end
     @wiki_page
   end
-  
+
   def to_s; name end
-  
   # Versions are sorted by effective_date and name
   # Those with no effective_date are at the end, sorted by name
   def <=>(version)
@@ -98,9 +98,36 @@ class Version < ActiveRecord::Base
       version.effective_date ? 1 : (self.name <=> version.name)
     end
   end
-  
+
 private
   def check_integrity
     raise "Can't delete version" if self.fixed_issues.find(:first)
   end
+
+  # Calculates the % complete on a project based off the total esimated
+  # time left on the issues divided by the total time
+  def calculate_percent_from_hours
+    spent = 0
+    total = 0
+    Issue.find(:all, :include => 'status', :conditions => ["fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", id, false]).each do |i|
+      unless i.estimated_hours.nil?
+        spent += i.estimated_hours * i.done_ratio
+        total += i.estimated_hours
+      end
+    end
+
+    Issue.find(:all, :conditions => ["fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", id, true], :include => :status).each do |i|
+      unless i.estimated_hours.nil?
+        spent += i.estimated_hours * 100
+        total += i.estimated_hours
+      end
+    end
+
+    if spent == 0 and total == 0
+      # Redmine default
+      return (closed_issues_count * 100 + Issue.sum('done_ratio', :include => 'status', :conditions => ["fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", id, false]).to_f) / fixed_issues.count
+    else
+      return spent / total  
+    end
+  end
 end
