Module: Models::CouponDateOverridable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/concerns/models/coupon_date_overridable.rb
Overview
ActiveSupport::Concern mixin: coupon date overridable.
Instance Method Summary collapse
Instance Method Details
#override_coupon_date_limit ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/concerns/models/coupon_date_overridable.rb', line 13 def override_coupon_date_limit return unless override_coupon_date && created_at return if override_coupon_date_without_limits return unless will_save_change_to_override_coupon_date? min_date = (created_at - 45.days).to_date max_date = (created_at + 45.days).to_date valid_range = min_date..max_date return if valid_range === override_coupon_date = "exceeds 45 days grace period limits. Must be between #{valid_range.first.to_fs(:crm_date_only)} and #{valid_range.last.to_fs(:crm_date_only)}" errors.add(:override_coupon_date, ) end |