Class: Payday::Invoice

Inherits:
Object
  • Object
show all
Includes:
Invoiceable
Defined in:
lib/payday/invoice.rb

Overview

Basically just an invoice. Stick a ton of line items in it, add some details, and then render it out!

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Invoiceable

#each_detail, #overdue?, #paid?, #refunded?, #render_pdf, #render_pdf_to_file, #shipping, #subtotal, #tax, #total

Constructor Details

#initialize(options = {}) ⇒ Invoice

rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/MethodLength rubocop:todo Metrics/AbcSize



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/payday/invoice.rb', line 18

def initialize(options = {}) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
  self.invoice_number = options[:invoice_number] || nil
  self.bill_to = options[:bill_to] || nil
  self.ship_to = options[:ship_to] || nil
  self.notes = options[:notes] || nil
  self.line_items = options[:line_items] || []
  self.shipping_rate = options[:shipping_rate] || nil
  self.shipping_description = options[:shipping_description] || nil
  self.tax_rate = options[:tax_rate] || nil
  self.tax_description = options[:tax_description] || nil
  self.due_at = options[:due_at] || nil
  self.paid_at = options[:paid_at] || nil
  self.refunded_at = options[:refunded_at] || nil
  self.currency = options[:currency] || nil
  self.invoice_details = options[:invoice_details] || []
  self.invoice_date = options[:invoice_date] || nil
end

Instance Attribute Details

#bill_toObject

Returns the value of attribute bill_to.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def bill_to
  @bill_to
end

#currencyObject

Returns the value of attribute currency.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def currency
  @currency
end

#due_atObject

Returns the value of attribute due_at.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def due_at
  @due_at
end

#invoice_dateObject

Returns the value of attribute invoice_date.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def invoice_date
  @invoice_date
end

#invoice_detailsObject

Returns the value of attribute invoice_details.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def invoice_details
  @invoice_details
end

#invoice_numberObject

Returns the value of attribute invoice_number.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def invoice_number
  @invoice_number
end

#line_itemsObject

Returns the value of attribute line_items.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def line_items
  @line_items
end

#notesObject

Returns the value of attribute notes.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def notes
  @notes
end

Returns the value of attribute paid_at.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def paid_at
  @paid_at
end

#refunded_atObject

Returns the value of attribute refunded_at.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def refunded_at
  @refunded_at
end

#ship_toObject

Returns the value of attribute ship_to.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def ship_to
  @ship_to
end

#shipping_descriptionObject

Returns the value of attribute shipping_description.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def shipping_description
  @shipping_description
end

#shipping_rateObject

Returns the value of attribute shipping_rate.



13
14
15
# File 'lib/payday/invoice.rb', line 13

def shipping_rate
  @shipping_rate
end

#tax_descriptionObject

Returns the value of attribute tax_description.



10
11
12
# File 'lib/payday/invoice.rb', line 10

def tax_description
  @tax_description
end

#tax_rateObject

Returns the value of attribute tax_rate.



13
14
15
# File 'lib/payday/invoice.rb', line 13

def tax_rate
  @tax_rate
end

Instance Method Details

#add_line_item(options = {}) ⇒ Object

Adds a line item



52
53
54
# File 'lib/payday/invoice.rb', line 52

def add_line_item(options = {})
  line_items << Payday::LineItem.new(options)
end