Beispiel #1
0
def is_review_in_the_future(**args) -> tuple:
    """
    Get review date start time from VIPS and compare it with today's
    date.  If the review is in the future, return True; otherwise
    False
    """
    vips_data = args.get('vips_data')
    review_start_datetime = vips_str_to_datetime(vips_data['reviewStartDtm'])
    today_date = args.get('today_date')
    return today_date < review_start_datetime, args
Beispiel #2
0
def paid_not_more_than_24hrs_ago(**args) -> tuple:
    today_date = args.get('today_date')
    payment_data = args.get('payment_data')
    if 'paymentDate' not in payment_data:
        return True, args
    payment_date = vips_str_to_datetime(payment_data['paymentDate'])
    if (today_date - payment_date).days < 1:
        return True, args
    error = 'the payment is older than 24 hours'
    args['error_string'] = "You are outside the 24-hour time allowed to schedule the review. " \
                           "Please call Appeals at 250-356-6573."
    logging.info(error)
    return False, args
Beispiel #3
0
def is_selected_timeslot_inside_schedule_window(**args) -> tuple:
    requested_time_slot = args.get('requested_time_slot')
    requested_date_time = vips.vips_str_to_datetime(
        requested_time_slot['reviewStartDtm'])
    min_review_date = args['min_review_date']
    max_review_date = args['max_review_date']
    if min_review_date <= requested_date_time < max_review_date + timedelta(
            days=1):
        return True, args
    error = 'selected time slot not within schedule window'
    logging.info(error)
    args['error_string'] = error
    return False, args
Beispiel #4
0
def get_invoice_details(**args) -> tuple:
    vips_application = args.get('vips_application')
    vips_data = args.get('vips_data')
    prohibition = pro.prohibition_factory(vips_data['noticeTypeCd'])
    presentation_type = vips_application['presentationTypeCd']
    args['amount_due'] = prohibition.amount_due(presentation_type)
    args['presentation_type'] = presentation_type
    args['service_date'] = vips.vips_str_to_datetime(
        vips_data['noticeServedDt'])
    args['prohibition'] = prohibition
    args['notice_type_verbose'] = prohibition.type_verbose()
    args['applicant_name'] = "{} {}".format(vips_application['firstGivenNm'],
                                            vips_application['surnameNm'])
    return True, args
Beispiel #5
0
def is_applicant_within_window_to_apply(**args) -> tuple:
    """
    If the prohibition type is ADP or IRP then check
    that the date served is no older than 7 days.
    Prohibitions may not be appealed after 7 days.
    """
    vips_data = args.get('vips_data')
    today = args.get('today_date')
    date_served_string = vips_data['noticeServedDt']
    date_served = vips_str_to_datetime(date_served_string)
    prohibition = pro.prohibition_factory(vips_data['noticeTypeCd'])
    if prohibition.is_okay_to_apply(date_served, today):
        return True, args
    error = 'the prohibition is older than one week'
    args[
        'error_string'] = "The Notice of Prohibition was issued more than 7 days ago."
    logging.info(error)
    return False, args
Beispiel #6
0
def is_review_more_than_48_hours_in_the_future(**args) -> tuple:
    """
    Get review date start time from VIPS and compare it with today's
    date.  If the review is more than 48 hours in the future, return
    True; otherwise False
    """
    seconds_in_an_hour = 60 * 60
    vips_data = args.get('vips_data')
    config = args.get('config')
    review_start_datetime = vips_str_to_datetime(vips_data['reviewStartDtm'])
    today_date = args.get('today_date')
    difference_seconds = (review_start_datetime - today_date).total_seconds()
    difference_hours = difference_seconds / seconds_in_an_hour
    is_okay = difference_hours > int(config.HOURS_BEFORE_REVIEW_EVIDENCE_DUE)
    if is_okay:
        return True, args
    error = "You can't submit evidence less than 48 hours before your review."
    args['error_string'] = error
    logging.info(error)
    return False, args
Beispiel #7
0
def is_any_unsent_disclosure(**args) -> tuple:
    """
    Returns True if there is unsent disclosure to send to applicant
    """
    vips_data = args.get('vips_data')
    config = args.get('config')
    today = args.get('today_date')
    unsent_disclosure = list()
    args['subsequent_disclosure'] = False
    if 'disclosure' in vips_data:
        for item in vips_data['disclosure']:
            if 'disclosedDtm' not in item:
                unsent_disclosure.append(item)
            elif (today - vips.vips_str_to_datetime(item['disclosedDtm'])
                  ).days > config.DAYS_ELAPSED_TO_RESEND_DISCLOSURE:
                unsent_disclosure.append(item)
            else:
                args['subsequent_disclosure'] = True
        if len(unsent_disclosure) > 0:
            args['disclosures'] = unsent_disclosure
            return True, args
    return False, args
Beispiel #8
0
def is_applicant_within_window_to_pay(**args) -> tuple:
    """
    If the prohibition type is ADP or IRP then check
    that the date served is no older than 8 days.
    Prohibitions may not be appealed after 7 days,
    but we allow a one-day grace period to pay.
    """
    vips_data = args.get('vips_data')
    today = args.get('today_date')
    date_served_string = vips_data['noticeServedDt']
    date_served = vips_str_to_datetime(date_served_string)
    prohibition = pro.prohibition_factory(vips_data['noticeTypeCd'])
    args['deadline_date_string'] = prohibition.get_deadline_date_string(
        date_served)
    logging.info('deadline date string: ' + args.get('deadline_date_string'))
    if prohibition.is_okay_to_pay(date_served, today):
        return True, args
    error = 'the prohibition is older than eight days'
    args[
        'error_string'] = "The Notice of Prohibition was issued more than 7 days ago."
    logging.info(error)
    return False, args
Beispiel #9
0
 def test_vips_datetime_conversion(self, vips_datetime, expected):
     actual = vips.vips_str_to_datetime(vips_datetime)
     assert actual == parse_date(expected)