Sha256: 7757b4c88dbc2b2227ed0d93dce7d56226662616c361534d741e6cb7f75474ac

Contents?: true

Size: 1.39 KB

Versions: 21

Compression:

Stored size: 1.39 KB

Contents

class DoorList
  attr_reader :show
  extend ::ArtfullyOseHelper

  def initialize(show)
    @show = show
  end

  def tickets
    @tickets ||= Ticket.where(:show_id => show.id).includes(:buyer, :section, :items => :order).select(&:committed?)
  end

  def items
    @items ||= tickets.map { |t| Item.new t, t.buyer }.sort
  end

  private

    class Item
      attr_accessor :ticket, :buyer, :special_instructions, :notes, :payment_method
      
      comma do
        buyer("First Name")             { |buyer| buyer.first_name }
        buyer("Last Name")              { |buyer| buyer.last_name }
        buyer("Email")                  { |buyer| buyer.email }
        ticket("Ticket Type")           { |ticket| ticket.ticket_type.name }
        ticket("Price")                 { |ticket| DoorList.number_as_cents ticket.sold_price }
        ticket("Special Instructions")  { |ticket| ticket.special_instructions }
        ticket("Notes")                 { |ticket| ticket.notes }
      end

      def initialize(ticket, buyer)
        self.ticket = ticket
        self.buyer = buyer
        self.special_instructions = ticket.special_instructions
        self.notes = ticket.notes
        self.payment_method = ticket.sold_item.try(:order).try(:payment_method)
      end

      def <=>(obj)
        (self.ticket.buyer.last_name.try(:downcase) || "") <=> (obj.ticket.buyer.last_name.try(:downcase) || "")
      end
    end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.23 app/models/door_list.rb
artfully_ose-1.2.0.pre.21 app/models/door_list.rb
artfully_ose-1.2.0.pre.20 app/models/door_list.rb
artfully_ose-1.2.0.pre.19 app/models/door_list.rb
artfully_ose-1.2.0.pre.18 app/models/door_list.rb
artfully_ose-1.2.0.pre.17 app/models/door_list.rb
artfully_ose-1.2.0.pre.16 app/models/door_list.rb
artfully_ose-1.2.0.pre.15 app/models/door_list.rb
artfully_ose-1.2.0.pre.12 app/models/door_list.rb
artfully_ose-1.2.0.pre.11 app/models/door_list.rb
artfully_ose-1.2.0.pre.10 app/models/door_list.rb
artfully_ose-1.2.0.pre.9 app/models/door_list.rb
artfully_ose-1.2.0.pre.8 app/models/door_list.rb
artfully_ose-1.2.0.pre.7 app/models/door_list.rb
artfully_ose-1.2.0.pre.6 app/models/door_list.rb
artfully_ose-1.2.0.pre.5 app/models/door_list.rb
artfully_ose-1.2.0.pre.4 app/models/door_list.rb
artfully_ose-1.2.0.pre.3 app/models/door_list.rb
artfully_ose-1.2.0.pre.2 app/models/door_list.rb
artfully_ose-1.2.0.pre.1 app/models/door_list.rb