Round total time of tasks to two decimals
This fixes misrepresentation errors. This occus for example when a task has a length that would be represented using a floating point number that has more than 2 decimals. For example: a task of length 59 minutes (i.e. 0.9833333333333333... hour) is shown on the invoice as having a length of 0.98 hours while in calculations still the unrounded task length is used. When a hourly rate of €100 pe rhour is defined, the invoice will show: 0.98h x €100/h = €98.33. which is confusing and although correct given maximal accurancy, it will obviously not be accepted by book keeping programs.
This commit is contained in:
parent
e61fa8e3cc
commit
97b6098bcd
|
@ -344,9 +344,10 @@ module StopTime::Models
|
|||
belongs_to :task
|
||||
has_one :customer, :through => :task
|
||||
|
||||
# Returns the total amount of time, the duration, in hours.
|
||||
# Returns the total amount of time, the duration, in hours (up to
|
||||
# 2 decimals only!).
|
||||
def hours_total
|
||||
(self.end - self.start) / 1.hour
|
||||
((self.end - self.start) / 1.hour).round(2)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue