Class: Eboshi::Work
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from LineItem
#<=>, #==, #checked?, #hours, #invoice_total, on_date, on_month, on_week, on_year, unbilled, #unbilled?, #user_name=
Class Method Details
.complete ⇒ Object
23
24
25
|
# File 'app/models/eboshi/work.rb', line 23
def self.complete
where("start <> finish")
end
|
.merge_from_ids(ids) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'app/models/eboshi/work.rb', line 27
def self.merge_from_ids(ids)
works = order(finish: :desc).find(ids)
hours = works.sum(&:hours)
notes = works.collect(&:notes).select(&:present?).join(' ')
works.first.update hours: hours, notes: notes
destroy ids[1..-1]
works.first
end
|
Instance Method Details
#clock_out ⇒ Object
57
58
59
|
# File 'app/models/eboshi/work.rb', line 57
def clock_out
update finish: Time.now
end
|
#hours=(total) ⇒ Object
53
54
55
|
# File 'app/models/eboshi/work.rb', line 53
def hours=(total)
update_attribute :finish, start + total.hours
end
|
#incomplete? ⇒ Boolean
61
62
63
|
# File 'app/models/eboshi/work.rb', line 61
def incomplete?
start >= finish
end
|
#to_adjustment! ⇒ Object
38
39
40
41
42
43
|
# File 'app/models/eboshi/work.rb', line 38
def to_adjustment!
self.type = "Eboshi::Adjustment"
self.rate = total
self.finish = start
save!
end
|
#total ⇒ Object
45
46
47
|
# File 'app/models/eboshi/work.rb', line 45
def total
(rate * hours).round(2)
end
|
#total=(value) ⇒ Object
49
50
51
|
# File 'app/models/eboshi/work.rb', line 49
def total=(value)
self.hours = value / rate
end
|