Class: DiscountsReport::Row
- Inherits:
-
Object
- Object
- DiscountsReport::Row
- Defined in:
- app/models/discounts_report.rb
Instance Attribute Summary collapse
-
#discount_code ⇒ Object
Returns the value of attribute discount_code.
-
#discounted ⇒ Object
Returns the value of attribute discounted.
-
#gross ⇒ Object
Returns the value of attribute gross.
-
#order ⇒ Object
Returns the value of attribute order.
-
#original_price ⇒ Object
Returns the value of attribute original_price.
-
#show ⇒ Object
Returns the value of attribute show.
-
#ticket_count ⇒ Object
Returns the value of attribute ticket_count.
Instance Method Summary collapse
-
#initialize(order) ⇒ Row
constructor
A new instance of Row.
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_code ⇒ Object
Returns the value of attribute discount_code.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def discount_code @discount_code end |
#discounted ⇒ Object
Returns the value of attribute discounted.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def discounted @discounted end |
#gross ⇒ Object
Returns the value of attribute gross.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def gross @gross end |
#order ⇒ Object
Returns the value of attribute order.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def order @order end |
#original_price ⇒ Object
Returns the value of attribute original_price.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def original_price @original_price end |
#show ⇒ Object
Returns the value of attribute show.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def show @show end |
#ticket_count ⇒ Object
Returns the value of attribute ticket_count.
58 59 60 |
# File 'app/models/discounts_report.rb', line 58 def ticket_count @ticket_count end |