module IntervalValidatable
  extend ActiveSupport::Concern

  INTERVALS = %w{Once Weekly Monthly Completion}

  included do
    validate :known_interval
  end

  def known_interval
    if self.respond_to?(:recurring)
      if self.recurring
        unless INTERVALS.include? self.interval
          errors.add(:interval, "should be one of #{INTERVALS}")
        end
      end
    else
      unless INTERVALS.include? self.interval
        errors.add(:interval, "should be one of #{INTERVALS}")
      end
    end
  end
end

module IntervalValidatable
  extend ActiveSupport::Concern

  INTERVALS = %w{Once Weekly Monthly}

  included do
    validate :known_interval
  end

  def known_interval
    if self.respond_to?(:recurring)
      if self.recurring
        unless INTERVALS.include? self.interval
          errors.add(:interval, "should be one of #{INTERVALS}")
        end
      end
    else
      unless INTERVALS.include? self.interval
        errors.add(:interval, "should be one of #{INTERVALS}")
      end
    end
  end
end

Remove completion recurrence from bills
Remove completion recurrence from bills
