]> source.dussan.org Git - redmine.git/commitdiff
Round hours when reading TimeEntry attribute.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 24 Feb 2012 18:40:22 +0000 (18:40 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 24 Feb 2012 18:40:22 +0000 (18:40 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8980 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb

index caa1019e511b5fbfbe12981be36818329d8e7572..9266eb86f184cc606a0eda978bd205872be241fa 100644 (file)
@@ -89,6 +89,15 @@ class TimeEntry < ActiveRecord::Base
     write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
   end
 
+  def hours
+    h = read_attribute(:hours)
+    if h.is_a?(Float)
+      h.round(2)
+    else
+      h
+    end
+  end
+
   # tyear, tmonth, tweek assigned where setting spent_on attributes
   # these attributes make time aggregations easier
   def spent_on=(date)