Class: PassesReport::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ Row

Returns a new instance of Row.



91
92
93
94
95
96
97
98
99
100
# File 'app/models/passes_report.rb', line 91

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

Instance Attribute Details

#discountedObject

Returns the value of attribute discounted.



89
90
91
# File 'app/models/passes_report.rb', line 89

def discounted
  @discounted
end

#grossObject

Returns the value of attribute gross.



89
90
91
# File 'app/models/passes_report.rb', line 89

def gross
  @gross
end

#orderObject

Returns the value of attribute order.



89
90
91
# File 'app/models/passes_report.rb', line 89

def order
  @order
end

#original_priceObject

Returns the value of attribute original_price.



89
90
91
# File 'app/models/passes_report.rb', line 89

def original_price
  @original_price
end

#pass_typeObject

Returns the value of attribute pass_type.



89
90
91
# File 'app/models/passes_report.rb', line 89

def pass_type
  @pass_type
end

#showObject

Returns the value of attribute show.



89
90
91
# File 'app/models/passes_report.rb', line 89

def show
  @show
end

#ticket_countObject

Returns the value of attribute ticket_count.



89
90
91
# File 'app/models/passes_report.rb', line 89

def ticket_count
  @ticket_count
end