Class: DailyMembershipReport::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ Row

Returns a new instance of Row.



36
37
38
39
40
41
42
43
44
# File 'app/models/daily_membership_report.rb', line 36

def initialize(items)
  @order = items.first.order
  @id = items.first.order.id
  @membership = items.first.product.membership_type.name
  @quantity = items.length
  @total = DailyMembershipReport.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.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def details
  @details
end

#idObject

Returns the value of attribute id.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def id
  @id
end

#membershipObject

Returns the value of attribute membership.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def membership
  @membership
end

#orderObject

Returns the value of attribute order.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def order
  @order
end

#personObject

Returns the value of attribute person.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def person
  @person
end

#person_idObject

Returns the value of attribute person_id.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def person_id
  @person_id
end

#quantityObject

Returns the value of attribute quantity.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def quantity
  @quantity
end

#totalObject

Returns the value of attribute total.



35
36
37
# File 'app/models/daily_membership_report.rb', line 35

def total
  @total
end

Instance Method Details

#calculate_totalObject



46
47
48
# File 'app/models/daily_membership_report.rb', line 46

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