Class: MOCO::Invoice
Overview
Represents a MOCO invoice Provides methods for invoice-specific operations and associations
Instance Attribute Summary
Attributes inherited from BaseEntity
#attributes, #client
Instance Method Summary
collapse
Methods inherited from BaseEntity
#==, #association, #destroy, #eql?, #has_many, #hash, #id, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update
Instance Method Details
#company ⇒ Object
41
42
43
|
# File 'lib/moco/entities/invoice.rb', line 41
def company
association(:customer, "Company")
end
|
#expenses ⇒ Object
25
26
27
|
# File 'lib/moco/entities/invoice.rb', line 25
def expenses
client.get("invoices/#{id}/expenses")
end
|
#pdf ⇒ Object
13
14
15
|
# File 'lib/moco/entities/invoice.rb', line 13
def pdf
client.get("invoices/#{id}.pdf")
end
|
#project ⇒ Object
45
46
47
|
# File 'lib/moco/entities/invoice.rb', line 45
def project
association(:project)
end
|
#send_email(recipient:, subject:, text:, **options) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/moco/entities/invoice.rb', line 29
def send_email(recipient:, subject:, text:, **options)
payload = {
recipient:,
subject:,
text:
}.merge(options)
client.post("invoices/#{id}/send_email", payload)
self
end
|
#timesheet ⇒ Object
17
18
19
|
# File 'lib/moco/entities/invoice.rb', line 17
def timesheet
client.get("invoices/#{id}/timesheet")
end
|
#timesheet_pdf ⇒ Object
21
22
23
|
# File 'lib/moco/entities/invoice.rb', line 21
def timesheet_pdf
client.get("invoices/#{id}/timesheet.pdf")
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/moco/entities/invoice.rb', line 49
def to_s
"#{identifier} - #{title} (#{date})"
end
|
#update_status(status) ⇒ Object
Instance methods for invoice-specific operations
8
9
10
11
|
# File 'lib/moco/entities/invoice.rb', line 8
def update_status(status)
client.put("invoices/#{id}/update_status", { status: })
self
end
|