def register_correction():

    logging.info(session['original_regns']['applicant'])

    applicant = {
        'name': session['original_regns']['applicant']['name'],
        'address': session['original_regns']['applicant']['address'],
        'key_number': session['original_regns']['applicant']['key_number'],
        'reference': session['original_regns']['applicant']['reference'],
        'address_type': session['original_regns']['applicant']['address_type'],
    }

    registration = {
        'parties': session['parties'],
        'class_of_charge': session['original_regns']['class_of_charge'],
        'applicant': applicant,
        'update_registration': {
            'type': 'Correction'
        }
    }

    application = {
        'registration': registration,
        'orig_regn': session['details_entered'],
        'update_registration': {
            'type': 'Correction'
        }
    }

    if request.form['generate_K22'] == 'yes':
        application['k22'] = True
    else:
        application['k22'] = False

    url = app.config[
        'CASEWORK_API_URL'] + '/applications/0' + '?action=correction'

    headers = get_headers({'Content-Type': 'application/json'})
    headers['X-Transaction-ID'] = session['transaction_id']
    logging.debug("bankruptcy details: " + json.dumps(application))
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(
            format_message("Registration (bank) submitted to CASEWORK_API"))
        data = response.json()
        reg_list = []

        for item in data['new_registrations']:
            reg_list.append(item['number'])
        session['confirmation'] = {'reg_no': reg_list}
    return response
def submit_lc_rectification(form):
    rect_details = (session['rectification_details'])
    if 'instrument' in rect_details['update_registration']:
        orig_date = rect_details['update_registration']['instrument']['original']
        orig_date = datetime.strptime(orig_date, "%d/%m/%Y").strftime("%Y-%m-%d")
        cur_date = rect_details['update_registration']['instrument']['current']
        cur_date = datetime.strptime(cur_date, "%d/%m/%Y").strftime("%Y-%m-%d")
        rect_details['update_registration']['instrument']['original'] = orig_date
        rect_details['update_registration']['instrument']['current'] = cur_date
    cust_address = form['customer_address'].replace("\r\n", ", ").strip()
    application = {'update_registration': {'type': 'Rectification'},
                   'applicant': {
                       'key_number': form['key_number'],
                       'name': form['customer_name'],
                       'address': cust_address,
                       'address_type': form['address_type'],
                       'reference': form['customer_ref']},
                   'parties': [get_party_name(rect_details)],
                   'particulars': {'counties': rect_details['county'], 'district': rect_details['district'],
                                   'description': rect_details['short_description']},
                   'class_of_charge': convert_class_of_charge(rect_details['class']),
                   'regn_no': session['regn_no'],
                   'registration': {'date': session['reg_date']},
                   'document_id': session['document_id'],
                   'additional_information': rect_details['additional_info'],
                   'fee_details': {'type': form['payment'],
                                   'fee_factor': 1,
                                   'delivery': session['application_dict']['delivery_method']}
                   }
    if "update_registration" in rect_details:
        application["update_registration"] = rect_details["update_registration"]
    url = app.config['CASEWORK_API_URL'] + '/applications/' + session['worklist_id'] + '?action=rectify'
    headers = get_headers({'Content-Type': 'application/json'})
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(format_message("Rectification submitted to CASEWORK_API"))
        data = response.json()

        if 'new_registrations' in data:
            reg_list = []
            for item in data['new_registrations']:
                reg_list.append(item['number'])
            session['confirmation'] = {'reg_no': reg_list}
        else:
            session['confirmation'] = {'reg_no': []}

    return Response(status=200)
예제 #3
0
def register_correction():

    logging.info(session["original_regns"]["applicant"])

    applicant = {
        "name": session["original_regns"]["applicant"]["name"],
        "address": session["original_regns"]["applicant"]["address"],
        "key_number": session["original_regns"]["applicant"]["key_number"],
        "reference": session["original_regns"]["applicant"]["reference"],
        "address_type": session["original_regns"]["applicant"]["address_type"],
    }

    registration = {
        "parties": session["parties"],
        "class_of_charge": session["original_regns"]["class_of_charge"],
        "applicant": applicant,
        "update_registration": {"type": "Correction"},
    }

    application = {
        "registration": registration,
        "orig_regn": session["details_entered"],
        "update_registration": {"type": "Correction"},
    }

    if request.form["generate_K22"] == "yes":
        application["k22"] = True
    else:
        application["k22"] = False

    url = app.config["CASEWORK_API_URL"] + "/applications/0" + "?action=correction"

    headers = get_headers({"Content-Type": "application/json"})
    headers["X-Transaction-ID"] = session["transaction_id"]
    logging.debug("bankruptcy details: " + json.dumps(application))
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(format_message("Registration (bank) submitted to CASEWORK_API"))
        data = response.json()
        reg_list = []

        for item in data["new_registrations"]:
            reg_list.append(item["number"])
        session["confirmation"] = {"reg_no": reg_list}
    return response
예제 #4
0
def submit_lc_registration(cust_fee_data):
    application = session['application_dict']
    application['class_of_charge'] = convert_application_type(session['application_type'])
    application['application_ref'] = cust_fee_data['application_reference']
    application['key_number'] = cust_fee_data['key_number']
    application['customer_name'] = cust_fee_data['customer_name']
    application['customer_address'] = cust_fee_data['customer_address']
    application['address_type'] = cust_fee_data['address_type']
    today = datetime.now().strftime('%Y-%m-%d')
    application['date'] = today
    application['residence_withheld'] = False
    #application['date_of_birth'] = "1980-01-01"  # DONE?: what are we doing about the DOB??
    application['document_id'] = session['document_id']
    application['fee_details'] = {'type': cust_fee_data['payment'],
                                  'fee_factor': 1,
                                  'delivery': session['application_dict']['delivery_method']}

    if session['application_dict']['form'] == 'K6':
        application['priority_notice_ind'] = True
        result_string = 'priority_notices'
    else:
        result_string = 'new_registrations'

    session['register_details']['estate_owner']['estate_owner_ind'] = session['register_details']['estate_owner_ind']
    #     convert_estate_owner_ind(session['register_details']['estate_owner_ind'])
    application['lc_register_details'] = session['register_details']

    url = app.config['CASEWORK_API_URL'] + '/applications/' + session['worklist_id'] + '?action=complete'
    headers = get_headers({'Content-Type': 'application/json'})
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(format_message("Registration submitted to CASEWORK_API"))
        data = response.json()
        reg_list = []

        for item in data[result_string]:
            reg_list.append(item['number'])
        session['confirmation'] = {'reg_no': reg_list}

    return response
def submit_lc_rectification(form):
    rect_details = (session['rectification_details'])
    if 'instrument' in rect_details['update_registration']:
        orig_date = rect_details['update_registration']['instrument'][
            'original']
        orig_date = datetime.strptime(orig_date,
                                      "%d/%m/%Y").strftime("%Y-%m-%d")
        cur_date = rect_details['update_registration']['instrument']['current']
        cur_date = datetime.strptime(cur_date, "%d/%m/%Y").strftime("%Y-%m-%d")
        rect_details['update_registration']['instrument'][
            'original'] = orig_date
        rect_details['update_registration']['instrument']['current'] = cur_date
    cust_address = form['customer_address'].replace("\r\n", ", ").strip()
    application = {
        'update_registration': {
            'type': 'Rectification'
        },
        'applicant': {
            'key_number': form['key_number'],
            'name': form['customer_name'],
            'address': cust_address,
            'address_type': form['address_type'],
            'reference': form['customer_ref']
        },
        'parties': [get_party_name(rect_details)],
        'particulars': {
            'counties': rect_details['county'],
            'district': rect_details['district'],
            'description': rect_details['short_description']
        },
        'class_of_charge': convert_class_of_charge(rect_details['class']),
        'regn_no': session['regn_no'],
        'registration': {
            'date': session['reg_date']
        },
        'document_id': session['document_id'],
        'additional_information': rect_details['additional_info'],
        'fee_details': {
            'type': form['payment'],
            'fee_factor': 1,
            'delivery': session['application_dict']['delivery_method']
        }
    }
    if "update_registration" in rect_details:
        application["update_registration"] = rect_details[
            "update_registration"]
    url = app.config['CASEWORK_API_URL'] + '/applications/' + session[
        'worklist_id'] + '?action=rectify'
    headers = get_headers({'Content-Type': 'application/json'})
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(format_message("Rectification submitted to CASEWORK_API"))
        data = response.json()

        if 'new_registrations' in data:
            reg_list = []
            for item in data['new_registrations']:
                reg_list.append(item['number'])
            session['confirmation'] = {'reg_no': reg_list}
        else:
            session['confirmation'] = {'reg_no': []}

    return Response(status=200)
def register_bankruptcy(key_number):

    url = app.config['CASEWORK_API_URL'] + '/keyholders/' + key_number
    response = http_get(
        url, headers={'X-Transaction-ID': session['transaction_id']})
    text = json.loads(response.text)
    if response.status_code == 200:
        cust_address = ', '.join(text['address']['address_lines']
                                 ) + ', ' + text['address']['postcode']
        address_type = "RM"
        if ("dx_number" in text) and ("dx_exchange" in text):
            if text["dx_number"]:  # switch to dx address if available
                if text["dx_exchange"]:
                    dx_no = str(text["dx_number"]).upper()
                    if not dx_no.startswith("DX"):
                        dx_no = "DX " + dx_no
                    cust_address = dx_no + ', ' + text["dx_exchange"]
                    address_type = "DX"
        cust_name = text['name']
        applicant = {
            'name': cust_name,
            'address': cust_address.upper(),
            'key_number': key_number,
            'reference': ' ',
            'address_type': address_type
        }
    else:
        return response

    if session['application_type'] == 'bank_amend':
        class_of_charge = session['original_regns']['class_of_charge']
    elif session['application_dict']['form'] == 'PA(B)':
        class_of_charge = 'PAB'
    elif session['application_dict']['form'] == 'WO(B)':
        class_of_charge = 'WOB'
    else:
        class_of_charge = session['application_dict']['form']

    registration = {
        'parties': session['parties'],
        'class_of_charge': class_of_charge,
        'applicant': applicant
    }

    application = {
        'registration': registration,
        'application_data': session['application_dict']['application_data'],
        'form': session['application_dict']['form']
    }

    if session['application_type'] == 'bank_amend':
        # TODO: update registration added twice to get around bad structure for rectifications which needs changing!
        application['update_registration'] = {'type': 'Amendment'}
        application['registration']['update_registration'] = {
            'type': 'Amendment'
        }
        if 'wob_entered' in session:
            application['wob_original'] = session['wob_entered']
        if 'pab_entered' in session:
            application['pab_original'] = session['pab_entered']
        url = app.config['CASEWORK_API_URL'] + '/applications/' + session[
            'worklist_id'] + '?action=amend'
    else:
        url = app.config['CASEWORK_API_URL'] + '/applications/' + session[
            'worklist_id'] + '?action=complete'

    headers = get_headers({'Content-Type': 'application/json'})
    logging.debug("bankruptcy details: " + json.dumps(application))
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(
            format_message("Registration (bank) submitted to CASEWORK_API"))
        data = response.json()
        reg_list = []

        for item in data['new_registrations']:
            reg_list.append(item['number'])
        session['confirmation'] = {'reg_no': reg_list}

    return response
예제 #7
0
def register_bankruptcy(key_number):

    url = app.config["CASEWORK_API_URL"] + "/keyholders/" + key_number
    response = http_get(url, headers={"X-Transaction-ID": session["transaction_id"]})
    text = json.loads(response.text)
    if response.status_code == 200:
        cust_address = ", ".join(text["address"]["address_lines"]) + ", " + text["address"]["postcode"]
        address_type = "RM"
        if ("dx_number" in text) and ("dx_exchange" in text):
            if text["dx_number"]:  # switch to dx address if available
                if text["dx_exchange"]:
                    dx_no = str(text["dx_number"]).upper()
                    if not dx_no.startswith("DX"):
                        dx_no = "DX " + dx_no
                    cust_address = dx_no + ", " + text["dx_exchange"]
                    address_type = "DX"
        cust_name = text["name"]
        applicant = {
            "name": cust_name,
            "address": cust_address.upper(),
            "key_number": key_number,
            "reference": " ",
            "address_type": address_type,
        }
    else:
        return response

    if session["application_type"] == "bank_amend":
        class_of_charge = session["original_regns"]["class_of_charge"]
    elif session["application_dict"]["form"] == "PA(B)":
        class_of_charge = "PAB"
    elif session["application_dict"]["form"] == "WO(B)":
        class_of_charge = "WOB"
    else:
        class_of_charge = session["application_dict"]["form"]

    registration = {"parties": session["parties"], "class_of_charge": class_of_charge, "applicant": applicant}

    application = {
        "registration": registration,
        "application_data": session["application_dict"]["application_data"],
        "form": session["application_dict"]["form"],
    }

    if session["application_type"] == "bank_amend":
        # TODO: update registration added twice to get around bad structure for rectifications which needs changing!
        application["update_registration"] = {"type": "Amendment"}
        application["registration"]["update_registration"] = {"type": "Amendment"}
        if "wob_entered" in session:
            application["wob_original"] = session["wob_entered"]
        if "pab_entered" in session:
            application["pab_original"] = session["pab_entered"]
        url = app.config["CASEWORK_API_URL"] + "/applications/" + session["worklist_id"] + "?action=amend"
    else:
        url = app.config["CASEWORK_API_URL"] + "/applications/" + session["worklist_id"] + "?action=complete"

    headers = get_headers({"Content-Type": "application/json"})
    logging.debug("bankruptcy details: " + json.dumps(application))
    response = http_put(url, data=json.dumps(application), headers=headers)
    if response.status_code == 200:
        logging.info(format_message("Registration (bank) submitted to CASEWORK_API"))
        data = response.json()
        reg_list = []

        for item in data["new_registrations"]:
            reg_list.append(item["number"])
        session["confirmation"] = {"reg_no": reg_list}

    return response