Class: FreshBooks::Invoice
- Inherits:
-
Object
- Object
- FreshBooks::Invoice
- Defined in:
- lib/freshbooks/extensions/invoice.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
- #[](m) ⇒ Object
- #[]=(m, v) ⇒ Object
- #client ⇒ Object
- #old_brackets ⇒ Object
- #old_brackets_equal ⇒ Object
- #open? ⇒ Boolean
- #owed_amount ⇒ Object
- #paid_amount ⇒ Object
- #payments ⇒ Object
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
25 26 27 |
# File 'lib/freshbooks/extensions/invoice.rb', line 25 def number @number end |
Class Method Details
.members ⇒ Object
47 48 49 |
# File 'lib/freshbooks/extensions/invoice.rb', line 47 def members old_members + ['number'] end |
.old_members ⇒ Object
46 |
# File 'lib/freshbooks/extensions/invoice.rb', line 46 alias_method :old_members, :members |
Instance Method Details
#[](m) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/freshbooks/extensions/invoice.rb', line 28 def [](m) if m.to_s == 'number' self.number else old_brackets(m) end end |
#[]=(m, v) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/freshbooks/extensions/invoice.rb', line 37 def []=(m, v) if m.to_s == 'number' self.number = v else old_brackets_equal(m, v) end end |
#client ⇒ Object
9 10 11 |
# File 'lib/freshbooks/extensions/invoice.rb', line 9 def client Client.get(client_id) end |
#old_brackets ⇒ Object
27 |
# File 'lib/freshbooks/extensions/invoice.rb', line 27 alias_method :old_brackets, :[] |
#old_brackets_equal ⇒ Object
36 |
# File 'lib/freshbooks/extensions/invoice.rb', line 36 alias_method :old_brackets_equal, :[]= |
#open? ⇒ Boolean
5 6 7 |
# File 'lib/freshbooks/extensions/invoice.rb', line 5 def open? !%w[draft paid].include?(status) end |
#owed_amount ⇒ Object
21 22 23 |
# File 'lib/freshbooks/extensions/invoice.rb', line 21 def owed_amount amount - paid_amount end |
#paid_amount ⇒ Object
17 18 19 |
# File 'lib/freshbooks/extensions/invoice.rb', line 17 def paid_amount payments.inject(0) { |sum, pay| sum + pay.amount } end |
#payments ⇒ Object
13 14 15 |
# File 'lib/freshbooks/extensions/invoice.rb', line 13 def payments Payment.list('invoice_id' => invoice_id) || [] end |