Class: DiscountsReport::Row

Inherits:
Object
  • Object
show all
Defined in:
app/models/discounts_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ Row

Returns a new instance of Row.



60
61
62
63
64
65
66
67
68
69
# File 'app/models/discounts_report.rb', line 60

def initialize(order)
  self.order = order
  self.discount_code  = order.items.first.discount.code
  self.show           = order.items.first.show
  self.original_price = order.items.inject(0) { |total, item| total + item.original_price }
  self.gross          = order.items.inject(0) { |total, item| total + item.price }
  self.discounted     = self.original_price - self.gross
  self.ticket_count   = order.items.length
  self.ticket_count   = self.ticket_count * -1 if !order.items.select(&:refund?).empty?
end

Instance Attribute Details

#discount_codeObject

Returns the value of attribute discount_code.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def discount_code
  @discount_code
end

#discountedObject

Returns the value of attribute discounted.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def discounted
  @discounted
end

#grossObject

Returns the value of attribute gross.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def gross
  @gross
end

#orderObject

Returns the value of attribute order.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def order
  @order
end

#original_priceObject

Returns the value of attribute original_price.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def original_price
  @original_price
end

#showObject

Returns the value of attribute show.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def show
  @show
end

#ticket_countObject

Returns the value of attribute ticket_count.



58
59
60
# File 'app/models/discounts_report.rb', line 58

def ticket_count
  @ticket_count
end