Class: DailyPassReport::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ Row

Returns a new instance of Row.



34
35
36
37
38
39
40
41
42
# File 'app/models/daily_pass_report.rb', line 34

def initialize(items)
  @order = items.first.order
  @id = items.first.order.id
  @pass_type = items.first.product.pass_type.name
  @quantity = items.length
  @total = DailyPassReport.number_to_currency(items.sum(&:price).to_f/100)
  @person = items.first.order.person
  @person_id = items.first.order.person.id
end

Instance Attribute Details

#detailsObject

Returns the value of attribute details.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def details
  @details
end

#idObject

Returns the value of attribute id.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def id
  @id
end

#orderObject

Returns the value of attribute order.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def order
  @order
end

#pass_typeObject

Returns the value of attribute pass_type.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def pass_type
  @pass_type
end

#personObject

Returns the value of attribute person.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def person
  @person
end

#person_idObject

Returns the value of attribute person_id.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def person_id
  @person_id
end

#quantityObject

Returns the value of attribute quantity.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def quantity
  @quantity
end

#totalObject

Returns the value of attribute total.



33
34
35
# File 'app/models/daily_pass_report.rb', line 33

def total
  @total
end

Instance Method Details

#calculate_totalObject



44
45
46
# File 'app/models/daily_pass_report.rb', line 44

def calculate_total
  DailyPassReport.number_to_currency(@order.passes.sum(&:price).to_f/100)
end