'Calculate and return the refund window end date.'

def refund_cutoff_date(self):

    from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, ECOMMERCE_DATE_FORMAT
    try:
        attribute = self.attributes.get(namespace='order', name='order_number')
    except ObjectDoesNotExist:
        return None
    except MultipleObjectsReturned:
        enrollment_id = self.get_enrollment(self.user, self.course_id).id
        log.warning(u'Multiple    CourseEnrollmentAttributes    found    for    user    %s    with    enrollment-ID    %s', self.user.id, enrollment_id)
        attribute = self.attributes.filter(namespace='order', name='order_number').last()
    order_number = attribute.value
    try:
        order = ecommerce_api_client(self.user).orders(order_number).get()
    except HttpClientError:
        log.warning(u'Encountered    HttpClientError    while    getting    order    details    from    ecommerce.    Order={number}    and    user    {user}'.format(number=order_number, user=self.user.id))
        return None
    except HttpServerError:
        log.warning(u'Encountered    HttpServerError    while    getting    order    details    from    ecommerce.    Order={number}    and    user    {user}'.format(number=order_number, user=self.user.id))
        return None
    except SlumberBaseException:
        log.warning(u'Encountered    an    error    while    getting    order    details    from    ecommerce.    Order={number}    and    user    {user}'.format(number=order_number, user=self.user.id))
        return None
    refund_window_start_date = max(datetime.strptime(order['date_placed'], ECOMMERCE_DATE_FORMAT), self.course_overview.start.replace(tzinfo=None))
    return (refund_window_start_date.replace(tzinfo=UTC) + EnrollmentRefundConfiguration.current().refund_window)
