Class: Payday::LineItem

Inherits:
Object
  • Object
show all
Includes:
LineItemable
Defined in:
lib/payday/line_item.rb

Overview

Represents a line item in an invoice.

rubocop:todo Layout/LineLength quantity and price are written to be pretty picky, primarily because if we’re not picky about what values are set to rubocop:enable Layout/LineLength them your invoice math could get pretty messed up. It’s recommended that both values be set to BigDecimal values. Otherwise, we’ll do our best to convert the set values to a BigDecimal.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LineItemable

#amount

Constructor Details

#initialize(options = {}) ⇒ LineItem

Initializes a new LineItem



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/payday/line_item.rb', line 20

def initialize(options = {})
  if options[:predefined_amount]
    self.predefined_amount = options[:predefined_amount]
  else
    self.quantity = options[:quantity] || '1'
    self.display_quantity = options[:display_quantity]
    self.display_price = options[:display_price]
    self.price = options[:price] || '0.00'
  end
  self.description = options[:description] || ''
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



16
17
18
# File 'lib/payday/line_item.rb', line 16

def description
  @description
end

#display_priceObject

Returns the value of attribute display_price.



16
17
18
# File 'lib/payday/line_item.rb', line 16

def display_price
  @display_price
end

#display_quantityObject

Returns the value of attribute display_quantity.



16
17
18
# File 'lib/payday/line_item.rb', line 16

def display_quantity
  @display_quantity
end

#predefined_amountObject

Returns the value of attribute predefined_amount.



17
18
19
# File 'lib/payday/line_item.rb', line 17

def predefined_amount
  @predefined_amount
end

#priceObject

Returns the value of attribute price.



17
18
19
# File 'lib/payday/line_item.rb', line 17

def price
  @price
end

#quantityObject

Returns the value of attribute quantity.



17
18
19
# File 'lib/payday/line_item.rb', line 17

def quantity
  @quantity
end