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:
parent
8d8eba1e18
commit
b94d5ccff2
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue