Class: Eboshi::Budget

Inherits:
ApplicationRecord show all
Defined in:
app/models/eboshi/budget.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#unbilled_invoiceObject

Returns the value of attribute unbilled_invoice.



10
11
12
# File 'app/models/eboshi/budget.rb', line 10

def unbilled_invoice
  @unbilled_invoice
end

Instance Method Details

#name_and_totalObject



20
21
22
# File 'app/models/eboshi/budget.rb', line 20

def name_and_total
  [name, total.to_s].join(" - $")
end

#over?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/eboshi/budget.rb', line 28

def over?
  used > total
end

#remainingObject



16
17
18
# File 'app/models/eboshi/budget.rb', line 16

def remaining
  total - used
end

#under?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/eboshi/budget.rb', line 24

def under?
  used < total
end

#usedObject



12
13
14
# File 'app/models/eboshi/budget.rb', line 12

def used
  invoices.to_a.sum(&:total) + unbilled_invoice.try(:total).to_f
end