Sha256: 70760ec318f528a86e00ff773558f443ae234c8b2f5a391f536ccb2976c131d1

Contents?: true

Size: 958 Bytes

Versions: 11

Compression:

Stored size: 958 Bytes

Contents

module Payday
  # Represents a line item in an invoice.
  #
  # +quantity+ and +price+ are written to be pretty picky, primarily because if we're not picky about what values are set to
  # 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+.
  class LineItem
    include LineItemable
    
    attr_accessor :description, :quantity, :price
    
    # Initializes a new LineItem
    def initialize(options = {})
      self.quantity = options[:quantity] || "1"
      self.price = options[:price] || "0.00"
      self.description = options[:description] || ""
    end
    
    # Sets the quantity of this {LineItem}
    def quantity=(value)
      @quantity = BigDecimal.new(value.to_s)
    end
    
    # Sets the price for this {LineItem}
    def price=(value)
      @price = BigDecimal.new(value.to_s)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
payday-1.0.2 lib/payday/line_item.rb
payday-1.0.1 lib/payday/line_item.rb
payday-1.0.0 lib/payday/line_item.rb
payday-1.0.0beta8 lib/payday/line_item.rb
payday-1.0.0beta7 lib/payday/line_item.rb
payday-1.0.0beta6 lib/payday/line_item.rb
payday-1.0.0beta5 lib/payday/line_item.rb
payday-1.0.0beta4 lib/payday/line_item.rb
payday-1.0.0beta3 lib/payday/line_item.rb
payday-1.0.0beta2 lib/payday/line_item.rb
payday-1.0.0beta1 lib/payday/line_item.rb