From b94d5ccff2b965d4bcf268043076f35561229b27 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 28 Oct 2014 10:02:11 +0100 Subject: [PATCH] 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. --- stoptime.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 87bf2fd..8ec427b 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -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]