'For paid/verified certificates, students may always receive a refund if
this CourseEnrollment\'s `can_refund` attribute is not `None` (that
overrides all other rules).
If the `.can_refund` attribute is `None` or doesn\'t exist, then ALL of
the following must be true for this enrollment to be refundable:
* The user does not have a certificate issued for this course.
* We are not past the refund cutoff date
* There exists a \'verified\' CourseMode for this course.
Arguments:
`user_already_has_certs_for` (set of `CourseKey`):
An optional param that is a set of `CourseKeys` that the user
has already been issued certificates in.
Returns:
bool: Whether is CourseEnrollment can be refunded.'

def refundable(self, user_already_has_certs_for=None):

    if (getattr(self, 'can_refund', None) is not None):
        return True
    if (user_already_has_certs_for is not None):
        if (self.course_id in user_already_has_certs_for):
            return False
    elif (GeneratedCertificate.certificate_for_student(self.user, self.course_id) is not None):
        return False
    refund_cutoff_date = self.refund_cutoff_date()
    if (refund_cutoff_date is None):
        return False
    if (datetime.now(UTC) > refund_cutoff_date):
        return False
    course_mode = CourseMode.mode_for_course(self.course_id, 'verified', include_expired=True)
    if (course_mode is None):
        return False
    else:
        return True
