Fix invoice period calculation

Currently, the end time of the period was always the creation time of
the invoice (due to the initialisation), as it is generally by definition
later than any of the task periods.
This commit is contained in:
Paul van Tilburg 2014-10-28 10:02:11 +01:00
parent 8d8eba1e18
commit b94d5ccff2
1 changed files with 2 additions and 3 deletions

View File

@ -431,10 +431,9 @@ module StopTime::Models
# Returns the invoice period based on the contained tasks (Array of Time).
# See also Task#bill_period.
def period
# FIXME: maybe should be updated_at?
p = [created_at, created_at]
return p if tasks.empty?
return [created_at, created_at] if tasks.empty?
p = [DateTime.now, DateTime.new(0)]
tasks.each do |task|
tp = task.bill_period
p[0] = tp[0] if tp[0] < p[0]