Sha256: b9f5c3c2f975ef70183dea2b3401665ee7f49a9c02e69a8b596c99925753ce3b
Contents?: true
Size: 850 Bytes
Versions: 87
Compression:
Stored size: 850 Bytes
Contents
module Spree class StoreCreditCategory < Spree::Base validates :name, presence: true before_destroy :validate_not_used GIFT_CARD_CATEGORY_NAME = 'Gift Card'.freeze DEFAULT_NON_EXPIRING_TYPES = [GIFT_CARD_CATEGORY_NAME] def non_expiring? non_expiring_category_types.include? name end def non_expiring_category_types DEFAULT_NON_EXPIRING_TYPES | Spree::Config[:non_expiring_credit_types] end def store_credit_category_used? Spree::StoreCredit.exists?(category_id: id) end def validate_not_used if store_credit_category_used? errors.add(:base, :cannot_destroy_if_used_in_store_credit) throw(:abort) end end class << self def default_reimbursement_category(_options = {}) Spree::StoreCreditCategory.first end end end end
Version data entries
87 entries across 87 versions & 1 rubygems