Class: Accountability::Discount
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Accountability::Discount
- Defined in:
- app/models/accountability/discount.rb
Instance Method Summary collapse
Methods inherited from ApplicationRecord
Instance Method Details
#apply(credit) ⇒ Object
8 9 10 11 12 |
# File 'app/models/accountability/discount.rb', line 8 def apply(credit) return unless usable? credit.deductions.new(discount: self) end |
#expected_savings ⇒ Object
24 25 26 27 |
# File 'app/models/accountability/discount.rb', line 24 def expected_savings percent_off = coupon_amount / 100.00 order_item.default_price * percent_off end |
#usable? ⇒ Boolean
18 19 20 21 22 |
# File 'app/models/accountability/discount.rb', line 18 def usable? return false if used_up? coupon.usable? end |
#usages ⇒ Object
14 15 16 |
# File 'app/models/accountability/discount.rb', line 14 def usages deductions.count end |