class Rubill::Invoice

Public Class Methods

line_item(amount, description, item_id) click to toggle source
# File lib/rubill/entities/invoice.rb, line 35
def self.line_item(amount, description, item_id)
  {
    entity: "InvoiceLineItem",
    quantity: 1,
    itemId: item_id,
    # must to_f amount otherwise decimal will be converted to string in JSON
    price: amount.to_f,
    description: description,
  }
end

Public Instance Methods

amount() click to toggle source
# File lib/rubill/entities/invoice.rb, line 7
def amount
  remote_record[:amount]
end
amount_due() click to toggle source
# File lib/rubill/entities/invoice.rb, line 31
def amount_due
  remote_record[:amountDue]
end
amount_paid() click to toggle source
# File lib/rubill/entities/invoice.rb, line 3
def amount_paid
  amount - amount_due
end
send_email(headers = {}, body = nil) click to toggle source

Send email about invoice to customer

Bill.com Documentation: developer.bill.com/hc/en-us/articles/208197236

Possible header keys:

* fromUserId
* toEmailAddresses
* ccMe
* subject

Will use headers and body from the Default Email Template if not otherwise specified

# File lib/rubill/entities/invoice.rb, line 25
def send_email(headers = {}, body = nil)
  options = { headers: headers, content: body ? { body: body } : {}}

  Query.execute("/SendInvoice.json", { invoiceId: id }.merge(options))
end