Changed period logic, use update_at attribute if there are no time entries.
This commit is contained in:
parent
f0c7f59529
commit
e4e709bd72
11
stoptime.rb
11
stoptime.rb
|
@ -78,7 +78,7 @@ module StopTime::Models
|
||||||
def bill_period
|
def bill_period
|
||||||
bte = billable_time_entries
|
bte = billable_time_entries
|
||||||
if bte.empty?
|
if bte.empty?
|
||||||
[nil, nil]
|
[updated_at, updated_at]
|
||||||
else
|
else
|
||||||
[bte.first.start, bte.last.end]
|
[bte.first.start, bte.last.end]
|
||||||
end
|
end
|
||||||
|
@ -113,19 +113,18 @@ module StopTime::Models
|
||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
|
|
||||||
def summary
|
def summary
|
||||||
# FIXME: ensure that month is a DateTime/Time object.
|
|
||||||
summ = {}
|
summ = {}
|
||||||
tasks.each { |task| summ[task.name] = task.summary }
|
tasks.each { |task| summ[task.name] = task.summary }
|
||||||
return summ
|
return summ
|
||||||
end
|
end
|
||||||
|
|
||||||
def period
|
def period
|
||||||
p = [Time.now, Time.now]
|
return [updated_at, updated_at] if tasks.empty?
|
||||||
|
p = tasks.first.bill_period
|
||||||
tasks.each do |task|
|
tasks.each do |task|
|
||||||
tp = task.bill_period
|
tp = task.bill_period
|
||||||
p tp
|
p[0] = tp[0] if tp[0] < p[0]
|
||||||
p[0] = tp[0] if !tp[0].nil? and tp[0] < p[0]
|
p[1] = tp[1] if tp[1] > p[1]
|
||||||
p[1] = tp[1] if !tp[1].nil? and tp[1] > p[1]
|
|
||||||
end
|
end
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue