Sha256: a50d4736dacde7ac2779ce7e9424a34ea023a9ef58fd9b461bcaa94f159c861f

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

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, :display_quantity, :display_price, :price

    # Initializes a new LineItem
    def initialize(options = {})
      self.quantity = options[:quantity] || "1"
      self.display_quantity = options[:display_quantity]
      self.display_price = options[:display_price]
      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

2 entries across 2 versions & 1 rubygems

Version Path
payday-1.1.5 lib/payday/line_item.rb
payday-1.1.4 lib/payday/line_item.rb