Sha256: 7de96322793445cd27cb36d38cf1ba84f24efcaf10997c731cdd30e67a6a571a

Contents?: true

Size: 1.06 KB

Versions: 14

Compression:

Stored size: 1.06 KB

Contents

module Ticket::Transfers
  extend ActiveSupport::Concern

  def sell_to(buyer, time=Time.now)
    begin
      self.buyer = buyer
      self.sold_at = time
      self.sell!
    rescue Transitions::InvalidTransition
      return false
    end
  end
  
  #
  # Deals solely with changing the buyer.  Pricing should be handled in exchange_prices_from
  #
  def exchange_to(buyer, time=Time.now)
    begin
      self.buyer = buyer
      self.sold_at = time
      self.exchange!
    rescue Transitions::InvalidTransition => e
      puts e
      return false
    end
  end

  def comp_to(buyer, time=Time.now)
    begin
      self.buyer = buyer
      self.sold_price = 0
      self.sold_at = time
      self.comp!
    rescue Transitions::InvalidTransition => e
      puts e
      return false
    end
  end

  def return!(and_return_to_inventory = true)
    and_return_to_inventory ? return_to_inventory! : return_off_sale!
    remove_from_cart
    self.buyer = nil
    self.sold_at = nil
    self.buyer_id = nil
    Rails.logger.debug(self.inspect)
    self.reset_price!
    save
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.15 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.12 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.11 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.10 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.9 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.8 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.7 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.6 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.5 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.4 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.3 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.2 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre.1 app/models/ticket/transfers.rb
artfully_ose-1.2.0.pre app/models/ticket/transfers.rb