Class: Receipts::Invoice

Inherits:
Prawn::Document
  • Object
show all
Defined in:
lib/receipts/invoice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Invoice

Returns a new instance of Invoice.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/receipts/invoice.rb', line 8

def initialize(attributes)
  @attributes  = attributes
  @id          = attributes.fetch(:id)
  @company     = attributes.fetch(:company)
  @line_items  = attributes.fetch(:line_items)
  @custom_font = attributes.fetch(:font, {})
  @message     = attributes.fetch(:message) { default_message }
  @subheading  = attributes.fetch(:subheading) { default_subheading }
  @bill_to     = Array(attributes.fetch(:bill_to)).join("\n")
  @issue_date  = attributes.fetch(:issue_date)
  @due_date    = attributes.fetch(:due_date)
  @status      = attributes.fetch(:status)

  super(margin: 0)

  setup_fonts if custom_font.any?
  generate
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def attributes
  @attributes
end

#bill_toObject (readonly)

Returns the value of attribute bill_to.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def bill_to
  @bill_to
end

#companyObject (readonly)

Returns the value of attribute company.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def company
  @company
end

#custom_fontObject (readonly)

Returns the value of attribute custom_font.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def custom_font
  @custom_font
end

#due_dateObject (readonly)

Returns the value of attribute due_date.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def due_date
  @due_date
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def id
  @id
end

#issue_dateObject (readonly)

Returns the value of attribute issue_date.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def issue_date
  @issue_date
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def line_items
  @line_items
end

#logoObject (readonly)

Returns the value of attribute logo.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def 
  @logo
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def message
  @message
end

#productObject (readonly)

Returns the value of attribute product.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def product
  @product
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def status
  @status
end

#subheadingObject (readonly)

Returns the value of attribute subheading.



6
7
8
# File 'lib/receipts/invoice.rb', line 6

def subheading
  @subheading
end