Пример #1
0
def estimator(request, dob=None, income=None):
    today = datetime.datetime.now().date()
    legal_year = today.year - 22  # calculator isn't for people under 22
    if dob is None:
        dob = param_check(request, 'dob')
        if not dob:
            return HttpResponseBadRequest("invalid date of birth")
    if income is None:
        income_raw = param_check(request, 'income')
        if not income_raw:
            return HttpResponseBadRequest("invalid income")
        else:
            income = income_check(income_raw)
            if income is None:
                return HttpResponseBadRequest("invalid income")
    else:
        income = income_check(income)
        if income is None:
            return HttpResponseBadRequest("invalid income")
    try:
        dob_parsed = parser.parse(dob)
    except:
        return HttpResponseBadRequest("invalid date of birth")
    else:
        DOB = dob_parsed.date()
    params['dobmon'] = DOB.month
    params['dobday'] = DOB.day
    params['yob'] = DOB.year
    params['earnings'] = income
    if standalone:
        data = get_retire_data(params, timeout=False)
    else:
        data = get_retire_data(params)
    return HttpResponse(data, content_type='application/json')
Пример #2
0
def estimator(request, dob=None, income=None):
    today = datetime.datetime.now().date()
    legal_year = today.year - 22  # calculator isn't for people under 22
    if dob is None:
        dob = param_check(request, 'dob')
        if not dob:
            return HttpResponseBadRequest("invalid date of birth")
    if income is None:
        income_raw = param_check(request, 'income')
        if not income_raw:
            return HttpResponseBadRequest("invalid income")
        else:
            income = income_check(income_raw)
            if income is None:
                return HttpResponseBadRequest("invalid income")
    else:
        income = income_check(income)
        if income is None:
            return HttpResponseBadRequest("invalid income")
    try:
        dob_parsed = parser.parse(dob)
    except:
        return HttpResponseBadRequest("invalid date of birth")
    else:
        DOB = dob_parsed.date()
    params['dobmon'] = DOB.month
    params['dobday'] = DOB.day
    params['yob'] = DOB.year
    params['earnings'] = income
    if standalone:
        data = get_retire_data(params, timeout=False)
    else:
        data = get_retire_data(params)
    return HttpResponse(data, content_type='application/json')
Пример #3
0
def estimator(request, dob=None, income=None, language='en'):
    today = datetime.datetime.now().date()
    ssa_params = {
        'dobmon': 0,
        'dobday': 0,
        'yob': 0,
        'earnings': 0,
        'lastYearEarn': '',  # not using
        'lastEarn': '',  # not using
        'retiremonth': '',  # only using for past-FRA users
        'retireyear': '',  # only using for past-FRA users
        'dollars': 1,  # benefits to be calculated in current-year dollars
        'prgf': 2
    }
    if dob is None:
        dob = param_check(request, 'dob')
        if not dob:
            return HttpResponseBadRequest("invalid date of birth")
    if income is None:
        income_raw = param_check(request, 'income')
        if not income_raw:
            return HttpResponseBadRequest("invalid income")
        else:
            income = income_check(income_raw)
            if income is None:
                return HttpResponseBadRequest("invalid income")
    else:
        income = income_check(income)
        if income is None:
            return HttpResponseBadRequest("invalid income")
    try:
        dob_parsed = parser.parse(dob)
    except:
        return HttpResponseBadRequest("invalid date of birth")
    else:
        DOB = dob_parsed.date()
    ssa_params['dobmon'] = DOB.month
    ssa_params['dobday'] = DOB.day
    ssa_params['yob'] = DOB.year
    ssa_params['earnings'] = income
    data = get_retire_data(ssa_params, language)
    return HttpResponse(json.dumps(data), content_type='application/json')
Пример #4
0
def estimator(request, dob=None, income=None):
    today = datetime.datetime.now().date()
    legal_year = today.year - 22 # calculator should not be used for people under 22
    if dob == None:
        dob = param_check(request, 'dob')
        if not dob:
            return HttpResponseBadRequest("invalid date of birth")
    if income == None:
        income_raw = param_check(request, 'income')
        if not income_raw:
            return HttpResponseBadRequest("invalid income")
        else:
            income = income_check(income_raw)
            if income == None:
                return HttpResponseBadRequest("invalid income")
    else:
        income = income_check(income)
        if income == None:
            return HttpResponseBadRequest("invalid income")
    try:
        dob_parsed = parser.parse(dob)
    except:
        return HttpResponseBadRequest("invalid date of birth")
    else:
        DOB = dob_parsed.date()
    if DOB == today:
        print "birth date can't be parsed"
        return HttpResponseBadRequest("birth date can't be parsed")
    elif DOB.year >= legal_year:
        print "subject is too young to use SSA quick calculator"
        return HttpResponseBadRequest("subject is too young to use SSA quick calculator")
    else:
        params['dobmon'] = DOB.month
        params['dobday'] = DOB.day
        params['yob'] = DOB.year
        params['earnings'] = income
        data = get_retire_data(params)
        return HttpResponse(data, content_type='application/json')