Exemple #1
0
def delete_lc_row(number, date, class_of_charge):
    info('INTENT: Delete LC row %d %s (%s)', number, date, class_of_charge)
    resource = "/{}/{}/{}".format(number, date, class_to_roman(class_of_charge))
    delete = requests.delete(CONFIG['LEGACY_DB_URI'] + '/land_charges' + resource, headers=get_headers())
    if delete.status_code != 200:
        error('DELETE /land_charges - %s', str(delete.status_code))
        raise SynchroniserError('DELETE /land_charges - . ' + str(delete.status_code))
    info("  > Deleted")
Exemple #2
0
def create_legacy_data(data):
    app_type = class_to_roman(data['class_of_charge'])

    legacy_object = {
        'time': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'),
        'registration_no': str(data['registration']['number']).rjust(8),
        'priority_notice': '',
        'registration_date': data['registration']['date'],
        'class_type': app_type,
        'priority_notice_ref': '',
        'amendment_info': data['additional_information'].upper()[0:254]
    }

    eo_party = get_eo_party(data)

    if data['class_of_charge'] in ['PAB', 'WOB']:
        legacy_object['address'] = residences_to_string(eo_party)
        legacy_object['property_county'] = ''
        legacy_object['counties'] = ''
        legacy_object['parish_district'] = ''
        legacy_object['property'] = ''

    else:
        if 'priority_notice' in data['particulars']:
            legacy_object['priority_notice_ref'] = data['particulars']['priority_notice']

        if 'priority_notice' in data and 'expires' in data['priority_notice']:
            legacy_object['priority_notice'] = 'P'

        legacy_object['address'] = ''
        legacy_object['parish_district'] = data['particulars']['district'].upper()
        legacy_object['property'] = data['particulars']['description'].upper()

        if data['class_of_charge'] in ['PA', 'WO']:
            legacy_object['property_county'] = ""
            legacy_object['counties'] = data['particulars']['counties'][0].upper()

        else:
            county = data['particulars']['counties'][0].upper()
            county = re.sub("(.*) \(CITY OF\)", r"CITY OF \1", county)

            legacy_object['property_county'] = county
            legacy_object['counties'] = ''


    # Only sync the top name/county...
    eo_name = eo_party['names'][0]

    if eo_name['type'] == 'Private Individual':
        encoded_name = encode_name(eo_name)
        occupation = occupation_string(eo_party)[0:254]
        hex_append = ''

    elif eo_name['type'] == 'County Council':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['local']['name'].upper(),
            'hex_code': ''
        }
        hex_append = "01"
        occupation = ''

    elif eo_name['type'] == 'Rural Council':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['local']['name'].upper(),
            'hex_code': ''
        }
        hex_append = "02"
        occupation = ''

    elif eo_name['type'] == 'Parish Council':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['local']['name'].upper(),
            'hex_code': ''
        }
        hex_append = "04"
        occupation = ''

    elif eo_name['type'] == 'Other Council':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['local']['name'].upper(),
            'hex_code': ''
        }
        hex_append = "08"
        occupation = ''

    elif eo_name['type'] == 'Development Corporation':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['other'].upper(),
            'hex_code': ''
        }
        hex_append = "10"
        occupation = ''

    elif eo_name['type'] == 'Limited Company':
        encoded_name = {
            'coded_name': eo_name['search_key'][:11],
            'remainder_name': eo_name['search_key'][11:],
            'name': eo_name['company'].upper(),
            'hex_code': ''
        }
        hex_append = "F1"
        occupation = ''

    elif eo_name['type'] == 'Complex Name':
        cnum_hex = hex(eo_name['complex']['number'])[2:].zfill(6).upper()
        hex_string = 'F9' + cnum_hex + '00000000000000F3'
        encoded_name = {
            'coded_name': hex_string,
            'remainder_name': '',
            'name': eo_name['complex']['name'].upper(),
            'hex_code': ''
        }
        hex_append = 'F3'
        occupation = ''
        
    # elif eo_name['type'] == 'Coded Name':
    #     cnum_hex = hex(9999924)[2:].zfill(6).upper()
    #     hex_string = 'F9' + cnum_hex + '00000000000000F3'
    #     encoded_name = {
    #         'coded_name': hex_string,
    #         'remainder_name': '',
    #         'name': eo_name['other'].upper(),
    #         'hex_code': ''
    #     }
    #     hex_append = 'F3'
    #     occupation = ''

    elif eo_name['type'] == 'Other':
        if eo_name['subtype'] == 'A':  # VARNAM A
            encoded_name = encode_variant_a_name(eo_name['other'])
            encoded_name['name'] = ''  # eo_name['other'].upper()
            hex_append = ""
        else:  # VARNAM B
            encoded_name = {
                'coded_name': eo_name['search_key'][:11],
                'remainder_name': eo_name['search_key'][11:],
                'name': eo_name['other'].upper(),
                'hex_code': ''
            }
            hex_append = "F2"
        occupation = ''

    else:
        raise SynchroniserError("Unknown name type: {}".format(eo_name['type']))

    legacy_object['reverse_name'] = encoded_name['coded_name']
    legacy_object['remainder_name'] = encoded_name['remainder_name']
    legacy_object['punctuation_code'] = encoded_name['hex_code']
    legacy_object['occupation'] = occupation
    legacy_object['append_with_hex'] = hex_append
    legacy_object['name'] = encoded_name['name']
    return legacy_object