diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 000000000..d32ab0e05 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,31 @@ +version: "3.1" + +services: + ####################### PPR Database Definition ####################### + pprdb: + image: postgres:11 + restart: always + environment: + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + ports: + - "54360:5432" + volumes: + - db-data:/var/lib/postgresql/data0 + + ####################### PPR Unit Test Database Definition ####################### + # pprdb-test: + # image: postgres:11 + # restart: always + # environment: + # POSTGRES_DB: postgres + # POSTGRES_PASSWORD: postgres + # ports: + # - "54361:5432" + # volumes: + # - db-data:/var/lib/postgresql/data1 + + +volumes: + db-data: + driver: local diff --git a/ppr-api/README.md b/ppr-api/README.md index 790a351e1..5dbd6e696 100755 --- a/ppr-api/README.md +++ b/ppr-api/README.md @@ -62,9 +62,12 @@ To use the mock pay-api service for local testing, set the .env variable: 1. Open the ppr-api directory in VS Code to treat it as a project (or WSL projec). To prevent version clashes, set up a virtual environment to install the Python packages used by this project. 1. Run `make setup` 1. Run `pip install .` -1. See [Oracle DB README](https://github.com/bcgov/ppr/tree/main/oracle-db/README.md) on running a local Docker Oracle PPR database. 1. Update the .env file to add your local environment variables including the database configuration. A sample .env file is provided. -1. See [test data README](./test_data/README.md) for instructions to set up unit test data. +1. Run a local instance of the Postgres PPR database. + 1. From your project root run: `docker-compose up -d` + 1. In your `venv` environment run: `python manage.py db upgrade` + 1. In your `venv` environment load/reload unit test data. Run: `python manage.py create_test_data` + ### Running the PPR-API Start the flask server with `(python -m flask run -p 5000)` diff --git a/ppr-api/manage.py b/ppr-api/manage.py index 52dfb3378..ff8428d69 100644 --- a/ppr-api/manage.py +++ b/ppr-api/manage.py @@ -15,21 +15,24 @@ """Manage the database and some other items required to run the API """ import logging +import os +import sys -from flask import url_for +from flask import current_app, url_for from flask_script import Manager # class for handling a set of commands from flask_migrate import Migrate, MigrateCommand +from sqlalchemy.sql import text from ppr_api import create_app from ppr_api.models import db # models included so that migrate can build the database migrations -# from ppr_api import models # pylint: disable=unused-import +from ppr_api import models # pylint: disable=unused-import APP = create_app() MIGRATE = Migrate(APP, db) MANAGER = Manager(APP) -# MANAGER.add_command('db', MigrateCommand) +MANAGER.add_command('db', MigrateCommand) @MANAGER.command @@ -50,6 +53,49 @@ def list_routes(): print(line) +def execute_script(session, file_name): + """Execute a SQL script as one or more SQL statements in a single file.""" + print('Executing SQL statements in file ' + file_name) + with open(file_name, 'r') as sql_file: + sql_command = '' + # Iterate over all lines in the sql file + for line in sql_file: + # Ignore commented lines + if not line.startswith('--') and line.strip('\n'): + # Append line to the command string + sql_command += line.strip('\n') + + # If the command string ends with ';', it is a full statement + if sql_command.endswith(';'): + sql_command = sql_command.replace(';', '') + # print('Executing SQL: ' + sql_command) + # Try to execute statement and commit it + try: + session.execute(text(sql_command)) + + # Assert in case of error + except Exception as ex: + print(repr(ex)) + + # Finally, clear command string + finally: + sql_command = '' + + session.commit() + sql_file.close() + + +@MANAGER.command +def create_test_data(): + """Load unit test data in the dev/local environment. Delete all existing test data as a first step.""" + execute_script(db.session, 'test_data/postgres_test_reset.sql') + execute_script(db.session, 'test_data/postgres_create_first.sql') + filenames = os.listdir(os.path.join(os.getcwd(), 'test_data/postgres_data_files')) + sorted_names = sorted(filenames) + for filename in sorted_names: + execute_script(db.session, os.path.join(os.getcwd(), ('test_data/postgres_data_files/' + filename))) + + if __name__ == '__main__': logging.log(logging.INFO, 'Running the Manager') MANAGER.run() diff --git a/ppr-api/migrations/README b/ppr-api/migrations/README new file mode 100644 index 000000000..98e4f9c44 --- /dev/null +++ b/ppr-api/migrations/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/ppr-api/migrations/alembic.ini b/ppr-api/migrations/alembic.ini new file mode 100644 index 000000000..961f27ea2 --- /dev/null +++ b/ppr-api/migrations/alembic.ini @@ -0,0 +1,50 @@ +# A generic, single database configuration. + +[alembic] +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic,alembic_utils + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[logger_alembic_utils] +level = INFO +handlers = +qualname = alembic_utils + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/ppr-api/migrations/env.py b/ppr-api/migrations/env.py new file mode 100644 index 000000000..384823d44 --- /dev/null +++ b/ppr-api/migrations/env.py @@ -0,0 +1,125 @@ +from __future__ import with_statement + +import logging +from logging.config import fileConfig + +from sqlalchemy import engine_from_config +from sqlalchemy import pool + +from alembic import context +from alembic_utils.replaceable_entity import register_entities + +from database.postgres_functions import ( + get_draft_document_number, + get_registration_num, + match_individual_name, + searchkey_aircraft, + searchkey_business_name, + searchkey_first_name, + searchkey_last_name, + searchkey_mhr, + searchkey_name_match, + searchkey_nickname_match, + searchkey_vehicle +) + + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) +logger = logging.getLogger('alembic.env') + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +from flask import current_app +config.set_main_option( + 'sqlalchemy.url', + str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%')) +target_metadata = current_app.extensions['migrate'].db.metadata + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + +# Registering db functions here +register_entities([get_draft_document_number, + get_registration_num, + searchkey_name_match, + searchkey_nickname_match, + match_individual_name, + searchkey_aircraft, + searchkey_business_name, + searchkey_first_name, + searchkey_last_name, + searchkey_mhr, + searchkey_vehicle]) + + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure( + url=url, target_metadata=target_metadata, literal_binds=True + ) + + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + + # this callback is used to prevent an auto-migration from being generated + # when there are no changes to the schema + # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html + def process_revision_directives(context, revision, directives): + if getattr(config.cmd_opts, 'autogenerate', False): + script = directives[0] + if script.upgrade_ops.is_empty(): + directives[:] = [] + logger.info('No changes in schema detected.') + + connectable = engine_from_config( + config.get_section(config.config_ini_section), + prefix='sqlalchemy.', + poolclass=pool.NullPool, + ) + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=target_metadata, + process_revision_directives=process_revision_directives, + **current_app.extensions['migrate'].configure_args + ) + + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/ppr-api/migrations/script.py.mako b/ppr-api/migrations/script.py.mako new file mode 100644 index 000000000..2c0156303 --- /dev/null +++ b/ppr-api/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/ppr-api/migrations/versions/ca3675d682cc_initial_migration.py b/ppr-api/migrations/versions/ca3675d682cc_initial_migration.py new file mode 100644 index 000000000..e94801114 --- /dev/null +++ b/ppr-api/migrations/versions/ca3675d682cc_initial_migration.py @@ -0,0 +1,5465 @@ +"""Initial migration. + +Revision ID: ca3675d682cc +Revises: +Create Date: 2021-05-26 17:00:01.686728 + +""" +from alembic import op +import sqlalchemy as sa +from alembic_utils.pg_function import PGFunction +from sqlalchemy import text as sql_text +from sqlalchemy.schema import Sequence, CreateSequence, DropSequence # Added manually. + +# revision identifiers, used by Alembic. +revision = 'ca3675d682cc' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### Manually create sequences and add them to pk columns. ### + op.execute(CreateSequence(Sequence('address_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('code_branch_id_seq', start=7162, increment=1, minvalue=7162, maxvalue=8999))) + op.execute(CreateSequence(Sequence('court_order_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('draft_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('financing_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('general_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('historical_head_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('party_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('registration_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('search_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('trust_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('vehicle_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('word_id_seq', start=55, increment=1))) + op.execute(CreateSequence(Sequence('name_id_seq', start=100528, increment=1))) + op.execute(CreateSequence(Sequence('user_id_seq', start=1, increment=1))) + op.execute(CreateSequence(Sequence('document_number_seq', start=9000000, increment=1))) + op.execute(CreateSequence(Sequence('registration_num_seq', start=100000, increment=1))) + # ### commands auto generated by Alembic - please adjust! ### + # ### Manually modify order to resolve relation does not exist errors. ### + country_type = op.create_table('country_types', + sa.Column('country_type', sa.String(length=2), nullable=False), + sa.Column('country_desc', sa.String(length=75), nullable=False), + sa.PrimaryKeyConstraint('country_type') + ) + party_type = op.create_table('party_types', + sa.Column('party_type', sa.String(length=2), nullable=False), + sa.Column('party_type_desc', sa.String(length=30), nullable=False), + sa.PrimaryKeyConstraint('party_type') + ) + province_type = op.create_table('province_types', + sa.Column('province_type', sa.String(length=2), nullable=False), + sa.Column('country_type', sa.String(length=2), nullable=False), + sa.Column('province_desc', sa.String(length=75), nullable=False), + sa.ForeignKeyConstraint(['country_type'], ['country_types.country_type'], ), + sa.PrimaryKeyConstraint('province_type') + ) + registration_type_class = op.create_table('registration_type_classes', + sa.Column('registration_type_cl', sa.String(length=10), nullable=False), + sa.Column('registration_desc', sa.String(length=100), nullable=False), + sa.PrimaryKeyConstraint('registration_type_cl') + ) + registration_type = op.create_table('registration_types', + sa.Column('registration_type', sa.String(length=2), nullable=False), + sa.Column('registration_type_cl', sa.String(length=10), nullable=False), + sa.Column('registration_desc', sa.String(length=100), nullable=False), + sa.Column('registration_act', sa.String(length=60), nullable=False), + sa.ForeignKeyConstraint(['registration_type_cl'], ['registration_type_classes.registration_type_cl'], ), + sa.PrimaryKeyConstraint('registration_type') + ) + search_type = op.create_table('search_types', + sa.Column('search_type', sa.String(length=2), nullable=False), + sa.Column('search_type_desc', sa.String(length=60), nullable=False), + sa.PrimaryKeyConstraint('search_type') + ) + serial_type = op.create_table('serial_types', + sa.Column('serial_type', sa.String(length=2), nullable=False), + sa.Column('serial_type_desc', sa.String(length=30), nullable=False), + sa.PrimaryKeyConstraint('serial_type') + ) + state_type = op.create_table('state_types', + sa.Column('state_type', sa.String(length=3), nullable=False), + sa.Column('state_type_desc', sa.String(length=30), nullable=False), + sa.PrimaryKeyConstraint('state_type') + ) + nickname = op.create_table('nicknames', + sa.Column('name_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=25), nullable=False), + ) + op.create_index(op.f('ix_nickname_name_id'), 'nicknames', ['name_id'], unique=False) + op.create_index(op.f('ix_nickname_name'), 'nicknames', ['name'], unique=False) + op.create_table('users', + sa.Column('id', sa.Integer(), sa.Sequence('user_id_seq'), nullable=False), + sa.Column('creation_date', sa.DateTime(), nullable=False), + sa.Column('username', sa.String(length=1000), nullable=False), + sa.Column('sub', sa.String(length=36), nullable=False), + sa.Column('account_id', sa.String(length=20), nullable=True), + sa.Column('firstname', sa.String(length=1000), nullable=True), + sa.Column('lastname', sa.String(length=1000), nullable=True), + sa.Column('email', sa.String(length=1024), nullable=True), + sa.Column('iss', sa.String(length=1024), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('sub'), + sa.UniqueConstraint('sub') + ) + op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=False) + op.create_table('addresses', + sa.Column('id', sa.Integer(), sa.Sequence('address_id_seq'), nullable=False), + sa.Column('street', sa.String(length=50), nullable=False), + sa.Column('street_additional', sa.String(length=50), nullable=True), + sa.Column('city', sa.String(length=40), nullable=False), + sa.Column('region', sa.String(length=2), nullable=False), + sa.Column('postal_code', sa.String(length=15), nullable=False), + sa.Column('country', sa.String(length=2), nullable=True), + sa.ForeignKeyConstraint(['country'], ['country_types.country_type'], ), + sa.ForeignKeyConstraint(['region'], ['province_types.province_type'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('client_codes', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('head_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=150), nullable=False), + sa.Column('bconline_account', sa.Integer(), nullable=True), + sa.Column('contact_name', sa.String(length=100), nullable=False), + sa.Column('contact_area_cd', sa.String(length=3), nullable=True), + sa.Column('contact_phone_number', sa.String(length=15), nullable=False), + sa.Column('email_address', sa.String(length=250), nullable=True), + sa.Column('user_id', sa.String(length=7), nullable=True), + sa.Column('date_ts', sa.DateTime(), nullable=True), + sa.Column('address_id', sa.Integer(), nullable=False), + sa.Column('users_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['address_id'], ['addresses.id'], ), + sa.ForeignKeyConstraint(['users_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_client_codes_head_id'), 'client_codes', ['head_id'], unique=False) + op.create_index(op.f('ix_client_codes_name'), 'client_codes', ['name'], unique=False) + op.create_table('client_codes_historical', + sa.Column('id', sa.Integer(), sa.Sequence('historical_head_id_seq'), nullable=False), + sa.Column('head_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=150), nullable=False), + sa.Column('historical_type', sa.String(length=1), nullable=False), + sa.Column('bconline_account', sa.Integer(), nullable=True), + sa.Column('contact_name', sa.String(length=100), nullable=False), + sa.Column('contact_area_cd', sa.String(length=3), nullable=True), + sa.Column('contact_phone_number', sa.String(length=15), nullable=False), + sa.Column('email_addresss', sa.String(length=250), nullable=True), + sa.Column('user_id', sa.String(length=7), nullable=True), + sa.Column('date_ts', sa.DateTime(), nullable=True), + sa.Column('branch_id', sa.Integer(), nullable=False), + sa.Column('address_id', sa.Integer(), nullable=False), + sa.Column('users_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['address_id'], ['addresses.id'], ), + sa.ForeignKeyConstraint(['branch_id'], ['client_codes.id'], ), + sa.ForeignKeyConstraint(['users_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_client_codes_historical_head_id'), 'client_codes_historical', ['head_id'], unique=False) + op.create_index(op.f('ix_client_codes_historical_name'), 'client_codes_historical', ['name'], unique=False) + op.create_table('drafts', + sa.Column('id', sa.Integer(), sa.Sequence('draft_id_seq'), nullable=False), + sa.Column('document_number', sa.String(length=10), nullable=False), + sa.Column('account_id', sa.String(length=20), nullable=False), + sa.Column('create_ts', sa.DateTime(), nullable=False), + sa.Column('registration_type_cl', sa.String(length=10), nullable=False), + sa.Column('registration_type', sa.String(length=2), nullable=False), + sa.Column('draft', sa.JSON(), nullable=False), + sa.Column('registration_number', sa.String(length=10), nullable=True), + sa.Column('update_ts', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['registration_type'], ['registration_types.registration_type'], ), + sa.ForeignKeyConstraint(['registration_type_cl'], ['registration_type_classes.registration_type_cl'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('document_number'), + sa.UniqueConstraint('document_number') + ) + op.create_index(op.f('ix_drafts_account_id'), 'drafts', ['account_id'], unique=False) + op.create_index(op.f('ix_drafts_create_ts'), 'drafts', ['create_ts'], unique=False) + op.create_table('financing_statements', + sa.Column('id', sa.Integer(), sa.Sequence('financing_id_seq'), nullable=False), + sa.Column('state_type', sa.String(length=3), nullable=False), + sa.Column('life', sa.Integer(), nullable=True), + sa.Column('expire_date', sa.DateTime(), nullable=True), + sa.Column('discharged', sa.String(length=1), nullable=True), + sa.Column('renewed', sa.String(length=1), nullable=True), + sa.Column('type_claim', sa.String(length=2), nullable=True), + sa.Column('crown_charge_type', sa.String(length=2), nullable=True), + sa.Column('crown_charge_other', sa.String(length=70), nullable=True), + sa.ForeignKeyConstraint(['state_type'], ['state_types.state_type'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('registrations', + sa.Column('id', sa.Integer(), sa.Sequence('registration_id_seq'), nullable=False), + sa.Column('registration_type_cl', sa.String(length=10), nullable=False), + sa.Column('registration_ts', sa.DateTime(), nullable=False), + sa.Column('registration_number', sa.String(length=10), nullable=False), + sa.Column('base_reg_number', sa.String(length=10), nullable=True), + sa.Column('account_id', sa.String(length=20), nullable=True), + sa.Column('client_reference_id', sa.String(length=20), nullable=True), + sa.Column('life', sa.Integer(), nullable=True), + sa.Column('lien_value', sa.String(length=15), nullable=True), + sa.Column('surrender_date', sa.DateTime(), nullable=True), + sa.Column('ver_bypassed', sa.String(length=1), nullable=True), + sa.Column('pay_invoice_id', sa.Integer(), nullable=True), + sa.Column('pay_path', sa.String(length=256), nullable=True), + sa.Column('user_id', sa.String(length=1000), nullable=True), + sa.Column('detail_description', sa.String(length=180), nullable=True), + sa.Column('financing_id', sa.Integer(), nullable=False), + sa.Column('draft_id', sa.Integer(), nullable=False), + sa.Column('registration_type', sa.String(length=2), nullable=False), + sa.ForeignKeyConstraint(['draft_id'], ['drafts.id'], ), + sa.ForeignKeyConstraint(['financing_id'], ['financing_statements.id'], ), + sa.ForeignKeyConstraint(['registration_type'], ['registration_types.registration_type'], ), + sa.ForeignKeyConstraint(['registration_type_cl'], ['registration_type_classes.registration_type_cl'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_registrations_account_id'), 'registrations', ['account_id'], unique=False) + op.create_index(op.f('ix_registrations_base_reg_number'), 'registrations', ['base_reg_number'], unique=False) + op.create_index(op.f('ix_registrations_registration_number'), 'registrations', ['registration_number'], unique=False) + op.create_index(op.f('ix_registrations_registration_ts'), 'registrations', ['registration_ts'], unique=False) + op.create_table('court_orders', + sa.Column('id', sa.Integer(), sa.Sequence('court_order_id_seq'), nullable=False), + sa.Column('order_date', sa.DateTime(), nullable=False), + sa.Column('court_name', sa.String(length=256), nullable=False), + sa.Column('court_registry', sa.String(length=64), nullable=False), + sa.Column('file_number', sa.String(length=20), nullable=False), + sa.Column('effect_of_order', sa.String(length=512), nullable=True), + sa.Column('registration_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['registration_id'], ['registrations.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('general_collateral', + sa.Column('id', sa.Integer(), sa.Sequence('general_id_seq'), nullable=False), + sa.Column('description', sa.String(length=4000), nullable=False), + sa.Column('status', sa.String(length=1), nullable=True), + sa.Column('registration_id', sa.Integer(), nullable=False), + sa.Column('financing_id', sa.Integer(), nullable=False), + sa.Column('registration_id_end', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['financing_id'], ['financing_statements.id'], ), + sa.ForeignKeyConstraint(['registration_id'], ['registrations.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('serial_collateral', + sa.Column('id', sa.Integer(), sa.Sequence('vehicle_id_seq'), nullable=False), + sa.Column('serial_type', sa.String(length=2), nullable=False), + sa.Column('year', sa.Integer(), nullable=True), + sa.Column('make', sa.String(length=60), nullable=True), + sa.Column('model', sa.String(length=60), nullable=True), + sa.Column('serial_number', sa.String(length=30), nullable=True), + sa.Column('mhr_number', sa.String(length=6), nullable=True), + sa.Column('srch_vin', sa.String(length=6), nullable=True), + sa.Column('registration_id', sa.Integer(), nullable=False), + sa.Column('financing_id', sa.Integer(), nullable=False), + sa.Column('registration_id_end', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['financing_id'], ['financing_statements.id'], ), + sa.ForeignKeyConstraint(['registration_id'], ['registrations.id'], ), + sa.ForeignKeyConstraint(['serial_type'], ['serial_types.serial_type'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_serial_collateral_srch_vin'), 'serial_collateral', ['srch_vin'], unique=False) + op.create_table('trust_indentures', + sa.Column('id', sa.Integer(), sa.Sequence('trust_id_seq'), nullable=False), + sa.Column('trust_indenture', sa.String(length=1), nullable=False), + sa.Column('registration_id', sa.Integer(), nullable=False), + sa.Column('financing_id', sa.Integer(), nullable=False), + sa.Column('registration_id_end', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['financing_id'], ['financing_statements.id'], ), + sa.ForeignKeyConstraint(['registration_id'], ['registrations.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('parties', + sa.Column('id', sa.Integer(), sa.Sequence('party_id_seq'), nullable=False), + sa.Column('party_type', sa.String(length=30), nullable=False), + sa.Column('first_name', sa.String(length=50), nullable=True), + sa.Column('middle_initial', sa.String(length=50), nullable=True), + sa.Column('last_name', sa.String(length=50), nullable=True), + sa.Column('business_name', sa.String(length=150), nullable=True), + sa.Column('birth_date', sa.DateTime(), nullable=True), + sa.Column('first_name_key', sa.String(length=50), nullable=True), + sa.Column('last_name_key', sa.String(length=50), nullable=True), + sa.Column('business_srch_key', sa.String(length=150), nullable=True), + sa.Column('address_id', sa.Integer(), nullable=True), + sa.Column('branch_id', sa.Integer(), nullable=True), + sa.Column('registration_id', sa.Integer(), nullable=False), + sa.Column('financing_id', sa.Integer(), nullable=False), + sa.Column('registration_id_end', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['address_id'], ['addresses.id'], ), + sa.ForeignKeyConstraint(['branch_id'], ['client_codes.id'], ), + sa.ForeignKeyConstraint(['financing_id'], ['financing_statements.id'], ), + sa.ForeignKeyConstraint(['party_type'], ['party_types.party_type'], ), + sa.ForeignKeyConstraint(['registration_id'], ['registrations.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_parties_business_name'), 'parties', ['business_name'], unique=False) + op.create_index(op.f('ix_parties_business_srch_key'), 'parties', ['business_srch_key'], unique=False) + op.create_index(op.f('ix_parties_first_name_key'), 'parties', ['first_name_key'], unique=False) + op.create_index(op.f('ix_parties_last_name_key'), 'parties', ['last_name_key'], unique=False) + op.create_table('search_requests', + sa.Column('id', sa.Integer(), sa.Sequence('search_id_seq'), nullable=False), + sa.Column('search_ts', sa.DateTime(), nullable=False), + sa.Column('search_type', sa.String(length=2), nullable=False), + sa.Column('api_criteria', sa.JSON(), nullable=False), + sa.Column('search_response', sa.JSON(), nullable=True), + sa.Column('account_id', sa.String(length=20), nullable=True), + sa.Column('client_reference_id', sa.String(length=20), nullable=True), + sa.Column('total_results_size', sa.Integer(), nullable=True), + sa.Column('returned_results_size', sa.Integer(), nullable=True), + sa.Column('pay_invoice_id', sa.Integer(), nullable=True), + sa.Column('pay_path', sa.String(length=256), nullable=True), + sa.ForeignKeyConstraint(['search_type'], ['search_types.search_type'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_search_requests_account_id'), 'search_requests', ['account_id'], unique=False) + op.create_index(op.f('ix_search_requests_search_ts'), 'search_requests', ['search_ts'], unique=False) + op.create_table('user_profiles', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('payment_confirmation', sa.String(length=1), nullable=False), + sa.Column('search_selection_confirmation', sa.String(length=1), nullable=False), + sa.Column('default_drop_downs', sa.String(length=1), nullable=False), + sa.Column('default_table_filters', sa.String(length=1), nullable=False), + sa.ForeignKeyConstraint(['id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('search_results', + sa.Column('search_id', sa.Integer(), nullable=False), + sa.Column('api_result', sa.JSON(), nullable=True), + sa.Column('registrations', sa.JSON(), nullable=False), + sa.Column('score', sa.Integer(), nullable=True), + sa.Column('exact_match_count', sa.Integer(), nullable=True), + sa.Column('similar_match_count', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['search_id'], ['search_requests.id'], ), + sa.PrimaryKeyConstraint('search_id') + ) + public_get_draft_document_number = PGFunction( + schema="public", + signature="get_draft_document_number()", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n BEGIN\n RETURN 'D' || trim(to_char(nextval('document_number_seq'), '0000000'));\n END\n ; \n $$" + ) + op.create_entity(public_get_draft_document_number) + + public_get_registration_num = PGFunction( + schema="public", + signature="get_registration_num()", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n BEGIN\n RETURN trim(to_char(nextval('registration_num_seq'), '000000')) || 'B';\n END\n ; \n $$" + ) + op.create_entity(public_get_registration_num) + + public_searchkey_nickname_match = PGFunction( + schema="public", + signature="searchkey_nickname_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on nickname: search key may have up to 3 names, a nickname match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + SELECT COUNT(name_id) + INTO v_match_count + FROM nicknames n1 + WHERE (name = v_name1 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name2 IS NOT NULL AND + name = v_name2 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name3 IS NOT NULL AND + name = v_name3 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))); + + RETURN v_match_count; + END + ; + $$; + """ + ) + op.create_entity(public_searchkey_nickname_match) + + public_searchkey_name_match = PGFunction( + schema="public", + signature="searchkey_name_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on name: search key may have up to 3 names, an exact match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + IF (v_name1 = name1 OR (name2 IS NOT NULL AND v_name1 = name2) OR (name3 IS NOT NULL AND v_name1 = name3)) THEN + v_match_count := 1; + ELSIF (v_name2 IS NOT NULL AND v_name2 = name1 OR (name2 IS NOT NULL AND v_name2 = name2) OR (name3 IS NOT NULL AND v_name2 = name3)) THEN + v_match_count := 1; + ELSIF (v_name3 IS NOT NULL AND v_name3 = name1 OR (name2 IS NOT NULL AND v_name3 = name2) OR (name3 IS NOT NULL AND v_name3 = name3)) THEN + v_match_count := 1; + END IF; + + RETURN v_match_count; + END + ; + $$; + """ + ) + op.create_entity(public_searchkey_name_match) + + public_match_individual_name = PGFunction( + schema="public", + signature="match_individual_name(lastname IN VARCHAR, firstname IN VARCHAR)", + definition=""" + RETURNS int[] + LANGUAGE plpgsql + AS + $$ + -- Debtor individual name matching comparison is between party.last_name_key and a key generated from lastname, and + -- between party.first_name_key and a key generated from the firstname parameter. + -- For matching, a last name key may have 2 names separated by a space character. + -- For matching, a first name key may have 3 names separated by a space character. + -- In all cases, first name matching is a cartesian cross product on either exact name or nickname. + -- Cases from Oracle PL/SQL: + -- 1. Match last name by keys on algorithm and first name by either algorithm, name, or nickname. + -- 2. Match last name by exact match on party.last_name_key second name and lastname first name; first name by either name or nickname. + -- 3. Match last name by exact match on party.last_name_key first name and lastname second name; first name by either name or nickname. + -- 4. Match last name by exact match on party.last_name_key second name and lastname second name; first name by either name or nickname. + -- As any of 2, 3 and 4 is a hit they are collapsed to the same condition below. + -- Performance should improve if split names are stored as separate columns in the party table and indexed or stored in a separate table. + DECLARE + v_ids integer ARRAY; + v_lastname_key VARCHAR(50); + v_last1 VARCHAR(50); + v_last2 VARCHAR(50); + v_firstname_key VARCHAR(50); + v_first1 VARCHAR(50); + v_first2 VARCHAR(50); + v_first3 VARCHAR(50); + BEGIN + v_lastname_key := searchkey_last_name(lastname); + v_last1 = split_part(v_lastname_key, ' ', 1); + v_last2 = split_part(v_lastname_key, ' ', 2); -- May be null + v_firstname_key := searchkey_first_name(firstname); + v_first1 = split_part(v_firstname_key, ' ', 1); + v_first2 = split_part(v_firstname_key, ' ', 2); -- May be null + v_first3 = split_part(v_firstname_key, ' ', 3); -- May be null + + -- Replace where clause: Oracle uses UTL_MATCH.JARO_WINKLER_SIMILARITY + SELECT array_agg(id) + INTO v_ids + FROM parties p + WHERE registration_id_end IS NULL AND + party_type = 'DI' AND + ((levenshtein(p.last_name_key, v_lastname_key) <= 2 AND + (levenshtein(p.first_name_key, v_firstname_key) <= 2 OR + searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0)) OR + -- This looks like a full party table scan + (searchkey_name_match(p.last_name_key, v_last1, v_last2, null) > 0 AND + (searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0))); + + RETURN v_ids; + END + ; + $$; + """ + ) + op.create_entity(public_match_individual_name) + + public_searchkey_aircraft = PGFunction( + schema="public", + signature="searchkey_aircraft(aircraft_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(25);\n BEGIN\n v_search_key := TRIM(REGEXP_REPLACE(aircraft_number,'\\s|-','','gi'));\n IF (LENGTH(v_search_key) > 6) THEN\n v_search_key := RIGHT(v_search_key, 6);\n END IF;\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_aircraft) + + public_searchkey_business_name = PGFunction( + schema="public", + signature="searchkey_business_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(150);\n BEGIN\n v_search_key :=\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(actual_name,'^0000|^000|^00|^0|^THE | THE |\\([^()]*\\)',''),\n 'CORPORATION|CORP|COMPANY|CO\\.|LTD|INCORPORATED|INC$|INC.|INCORPOREE|LIMITED|LIMITEE|LTEE|LTD|ASSOCIATION$|ASSOC$|ASSN$|NON PERSONAL LIABILITY$|UNLIMITED LIABILITY COMPANY|N P L$|NPL$|PARTNERSHIP|SOCIETY$|SOC$',''),\n 'BRITISH COLUMBIA|BRITISHCOLUMBIA','BC'),\n '&','AND'),\n '#','NUMBER'),\n '1','ONE'),\n '2','TWO'),\n '3','THREE'),\n '4','FOUR'),\n '5','FIVE'),\n '6','SIX'),\n '7','SEVEN'),\n '8','EIGHT'),\n '9','NINE'),\n '0','ZERO'),\n 'TEN','ONEZERO'),\n 'TWENTY','TWOZERO'),\n 'THIRTY','THREEERO'),\n 'FORTY','FOURZERO'),\n 'FOURTY','FOURZERO'),\n 'FIFTY','FIVEZERO'),\n 'SIXTY','SIXZERO'),\n 'SEVENTY','SEVENZERO'),\n 'EIGHTY','EIGHTZERO'),\n 'NINETY','NINEZERO'),\n '[^0-9A-Za-z]','','gi');\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_business_name) + + public_searchkey_first_name = PGFunction( + schema="public", + signature="searchkey_first_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(92);\n BEGIN\n -- Remove prefixes\n v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi');\n -- Remove suffixes\n v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi');\n v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi');\n -- Remove internal extra space characters\n v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g'));\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_first_name) + + public_searchkey_last_name = PGFunction( + schema="public", + signature="searchkey_last_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(60);\n BEGIN\n -- Remove prefixes\n v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi');\n -- Remove suffixes\n v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi');\n v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi');\n -- Remove internal extra space characters\n v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g'));\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_last_name) + + public_searchkey_mhr = PGFunction( + schema="public", + signature="searchkey_mhr(mhr_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(6);\n BEGIN\n v_search_key := TRIM(REGEXP_REPLACE(mhr_number,'[^0-9A-Za-z]','','gi'));\n v_search_key := LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','0'),6,'0');\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_mhr) + + public_searchkey_vehicle = PGFunction( + schema="public", + signature="searchkey_vehicle(serial_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(25);\n v_vin VARCHAR(25);\n v_digits VARCHAR(25);\n v_length_digits integer;\n v_last_digit_index integer;\n BEGIN\n v_search_key := UPPER(REGEXP_REPLACE(serial_number,'[^0-9A-Za-z]','','gi'));\n v_digits := regexp_replace(v_search_key, '[^0-9]', '', 'g');\n v_length_digits := length(v_digits);\n v_vin := '';\n IF (v_length_digits > 0) THEN\n v_last_digit_index := length(v_search_key) - length(regexp_replace(v_search_key, '.*' || RIGHT(v_digits, 1),'', 'g'));\n ELSE\n v_last_digit_index := 0;\n END IF;\n \n SELECT \n CASE \n WHEN v_length_digits = 0 THEN '000000'\n WHEN v_length_digits = 1 THEN LPAD(v_digits, 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN '0' AND '9' THEN LPAD(RIGHT(v_search_key, LEAST(LENGTH(v_search_key), 6)), 6, '0')\n WHEN RIGHT(v_search_key, 1) IN ('B','C','G','H','I','L','S','O','Y','Z') AND \n LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' THEN LPAD(RIGHT(v_search_key, 6), 6, '0')\n WHEN RIGHT(v_search_key, 1) NOT IN ('B','C','G','H','I','L','S','O','Y','Z') AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN '0' AND '9' AND\n LENGTH(v_search_key) > 6 THEN LEFT(RIGHT(v_search_key, 7), 6)\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) < 6 THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' AND\n v_last_digit_index BETWEEN 1 AND 5\n THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) > 6\n -- This does not appear to always work correctly.\n THEN LPAD(SUBSTR(v_search_key, (v_last_digit_index - 5), 5), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) > 6\n -- This does not appear to always work correctly.\n THEN SUBSTR(v_search_key, (v_last_digit_index - 5), 6)\n END\n INTO v_vin;\n\n IF (LENGTH(v_vin) > 0) THEN\n v_search_key := v_vin;\n END IF;\n IF (LENGTH(v_search_key) > 6) THEN\n v_search_key := RIGHT(v_search_key, 6);\n END IF;\n\n v_search_key := REGEXP_REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(v_search_key,'I','1'),\n 'L','1'),\n 'Z','2'),\n 'H','4'),\n 'Y','4'),\n 'S','5'),\n 'C','6'),\n 'G','6'),\n 'B','8'),\n 'O','0'),\n '[A-Za-z]','0'); \n\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.create_entity(public_searchkey_vehicle) + # ### Manually add type table data ### + op.bulk_insert(party_type, + [ + { 'party_type': 'DB', 'party_type_desc': 'BUSINESS DEBTOR' }, + { 'party_type': 'DI', 'party_type_desc': 'INDIVIDUAL DEBTOR' }, + { 'party_type': 'RG', 'party_type_desc': 'REGISTERING PARTY' }, + { 'party_type': 'SP', 'party_type_desc': 'SECURED PARTY' } + ] + ) + op.bulk_insert(registration_type_class, + [ + { 'registration_type_cl': 'PPSALIEN', + 'registration_desc': 'NEW REGISTRATION FILED UNDER THE PPSA SECURITY ACT' }, + { 'registration_type_cl': 'MISCLIEN', + 'registration_desc': 'NEW REGISTRATION FILED UNDER MISCELLANEOUS REGISTRATIONS ACT' }, + { 'registration_type_cl': 'CROWNLIEN', + 'registration_desc': 'NEW REGISTRATION FILED UNDER MISCELLANEOUS REGISTRATIONS ACT AS A CROWN CHARGE' }, + { 'registration_type_cl': 'AMENDMENT', + 'registration_desc': 'AMENDMENT REGISTRATION FILED UNDER THE PPSA SECURITY ACT' }, + { 'registration_type_cl': 'COURTORDER', + 'registration_desc': 'COURT ORDERED AMENDMENT FILED UNDER THE PPSA SECURITY ACT' }, + { 'registration_type_cl': 'CHANGE', + 'registration_desc': 'CHANGE REGISTRATION FILED UNDER THE PPSA SECURITY ACT' }, + { 'registration_type_cl': 'RENEWAL', + 'registration_desc': 'RENEWAL REGISTRATION FILED UNDER THE PPSA SECURITY ACT' }, + { 'registration_type_cl': 'DISCHARGE', + 'registration_desc': 'TOTAL DISCHARE REGISTRATION FILED UNDER THE PPSA SECURITY ACT' } + ] + ) + op.bulk_insert(registration_type, + [ + { + 'registration_type_cl': 'AMENDMENT', + 'registration_type': 'AM', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'AMENDMENT/OTHER CHANGE' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'AC', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'ADDITION OF COLLATERAL/PROCEEDS' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'DR', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'DEBTOR RELEASE' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'DT', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'DEBTOR TRANSFER' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'PD', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'PARTIAL DISCHARGE' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'ST', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'SECURED PARTY TRANSFER' + }, + { + 'registration_type_cl': 'CHANGE', + 'registration_type': 'SU', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'SUBSTITUTION OF COLLATERAL' + }, + { + 'registration_type_cl': 'COURTORDER', + 'registration_type': 'CO', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'COURT ORDER' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'CC', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO CORPORATION CAPITAL TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'CT', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO CARBON TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'DP', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO CONSUMPTION, TRANSITION TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'ET', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO EXCISE TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'FO', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO FOREST ACT' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'FT', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO MOTOR FUEL TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'HR', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO HOTEL ROOM TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'IP', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO INSURANCE PREMIUM TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'IT', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO INCOME TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'LO', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO LOGGING TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'MI', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO MINING TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'MR', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO MINERAL RESOURCE TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'OT', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'OTHER' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'PG', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO PETROLEUM and NATURAL GAS TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'PS', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO PROVINCIAL SALES TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'RA', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO RURAL PROPERTY TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'SS', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'CROWN CHARGE FILED PURSUANT TO SOCIAL SERVICE TAX' + }, + { + 'registration_type_cl': 'CROWNLIEN', + 'registration_type': 'TL', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'TAX LIEN UNDER SOCIAL SERVICE OR HOTEL ROOM TAX ACTS' + }, + { + 'registration_type_cl': 'DISCHARGE', + 'registration_type': 'DC', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'TOTAL DISCHARGE' + }, + { + 'registration_type_cl': 'MISCLIEN', + 'registration_type': 'HN', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'HERITAGE CONSERVATION NOTICE' + }, + { + 'registration_type_cl': 'MISCLIEN', + 'registration_type': 'ML', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'MAINTENANCE LIEN' + }, + { + 'registration_type_cl': 'MISCLIEN', + 'registration_type': 'MN', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'MANUFACTURED HOME NOTICE' + }, + { + 'registration_type_cl': 'MISCLIEN', + 'registration_type': 'PN', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'PROCEEDS OF CRIME NOTICE' + }, + { + 'registration_type_cl': 'MISCLIEN', + 'registration_type': 'WL', + 'registration_act': 'MISCELLANEOUS REGISTRATIONS ACT', + 'registration_desc': 'LIEN FOR UNPAID WAGES' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'FA', + 'registration_act': 'FORESTRY - CONTRACTOR CHARGE', + 'registration_desc': 'FORESTRY - CONTRACTOR CHARGE' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'FL', + 'registration_act': 'FORESTRY - CONTRACTOR LIEN', + 'registration_desc': 'FORESTRY - CONTRACTOR LIEN' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'FR', + 'registration_act': 'FAMILY LAW ACT', + 'registration_desc': 'MARRIAGE/SEPARATION AGREEMENT AFFECTING MANUFACTURED HOME' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'FS', + 'registration_act': 'FORESTRY - SUB-CONTRACTOR CHARGE', + 'registration_desc': 'FORESTRY - SUB-CONTRACTOR CHARGE' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'LT', + 'registration_act': 'LAND TAX DEFERMENT ACT', + 'registration_desc': 'LAND TAX DEFERMENT LIEN ON A MANUFACTURED HOME' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'MH', + 'registration_act': 'MANUFACTURED HOME ACT, S.27/28', + 'registration_desc': 'TAX LIEN UNDER S.27/28 OF THE MANUFACTURED HOME ACT' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'RL', + 'registration_act': 'REPAIRERS LIEN ACT', + 'registration_desc': 'REPAIRER''S LIEN' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'SA', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'PPSA SECURITY AGREEMENT' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'SG', + 'registration_act': 'SALE OF GOODS ACT, S.30', + 'registration_desc': 'POSSESSION UNDER S.30 OF THE SALE OF GOODS ACT' + }, + { + 'registration_type_cl': 'PPSALIEN', + 'registration_type': 'TF', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'PPSA TRANSITION FINANCING STATEMENT' + }, + { + 'registration_type_cl': 'RENEWAL', + 'registration_type': 'RE', + 'registration_act': 'PPSA SECURITY ACT', + 'registration_desc': 'RENEWAL' + } + ] + ) + op.bulk_insert(search_type, + [ + { 'search_type': 'AC', 'search_type_desc': 'AIRCRAFT AIRFRAME D.O.T. NUMBER' }, + { 'search_type': 'BS', 'search_type_desc': 'BUSINESS DEBTOR NAME' }, + { 'search_type': 'IS', 'search_type_desc': 'INDIVIDUAL DEBTOR NAME' }, + { 'search_type': 'MH', 'search_type_desc': 'MANUFACTURED HOME REGISTRATION NUMBER' }, + { 'search_type': 'RG', 'search_type_desc': 'REGISTRATION NUMBER' }, + { 'search_type': 'SS', 'search_type_desc': 'SERIAL NUMBER SEARCH' } + ] + ) + op.bulk_insert(serial_type, + [ + { 'serial_type': 'AC', 'serial_type_desc': 'AIRCRAFT' }, + { 'serial_type': 'AF', 'serial_type_desc': 'AIRCRAFT AIRFRAME' }, + { 'serial_type': 'AP', 'serial_type_desc': 'AIRPLANE' }, + { 'serial_type': 'BO', 'serial_type_desc': 'BOAT' }, + { 'serial_type': 'EV', 'serial_type_desc': 'ELECTRIC MOTOR VEHICLE' }, + { 'serial_type': 'MH', 'serial_type_desc': 'MANUFACTURED HOME' }, + { 'serial_type': 'MV', 'serial_type_desc': 'MOTOR VEHICLE' }, + { 'serial_type': 'OB', 'serial_type_desc': 'OUTBOARD BOAT MOTOR' }, + { 'serial_type': 'TR', 'serial_type_desc': 'TRAILER' } + ] + ) + op.bulk_insert(state_type, + [ + { 'state_type': 'ACT', 'state_type_desc': 'ACTIVE' }, + { 'state_type': 'HEX', 'state_type_desc': 'REGISTRATION HAS EXPIRED' }, + { 'state_type': 'HDC', 'state_type_desc': 'REGISTRATION DISCHARGED' } + ] + ) + op.bulk_insert(country_type, + [ + { + 'country_type': 'AD', + 'country_desc': 'ANDORRA' + }, + { + 'country_type': 'AE', + 'country_desc': 'UNITED ARAB EMIRATES' + }, + { + 'country_type': 'AF', + 'country_desc': 'AFGHANISTAN' + }, + { + 'country_type': 'AG', + 'country_desc': 'ANTIGUA AND BARBUDA' + }, + { + 'country_type': 'AI', + 'country_desc': 'ANGUILLA' + }, + { + 'country_type': 'AL', + 'country_desc': 'ALBANIA' + }, + { + 'country_type': 'AM', + 'country_desc': 'ARMENIA' + }, + { + 'country_type': 'AN', + 'country_desc': 'NETHERLANDS ANTILLES' + }, + { + 'country_type': 'AO', + 'country_desc': 'ANGOLA' + }, + { + 'country_type': 'AQ', + 'country_desc': 'ANTARCTICA' + }, + { + 'country_type': 'AR', + 'country_desc': 'ARGENTINA' + }, + { + 'country_type': 'AS', + 'country_desc': 'AMERICAN SAMOA' + }, + { + 'country_type': 'AT', + 'country_desc': 'AUSTRIA' + }, + { + 'country_type': 'AU', + 'country_desc': 'AUSTRALIA' + }, + { + 'country_type': 'AW', + 'country_desc': 'ARUBA' + }, + { + 'country_type': 'AX', + 'country_desc': 'ALAND ISLANDS' + }, + { + 'country_type': 'AZ', + 'country_desc': 'AZERBAIJAN' + }, + { + 'country_type': 'BA', + 'country_desc': 'BOSNIA AND HERZEGOVINA' + }, + { + 'country_type': 'BB', + 'country_desc': 'BARBADOS' + }, + { + 'country_type': 'BD', + 'country_desc': 'BANGLADESH' + }, + { + 'country_type': 'BE', + 'country_desc': 'BELGIUM' + }, + { + 'country_type': 'BF', + 'country_desc': 'BURKINA FASO' + }, + { + 'country_type': 'BG', + 'country_desc': 'BULGARIA' + }, + { + 'country_type': 'BH', + 'country_desc': 'BAHRAIN' + }, + { + 'country_type': 'BI', + 'country_desc': 'BURUNDI' + }, + { + 'country_type': 'BJ', + 'country_desc': 'BENIN' + }, + { + 'country_type': 'BL', + 'country_desc': 'SAINT BARTHELEMY' + }, + { + 'country_type': 'BM', + 'country_desc': 'BERMUDA' + }, + { + 'country_type': 'BN', + 'country_desc': 'BRUNEI DARUSSALAM' + }, + { + 'country_type': 'BO', + 'country_desc': 'BOLIVIA' + }, + { + 'country_type': 'BQ', + 'country_desc': 'BONAIRE, ST EUSTATIUS AND SABA' + }, + { + 'country_type': 'BR', + 'country_desc': 'BRAZIL' + }, + { + 'country_type': 'BS', + 'country_desc': 'BAHAMAS' + }, + { + 'country_type': 'BT', + 'country_desc': 'BHUTAN' + }, + { + 'country_type': 'BV', + 'country_desc': 'BOUVET ISLAND' + }, + { + 'country_type': 'BW', + 'country_desc': 'BOTSWANA' + }, + { + 'country_type': 'BY', + 'country_desc': 'BELARUS' + }, + { + 'country_type': 'BZ', + 'country_desc': 'BELIZE' + }, + { + 'country_type': 'CA', + 'country_desc': 'CANADA' + }, + { + 'country_type': 'CC', + 'country_desc': 'COCOS (KEELING) ISLANDS' + }, + { + 'country_type': 'CD', + 'country_desc': 'CONGO, THE DEMOCRATIC REPUBLIC OF THE' + }, + { + 'country_type': 'CF', + 'country_desc': 'CENTRAL AFRICAN REPUBLIC' + }, + { + 'country_type': 'CG', + 'country_desc': 'CONGO' + }, + { + 'country_type': 'CH', + 'country_desc': 'SWITZERLAND' + }, + { + 'country_type': 'CI', + 'country_desc': 'COTE D''IVOIRE' + }, + { + 'country_type': 'CK', + 'country_desc': 'COOK ISLANDS' + }, + { + 'country_type': 'CL', + 'country_desc': 'CHILE' + }, + { + 'country_type': 'CM', + 'country_desc': 'CAMEROON' + }, + { + 'country_type': 'CN', + 'country_desc': 'CHINA' + }, + { + 'country_type': 'CO', + 'country_desc': 'COLOMBIA' + }, + { + 'country_type': 'CR', + 'country_desc': 'COSTA RICA' + }, + { + 'country_type': 'CU', + 'country_desc': 'CUBA' + }, + { + 'country_type': 'CV', + 'country_desc': 'CAPE VERDE' + }, + { + 'country_type': 'CW', + 'country_desc': 'CURACAO' + }, + { + 'country_type': 'CX', + 'country_desc': 'CHRISTMAS ISLAND' + }, + { + 'country_type': 'CY', + 'country_desc': 'CYPRUS' + }, + { + 'country_type': 'CZ', + 'country_desc': 'CZECH REPUBLIC' + }, + { + 'country_type': 'DE', + 'country_desc': 'GERMANY' + }, + { + 'country_type': 'DJ', + 'country_desc': 'DJIBOUTI' + }, + { + 'country_type': 'DK', + 'country_desc': 'DENMARK' + }, + { + 'country_type': 'DM', + 'country_desc': 'DOMINICA' + }, + { + 'country_type': 'DO', + 'country_desc': 'DOMINICAN REPUBLIC' + }, + { + 'country_type': 'DZ', + 'country_desc': 'ALGERIA' + }, + { + 'country_type': 'EC', + 'country_desc': 'ECUADOR' + }, + { + 'country_type': 'EE', + 'country_desc': 'ESTONIA' + }, + { + 'country_type': 'EG', + 'country_desc': 'EGYPT' + }, + { + 'country_type': 'EH', + 'country_desc': 'WESTERN SAHARA' + }, + { + 'country_type': 'ER', + 'country_desc': 'ERITREA' + }, + { + 'country_type': 'ES', + 'country_desc': 'SPAIN' + }, + { + 'country_type': 'ET', + 'country_desc': 'ETHIOPIA' + }, + { + 'country_type': 'FI', + 'country_desc': 'FINLAND' + }, + { + 'country_type': 'FJ', + 'country_desc': 'FIJI' + }, + { + 'country_type': 'FK', + 'country_desc': 'FALKLAND ISLANDS (MALVINAS)' + }, + { + 'country_type': 'FM', + 'country_desc': 'MICRONESIA, FEDERATED STATES OF' + }, + { + 'country_type': 'FO', + 'country_desc': 'FAROE ISLANDS' + }, + { + 'country_type': 'FR', + 'country_desc': 'FRANCE' + }, + { + 'country_type': 'FX', + 'country_desc': 'FRANCE, METROPOLITAN' + }, + { + 'country_type': 'GA', + 'country_desc': 'GABON' + }, + { + 'country_type': 'GB', + 'country_desc': 'UNITED KINGDOM' + }, + { + 'country_type': 'GD', + 'country_desc': 'GRENADA' + }, + { + 'country_type': 'GE', + 'country_desc': 'GEORGIA' + }, + { + 'country_type': 'GF', + 'country_desc': 'FRENCH GUIANA' + }, + { + 'country_type': 'GG', + 'country_desc': 'GUERNSEY' + }, + { + 'country_type': 'GH', + 'country_desc': 'GHANA' + }, + { + 'country_type': 'GI', + 'country_desc': 'GIBRALTAR' + }, + { + 'country_type': 'GL', + 'country_desc': 'GREENLAND' + }, + { + 'country_type': 'GM', + 'country_desc': 'GAMBIA' + }, + { + 'country_type': 'GN', + 'country_desc': 'GUINEA' + }, + { + 'country_type': 'GP', + 'country_desc': 'GUADELOUPE' + }, + { + 'country_type': 'GQ', + 'country_desc': 'EQUATORIAL GUINEA' + }, + { + 'country_type': 'GR', + 'country_desc': 'GREECE' + }, + { + 'country_type': 'GS', + 'country_desc': 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISL' + }, + { + 'country_type': 'GT', + 'country_desc': 'GUATEMALA' + }, + { + 'country_type': 'GU', + 'country_desc': 'GUAM' + }, + { + 'country_type': 'GW', + 'country_desc': 'GUINEA-BISSAU' + }, + { + 'country_type': 'GY', + 'country_desc': 'GUYANA' + }, + { + 'country_type': 'HK', + 'country_desc': 'HONG KONG' + }, + { + 'country_type': 'HM', + 'country_desc': 'HEARD ISLAND AND MCDONALD ISLANDS' + }, + { + 'country_type': 'HN', + 'country_desc': 'HONDURAS' + }, + { + 'country_type': 'HR', + 'country_desc': 'CROATIA' + }, + { + 'country_type': 'HT', + 'country_desc': 'HAITI' + }, + { + 'country_type': 'HU', + 'country_desc': 'HUNGARY' + }, + { + 'country_type': 'ID', + 'country_desc': 'INDONESIA' + }, + { + 'country_type': 'IE', + 'country_desc': 'IRELAND' + }, + { + 'country_type': 'IL', + 'country_desc': 'ISRAEL' + }, + { + 'country_type': 'IM', + 'country_desc': 'ISLE OF MAN' + }, + { + 'country_type': 'IN', + 'country_desc': 'INDIA' + }, + { + 'country_type': 'IO', + 'country_desc': 'BRITISH INDIAN OCEAN TERRITORY' + }, + { + 'country_type': 'IQ', + 'country_desc': 'IRAQ' + }, + { + 'country_type': 'IR', + 'country_desc': 'IRAN, ISLAMIC REPUBLIC OF' + }, + { + 'country_type': 'IS', + 'country_desc': 'ICELAND' + }, + { + 'country_type': 'IT', + 'country_desc': 'ITALY' + }, + { + 'country_type': 'JE', + 'country_desc': 'JERSEY' + }, + { + 'country_type': 'JM', + 'country_desc': 'JAMAICA' + }, + { + 'country_type': 'JO', + 'country_desc': 'JORDAN' + }, + { + 'country_type': 'JP', + 'country_desc': 'JAPAN' + }, + { + 'country_type': 'KE', + 'country_desc': 'KENYA' + }, + { + 'country_type': 'KG', + 'country_desc': 'KYRGYZSTAN' + }, + { + 'country_type': 'KH', + 'country_desc': 'CAMBODIA' + }, + { + 'country_type': 'KI', + 'country_desc': 'KIRIBATI' + }, + { + 'country_type': 'KM', + 'country_desc': 'COMOROS' + }, + { + 'country_type': 'KN', + 'country_desc': 'SAINT KITTS AND NEVIS' + }, + { + 'country_type': 'KP', + 'country_desc': 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF' + }, + { + 'country_type': 'KR', + 'country_desc': 'KOREA, REPUBLIC OF' + }, + { + 'country_type': 'KW', + 'country_desc': 'KUWAIT' + }, + { + 'country_type': 'KY', + 'country_desc': 'CAYMAN ISLANDS' + }, + { + 'country_type': 'KZ', + 'country_desc': 'KAZAKHSTAN' + }, + { + 'country_type': 'LA', + 'country_desc': 'LAO PEOPLE''S DEMOCRATIC REPUBLIC' + }, + { + 'country_type': 'LB', + 'country_desc': 'LEBANON' + }, + { + 'country_type': 'LC', + 'country_desc': 'SAINT LUCIA' + }, + { + 'country_type': 'LI', + 'country_desc': 'LIECHTENSTEIN' + }, + { + 'country_type': 'LK', + 'country_desc': 'SRI LANKA' + }, + { + 'country_type': 'LR', + 'country_desc': 'LIBERIA' + }, + { + 'country_type': 'LS', + 'country_desc': 'LESOTHO' + }, + { + 'country_type': 'LT', + 'country_desc': 'LITHUANIA' + }, + { + 'country_type': 'LU', + 'country_desc': 'LUXEMBOURG' + }, + { + 'country_type': 'LV', + 'country_desc': 'LATVIA' + }, + { + 'country_type': 'LY', + 'country_desc': 'LIBYA' + }, + { + 'country_type': 'MA', + 'country_desc': 'MOROCCO' + }, + { + 'country_type': 'MC', + 'country_desc': 'MONACO' + }, + { + 'country_type': 'MD', + 'country_desc': 'MOLDOVA, REPUBLIC OF' + }, + { + 'country_type': 'ME', + 'country_desc': 'MONTENEGRO' + }, + { + 'country_type': 'MF', + 'country_desc': 'SAINT MARTIN(FRENCH PART)' + }, + { + 'country_type': 'MG', + 'country_desc': 'MADAGASCAR' + }, + { + 'country_type': 'MH', + 'country_desc': 'MARSHALL ISLANDS' + }, + { + 'country_type': 'MK', + 'country_desc': 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC ' + }, + { + 'country_type': 'ML', + 'country_desc': 'MALI' + }, + { + 'country_type': 'MM', + 'country_desc': 'MYANMAR' + }, + { + 'country_type': 'MN', + 'country_desc': 'MONGOLIA' + }, + { + 'country_type': 'MO', + 'country_desc': 'MACAO' + }, + { + 'country_type': 'MP', + 'country_desc': 'NORTHERN MARIANA ISLANDS' + }, + { + 'country_type': 'MQ', + 'country_desc': 'MARTINIQUE' + }, + { + 'country_type': 'MR', + 'country_desc': 'MAURITANIA' + }, + { + 'country_type': 'MS', + 'country_desc': 'MONTSERRAT' + }, + { + 'country_type': 'MT', + 'country_desc': 'MALTA' + }, + { + 'country_type': 'MU', + 'country_desc': 'MAURITIUS' + }, + { + 'country_type': 'MV', + 'country_desc': 'MALDIVES' + }, + { + 'country_type': 'MW', + 'country_desc': 'MALAWI' + }, + { + 'country_type': 'MX', + 'country_desc': 'MEXICO' + }, + { + 'country_type': 'MY', + 'country_desc': 'MALAYSIA' + }, + { + 'country_type': 'MZ', + 'country_desc': 'MOZAMBIQUE' + }, + { + 'country_type': 'NA', + 'country_desc': 'NAMIBIA' + }, + { + 'country_type': 'NC', + 'country_desc': 'NEW CALEDONIA' + }, + { + 'country_type': 'NE', + 'country_desc': 'NIGER' + }, + { + 'country_type': 'NF', + 'country_desc': 'NORFOLK ISLAND' + }, + { + 'country_type': 'NG', + 'country_desc': 'NIGERIA' + }, + { + 'country_type': 'NI', + 'country_desc': 'NICARAGUA' + }, + { + 'country_type': 'NL', + 'country_desc': 'NETHERLANDS' + }, + { + 'country_type': 'NO', + 'country_desc': 'NORWAY' + }, + { + 'country_type': 'NP', + 'country_desc': 'NEPAL' + }, + { + 'country_type': 'NR', + 'country_desc': 'NAURU' + }, + { + 'country_type': 'NU', + 'country_desc': 'NIUE' + }, + { + 'country_type': 'NZ', + 'country_desc': 'NEW ZEALAND' + }, + { + 'country_type': 'OM', + 'country_desc': 'OMAN' + }, + { + 'country_type': 'PA', + 'country_desc': 'PANAMA' + }, + { + 'country_type': 'PE', + 'country_desc': 'PERU' + }, + { + 'country_type': 'PF', + 'country_desc': 'FRENCH POLYNESIA' + }, + { + 'country_type': 'PG', + 'country_desc': 'PAPUA NEW GUINEA' + }, + { + 'country_type': 'PH', + 'country_desc': 'PHILIPPINES' + }, + { + 'country_type': 'PK', + 'country_desc': 'PAKISTAN' + }, + { + 'country_type': 'PL', + 'country_desc': 'POLAND' + }, + { + 'country_type': 'PM', + 'country_desc': 'SAINT PIERRE AND MIQUELON' + }, + { + 'country_type': 'PN', + 'country_desc': 'PITCAIRN' + }, + { + 'country_type': 'PR', + 'country_desc': 'PUERTO RICO' + }, + { + 'country_type': 'PS', + 'country_desc': 'PALESTINIAN TERRITORY, OCCUPIED' + }, + { + 'country_type': 'PT', + 'country_desc': 'PORTUGAL' + }, + { + 'country_type': 'PW', + 'country_desc': 'PALAU' + }, + { + 'country_type': 'PY', + 'country_desc': 'PARAGUAY' + }, + { + 'country_type': 'QA', + 'country_desc': 'QATAR' + }, + { + 'country_type': 'RE', + 'country_desc': 'REUNION' + }, + { + 'country_type': 'RO', + 'country_desc': 'ROMANIA' + }, + { + 'country_type': 'RS', + 'country_desc': 'SERBIA' + }, + { + 'country_type': 'RU', + 'country_desc': 'RUSSIAN FEDERATION' + }, + { + 'country_type': 'RW', + 'country_desc': 'RWANDA' + }, + { + 'country_type': 'SA', + 'country_desc': 'SAUDI ARABIA' + }, + { + 'country_type': 'SB', + 'country_desc': 'SOLOMON ISLANDS' + }, + { + 'country_type': 'SC', + 'country_desc': 'SEYCHELLES' + }, + { + 'country_type': 'SD', + 'country_desc': 'SUDAN' + }, + { + 'country_type': 'SE', + 'country_desc': 'SWEDEN' + }, + { + 'country_type': 'SG', + 'country_desc': 'SINGAPORE' + }, + { + 'country_type': 'SH', + 'country_desc': 'SAINT HELENA' + }, + { + 'country_type': 'SI', + 'country_desc': 'SLOVENIA' + }, + { + 'country_type': 'SJ', + 'country_desc': 'SVALBARD AND JAN MAYEN' + }, + { + 'country_type': 'SK', + 'country_desc': 'SLOVAKIA' + }, + { + 'country_type': 'SL', + 'country_desc': 'SIERRA LEONE' + }, + { + 'country_type': 'SM', + 'country_desc': 'SAN MARINO' + }, + { + 'country_type': 'SN', + 'country_desc': 'SENEGAL' + }, + { + 'country_type': 'SO', + 'country_desc': 'SOMALIA' + }, + { + 'country_type': 'SR', + 'country_desc': 'SURINAME' + }, + { + 'country_type': 'SS', + 'country_desc': 'SOUTH SUDAN' + }, + { + 'country_type': 'ST', + 'country_desc': 'SAO TOME AND PRINCIPE' + }, + { + 'country_type': 'SV', + 'country_desc': 'EL SALVADOR' + }, + { + 'country_type': 'SX', + 'country_desc': 'SINT MAARTEN(DUTCH PART)' + }, + { + 'country_type': 'SY', + 'country_desc': 'SYRIAN ARAB REPUBLIC' + }, + { + 'country_type': 'SZ', + 'country_desc': 'SWAZILAND' + }, + { + 'country_type': 'TA', + 'country_desc': 'TRISTAN DA CUNHA' + }, + { + 'country_type': 'TC', + 'country_desc': 'TURKS AND CAICOS ISLANDS' + }, + { + 'country_type': 'TD', + 'country_desc': 'CHAD' + }, + { + 'country_type': 'TF', + 'country_desc': 'FRENCH SOUTHERN TERRITORIES' + }, + { + 'country_type': 'TG', + 'country_desc': 'TOGO' + }, + { + 'country_type': 'TH', + 'country_desc': 'THAILAND' + }, + { + 'country_type': 'TJ', + 'country_desc': 'TAJIKISTAN' + }, + { + 'country_type': 'TK', + 'country_desc': 'TOKELAU' + }, + { + 'country_type': 'TL', + 'country_desc': 'TIMOR-LESTE' + }, + { + 'country_type': 'TM', + 'country_desc': 'TURKMENISTAN' + }, + { + 'country_type': 'TN', + 'country_desc': 'TUNISIA' + }, + { + 'country_type': 'TO', + 'country_desc': 'TONGA' + }, + { + 'country_type': 'TR', + 'country_desc': 'TURKEY' + }, + { + 'country_type': 'TT', + 'country_desc': 'TRINIDAD AND TOBAGO' + }, + { + 'country_type': 'TV', + 'country_desc': 'TUVALU' + }, + { + 'country_type': 'TW', + 'country_desc': 'TAIWAN' + }, + { + 'country_type': 'TZ', + 'country_desc': 'TANZANIA, UNITED REPUBLIC OF' + }, + { + 'country_type': 'UA', + 'country_desc': 'UKRAINE' + }, + { + 'country_type': 'UG', + 'country_desc': 'UGANDA' + }, + { + 'country_type': 'UM', + 'country_desc': 'UNITED STATES MINOR OUTLYING ISLANDS' + }, + { + 'country_type': 'US', + 'country_desc': 'UNITED STATES' + }, + { + 'country_type': 'UY', + 'country_desc': 'URUGUAY' + }, + { + 'country_type': 'UZ', + 'country_desc': 'UZBEKISTAN' + }, + { + 'country_type': 'VA', + 'country_desc': 'HOLY SEE (VATICAN CITY STATE)' + }, + { + 'country_type': 'VC', + 'country_desc': 'SAINT VINCENT AND THE GRENADINES' + }, + { + 'country_type': 'VE', + 'country_desc': 'VENEZUELA' + }, + { + 'country_type': 'VG', + 'country_desc': 'VIRGIN ISLANDS, BRITISH' + }, + { + 'country_type': 'VI', + 'country_desc': 'VIRGIN ISLANDS, U.S.' + }, + { + 'country_type': 'VN', + 'country_desc': 'VIET NAM' + }, + { + 'country_type': 'VU', + 'country_desc': 'VANUATU' + }, + { + 'country_type': 'WF', + 'country_desc': 'WALLIS AND FUTUNA' + }, + { + 'country_type': 'WS', + 'country_desc': 'SAMOA' + }, + { + 'country_type': 'XZ', + 'country_desc': 'KOSOVO' + }, + { + 'country_type': 'YE', + 'country_desc': 'YEMEN' + }, + { + 'country_type': 'YT', + 'country_desc': 'MAYOTTE' + }, + { + 'country_type': 'YU', + 'country_desc': 'YUGOSLAVIA' + }, + { + 'country_type': 'ZA', + 'country_desc': 'SOUTH AFRICA' + }, + { + 'country_type': 'ZM', + 'country_desc': 'ZAMBIA' + }, + { + 'country_type': 'ZW', + 'country_desc': 'ZIMBABWE' + } + ] + ) + op.bulk_insert(province_type, + [ + { + 'province_type': 'AB', + 'country_type': 'CA', + 'province_desc': 'ALBERTA' + }, + { + 'province_type': 'BC', + 'country_type': 'CA', + 'province_desc': 'BRITISH COLUMBIA' + }, + { + 'province_type': 'MB', + 'country_type': 'CA', + 'province_desc': 'MANITOBA' + }, + { + 'province_type': 'NB', + 'country_type': 'CA', + 'province_desc': 'NEW BRUNSWICK' + }, + { + 'province_type': 'NL', + 'country_type': 'CA', + 'province_desc': 'NEWFOUNDLAND AND LABRADOR' + }, + { + 'province_type': 'NS', + 'country_type': 'CA', + 'province_desc': 'NOVA SCOTIA' + }, + { + 'province_type': 'NT', + 'country_type': 'CA', + 'province_desc': 'NORTHWEST TERRITORIES' + }, + { + 'province_type': 'NU', + 'country_type': 'CA', + 'province_desc': 'NUNAVUT' + }, + { + 'province_type': 'ON', + 'country_type': 'CA', + 'province_desc': 'ONTARIO' + }, + { + 'province_type': 'PE', + 'country_type': 'CA', + 'province_desc': 'PRINCE EDWARD ISLAND' + }, + { + 'province_type': 'QC', + 'country_type': 'CA', + 'province_desc': 'QUEBEC' + }, + { + 'province_type': 'SK', + 'country_type': 'CA', + 'province_desc': 'SASKATCHEWAN' + }, + { + 'province_type': 'YT', + 'country_type': 'CA', + 'province_desc': 'YUKON TERRITORIES' + }, + { + 'province_type': 'AA', + 'country_type': 'US', + 'province_desc': 'ARMED FORCES - AMERICAS' + }, + { + 'province_type': 'AE', + 'country_type': 'US', + 'province_desc': 'ARMED FORCES - OTHER' + }, + { + 'province_type': 'AK', + 'country_type': 'US', + 'province_desc': 'ALASKA' + }, + { + 'province_type': 'AL', + 'country_type': 'US', + 'province_desc': 'ALABAMA' + }, + { + 'province_type': 'AP', + 'country_type': 'US', + 'province_desc': 'ARMED FORCES - PACIFIC' + }, + { + 'province_type': 'AR', + 'country_type': 'US', + 'province_desc': 'ARKANSAS' + }, + { + 'province_type': 'AS', + 'country_type': 'US', + 'province_desc': 'AMERICAN SAMOA' + }, + { + 'province_type': 'AZ', + 'country_type': 'US', + 'province_desc': 'ARIZONA' + }, + { + 'province_type': 'CA', + 'country_type': 'US', + 'province_desc': 'CALIFORNIA' + }, + { + 'province_type': 'CO', + 'country_type': 'US', + 'province_desc': 'COLORADO' + }, + { + 'province_type': 'CT', + 'country_type': 'US', + 'province_desc': 'CONNECTICUT' + }, + { + 'province_type': 'DC', + 'country_type': 'US', + 'province_desc': 'DISTRICT OF COLUMBIA' + }, + { + 'province_type': 'DE', + 'country_type': 'US', + 'province_desc': 'DELAWARE' + }, + { + 'province_type': 'FL', + 'country_type': 'US', + 'province_desc': 'FLORIDA' + }, + { + 'province_type': 'FM', + 'country_type': 'US', + 'province_desc': 'FED. STATES' + }, + { + 'province_type': 'GA', + 'country_type': 'US', + 'province_desc': 'GEORGIA' + }, + { + 'province_type': 'GU', + 'country_type': 'US', + 'province_desc': 'GUAM' + }, + { + 'province_type': 'HI', + 'country_type': 'US', + 'province_desc': 'HAWAII' + }, + { + 'province_type': 'IA', + 'country_type': 'US', + 'province_desc': 'IOWA' + }, + { + 'province_type': 'ID', + 'country_type': 'US', + 'province_desc': 'IDAHO' + }, + { + 'province_type': 'IL', + 'country_type': 'US', + 'province_desc': 'ILLINOIS' + }, + { + 'province_type': 'IN', + 'country_type': 'US', + 'province_desc': 'INDIANA' + }, + { + 'province_type': 'KS', + 'country_type': 'US', + 'province_desc': 'KANSAS' + }, + { + 'province_type': 'KY', + 'country_type': 'US', + 'province_desc': 'KENTUCKY' + }, + { + 'province_type': 'LA', + 'country_type': 'US', + 'province_desc': 'LOUISIANA' + }, + { + 'province_type': 'MA', + 'country_type': 'US', + 'province_desc': 'MASSACHUSETTS' + }, + { + 'province_type': 'MD', + 'country_type': 'US', + 'province_desc': 'MARYLAND' + }, + { + 'province_type': 'ME', + 'country_type': 'US', + 'province_desc': 'MAINE' + }, + { + 'province_type': 'MH', + 'country_type': 'US', + 'province_desc': 'MARSHALL ISLANDS' + }, + { + 'province_type': 'MI', + 'country_type': 'US', + 'province_desc': 'MICHIGAN' + }, + { + 'province_type': 'MN', + 'country_type': 'US', + 'province_desc': 'MINNESOTA' + }, + { + 'province_type': 'MO', + 'country_type': 'US', + 'province_desc': 'MISSOURI' + }, + { + 'province_type': 'MP', + 'country_type': 'US', + 'province_desc': 'N. MARIANA ISLANDS' + }, + { + 'province_type': 'MS', + 'country_type': 'US', + 'province_desc': 'MISSISSIPPI' + }, + { + 'province_type': 'MT', + 'country_type': 'US', + 'province_desc': 'MONTANA' + }, + { + 'province_type': 'NC', + 'country_type': 'US', + 'province_desc': 'NORTH CAROLINA' + }, + { + 'province_type': 'ND', + 'country_type': 'US', + 'province_desc': 'NORTH DAKOTA' + }, + { + 'province_type': 'NE', + 'country_type': 'US', + 'province_desc': 'NEBRASKA' + }, + { + 'province_type': 'NH', + 'country_type': 'US', + 'province_desc': 'NEW HAMPSHIRE' + }, + { + 'province_type': 'NJ', + 'country_type': 'US', + 'province_desc': 'NEW JERSEY' + }, + { + 'province_type': 'NM', + 'country_type': 'US', + 'province_desc': 'NEW MEXICO' + }, + { + 'province_type': 'NV', + 'country_type': 'US', + 'province_desc': 'NEVADA' + }, + { + 'province_type': 'NY', + 'country_type': 'US', + 'province_desc': 'NEW YORK' + }, + { + 'province_type': 'OH', + 'country_type': 'US', + 'province_desc': 'OHIO' + }, + { + 'province_type': 'OK', + 'country_type': 'US', + 'province_desc': 'OKLAHOMA' + }, + { + 'province_type': 'OR', + 'country_type': 'US', + 'province_desc': 'OREGON' + }, + { + 'province_type': 'PA', + 'country_type': 'US', + 'province_desc': 'PENNSYLVANIA' + }, + { + 'province_type': 'PR', + 'country_type': 'US', + 'province_desc': 'PUERTO RICO' + }, + { + 'province_type': 'PW', + 'country_type': 'US', + 'province_desc': 'PALAU' + }, + { + 'province_type': 'RI', + 'country_type': 'US', + 'province_desc': 'RHODE ISLAND' + }, + { + 'province_type': 'SC', + 'country_type': 'US', + 'province_desc': 'SOUTH CAROLINA' + }, + { + 'province_type': 'SD', + 'country_type': 'US', + 'province_desc': 'SOUTH DAKOTA' + }, + { + 'province_type': 'TN', + 'country_type': 'US', + 'province_desc': 'TENNESSEE' + }, + { + 'province_type': 'TX', + 'country_type': 'US', + 'province_desc': 'TEXAS' + }, + { + 'province_type': 'UM', + 'country_type': 'US', + 'province_desc': 'U.S. MINOR ISLANDS' + }, + { + 'province_type': 'UT', + 'country_type': 'US', + 'province_desc': 'UTAH' + }, + { + 'province_type': 'VA', + 'country_type': 'US', + 'province_desc': 'VIRGINIA' + }, + { + 'province_type': 'VI', + 'country_type': 'US', + 'province_desc': 'VIRGIN ISLANDS' + }, + { + 'province_type': 'VT', + 'country_type': 'US', + 'province_desc': 'VERMONT' + }, + { + 'province_type': 'WA', + 'country_type': 'US', + 'province_desc': 'WASHINGTON' + }, + { + 'province_type': 'WI', + 'country_type': 'US', + 'province_desc': 'WISCONSIN' + }, + { + 'province_type': 'WV', + 'country_type': 'US', + 'province_desc': 'WEST VIRGINIA' + }, + { + 'province_type': 'WY', + 'country_type': 'US', + 'province_desc': 'WYOMING' + } + ] + ) + op.bulk_insert(nickname, + [ + { 'name_id': 100002, 'name': 'ABDUL'}, + { 'name_id': 100002, 'name': 'AB'}, + { 'name_id': 100002, 'name': 'ABDLE'}, + { 'name_id': 100002, 'name': 'ABDOU'}, + { 'name_id': 100002, 'name': 'ABDUH'}, + { 'name_id': 100002, 'name': 'ABDULLA'}, + { 'name_id': 100002, 'name': 'ABDULLAH'}, + { 'name_id': 100003, 'name': 'ABEL'}, + { 'name_id': 100003, 'name': 'ABE'}, + { 'name_id': 100004, 'name': 'ABIGAIL'}, + { 'name_id': 100004, 'name': 'ABAGAYLE'}, + { 'name_id': 100004, 'name': 'ABBIE'}, + { 'name_id': 100004, 'name': 'ABBEY'}, + { 'name_id': 100004, 'name': 'ABBY'}, + { 'name_id': 100004, 'name': 'ABIGAYLE'}, + { 'name_id': 100004, 'name': 'GAIL'}, + { 'name_id': 100005, 'name': 'ABRAHAM'}, + { 'name_id': 100005, 'name': 'ABDUL'}, + { 'name_id': 100005, 'name': 'ABEL'}, + { 'name_id': 100005, 'name': 'ABNER'}, + { 'name_id': 100005, 'name': 'ABRAM'}, + { 'name_id': 100005, 'name': 'BRAM'}, + { 'name_id': 100006, 'name': 'ABRAMSON'}, + { 'name_id': 100006, 'name': 'ABRAMS'}, + { 'name_id': 100007, 'name': 'ADELINE'}, + { 'name_id': 100007, 'name': 'ADALINE'}, + { 'name_id': 100007, 'name': 'ADELA'}, + { 'name_id': 100007, 'name': 'ADELE'}, + { 'name_id': 100007, 'name': 'ADELENE'}, + { 'name_id': 100007, 'name': 'ADELETTE'}, + { 'name_id': 100007, 'name': 'ADELIA'}, + { 'name_id': 100007, 'name': 'DELLE'}, + { 'name_id': 100007, 'name': 'DELLENE'}, + { 'name_id': 100008, 'name': 'ADOLPH'}, + { 'name_id': 100008, 'name': 'ADOLF'}, + { 'name_id': 100008, 'name': 'ADOLPHUS'}, + { 'name_id': 100009, 'name': 'ADRIAN'}, + { 'name_id': 100009, 'name': 'ADRIA'}, + { 'name_id': 100009, 'name': 'ADRIANA'}, + { 'name_id': 100009, 'name': 'ADRIANNE'}, + { 'name_id': 100009, 'name': 'ADRIENNE'}, + { 'name_id': 100010, 'name': 'ADVINCULA'}, + { 'name_id': 100010, 'name': 'ADVINCUL'}, + { 'name_id': 100011, 'name': 'AGNES'}, + { 'name_id': 100011, 'name': 'AG'}, + { 'name_id': 100011, 'name': 'AGGIE'}, + { 'name_id': 100011, 'name': 'AGNEATHA'}, + { 'name_id': 100011, 'name': 'AGNETA'}, + { 'name_id': 100011, 'name': 'AGNETTA'}, + { 'name_id': 100011, 'name': 'AGNITA'}, + { 'name_id': 100011, 'name': 'NESHA'}, + { 'name_id': 100011, 'name': 'NESS'}, + { 'name_id': 100011, 'name': 'NESSA'}, + { 'name_id': 100011, 'name': 'NESSIE'}, + { 'name_id': 100011, 'name': 'NESSY'}, + { 'name_id': 100011, 'name': 'NESTA'}, + { 'name_id': 100012, 'name': 'AGUILAR'}, + { 'name_id': 100012, 'name': 'AGUILA'}, + { 'name_id': 100013, 'name': 'ALBERT'}, + { 'name_id': 100013, 'name': 'ALBERTA'}, + { 'name_id': 100013, 'name': 'ALBERTE'}, + { 'name_id': 100013, 'name': 'ALBERTO'}, + { 'name_id': 100013, 'name': 'ALPERT'}, + { 'name_id': 100014, 'name': 'ALEXANDER'}, + { 'name_id': 100014, 'name': 'AL'}, + { 'name_id': 100014, 'name': 'ALASDAIR'}, + { 'name_id': 100014, 'name': 'ALASDAIRE'}, + { 'name_id': 100014, 'name': 'ALASTAIR'}, + { 'name_id': 100014, 'name': 'ALASTAIRE'}, + { 'name_id': 100014, 'name': 'ALBERT'}, + { 'name_id': 100014, 'name': 'ALEC'}, + { 'name_id': 100014, 'name': 'ALEJANDRO'}, + { 'name_id': 100014, 'name': 'ALEK'}, + { 'name_id': 100014, 'name': 'ALEKANDER'}, + { 'name_id': 100014, 'name': 'ALEKSANDER'}, + { 'name_id': 100014, 'name': 'ALESSANDRA'}, + { 'name_id': 100014, 'name': 'ALESSANDRO'}, + { 'name_id': 100014, 'name': 'ALEX'}, + { 'name_id': 100014, 'name': 'ALEXA'}, + { 'name_id': 100014, 'name': 'ALEXANDE'}, + { 'name_id': 100014, 'name': 'ALEXANDRA'}, + { 'name_id': 100014, 'name': 'ALEXANDRIA'}, + { 'name_id': 100014, 'name': 'ALEXIS'}, + { 'name_id': 100014, 'name': 'ALEXSANDER'}, + { 'name_id': 100014, 'name': 'ALFRED'}, + { 'name_id': 100014, 'name': 'ALICE'}, + { 'name_id': 100014, 'name': 'ALISDAIR'}, + { 'name_id': 100014, 'name': 'ALISDAIRE'}, + { 'name_id': 100014, 'name': 'ALISTAIR'}, + { 'name_id': 100014, 'name': 'ALISTAIRE'}, + { 'name_id': 100014, 'name': 'ALIX'}, + { 'name_id': 100014, 'name': 'ALLEN'}, + { 'name_id': 100014, 'name': 'ALLISON'}, + { 'name_id': 100014, 'name': 'ALPHONSE'}, + { 'name_id': 100014, 'name': 'ALVIN'}, + { 'name_id': 100014, 'name': 'BERTRAM'}, + { 'name_id': 100014, 'name': 'BURTON'}, + { 'name_id': 100014, 'name': 'CASSANDRA'}, + { 'name_id': 100014, 'name': 'EGBERT'}, + { 'name_id': 100014, 'name': 'FREDERICK'}, + { 'name_id': 100014, 'name': 'HERBERT'}, + { 'name_id': 100014, 'name': 'LEX'}, + { 'name_id': 100014, 'name': 'LEXA'}, + { 'name_id': 100014, 'name': 'LEXI'}, + { 'name_id': 100014, 'name': 'LEXIE'}, + { 'name_id': 100014, 'name': 'LEXIS'}, + { 'name_id': 100014, 'name': 'LEXY'}, + { 'name_id': 100014, 'name': 'SACHA'}, + { 'name_id': 100014, 'name': 'SANDERS'}, + { 'name_id': 100014, 'name': 'SANDIS'}, + { 'name_id': 100014, 'name': 'SANDOR'}, + { 'name_id': 100014, 'name': 'SANDORA'}, + { 'name_id': 100014, 'name': 'SANDRA'}, + { 'name_id': 100014, 'name': 'SASHA'}, + { 'name_id': 100014, 'name': 'SASCHA'}, + { 'name_id': 100014, 'name': 'SAUNDERS'}, + { 'name_id': 100014, 'name': 'SAUNDRA'}, + { 'name_id': 100015, 'name': 'ALFRED'}, + { 'name_id': 100015, 'name': 'ALFREDO'}, + { 'name_id': 100016, 'name': 'ALICE'}, + { 'name_id': 100016, 'name': 'ALECIA'}, + { 'name_id': 100016, 'name': 'ALICIA'}, + { 'name_id': 100016, 'name': 'ALISA'}, + { 'name_id': 100016, 'name': 'ALISE'}, + { 'name_id': 100016, 'name': 'ALYS'}, + { 'name_id': 100016, 'name': 'ELKA'}, + { 'name_id': 100016, 'name': 'ELKE'}, + { 'name_id': 100016, 'name': 'ELKIE'}, + { 'name_id': 100016, 'name': 'LECIA'}, + { 'name_id': 100017, 'name': 'ALLEN'}, + { 'name_id': 100017, 'name': 'ALAN'}, + { 'name_id': 100017, 'name': 'ALANA'}, + { 'name_id': 100017, 'name': 'ALANNA'}, + { 'name_id': 100017, 'name': 'ALANNAH'}, + { 'name_id': 100017, 'name': 'ALAYNA'}, + { 'name_id': 100017, 'name': 'ALENA'}, + { 'name_id': 100017, 'name': 'ALENE'}, + { 'name_id': 100017, 'name': 'ALLAN'}, + { 'name_id': 100017, 'name': 'LANA'}, + { 'name_id': 100017, 'name': 'LANNA'}, + { 'name_id': 100017, 'name': 'LANNAH'}, + { 'name_id': 100017, 'name': 'LLANA'}, + { 'name_id': 100018, 'name': 'ALLISON'}, + { 'name_id': 100018, 'name': 'ALISON'}, + { 'name_id': 100018, 'name': 'ALLYSON'}, + { 'name_id': 100018, 'name': 'ALLYSSON'}, + { 'name_id': 100018, 'name': 'ALYSON'}, + { 'name_id': 100019, 'name': 'ALPHONSE'}, + { 'name_id': 100019, 'name': 'ALF'}, + { 'name_id': 100019, 'name': 'ALFANSE'}, + { 'name_id': 100019, 'name': 'ALFANSO'}, + { 'name_id': 100019, 'name': 'ALFONSE'}, + { 'name_id': 100019, 'name': 'ALFONSO'}, + { 'name_id': 100019, 'name': 'ALONSO'}, + { 'name_id': 100019, 'name': 'ALONZO'}, + { 'name_id': 100019, 'name': 'ALPHONSO'}, + { 'name_id': 100019, 'name': 'LON'}, + { 'name_id': 100019, 'name': 'LONNIE'}, + { 'name_id': 100019, 'name': 'LONNY'}, + { 'name_id': 100020, 'name': 'ALVIN'}, + { 'name_id': 100020, 'name': 'ALVENA'}, + { 'name_id': 100020, 'name': 'ALVINA'}, + { 'name_id': 100020, 'name': 'ALVON'}, + { 'name_id': 100020, 'name': 'ALVYN'}, + { 'name_id': 100020, 'name': 'ELVIN'}, + { 'name_id': 100020, 'name': 'ELVINA'}, + { 'name_id': 100020, 'name': 'ELVIS'}, + { 'name_id': 100020, 'name': 'ELVY'}, + { 'name_id': 100020, 'name': 'ELWIN'}, + { 'name_id': 100020, 'name': 'ELWYN'}, + { 'name_id': 100021, 'name': 'AMANDA'}, + { 'name_id': 100021, 'name': 'AM'}, + { 'name_id': 100021, 'name': 'MAND'}, + { 'name_id': 100022, 'name': 'AMELIA'}, + { 'name_id': 100022, 'name': 'AMELI'}, + { 'name_id': 100023, 'name': 'ANASTASIA'}, + { 'name_id': 100023, 'name': 'EUSTACE'}, + { 'name_id': 100023, 'name': 'STACEY'}, + { 'name_id': 100023, 'name': 'STACI'}, + { 'name_id': 100023, 'name': 'STACIA'}, + { 'name_id': 100023, 'name': 'STACIE'}, + { 'name_id': 100023, 'name': 'STACY'}, + { 'name_id': 100023, 'name': 'STASIA'}, + { 'name_id': 100023, 'name': 'STASSIA'}, + { 'name_id': 100024, 'name': 'ANDREW'}, + { 'name_id': 100024, 'name': 'AND'}, + { 'name_id': 100024, 'name': 'ANDOR'}, + { 'name_id': 100024, 'name': 'ANDRA'}, + { 'name_id': 100024, 'name': 'ANDRAS'}, + { 'name_id': 100024, 'name': 'ANDREA'}, + { 'name_id': 100024, 'name': 'ANDRIANA'}, + { 'name_id': 100024, 'name': 'ANDRIANES'}, + { 'name_id': 100024, 'name': 'ANDRIANI'}, + { 'name_id': 100024, 'name': 'DANDO'}, + { 'name_id': 100024, 'name': 'DANDY'}, + { 'name_id': 100024, 'name': 'DREW'}, + { 'name_id': 100024, 'name': 'DRU'}, + { 'name_id': 100024, 'name': 'DRUE'}, + { 'name_id': 100024, 'name': 'TANDY'}, + { 'name_id': 100025, 'name': 'ANGELA'}, + { 'name_id': 100025, 'name': 'ANG'}, + { 'name_id': 100025, 'name': 'ANGEL'}, + { 'name_id': 100025, 'name': 'ANGELICA'}, + { 'name_id': 100025, 'name': 'ANGELIKA'}, + { 'name_id': 100025, 'name': 'ANGELINA'}, + { 'name_id': 100025, 'name': 'ANGELINE'}, + { 'name_id': 100025, 'name': 'ANGELITA'}, + { 'name_id': 100025, 'name': 'ANJELICA'}, + { 'name_id': 100025, 'name': 'ANJELIKA'}, + { 'name_id': 100026, 'name': 'ANNETTE'}, + { 'name_id': 100026, 'name': 'AN'}, + { 'name_id': 100026, 'name': 'ANA'}, + { 'name_id': 100026, 'name': 'ANN'}, + { 'name_id': 100026, 'name': 'ANNA'}, + { 'name_id': 100026, 'name': 'ANNE'}, + { 'name_id': 100026, 'name': 'ANNIE'}, + { 'name_id': 100026, 'name': 'ANETTE'}, + { 'name_id': 100026, 'name': 'ANITA'}, + { 'name_id': 100026, 'name': 'ANNINA'}, + { 'name_id': 100026, 'name': 'NENA'}, + { 'name_id': 100026, 'name': 'NENE'}, + { 'name_id': 100026, 'name': 'NENIA'}, + { 'name_id': 100026, 'name': 'NINA'}, + { 'name_id': 100026, 'name': 'NITA'}, + { 'name_id': 100027, 'name': 'ANTHONY'}, + { 'name_id': 100027, 'name': 'AGNES'}, + { 'name_id': 100027, 'name': 'ANNETTE'}, + { 'name_id': 100027, 'name': 'ANTOINE'}, + { 'name_id': 100027, 'name': 'ANTOINETTE'}, + { 'name_id': 100027, 'name': 'ANTON'}, + { 'name_id': 100027, 'name': 'ANTONIA'}, + { 'name_id': 100027, 'name': 'ANTONIO'}, + { 'name_id': 100027, 'name': 'ANTONITA'}, + { 'name_id': 100027, 'name': 'NANCY'}, + { 'name_id': 100027, 'name': 'ONI'}, + { 'name_id': 100027, 'name': 'ONITA'}, + { 'name_id': 100027, 'name': 'TANIA'}, + { 'name_id': 100027, 'name': 'TANJA'}, + { 'name_id': 100027, 'name': 'TANYA'}, + { 'name_id': 100027, 'name': 'TATANIA'}, + { 'name_id': 100027, 'name': 'TATANYA'}, + { 'name_id': 100027, 'name': 'TONEY'}, + { 'name_id': 100027, 'name': 'TONI'}, + { 'name_id': 100027, 'name': 'TONIA'}, + { 'name_id': 100027, 'name': 'TONY'}, + { 'name_id': 100027, 'name': 'TONINA'}, + { 'name_id': 100027, 'name': 'TONJA'}, + { 'name_id': 100027, 'name': 'TONYA'}, + { 'name_id': 100027, 'name': 'VANESSA'}, + { 'name_id': 100028, 'name': 'APRAHAMIAN'}, + { 'name_id': 100028, 'name': 'APRAHAMI'}, + { 'name_id': 100029, 'name': 'APRIL'}, + { 'name_id': 100029, 'name': 'AVRIL'}, + { 'name_id': 100030, 'name': 'ARAMINTA'}, + { 'name_id': 100030, 'name': 'AMINTA'}, + { 'name_id': 100030, 'name': 'MENTIE'}, + { 'name_id': 100030, 'name': 'MENTY'}, + { 'name_id': 100030, 'name': 'MINTY'}, + { 'name_id': 100031, 'name': 'ARCHIBALD'}, + { 'name_id': 100031, 'name': 'ARCH'}, + { 'name_id': 100032, 'name': 'ARETHA'}, + { 'name_id': 100032, 'name': 'RETHA'}, + { 'name_id': 100033, 'name': 'ARNOLD'}, + { 'name_id': 100033, 'name': 'ARN'}, + { 'name_id': 100033, 'name': 'ARNALDO'}, + { 'name_id': 100034, 'name': 'ARTHUR'}, + { 'name_id': 100034, 'name': 'ART'}, + { 'name_id': 100034, 'name': 'ARTURO'}, + { 'name_id': 100035, 'name': 'AUGUSTINE'}, + { 'name_id': 100035, 'name': 'AUGUST'}, + { 'name_id': 100035, 'name': 'AUGUSTA'}, + { 'name_id': 100036, 'name': 'AUGUSTUS'}, + { 'name_id': 100036, 'name': 'GUS'}, + { 'name_id': 100036, 'name': 'AUGUSTINE'}, + { 'name_id': 100036, 'name': 'GUSTOV'}, + { 'name_id': 100037, 'name': 'AZUBA'}, + { 'name_id': 100037, 'name': 'AZUBAH'}, + { 'name_id': 100037, 'name': 'ZUBA'}, + { 'name_id': 100038, 'name': 'BARBARA'}, + { 'name_id': 100038, 'name': 'BARB'}, + { 'name_id': 100038, 'name': 'BABS'}, + { 'name_id': 100038, 'name': 'BARBARELLA'}, + { 'name_id': 100038, 'name': 'BARBARETTA'}, + { 'name_id': 100038, 'name': 'BARBARINA'}, + { 'name_id': 100038, 'name': 'BARBRA'}, + { 'name_id': 100038, 'name': 'BEBE'}, + { 'name_id': 100039, 'name': 'BARNABY'}, + { 'name_id': 100039, 'name': 'BARN'}, + { 'name_id': 100040, 'name': 'BARRON'}, + { 'name_id': 100040, 'name': 'BARON'}, + { 'name_id': 100041, 'name': 'BARTLETT'}, + { 'name_id': 100041, 'name': 'BART'}, + { 'name_id': 100042, 'name': 'BASIL'}, + { 'name_id': 100042, 'name': 'BAS'}, + { 'name_id': 100042, 'name': 'BAZ'}, + { 'name_id': 100043, 'name': 'BAUMANN'}, + { 'name_id': 100043, 'name': 'BAUMAN'}, + { 'name_id': 100044, 'name': 'BEATRICE'}, + { 'name_id': 100044, 'name': 'TRIX'}, + { 'name_id': 100044, 'name': 'BEA'}, + { 'name_id': 100044, 'name': 'BEATRIX'}, + { 'name_id': 100044, 'name': 'BEATY'}, + { 'name_id': 100045, 'name': 'BELINDA'}, + { 'name_id': 100045, 'name': 'BALINDA'}, + { 'name_id': 100045, 'name': 'LIN'}, + { 'name_id': 100045, 'name': 'LINDA'}, + { 'name_id': 100045, 'name': 'LINDEY'}, + { 'name_id': 100045, 'name': 'LINDI'}, + { 'name_id': 100045, 'name': 'LINDIE'}, + { 'name_id': 100045, 'name': 'LINDY'}, + { 'name_id': 100045, 'name': 'LINNIE'}, + { 'name_id': 100045, 'name': 'LYN'}, + { 'name_id': 100045, 'name': 'LYNDA'}, + { 'name_id': 100045, 'name': 'VALINDA'}, + { 'name_id': 100046, 'name': 'BENJAMIN'}, + { 'name_id': 100046, 'name': 'BEN'}, + { 'name_id': 100046, 'name': 'BENJI'}, + { 'name_id': 100046, 'name': 'BENJY'}, + { 'name_id': 100046, 'name': 'BENOIS'}, + { 'name_id': 100047, 'name': 'BERJIKIAN'}, + { 'name_id': 100047, 'name': 'BERJIKIA'}, + { 'name_id': 100048, 'name': 'BERKOWITZ'}, + { 'name_id': 100048, 'name': 'BERKOWIT'}, + { 'name_id': 100049, 'name': 'BERNARD'}, + { 'name_id': 100049, 'name': 'BERN'}, + { 'name_id': 100049, 'name': 'BERNH'}, + { 'name_id': 100049, 'name': 'BARNAD'}, + { 'name_id': 100049, 'name': 'BERNADETTE'}, + { 'name_id': 100049, 'name': 'BERNADINE'}, + { 'name_id': 100049, 'name': 'BERNARDI'}, + { 'name_id': 100049, 'name': 'BERNARDINE'}, + { 'name_id': 100049, 'name': 'BERNARDO'}, + { 'name_id': 100049, 'name': 'BERNETTA'}, + { 'name_id': 100049, 'name': 'BERNETTE'}, + { 'name_id': 100050, 'name': 'BERNSTEIN'}, + { 'name_id': 100050, 'name': 'BERNSTEI'}, + { 'name_id': 100051, 'name': 'BEVERLEY'}, + { 'name_id': 100051, 'name': 'BEV'}, + { 'name_id': 100052, 'name': 'BONNIE'}, + { 'name_id': 100052, 'name': 'BONNI'}, + { 'name_id': 100053, 'name': 'BRADLEY'}, + { 'name_id': 100053, 'name': 'BRAD'}, + { 'name_id': 100053, 'name': 'BRADFORD'}, + { 'name_id': 100054, 'name': 'BRAVERMAN'}, + { 'name_id': 100054, 'name': 'BRAVERMA'}, + { 'name_id': 100055, 'name': 'BRENDA'}, + { 'name_id': 100055, 'name': 'BRENNA'}, + { 'name_id': 100056, 'name': 'BRENTON'}, + { 'name_id': 100056, 'name': 'BRENT'}, + { 'name_id': 100057, 'name': 'BRIAN'}, + { 'name_id': 100057, 'name': 'BRIANDT'}, + { 'name_id': 100057, 'name': 'BRIANT'}, + { 'name_id': 100057, 'name': 'BRYAN'}, + { 'name_id': 100057, 'name': 'BRYANDT'}, + { 'name_id': 100057, 'name': 'BRYANT'}, + { 'name_id': 100057, 'name': 'BRYEN'}, + { 'name_id': 100057, 'name': 'BRYN'}, + { 'name_id': 100057, 'name': 'BRYNA'}, + { 'name_id': 100057, 'name': 'BRYNN'}, + { 'name_id': 100057, 'name': 'BRYON'}, + { 'name_id': 100058, 'name': 'BRIDGET'}, + { 'name_id': 100058, 'name': 'BRID'}, + { 'name_id': 100058, 'name': 'BRIT'}, + { 'name_id': 100058, 'name': 'BRIDGETTE'}, + { 'name_id': 100058, 'name': 'BRIGETTE'}, + { 'name_id': 100058, 'name': 'BRIGID'}, + { 'name_id': 100058, 'name': 'BRIGIT'}, + { 'name_id': 100059, 'name': 'BRODERICK'}, + { 'name_id': 100059, 'name': 'BROD'}, + { 'name_id': 100059, 'name': 'BROD'}, + { 'name_id': 100059, 'name': 'BRODERIC'}, + { 'name_id': 100060, 'name': 'BRUCE'}, + { 'name_id': 100060, 'name': 'BRUSE'}, + { 'name_id': 100061, 'name': 'BUCKLEY'}, + { 'name_id': 100061, 'name': 'BUCK'}, + { 'name_id': 100062, 'name': 'BUDDY'}, + { 'name_id': 100062, 'name': 'BUD'}, + { 'name_id': 100063, 'name': 'BURTON'}, + { 'name_id': 100063, 'name': 'BERT'}, + { 'name_id': 100063, 'name': 'BERTON'}, + { 'name_id': 100063, 'name': 'BURT'}, + { 'name_id': 100064, 'name': 'BUSTAMANTE'}, + { 'name_id': 100064, 'name': 'BUSTAMAN'}, + { 'name_id': 100065, 'name': 'CAMPBELL'}, + { 'name_id': 100065, 'name': 'CAMBELL'}, + { 'name_id': 100066, 'name': 'CANDICE'}, + { 'name_id': 100066, 'name': 'CAND'}, + { 'name_id': 100066, 'name': 'CANDIS'}, + { 'name_id': 100066, 'name': 'CANDYCE'}, + { 'name_id': 100067, 'name': 'CARMEL'}, + { 'name_id': 100067, 'name': 'CARMELINA'}, + { 'name_id': 100067, 'name': 'CARMELINE'}, + { 'name_id': 100067, 'name': 'CARMELITA'}, + { 'name_id': 100067, 'name': 'CARMELITTA'}, + { 'name_id': 100067, 'name': 'CARMEN'}, + { 'name_id': 100067, 'name': 'MINA'}, + { 'name_id': 100067, 'name': 'MINNA'}, + { 'name_id': 100067, 'name': 'WILHELMENA'}, + { 'name_id': 100067, 'name': 'WILHELMIA'}, + { 'name_id': 100067, 'name': 'WILHELMINA'}, + { 'name_id': 100067, 'name': 'WILHELMINE'}, + { 'name_id': 100067, 'name': 'WILHEMENA'}, + { 'name_id': 100067, 'name': 'WILHEMIA'}, + { 'name_id': 100067, 'name': 'WILHEMINA'}, + { 'name_id': 100067, 'name': 'WILHEMINE'}, + { 'name_id': 100068, 'name': 'CARMEN'}, + { 'name_id': 100068, 'name': 'CARMINA'}, + { 'name_id': 100068, 'name': 'CARMINE'}, + { 'name_id': 100068, 'name': 'KARMEN'}, + { 'name_id': 100069, 'name': 'CAROLINE'}, + { 'name_id': 100069, 'name': 'CAR'}, + { 'name_id': 100069, 'name': 'KAR'}, + { 'name_id': 100069, 'name': 'KER'}, + { 'name_id': 100069, 'name': 'CARALYN'}, + { 'name_id': 100069, 'name': 'CAROL'}, + { 'name_id': 100069, 'name': 'CAROLE'}, + { 'name_id': 100069, 'name': 'CAROLYN'}, + { 'name_id': 100069, 'name': 'CAROLYNN'}, + { 'name_id': 100069, 'name': 'CAROLYNNE'}, + { 'name_id': 100069, 'name': 'KAROLYN'}, + { 'name_id': 100069, 'name': 'KAROLYNN'}, + { 'name_id': 100069, 'name': 'KAROLYNNE'}, + { 'name_id': 100069, 'name': 'LINA'}, + { 'name_id': 100070, 'name': 'CASSANDRA'}, + { 'name_id': 100070, 'name': 'CASANDRA'}, + { 'name_id': 100070, 'name': 'CASS'}, + { 'name_id': 100070, 'name': 'CASSIE'}, + { 'name_id': 100070, 'name': 'CASSY'}, + { 'name_id': 100070, 'name': 'KASANDRA'}, + { 'name_id': 100071, 'name': 'CATHERINE'}, + { 'name_id': 100071, 'name': 'CAITLIN'}, + { 'name_id': 100071, 'name': 'CAT'}, + { 'name_id': 100071, 'name': 'CATH'}, + { 'name_id': 100071, 'name': 'CATHARINE'}, + { 'name_id': 100071, 'name': 'CATHIE'}, + { 'name_id': 100071, 'name': 'CATHLEEN'}, + { 'name_id': 100071, 'name': 'CATHRYN'}, + { 'name_id': 100071, 'name': 'CATHY'}, + { 'name_id': 100071, 'name': 'CATLIN'}, + { 'name_id': 100071, 'name': 'CATLYN'}, + { 'name_id': 100071, 'name': 'CATLYNN'}, + { 'name_id': 100071, 'name': 'KAT'}, + { 'name_id': 100071, 'name': 'KATARINA'}, + { 'name_id': 100071, 'name': 'KATE'}, + { 'name_id': 100071, 'name': 'KATEY'}, + { 'name_id': 100071, 'name': 'KATH'}, + { 'name_id': 100071, 'name': 'KATHARINE'}, + { 'name_id': 100071, 'name': 'KATHERINE'}, + { 'name_id': 100071, 'name': 'KATHIE'}, + { 'name_id': 100071, 'name': 'KATHLEEN'}, + { 'name_id': 100071, 'name': 'KATHRYN'}, + { 'name_id': 100071, 'name': 'KATHY'}, + { 'name_id': 100071, 'name': 'KATI'}, + { 'name_id': 100071, 'name': 'KATIE'}, + { 'name_id': 100071, 'name': 'KATLIN'}, + { 'name_id': 100071, 'name': 'KATLYN'}, + { 'name_id': 100071, 'name': 'KATLYNN'}, + { 'name_id': 100071, 'name': 'KATRINA'}, + { 'name_id': 100071, 'name': 'KATY'}, + { 'name_id': 100071, 'name': 'KETTY'}, + { 'name_id': 100071, 'name': 'KIT'}, + { 'name_id': 100071, 'name': 'KITTA'}, + { 'name_id': 100071, 'name': 'KITTY'}, + { 'name_id': 100071, 'name': 'TREENA'}, + { 'name_id': 100071, 'name': 'TRENA'}, + { 'name_id': 100071, 'name': 'TRENNA'}, + { 'name_id': 100071, 'name': 'TRINA'}, + { 'name_id': 100072, 'name': 'CEASAR'}, + { 'name_id': 100072, 'name': 'CESAR'}, + { 'name_id': 100073, 'name': 'CECILIA'}, + { 'name_id': 100073, 'name': 'CECIL'}, + { 'name_id': 100073, 'name': 'CIS'}, + { 'name_id': 100073, 'name': 'CELIA'}, + { 'name_id': 100073, 'name': 'CESILY'}, + { 'name_id': 100073, 'name': 'CICELY'}, + { 'name_id': 100073, 'name': 'CICLE'}, + { 'name_id': 100073, 'name': 'CISSEL'}, + { 'name_id': 100073, 'name': 'SEELIA'}, + { 'name_id': 100073, 'name': 'SELIA'}, + { 'name_id': 100073, 'name': 'ZAZILIE'}, + { 'name_id': 100074, 'name': 'CEDRIC'}, + { 'name_id': 100074, 'name': 'ZEDRIC'}, + { 'name_id': 100075, 'name': 'CENA'}, + { 'name_id': 100075, 'name': 'XENA'}, + { 'name_id': 100075, 'name': 'XENIA'}, + { 'name_id': 100076, 'name': 'CHADWICK'}, + { 'name_id': 100076, 'name': 'CHAD'}, + { 'name_id': 100077, 'name': 'CHARLES'}, + { 'name_id': 100077, 'name': 'CHARL'}, + { 'name_id': 100077, 'name': 'CHUCK'}, + { 'name_id': 100077, 'name': 'CARL'}, + { 'name_id': 100077, 'name': 'CARLETON'}, + { 'name_id': 100077, 'name': 'CARLO'}, + { 'name_id': 100077, 'name': 'CARLOS'}, + { 'name_id': 100077, 'name': 'CARLOF'}, + { 'name_id': 100077, 'name': 'CARLSON'}, + { 'name_id': 100077, 'name': 'CARLTON'}, + { 'name_id': 100077, 'name': 'CHAS'}, + { 'name_id': 100077, 'name': 'CHAZ'}, + { 'name_id': 100077, 'name': 'CHUCK'}, + { 'name_id': 100077, 'name': 'KARL'}, + { 'name_id': 100078, 'name': 'CHARLOTTE'}, + { 'name_id': 100078, 'name': 'CARLA'}, + { 'name_id': 100078, 'name': 'CARLANA'}, + { 'name_id': 100078, 'name': 'CARLEEN'}, + { 'name_id': 100078, 'name': 'CARLENE'}, + { 'name_id': 100078, 'name': 'CARLETTA'}, + { 'name_id': 100078, 'name': 'CARLI'}, + { 'name_id': 100078, 'name': 'CARLIE'}, + { 'name_id': 100078, 'name': 'CARLY'}, + { 'name_id': 100078, 'name': 'CARTLEY'}, + { 'name_id': 100078, 'name': 'CHARLA'}, + { 'name_id': 100078, 'name': 'CHARLAINE'}, + { 'name_id': 100078, 'name': 'CHARLAYNE'}, + { 'name_id': 100078, 'name': 'CHARLEEN'}, + { 'name_id': 100078, 'name': 'CHARLENE'}, + { 'name_id': 100078, 'name': 'CHATTY'}, + { 'name_id': 100078, 'name': 'KARLA'}, + { 'name_id': 100078, 'name': 'KARLI'}, + { 'name_id': 100078, 'name': 'KARLY'}, + { 'name_id': 100078, 'name': 'LENE'}, + { 'name_id': 100078, 'name': 'LOTTI'}, + { 'name_id': 100078, 'name': 'LOTTY'}, + { 'name_id': 100078, 'name': 'SHAR'}, + { 'name_id': 100078, 'name': 'SHARLA'}, + { 'name_id': 100078, 'name': 'SHARLENE'}, + { 'name_id': 100078, 'name': 'TOTI'}, + { 'name_id': 100078, 'name': 'TOTTI'}, + { 'name_id': 100078, 'name': 'TOTTY'}, + { 'name_id': 100079, 'name': 'CHARMAINE'}, + { 'name_id': 100079, 'name': 'CHAR'}, + { 'name_id': 100079, 'name': 'SHARMAIN'}, + { 'name_id': 100079, 'name': 'SHARMAINE'}, + { 'name_id': 100080, 'name': 'CHERYL'}, + { 'name_id': 100080, 'name': 'CHER'}, + { 'name_id': 100080, 'name': 'CHERALYN'}, + { 'name_id': 100080, 'name': 'CHERIL'}, + { 'name_id': 100080, 'name': 'CHERILENE'}, + { 'name_id': 100080, 'name': 'CHERILYN'}, + { 'name_id': 100080, 'name': 'CHERRIL'}, + { 'name_id': 100080, 'name': 'CHERRILYN'}, + { 'name_id': 100080, 'name': 'CHERYLYN'}, + { 'name_id': 100080, 'name': 'SCHERRY'}, + { 'name_id': 100080, 'name': 'SHARON'}, + { 'name_id': 100080, 'name': 'SHEREEN'}, + { 'name_id': 100080, 'name': 'SHERENE'}, + { 'name_id': 100080, 'name': 'SHERILYN'}, + { 'name_id': 100080, 'name': 'SHERRILYN'}, + { 'name_id': 100080, 'name': 'SHERYL'}, + { 'name_id': 100080, 'name': 'SHERYLYN'}, + { 'name_id': 100081, 'name': 'CHESTER'}, + { 'name_id': 100081, 'name': 'CHET'}, + { 'name_id': 100082, 'name': 'CHRISTINE'}, + { 'name_id': 100082, 'name': 'KRISTA'}, + { 'name_id': 100082, 'name': 'KRISTINA'}, + { 'name_id': 100082, 'name': 'KRISTINE'}, + { 'name_id': 100083, 'name': 'CHRISTOPHER'}, + { 'name_id': 100083, 'name': 'CHRIS'}, + { 'name_id': 100083, 'name': 'CHRISTEN'}, + { 'name_id': 100083, 'name': 'CHRISTIAN'}, + { 'name_id': 100083, 'name': 'CHRISTIE'}, + { 'name_id': 100083, 'name': 'CHRISTINA'}, + { 'name_id': 100083, 'name': 'CHRISTINE'}, + { 'name_id': 100083, 'name': 'CHRISTOPH'}, + { 'name_id': 100083, 'name': 'CHRISTY'}, + { 'name_id': 100083, 'name': 'CRYSTAL'}, + { 'name_id': 100083, 'name': 'KRIS'}, + { 'name_id': 100083, 'name': 'KRISTEN'}, + { 'name_id': 100083, 'name': 'KRISTI'}, + { 'name_id': 100083, 'name': 'KRISTIAN'}, + { 'name_id': 100083, 'name': 'KRISTIE'}, + { 'name_id': 100083, 'name': 'KRISTIN'}, + { 'name_id': 100083, 'name': 'KRISTOPHER'}, + { 'name_id': 100083, 'name': 'KRISTY'}, + { 'name_id': 100083, 'name': 'KRYS'}, + { 'name_id': 100083, 'name': 'KRYSTAL'}, + { 'name_id': 100083, 'name': 'KRYSTEL'}, + { 'name_id': 100083, 'name': 'KRYSTINA'}, + { 'name_id': 100083, 'name': 'KRYSTLE'}, + { 'name_id': 100084, 'name': 'CINDY'}, + { 'name_id': 100084, 'name': 'CINDA'}, + { 'name_id': 100084, 'name': 'CINDE'}, + { 'name_id': 100084, 'name': 'CINDEE'}, + { 'name_id': 100084, 'name': 'CINDEY'}, + { 'name_id': 100084, 'name': 'CINDERINA'}, + { 'name_id': 100084, 'name': 'CINDERELLA'}, + { 'name_id': 100084, 'name': 'CINDERETTA'}, + { 'name_id': 100084, 'name': 'CINDI'}, + { 'name_id': 100084, 'name': 'CINDIA'}, + { 'name_id': 100084, 'name': 'CINDIE'}, + { 'name_id': 100084, 'name': 'CYNDA'}, + { 'name_id': 100084, 'name': 'CYNDE'}, + { 'name_id': 100084, 'name': 'CYNDEE'}, + { 'name_id': 100084, 'name': 'CYNDEY'}, + { 'name_id': 100084, 'name': 'CYNDI'}, + { 'name_id': 100084, 'name': 'CYNDIA'}, + { 'name_id': 100084, 'name': 'CYNDIE'}, + { 'name_id': 100084, 'name': 'CYNDY'}, + { 'name_id': 100084, 'name': 'CYNTHIA'}, + { 'name_id': 100084, 'name': 'GINDY'}, + { 'name_id': 100084, 'name': 'SYNDA'}, + { 'name_id': 100084, 'name': 'SYNDE'}, + { 'name_id': 100084, 'name': 'SYNDEE'}, + { 'name_id': 100084, 'name': 'SYNDEY'}, + { 'name_id': 100084, 'name': 'SYNDI'}, + { 'name_id': 100084, 'name': 'SYNDIA'}, + { 'name_id': 100084, 'name': 'SYNDIE'}, + { 'name_id': 100084, 'name': 'SYNDY'}, + { 'name_id': 100085, 'name': 'CLAIRE'}, + { 'name_id': 100085, 'name': 'BELLA'}, + { 'name_id': 100085, 'name': 'BELLE'}, + { 'name_id': 100085, 'name': 'CLAIRISE'}, + { 'name_id': 100085, 'name': 'CLAIRISSE'}, + { 'name_id': 100085, 'name': 'CLAIRRIE'}, + { 'name_id': 100085, 'name': 'CLARA'}, + { 'name_id': 100085, 'name': 'CLARABELLE'}, + { 'name_id': 100085, 'name': 'CLARAN'}, + { 'name_id': 100085, 'name': 'CLARE'}, + { 'name_id': 100085, 'name': 'CLAREE'}, + { 'name_id': 100085, 'name': 'CLARI'}, + { 'name_id': 100085, 'name': 'CLARICE'}, + { 'name_id': 100085, 'name': 'CLARISSA'}, + { 'name_id': 100085, 'name': 'CLARISSE'}, + { 'name_id': 100085, 'name': 'CLARRI'}, + { 'name_id': 100085, 'name': 'CLARRIE'}, + { 'name_id': 100085, 'name': 'CLARRY'}, + { 'name_id': 100085, 'name': 'CLARY'}, + { 'name_id': 100085, 'name': 'CLARYCE'}, + { 'name_id': 100085, 'name': 'ISABEL'}, + { 'name_id': 100086, 'name': 'CLARK'}, + { 'name_id': 100086, 'name': 'CLARKE'}, + { 'name_id': 100087, 'name': 'CLAUDINE'}, + { 'name_id': 100087, 'name': 'CLAUD'}, + { 'name_id': 100087, 'name': 'CLAUDELLE'}, + { 'name_id': 100087, 'name': 'CLAUDETTE'}, + { 'name_id': 100087, 'name': 'CLAUDIUS'}, + { 'name_id': 100088, 'name': 'CLAUS'}, + { 'name_id': 100088, 'name': 'CLAUSE'}, + { 'name_id': 100088, 'name': 'KLAUSE'}, + { 'name_id': 100089, 'name': 'CLAYTON'}, + { 'name_id': 100089, 'name': 'CLAY'}, + { 'name_id': 100089, 'name': 'CLAYBORN'}, + { 'name_id': 100089, 'name': 'CLAIBOURNE'}, + { 'name_id': 100090, 'name': 'CLEMENT'}, + { 'name_id': 100090, 'name': 'CLEM'}, + { 'name_id': 100090, 'name': 'CLEMENCE'}, + { 'name_id': 100091, 'name': 'CLIFFORD'}, + { 'name_id': 100091, 'name': 'CLIF'}, + { 'name_id': 100091, 'name': 'CLIFF'}, + { 'name_id': 100091, 'name': 'CLIFTON'}, + { 'name_id': 100092, 'name': 'CLINTON'}, + { 'name_id': 100092, 'name': 'CLINT'}, + { 'name_id': 100093, 'name': 'CLORIS'}, + { 'name_id': 100093, 'name': 'CHLORIS'}, + { 'name_id': 100094, 'name': 'CLOTILDE'}, + { 'name_id': 100094, 'name': 'CLO'}, + { 'name_id': 100095, 'name': 'COHEN'}, + { 'name_id': 100095, 'name': 'COHAN'}, + { 'name_id': 100095, 'name': 'COHN'}, + { 'name_id': 100096, 'name': 'COLMAN'}, + { 'name_id': 100096, 'name': 'COLE'}, + { 'name_id': 100097, 'name': 'CONCANNON'}, + { 'name_id': 100097, 'name': 'CONCANNO'}, + { 'name_id': 100098, 'name': 'CONSTANTINE'}, + { 'name_id': 100098, 'name': 'CON'}, + { 'name_id': 100098, 'name': 'CONN'}, + { 'name_id': 100098, 'name': 'CONNIE'}, + { 'name_id': 100098, 'name': 'CONNOR'}, + { 'name_id': 100098, 'name': 'CONRAD'}, + { 'name_id': 100098, 'name': 'CONSTANCE'}, + { 'name_id': 100098, 'name': 'COSTIN'}, + { 'name_id': 100098, 'name': 'KONRAD'}, + { 'name_id': 100098, 'name': 'STANZA'}, + { 'name_id': 100098, 'name': 'STANZI'}, + { 'name_id': 100099, 'name': 'CORRINE'}, + { 'name_id': 100099, 'name': 'COR'}, + { 'name_id': 100099, 'name': 'KOR'}, + { 'name_id': 100099, 'name': 'CORAL'}, + { 'name_id': 100099, 'name': 'CORETTE'}, + { 'name_id': 100099, 'name': 'CORISSA'}, + { 'name_id': 100099, 'name': 'CORITA'}, + { 'name_id': 100099, 'name': 'CORITTA'}, + { 'name_id': 100100, 'name': 'CRICHTON'}, + { 'name_id': 100100, 'name': 'CREIGHTON'}, + { 'name_id': 100101, 'name': 'CURT'}, + { 'name_id': 100101, 'name': 'CURTIS'}, + { 'name_id': 100102, 'name': 'CYBIL'}, + { 'name_id': 100102, 'name': 'CIBYL'}, + { 'name_id': 100102, 'name': 'SIBBY'}, + { 'name_id': 100102, 'name': 'SIBELLA'}, + { 'name_id': 100102, 'name': 'SIBELLE'}, + { 'name_id': 100102, 'name': 'SIBYL'}, + { 'name_id': 100102, 'name': 'SYBEL'}, + { 'name_id': 100102, 'name': 'SYBELLA'}, + { 'name_id': 100102, 'name': 'SYBELLE'}, + { 'name_id': 100102, 'name': 'SYBIL'}, + { 'name_id': 100102, 'name': 'SYBILLE'}, + { 'name_id': 100103, 'name': 'CYRIL'}, + { 'name_id': 100103, 'name': 'CY'}, + { 'name_id': 100103, 'name': 'CYRUS'}, + { 'name_id': 100104, 'name': 'DANIEL'}, + { 'name_id': 100104, 'name': 'DAN'}, + { 'name_id': 100104, 'name': 'DANETTA'}, + { 'name_id': 100104, 'name': 'DANETTE'}, + { 'name_id': 100104, 'name': 'DANFORTH'}, + { 'name_id': 100104, 'name': 'DANICA'}, + { 'name_id': 100104, 'name': 'DANIKA'}, + { 'name_id': 100104, 'name': 'DANITA'}, + { 'name_id': 100104, 'name': 'DANITRA'}, + { 'name_id': 100104, 'name': 'DAYNA'}, + { 'name_id': 100105, 'name': 'DARIUS'}, + { 'name_id': 100105, 'name': 'DARIAN'}, + { 'name_id': 100105, 'name': 'DARIEN'}, + { 'name_id': 100106, 'name': 'DARLYN'}, + { 'name_id': 100106, 'name': 'DARLIN'}, + { 'name_id': 100107, 'name': 'DARREN'}, + { 'name_id': 100107, 'name': 'DARYN'}, + { 'name_id': 100107, 'name': 'DERYN'}, + { 'name_id': 100108, 'name': 'DARRYL'}, + { 'name_id': 100108, 'name': 'DAROL'}, + { 'name_id': 100108, 'name': 'DARREL'}, + { 'name_id': 100108, 'name': 'DARRELL'}, + { 'name_id': 100108, 'name': 'DARRY'}, + { 'name_id': 100108, 'name': 'DARYL'}, + { 'name_id': 100109, 'name': 'DAVID'}, + { 'name_id': 100109, 'name': 'DAF'}, + { 'name_id': 100109, 'name': 'DAV'}, + { 'name_id': 100109, 'name': 'DEW'}, + { 'name_id': 100109, 'name': 'TAF'}, + { 'name_id': 100109, 'name': 'DAEVID'}, + { 'name_id': 100109, 'name': 'DAFFYD'}, + { 'name_id': 100109, 'name': 'DAFYD'}, + { 'name_id': 100109, 'name': 'DAVEEN'}, + { 'name_id': 100109, 'name': 'DAVENE'}, + { 'name_id': 100109, 'name': 'DAVINA'}, + { 'name_id': 100109, 'name': 'DAVITA'}, + { 'name_id': 100109, 'name': 'DAVIS'}, + { 'name_id': 100109, 'name': 'DAYVID'}, + { 'name_id': 100109, 'name': 'DIVINA'}, + { 'name_id': 100110, 'name': 'DEBORAH'}, + { 'name_id': 100110, 'name': 'DEB'}, + { 'name_id': 100110, 'name': 'DEBERRA'}, + { 'name_id': 100110, 'name': 'DEBRA'}, + { 'name_id': 100110, 'name': 'DEBS'}, + { 'name_id': 100110, 'name': 'DEVORA'}, + { 'name_id': 100110, 'name': 'DEVORAH'}, + { 'name_id': 100110, 'name': 'DEVRA'}, + { 'name_id': 100111, 'name': 'DEIDRE'}, + { 'name_id': 100111, 'name': 'DEED'}, + { 'name_id': 100111, 'name': 'DEID'}, + { 'name_id': 100111, 'name': 'DEIRDRE'}, + { 'name_id': 100111, 'name': 'DIERDRE'}, + { 'name_id': 100112, 'name': 'DELILAH'}, + { 'name_id': 100112, 'name': 'DAL'}, + { 'name_id': 100112, 'name': 'DALLACE'}, + { 'name_id': 100112, 'name': 'DALLAS'}, + { 'name_id': 100112, 'name': 'DAYLE'}, + { 'name_id': 100113, 'name': 'DELISA'}, + { 'name_id': 100113, 'name': 'DELICE'}, + { 'name_id': 100113, 'name': 'DELICIA'}, + { 'name_id': 100113, 'name': 'DELYS'}, + { 'name_id': 100113, 'name': 'LOLA'}, + { 'name_id': 100113, 'name': 'LOLITA'}, + { 'name_id': 100113, 'name': 'LOLLY'}, + { 'name_id': 100114, 'name': 'DELMA'}, + { 'name_id': 100114, 'name': 'DEL'}, + { 'name_id': 100114, 'name': 'DELBERT'}, + { 'name_id': 100114, 'name': 'FIDELMA'}, + { 'name_id': 100114, 'name': 'HARDEL'}, + { 'name_id': 100115, 'name': 'DELPHINE'}, + { 'name_id': 100115, 'name': 'DELPHI'}, + { 'name_id': 100116, 'name': 'DELSIE'}, + { 'name_id': 100116, 'name': 'DULCIE'}, + { 'name_id': 100117, 'name': 'DENNIS'}, + { 'name_id': 100117, 'name': 'DEN'}, + { 'name_id': 100117, 'name': 'DEN'}, + { 'name_id': 100117, 'name': 'DENESE'}, + { 'name_id': 100117, 'name': 'DENICE'}, + { 'name_id': 100117, 'name': 'DENISE'}, + { 'name_id': 100117, 'name': 'DENNEY'}, + { 'name_id': 100117, 'name': 'DENNIE'}, + { 'name_id': 100117, 'name': 'DENNY'}, + { 'name_id': 100118, 'name': 'DERRICK'}, + { 'name_id': 100118, 'name': 'DEREK'}, + { 'name_id': 100118, 'name': 'DERI'}, + { 'name_id': 100118, 'name': 'DERIC'}, + { 'name_id': 100118, 'name': 'DERIK'}, + { 'name_id': 100118, 'name': 'DERRY'}, + { 'name_id': 100118, 'name': 'DERYC'}, + { 'name_id': 100118, 'name': 'DERYK'}, + { 'name_id': 100119, 'name': 'DESMOND'}, + { 'name_id': 100119, 'name': 'DES'}, + { 'name_id': 100119, 'name': 'DESI'}, + { 'name_id': 100119, 'name': 'DESIREE'}, + { 'name_id': 100119, 'name': 'DEZO'}, + { 'name_id': 100120, 'name': 'DEVIN'}, + { 'name_id': 100120, 'name': 'DEV'}, + { 'name_id': 100120, 'name': 'DEVINDA'}, + { 'name_id': 100120, 'name': 'DEVLIN'}, + { 'name_id': 100121, 'name': 'DEXTER'}, + { 'name_id': 100121, 'name': 'DEX'}, + { 'name_id': 100121, 'name': 'DEXY'}, + { 'name_id': 100122, 'name': 'DIANA'}, + { 'name_id': 100122, 'name': 'BIANA'}, + { 'name_id': 100123, 'name': 'DIANE'}, + { 'name_id': 100123, 'name': 'DEN'}, + { 'name_id': 100123, 'name': 'DYAN'}, + { 'name_id': 100123, 'name': 'DEE'}, + { 'name_id': 100123, 'name': 'DI'}, + { 'name_id': 100123, 'name': 'DIAHANN'}, + { 'name_id': 100123, 'name': 'DIONARA'}, + { 'name_id': 100123, 'name': 'DIONELLA'}, + { 'name_id': 100123, 'name': 'DIONETTA'}, + { 'name_id': 100123, 'name': 'DYNAH'}, + { 'name_id': 100124, 'name': 'DILLON'}, + { 'name_id': 100124, 'name': 'DILL'}, + { 'name_id': 100124, 'name': 'DYLAN'}, + { 'name_id': 100125, 'name': 'DOMINGUEZ'}, + { 'name_id': 100125, 'name': 'DOMINGUE'}, + { 'name_id': 100126, 'name': 'DOMINIC'}, + { 'name_id': 100126, 'name': 'DOM'}, + { 'name_id': 100126, 'name': 'DOMI'}, + { 'name_id': 100127, 'name': 'DONALD'}, + { 'name_id': 100127, 'name': 'DON'}, + { 'name_id': 100127, 'name': 'DONAH'}, + { 'name_id': 100127, 'name': 'DONAL'}, + { 'name_id': 100127, 'name': 'DONAVAN'}, + { 'name_id': 100127, 'name': 'DONOVAN'}, + { 'name_id': 100128, 'name': 'DORIS'}, + { 'name_id': 100128, 'name': 'DOR'}, + { 'name_id': 100129, 'name': 'DOROTHEA'}, + { 'name_id': 100129, 'name': 'DOLLY'}, + { 'name_id': 100129, 'name': 'DORA'}, + { 'name_id': 100129, 'name': 'DOREEN'}, + { 'name_id': 100129, 'name': 'DORENE'}, + { 'name_id': 100129, 'name': 'DORINE'}, + { 'name_id': 100129, 'name': 'DORO'}, + { 'name_id': 100129, 'name': 'DOROTHY'}, + { 'name_id': 100130, 'name': 'DOROTHY'}, + { 'name_id': 100130, 'name': 'DOT'}, + { 'name_id': 100131, 'name': 'DOUGAL'}, + { 'name_id': 100131, 'name': 'DUG'}, + { 'name_id': 100132, 'name': 'DOUGLAS'}, + { 'name_id': 100132, 'name': 'DOOGIE'}, + { 'name_id': 100132, 'name': 'DOUG'}, + { 'name_id': 100132, 'name': 'DOUGAL'}, + { 'name_id': 100133, 'name': 'DUANE'}, + { 'name_id': 100133, 'name': 'DUWAYNE'}, + { 'name_id': 100133, 'name': 'DWAYNE'}, + { 'name_id': 100133, 'name': 'WAYNE'}, + { 'name_id': 100134, 'name': 'DUSTIN'}, + { 'name_id': 100359, 'name': 'PHYLLIS'}, + { 'name_id': 100134, 'name': 'DUNSTAN'}, + { 'name_id': 100135, 'name': 'EARL'}, + { 'name_id': 100135, 'name': 'ERLE'}, + { 'name_id': 100136, 'name': 'EBENEZER'}, + { 'name_id': 100136, 'name': 'EB'}, + { 'name_id': 100136, 'name': 'EBEN'}, + { 'name_id': 100137, 'name': 'EDITH'}, + { 'name_id': 100137, 'name': 'EDIE'}, + { 'name_id': 100137, 'name': 'EDITA'}, + { 'name_id': 100137, 'name': 'EDYTH'}, + { 'name_id': 100138, 'name': 'EDWARD'}, + { 'name_id': 100138, 'name': 'ED'}, + { 'name_id': 100138, 'name': 'EDDIE'}, + { 'name_id': 100138, 'name': 'EDDY'}, + { 'name_id': 100138, 'name': 'EDMOND'}, + { 'name_id': 100138, 'name': 'EDMUND'}, + { 'name_id': 100138, 'name': 'EDUARD'}, + { 'name_id': 100138, 'name': 'EDUARDO'}, + { 'name_id': 100138, 'name': 'EDVARD'}, + { 'name_id': 100138, 'name': 'EDWIN'}, + { 'name_id': 100138, 'name': 'EDWINA'}, + { 'name_id': 100138, 'name': 'NED'}, + { 'name_id': 100138, 'name': 'TED'}, + { 'name_id': 100138, 'name': 'TEDDIE'}, + { 'name_id': 100138, 'name': 'TEDDY'}, + { 'name_id': 100138, 'name': 'THEO'}, + { 'name_id': 100138, 'name': 'THEODOR'}, + { 'name_id': 100138, 'name': 'THEODORA'}, + { 'name_id': 100138, 'name': 'THEODORE'}, + { 'name_id': 100138, 'name': 'THEODORUS'}, + { 'name_id': 100139, 'name': 'EILEEN'}, + { 'name_id': 100139, 'name': 'AILEEN'}, + { 'name_id': 100139, 'name': 'AILENE'}, + { 'name_id': 100139, 'name': 'AYLEEN'}, + { 'name_id': 100139, 'name': 'EILLEN'}, + { 'name_id': 100139, 'name': 'ILEEN'}, + { 'name_id': 100139, 'name': 'ILEN'}, + { 'name_id': 100139, 'name': 'ILENE'}, + { 'name_id': 100140, 'name': 'ELAINE'}, + { 'name_id': 100140, 'name': 'ELAYNE'}, + { 'name_id': 100141, 'name': 'ELEANOR'}, + { 'name_id': 100141, 'name': 'ELLEN'}, + { 'name_id': 100141, 'name': 'HELEN'}, + { 'name_id': 100141, 'name': 'LENOR'}, + { 'name_id': 100141, 'name': 'LENORA'}, + { 'name_id': 100141, 'name': 'LENORE'}, + { 'name_id': 100141, 'name': 'LEONORA'}, + { 'name_id': 100141, 'name': 'LINORE'}, + { 'name_id': 100141, 'name': 'NORA'}, + { 'name_id': 100141, 'name': 'NORAH'}, + { 'name_id': 100141, 'name': 'NOREEN'}, + { 'name_id': 100141, 'name': 'NORENE'}, + { 'name_id': 100141, 'name': 'NORINA'}, + { 'name_id': 100141, 'name': 'NORINE'}, + { 'name_id': 100142, 'name': 'ELIJAH'}, + { 'name_id': 100142, 'name': 'ELI'}, + { 'name_id': 100142, 'name': 'ELIAS'}, + { 'name_id': 100143, 'name': 'ELIZABETH'}, + { 'name_id': 100143, 'name': 'BES'}, + { 'name_id': 100143, 'name': 'BET'}, + { 'name_id': 100143, 'name': 'BETS'}, + { 'name_id': 100143, 'name': 'LIB'}, + { 'name_id': 100143, 'name': 'LIS'}, + { 'name_id': 100143, 'name': 'LIZ'}, + { 'name_id': 100143, 'name': 'BETH'}, + { 'name_id': 100143, 'name': 'BETINA'}, + { 'name_id': 100143, 'name': 'BETTINA'}, + { 'name_id': 100143, 'name': 'BETTS'}, + { 'name_id': 100143, 'name': 'ELISA'}, + { 'name_id': 100143, 'name': 'ELISE'}, + { 'name_id': 100143, 'name': 'ELISSA'}, + { 'name_id': 100143, 'name': 'ELIZA'}, + { 'name_id': 100143, 'name': 'ELIZBETH'}, + { 'name_id': 100143, 'name': 'ELSA'}, + { 'name_id': 100143, 'name': 'ELSE'}, + { 'name_id': 100143, 'name': 'ELSBETH'}, + { 'name_id': 100143, 'name': 'ELSPETH'}, + { 'name_id': 100143, 'name': 'ELSPET'}, + { 'name_id': 100143, 'name': 'ELYSE'}, + { 'name_id': 100143, 'name': 'LEESA'}, + { 'name_id': 100143, 'name': 'LEEZA'}, + { 'name_id': 100143, 'name': 'LEISA'}, + { 'name_id': 100143, 'name': 'LETHA'}, + { 'name_id': 100143, 'name': 'LIESA'}, + { 'name_id': 100143, 'name': 'LISABETH'}, + { 'name_id': 100143, 'name': 'LISBETH'}, + { 'name_id': 100143, 'name': 'LISETTE'}, + { 'name_id': 100143, 'name': 'LIZBETH'}, + { 'name_id': 100143, 'name': 'LYSETTE'}, + { 'name_id': 100143, 'name': 'TETTY'}, + { 'name_id': 100144, 'name': 'ELLEN'}, + { 'name_id': 100144, 'name': 'ELA'}, + { 'name_id': 100144, 'name': 'ELEA'}, + { 'name_id': 100144, 'name': 'ELEANA'}, + { 'name_id': 100144, 'name': 'ELENA'}, + { 'name_id': 100144, 'name': 'ELEENA'}, + { 'name_id': 100144, 'name': 'ELENI'}, + { 'name_id': 100144, 'name': 'ELIN'}, + { 'name_id': 100144, 'name': 'ELLA'}, + { 'name_id': 100144, 'name': 'ELLAN'}, + { 'name_id': 100144, 'name': 'ELLE'}, + { 'name_id': 100144, 'name': 'ELLENA'}, + { 'name_id': 100144, 'name': 'ELLI'}, + { 'name_id': 100144, 'name': 'ELLIE'}, + { 'name_id': 100144, 'name': 'ELLON'}, + { 'name_id': 100144, 'name': 'ELLY'}, + { 'name_id': 100144, 'name': 'ELLYN'}, + { 'name_id': 100144, 'name': 'ELYNA'}, + { 'name_id': 100145, 'name': 'ELLIOTT'}, + { 'name_id': 100145, 'name': 'ELIOT'}, + { 'name_id': 100145, 'name': 'ELLIOT'}, + { 'name_id': 100146, 'name': 'ELLIS'}, + { 'name_id': 100146, 'name': 'ELISHA'}, + { 'name_id': 100146, 'name': 'ELLICE'}, + { 'name_id': 100147, 'name': 'ELMER'}, + { 'name_id': 100147, 'name': 'ALMA'}, + { 'name_id': 100147, 'name': 'ALMER'}, + { 'name_id': 100147, 'name': 'AYLMER'}, + { 'name_id': 100148, 'name': 'ELOISE'}, + { 'name_id': 100148, 'name': 'HELOISA'}, + { 'name_id': 100148, 'name': 'HELOISE'}, + { 'name_id': 100149, 'name': 'ELROY'}, + { 'name_id': 100149, 'name': 'ROY'}, + { 'name_id': 100150, 'name': 'EMMANUEL'}, + { 'name_id': 100150, 'name': 'MAN'}, + { 'name_id': 100150, 'name': 'EMANUEL'}, + { 'name_id': 100150, 'name': 'IMMANUEL'}, + { 'name_id': 100150, 'name': 'MANNIE'}, + { 'name_id': 100150, 'name': 'MANNY'}, + { 'name_id': 100150, 'name': 'MANUAL'}, + { 'name_id': 100150, 'name': 'MANUEL'}, + { 'name_id': 100150, 'name': 'MANUELA'}, + { 'name_id': 100151, 'name': 'EMMELINE'}, + { 'name_id': 100151, 'name': 'EM'}, + { 'name_id': 100151, 'name': 'EMELYN'}, + { 'name_id': 100151, 'name': 'EMER'}, + { 'name_id': 100151, 'name': 'EMERE'}, + { 'name_id': 100151, 'name': 'EMERSON'}, + { 'name_id': 100151, 'name': 'EMILY'}, + { 'name_id': 100151, 'name': 'EMMA'}, + { 'name_id': 100151, 'name': 'EMMANUEL'}, + { 'name_id': 100151, 'name': 'EMMERSON'}, + { 'name_id': 100151, 'name': 'EMMERT'}, + { 'name_id': 100151, 'name': 'EMMET'}, + { 'name_id': 100151, 'name': 'EMMETT'}, + { 'name_id': 100151, 'name': 'MANGIT'}, + { 'name_id': 100151, 'name': 'MANJIT'}, + { 'name_id': 100153, 'name': 'ERMA'}, + { 'name_id': 100153, 'name': 'IRMA'}, + { 'name_id': 100154, 'name': 'ERNEST'}, + { 'name_id': 100154, 'name': 'EARN'}, + { 'name_id': 100154, 'name': 'ERN'}, + { 'name_id': 100154, 'name': 'EARNEST'}, + { 'name_id': 100154, 'name': 'ERNESTO'}, + { 'name_id': 100154, 'name': 'ERNST'}, + { 'name_id': 100155, 'name': 'ERWIN'}, + { 'name_id': 100155, 'name': 'ERVIN'}, + { 'name_id': 100155, 'name': 'IRWIN'}, + { 'name_id': 100156, 'name': 'ESPINOSA'}, + { 'name_id': 100156, 'name': 'ESPINOZA'}, + { 'name_id': 100157, 'name': 'ESTELLE'}, + { 'name_id': 100157, 'name': 'STELLA'}, + { 'name_id': 100157, 'name': 'STELLAN'}, + { 'name_id': 100158, 'name': 'ESTHER'}, + { 'name_id': 100158, 'name': 'HET'}, + { 'name_id': 100158, 'name': 'ESTA'}, + { 'name_id': 100158, 'name': 'ESTE'}, + { 'name_id': 100158, 'name': 'ESTER'}, + { 'name_id': 100158, 'name': 'HESTER'}, + { 'name_id': 100159, 'name': 'ETHEL'}, + { 'name_id': 100159, 'name': 'ETH'}, + { 'name_id': 100159, 'name': 'ETHL'}, + { 'name_id': 100160, 'name': 'EUGENE'}, + { 'name_id': 100160, 'name': 'GENE'}, + { 'name_id': 100161, 'name': 'EUNICE'}, + { 'name_id': 100161, 'name': 'UNICE'}, + { 'name_id': 100162, 'name': 'EUPHEMIA'}, + { 'name_id': 100162, 'name': 'EPHIE'}, + { 'name_id': 100162, 'name': 'PHEMIE'}, + { 'name_id': 100163, 'name': 'FELICE'}, + { 'name_id': 100163, 'name': 'FELICITY'}, + { 'name_id': 100164, 'name': 'FLEMING'}, + { 'name_id': 100164, 'name': 'FLEMMING'}, + { 'name_id': 100165, 'name': 'FLORENCE'}, + { 'name_id': 100165, 'name': 'FLO'}, + { 'name_id': 100165, 'name': 'FLORA'}, + { 'name_id': 100165, 'name': 'FLOREEN'}, + { 'name_id': 100165, 'name': 'FLORETTA'}, + { 'name_id': 100165, 'name': 'FLOS'}, + { 'name_id': 100165, 'name': 'FLOSSIE'}, + { 'name_id': 100165, 'name': 'FLOSSY'}, + { 'name_id': 100165, 'name': 'FLOY'}, + { 'name_id': 100166, 'name': 'FRANCIS'}, + { 'name_id': 100166, 'name': 'FAN'}, + { 'name_id': 100166, 'name': 'FANNIE'}, + { 'name_id': 100166, 'name': 'FANNY'}, + { 'name_id': 100166, 'name': 'FRACHESCA'}, + { 'name_id': 100166, 'name': 'FRAN'}, + { 'name_id': 100166, 'name': 'FRANCELLA'}, + { 'name_id': 100166, 'name': 'FRANCENE'}, + { 'name_id': 100166, 'name': 'FRANCES'}, + { 'name_id': 100166, 'name': 'FRANCESCA'}, + { 'name_id': 100166, 'name': 'FRANCETTE'}, + { 'name_id': 100166, 'name': 'FRANCEY'}, + { 'name_id': 100166, 'name': 'FRANCHESKA'}, + { 'name_id': 100166, 'name': 'FRANCIE'}, + { 'name_id': 100166, 'name': 'FRANCISKA'}, + { 'name_id': 100166, 'name': 'FRANCINE'}, + { 'name_id': 100166, 'name': 'FRANCO'}, + { 'name_id': 100166, 'name': 'FRANCOIS'}, + { 'name_id': 100166, 'name': 'FRANCOISE'}, + { 'name_id': 100166, 'name': 'FRANCY'}, + { 'name_id': 100166, 'name': 'FRANK'}, + { 'name_id': 100166, 'name': 'FRANKIE'}, + { 'name_id': 100166, 'name': 'FRANKLIN'}, + { 'name_id': 100166, 'name': 'FRANKO'}, + { 'name_id': 100166, 'name': 'FRANKY'}, + { 'name_id': 100166, 'name': 'FRANNIE'}, + { 'name_id': 100166, 'name': 'FRANNY'}, + { 'name_id': 100166, 'name': 'FRANZ'}, + { 'name_id': 100166, 'name': 'STEFANIE'}, + { 'name_id': 100166, 'name': 'STEVEN'}, + { 'name_id': 100167, 'name': 'FREDERICK'}, + { 'name_id': 100167, 'name': 'FRED'}, + { 'name_id': 100167, 'name': 'FREDDI'}, + { 'name_id': 100167, 'name': 'FREDDIE'}, + { 'name_id': 100167, 'name': 'FREDDY'}, + { 'name_id': 100167, 'name': 'FREDERIC'}, + { 'name_id': 100167, 'name': 'FREDRIC'}, + { 'name_id': 100167, 'name': 'FREDRICK'}, + { 'name_id': 100167, 'name': 'FREDRIK'}, + { 'name_id': 100168, 'name': 'GABRIEL'}, + { 'name_id': 100168, 'name': 'GAB'}, + { 'name_id': 100168, 'name': 'GAVRIELLE'}, + { 'name_id': 100168, 'name': 'GEBRIEL'}, + { 'name_id': 100169, 'name': 'GAE'}, + { 'name_id': 100169, 'name': 'GAY'}, + { 'name_id': 100170, 'name': 'GAIL'}, + { 'name_id': 100170, 'name': 'GAEL'}, + { 'name_id': 100170, 'name': 'GAELLE'}, + { 'name_id': 100170, 'name': 'GAILA'}, + { 'name_id': 100170, 'name': 'GALE'}, + { 'name_id': 100170, 'name': 'GAYLA'}, + { 'name_id': 100170, 'name': 'GAYLE'}, + { 'name_id': 100171, 'name': 'GENEVIEVE'}, + { 'name_id': 100171, 'name': 'JENAVEE'}, + { 'name_id': 100172, 'name': 'GEOFFREY'}, + { 'name_id': 100172, 'name': 'GEF'}, + { 'name_id': 100172, 'name': 'GEOF'}, + { 'name_id': 100172, 'name': 'GEOFF'}, + { 'name_id': 100172, 'name': 'JEFFREY'}, + { 'name_id': 100172, 'name': 'JEOFF'}, + { 'name_id': 100172, 'name': 'JEOFFREY'}, + { 'name_id': 100173, 'name': 'GEORGE'}, + { 'name_id': 100173, 'name': 'GEO'}, + { 'name_id': 100173, 'name': 'GIORGIO'}, + { 'name_id': 100174, 'name': 'GEORGINA'}, + { 'name_id': 100174, 'name': 'GEENA'}, + { 'name_id': 100174, 'name': 'GENA'}, + { 'name_id': 100174, 'name': 'GEORDIE'}, + { 'name_id': 100174, 'name': 'GEORGE'}, + { 'name_id': 100174, 'name': 'GEORGES'}, + { 'name_id': 100174, 'name': 'GEORGETTE'}, + { 'name_id': 100174, 'name': 'GEORGIA'}, + { 'name_id': 100174, 'name': 'GEORGIE'}, + { 'name_id': 100174, 'name': 'GEORGY'}, + { 'name_id': 100174, 'name': 'GINA'}, + { 'name_id': 100174, 'name': 'GINI'}, + { 'name_id': 100174, 'name': 'GINNI'}, + { 'name_id': 100174, 'name': 'GINNIE'}, + { 'name_id': 100174, 'name': 'GINNY'}, + { 'name_id': 100174, 'name': 'GINY'}, + { 'name_id': 100174, 'name': 'JINNY'}, + { 'name_id': 100174, 'name': 'REGINA'}, + { 'name_id': 100174, 'name': 'REGINALD'}, + { 'name_id': 100174, 'name': 'VIRGINIA'}, + { 'name_id': 100175, 'name': 'GERALD'}, + { 'name_id': 100175, 'name': 'GARRIE'}, + { 'name_id': 100175, 'name': 'GARRY'}, + { 'name_id': 100175, 'name': 'GARY'}, + { 'name_id': 100175, 'name': 'GERALDINE'}, + { 'name_id': 100175, 'name': 'GERALDO'}, + { 'name_id': 100175, 'name': 'GERRI'}, + { 'name_id': 100175, 'name': 'GERRIE'}, + { 'name_id': 100175, 'name': 'GERRY'}, + { 'name_id': 100175, 'name': 'JERALD'}, + { 'name_id': 100175, 'name': 'JERALDINE'}, + { 'name_id': 100175, 'name': 'JERE'}, + { 'name_id': 100175, 'name': 'JERI'}, + { 'name_id': 100175, 'name': 'JERIE'}, + { 'name_id': 100175, 'name': 'JEROLD'}, + { 'name_id': 100175, 'name': 'JERRALD'}, + { 'name_id': 100175, 'name': 'JERRI'}, + { 'name_id': 100175, 'name': 'JERRIE'}, + { 'name_id': 100175, 'name': 'JERROD'}, + { 'name_id': 100175, 'name': 'JERROLD'}, + { 'name_id': 100175, 'name': 'JERRY'}, + { 'name_id': 100175, 'name': 'JERY'}, + { 'name_id': 100176, 'name': 'GERTRUDE'}, + { 'name_id': 100176, 'name': 'TRUD'}, + { 'name_id': 100176, 'name': 'GERTIE'}, + { 'name_id': 100177, 'name': 'GILBERT'}, + { 'name_id': 100177, 'name': 'GIL'}, + { 'name_id': 100177, 'name': 'GILBERTO'}, + { 'name_id': 100178, 'name': 'GINGER'}, + { 'name_id': 100178, 'name': 'JINGA'}, + { 'name_id': 100179, 'name': 'GLENIS'}, + { 'name_id': 100179, 'name': 'GLEN'}, + { 'name_id': 100179, 'name': 'GLENISE'}, + { 'name_id': 100179, 'name': 'GLENN'}, + { 'name_id': 100179, 'name': 'GLENNA'}, + { 'name_id': 100179, 'name': 'GLENYS'}, + { 'name_id': 100179, 'name': 'GLYN'}, + { 'name_id': 100179, 'name': 'GLYNN'}, + { 'name_id': 100179, 'name': 'GLYNNIS'}, + { 'name_id': 100180, 'name': 'GLORIA'}, + { 'name_id': 100180, 'name': 'GLORIETTE'}, + { 'name_id': 100181, 'name': 'GOLDFEIN'}, + { 'name_id': 100181, 'name': 'GOLDFINE'}, + { 'name_id': 100182, 'name': 'GOLDIE'}, + { 'name_id': 100182, 'name': 'GOLDA'}, + { 'name_id': 100183, 'name': 'GORDON'}, + { 'name_id': 100183, 'name': 'GORD'}, + { 'name_id': 100184, 'name': 'GRACE'}, + { 'name_id': 100184, 'name': 'GRACIE'}, + { 'name_id': 100184, 'name': 'GRACEY'}, + { 'name_id': 100185, 'name': 'GRAHAM'}, + { 'name_id': 100185, 'name': 'GRAEME'}, + { 'name_id': 100185, 'name': 'GRAYAM'}, + { 'name_id': 100186, 'name': 'GREENBERG'}, + { 'name_id': 100186, 'name': 'GREENBER'}, + { 'name_id': 100187, 'name': 'GREENWALD'}, + { 'name_id': 100187, 'name': 'GREENWAL'}, + { 'name_id': 100188, 'name': 'GREGORY'}, + { 'name_id': 100188, 'name': 'GREG'}, + { 'name_id': 100188, 'name': 'GREGOR'}, + { 'name_id': 100189, 'name': 'GRIFFITH'}, + { 'name_id': 100189, 'name': 'GRIFF'}, + { 'name_id': 100190, 'name': 'GWENDOLYN'}, + { 'name_id': 100190, 'name': 'GWEN'}, + { 'name_id': 100190, 'name': 'GWENDA'}, + { 'name_id': 100190, 'name': 'GWENDOLINE'}, + { 'name_id': 100190, 'name': 'GWENETH'}, + { 'name_id': 100190, 'name': 'GWENITH'}, + { 'name_id': 100190, 'name': 'GWENIVER'}, + { 'name_id': 100190, 'name': 'GWENIVERE'}, + { 'name_id': 100190, 'name': 'GWENYTH'}, + { 'name_id': 100191, 'name': 'HANNAH'}, + { 'name_id': 100191, 'name': 'HAN'}, + { 'name_id': 100191, 'name': 'HANITA'}, + { 'name_id': 100192, 'name': 'HAROLD'}, + { 'name_id': 100192, 'name': 'HARALD'}, + { 'name_id': 100192, 'name': 'HARRY'}, + { 'name_id': 100192, 'name': 'HARRI'}, + { 'name_id': 100192, 'name': 'HARRIE'}, + { 'name_id': 100192, 'name': 'HARRIET'}, + { 'name_id': 100192, 'name': 'HARRIETT'}, + { 'name_id': 100192, 'name': 'HARRIETTE'}, + { 'name_id': 100192, 'name': 'HARRO'}, + { 'name_id': 100192, 'name': 'HARROLD'}, + { 'name_id': 100192, 'name': 'HAT'}, + { 'name_id': 100192, 'name': 'HATTIE'}, + { 'name_id': 100192, 'name': 'HATTY'}, + { 'name_id': 100192, 'name': 'HERALD'}, + { 'name_id': 100192, 'name': 'HERALDO'}, + { 'name_id': 100192, 'name': 'HETTA'}, + { 'name_id': 100192, 'name': 'HETTIE'}, + { 'name_id': 100192, 'name': 'HETTY'}, + { 'name_id': 100193, 'name': 'HARVEY'}, + { 'name_id': 100193, 'name': 'HARV'}, + { 'name_id': 100194, 'name': 'HELEN'}, + { 'name_id': 100194, 'name': 'HELENE'}, + { 'name_id': 100194, 'name': 'HELINA'}, + { 'name_id': 100194, 'name': 'HELLEN'}, + { 'name_id': 100194, 'name': 'NEL'}, + { 'name_id': 100194, 'name': 'NELLIE'}, + { 'name_id': 100195, 'name': 'HENRIK'}, + { 'name_id': 100195, 'name': 'ENRI'}, + { 'name_id': 100195, 'name': 'ENRICA'}, + { 'name_id': 100195, 'name': 'ENRICO'}, + { 'name_id': 100195, 'name': 'ENRIQUE'}, + { 'name_id': 100195, 'name': 'ENRIQUETA'}, + { 'name_id': 100195, 'name': 'ENRIQUITO'}, + { 'name_id': 100195, 'name': 'HAL'}, + { 'name_id': 100195, 'name': 'HANK'}, + { 'name_id': 100195, 'name': 'HAROLD'}, + { 'name_id': 100195, 'name': 'HENRY'}, + { 'name_id': 100195, 'name': 'YETTA'}, + { 'name_id': 100196, 'name': 'HERBERT'}, + { 'name_id': 100196, 'name': 'HERB'}, + { 'name_id': 100196, 'name': 'HERBIE'}, + { 'name_id': 100196, 'name': 'HERBY'}, + { 'name_id': 100196, 'name': 'HUBERT'}, + { 'name_id': 100196, 'name': 'HEW'}, + { 'name_id': 100196, 'name': 'HEWLETT'}, + { 'name_id': 100196, 'name': 'HUB'}, + { 'name_id': 100196, 'name': 'HUBBARD'}, + { 'name_id': 100196, 'name': 'HUGH'}, + { 'name_id': 100196, 'name': 'HUGHIE'}, + { 'name_id': 100196, 'name': 'HUGHEY'}, + { 'name_id': 100196, 'name': 'HUGHY'}, + { 'name_id': 100196, 'name': 'HUGO'}, + { 'name_id': 100197, 'name': 'HERMIONE'}, + { 'name_id': 100197, 'name': 'HERMIA'}, + { 'name_id': 100198, 'name': 'HESTER'}, + { 'name_id': 100198, 'name': 'HEDDA'}, + { 'name_id': 100198, 'name': 'HEDDY'}, + { 'name_id': 100198, 'name': 'HEDY'}, + { 'name_id': 100199, 'name': 'HILDA'}, + { 'name_id': 100199, 'name': 'HILDEGARD'}, + { 'name_id': 100199, 'name': 'HILDEGARDE'}, + { 'name_id': 100199, 'name': 'HILDER'}, + { 'name_id': 100199, 'name': 'HILDERGARD'}, + { 'name_id': 100199, 'name': 'HILDERGARDE'}, + { 'name_id': 100200, 'name': 'HORACE'}, + { 'name_id': 100200, 'name': 'HORATH'}, + { 'name_id': 100200, 'name': 'HORATIO'}, + { 'name_id': 100201, 'name': 'IAN'}, + { 'name_id': 100201, 'name': 'EAN'}, + { 'name_id': 100201, 'name': 'EOIN'}, + { 'name_id': 100201, 'name': 'EON'}, + { 'name_id': 100202, 'name': 'IMELDA'}, + { 'name_id': 100202, 'name': 'MELDA'}, + { 'name_id': 100203, 'name': 'INA'}, + { 'name_id': 100203, 'name': 'ENA'}, + { 'name_id': 100203, 'name': 'INES'}, + { 'name_id': 100203, 'name': 'INEZ'}, + { 'name_id': 100203, 'name': 'YNES'}, + { 'name_id': 100203, 'name': 'YNEZ'}, + { 'name_id': 100204, 'name': 'ISAAC'}, + { 'name_id': 100204, 'name': 'IKE'}, + { 'name_id': 100277, 'name': 'LYALL'}, + { 'name_id': 100278, 'name': 'LYNN'}, + { 'name_id': 100278, 'name': 'LYN'}, + { 'name_id': 100278, 'name': 'LYNELL'}, + { 'name_id': 100278, 'name': 'LYNELLE'}, + { 'name_id': 100278, 'name': 'LYNETH'}, + { 'name_id': 100278, 'name': 'LYNETTE'}, + { 'name_id': 100278, 'name': 'LYNNE'}, + { 'name_id': 100278, 'name': 'LYNNETTE'}, + { 'name_id': 100279, 'name': 'MABEL'}, + { 'name_id': 100279, 'name': 'MABBS'}, + { 'name_id': 100279, 'name': 'MABLE'}, + { 'name_id': 100279, 'name': 'MABS'}, + { 'name_id': 100279, 'name': 'MAYBEL'}, + { 'name_id': 100280, 'name': 'MADELENE'}, + { 'name_id': 100280, 'name': 'MAD'}, + { 'name_id': 100280, 'name': 'MADYLON'}, + { 'name_id': 100281, 'name': 'MADRONA'}, + { 'name_id': 100281, 'name': 'MADRA'}, + { 'name_id': 100282, 'name': 'MAGDALENE'}, + { 'name_id': 100282, 'name': 'MAGDA'}, + { 'name_id': 100282, 'name': 'MALENA'}, + { 'name_id': 100283, 'name': 'MAJA'}, + { 'name_id': 100283, 'name': 'MAIYA'}, + { 'name_id': 100284, 'name': 'MALLORY'}, + { 'name_id': 100284, 'name': 'MALLY'}, + { 'name_id': 100285, 'name': 'MARA'}, + { 'name_id': 100285, 'name': 'MARALA'}, + { 'name_id': 100286, 'name': 'MARCEL'}, + { 'name_id': 100286, 'name': 'MARC'}, + { 'name_id': 100286, 'name': 'MARCENE'}, + { 'name_id': 100286, 'name': 'MARCHA'}, + { 'name_id': 100286, 'name': 'MARCINE'}, + { 'name_id': 100286, 'name': 'MARCUS'}, + { 'name_id': 100286, 'name': 'MARK'}, + { 'name_id': 100286, 'name': 'MARKUS'}, + { 'name_id': 100286, 'name': 'MARSHA'}, + { 'name_id': 100287, 'name': 'MARDELLA'}, + { 'name_id': 100287, 'name': 'MARDI'}, + { 'name_id': 100288, 'name': 'MARGARET'}, + { 'name_id': 100288, 'name': 'GREETA'}, + { 'name_id': 100288, 'name': 'GRETA'}, + { 'name_id': 100288, 'name': 'MADGE'}, + { 'name_id': 100288, 'name': 'MAGGIE'}, + { 'name_id': 100288, 'name': 'MAGGY'}, + { 'name_id': 100288, 'name': 'MARG'}, + { 'name_id': 100288, 'name': 'MARGARETA'}, + { 'name_id': 100288, 'name': 'MARGARETHE'}, + { 'name_id': 100288, 'name': 'MARGARETHA'}, + { 'name_id': 100288, 'name': 'MARGARETTA'}, + { 'name_id': 100288, 'name': 'MARGARITA'}, + { 'name_id': 100288, 'name': 'MARGIE'}, + { 'name_id': 100288, 'name': 'MARGO'}, + { 'name_id': 100288, 'name': 'MARGOT'}, + { 'name_id': 100288, 'name': 'MARGRET'}, + { 'name_id': 100288, 'name': 'MARGUERITE'}, + { 'name_id': 100288, 'name': 'MEAGAN'}, + { 'name_id': 100288, 'name': 'MEG'}, + { 'name_id': 100288, 'name': 'MEGAN'}, + { 'name_id': 100288, 'name': 'MEGGIE'}, + { 'name_id': 100288, 'name': 'MEGGY'}, + { 'name_id': 100288, 'name': 'MEGHAN'}, + { 'name_id': 100288, 'name': 'MEGS'}, + { 'name_id': 100288, 'name': 'META'}, + { 'name_id': 100288, 'name': 'METTA'}, + { 'name_id': 100288, 'name': 'PEG'}, + { 'name_id': 100288, 'name': 'PEGGIE'}, + { 'name_id': 100288, 'name': 'PEGGY'}, + { 'name_id': 100289, 'name': 'MARILYN'}, + { 'name_id': 100289, 'name': 'MARYLYN'}, + { 'name_id': 100289, 'name': 'MARYLYNN'}, + { 'name_id': 100289, 'name': 'MARYLYNNE'}, + { 'name_id': 100290, 'name': 'MARION'}, + { 'name_id': 100290, 'name': 'MAMIE'}, + { 'name_id': 100290, 'name': 'MARGARET'}, + { 'name_id': 100290, 'name': 'MARJORY'}, + { 'name_id': 100290, 'name': 'MARY'}, + { 'name_id': 100290, 'name': 'MARYANN'}, + { 'name_id': 100290, 'name': 'MARYANNE'}, + { 'name_id': 100291, 'name': 'MARJORY'}, + { 'name_id': 100291, 'name': 'MARGERIE'}, + { 'name_id': 100291, 'name': 'MARGERY'}, + { 'name_id': 100291, 'name': 'MARJ'}, + { 'name_id': 100291, 'name': 'MARJA'}, + { 'name_id': 100291, 'name': 'MARJORIE'}, + { 'name_id': 100292, 'name': 'MARLENE'}, + { 'name_id': 100292, 'name': 'MARLA'}, + { 'name_id': 100292, 'name': 'MARLO'}, + { 'name_id': 100292, 'name': 'MARLOW'}, + { 'name_id': 100292, 'name': 'MARLY'}, + { 'name_id': 100292, 'name': 'MARLYN'}, + { 'name_id': 100292, 'name': 'MARLYNE'}, + { 'name_id': 100293, 'name': 'MARNIA'}, + { 'name_id': 100293, 'name': 'MARINA'}, + { 'name_id': 100294, 'name': 'MARTHA'}, + { 'name_id': 100294, 'name': 'MARTA'}, + { 'name_id': 100294, 'name': 'MARTHE'}, + { 'name_id': 100294, 'name': 'MERTA'}, + { 'name_id': 100294, 'name': 'MERTHIA'}, + { 'name_id': 100295, 'name': 'MARTIN'}, + { 'name_id': 100295, 'name': 'CATHERINE'}, + { 'name_id': 100295, 'name': 'CHRISTOPHER'}, + { 'name_id': 100295, 'name': 'MARTEL'}, + { 'name_id': 100295, 'name': 'MARTHA'}, + { 'name_id': 100295, 'name': 'MARTY'}, + { 'name_id': 100295, 'name': 'MARTYN'}, + { 'name_id': 100295, 'name': 'TEENA'}, + { 'name_id': 100295, 'name': 'TENA'}, + { 'name_id': 100295, 'name': 'TINA'}, + { 'name_id': 100295, 'name': 'TINAH'}, + { 'name_id': 100295, 'name': 'TINO'}, + { 'name_id': 100296, 'name': 'MARY'}, + { 'name_id': 100296, 'name': 'MAIR'}, + { 'name_id': 100296, 'name': 'MAIRE'}, + { 'name_id': 100296, 'name': 'MAIRI'}, + { 'name_id': 100296, 'name': 'MALIA'}, + { 'name_id': 100296, 'name': 'MALIN'}, + { 'name_id': 100296, 'name': 'MALYN'}, + { 'name_id': 100296, 'name': 'MARIA'}, + { 'name_id': 100296, 'name': 'MARIE'}, + { 'name_id': 100296, 'name': 'MARIETTA'}, + { 'name_id': 100296, 'name': 'MARIETTE'}, + { 'name_id': 100296, 'name': 'MARISA'}, + { 'name_id': 100296, 'name': 'MARISE'}, + { 'name_id': 100296, 'name': 'MARYA'}, + { 'name_id': 100296, 'name': 'MHAIRI'}, + { 'name_id': 100296, 'name': 'MIMI'}, + { 'name_id': 100296, 'name': 'MIRI'}, + { 'name_id': 100297, 'name': 'MATHEW'}, + { 'name_id': 100297, 'name': 'MAT'}, + { 'name_id': 100298, 'name': 'MATILDA'}, + { 'name_id': 100298, 'name': 'MATYA'}, + { 'name_id': 100298, 'name': 'TILDA'}, + { 'name_id': 100298, 'name': 'TILLA'}, + { 'name_id': 100298, 'name': 'TILLY'}, + { 'name_id': 100299, 'name': 'MAUDINE'}, + { 'name_id': 100299, 'name': 'MAUD'}, + { 'name_id': 100299, 'name': 'MAUDE'}, + { 'name_id': 100300, 'name': 'MAUREEN'}, + { 'name_id': 100300, 'name': 'MAURAYNE'}, + { 'name_id': 100300, 'name': 'MAURICE'}, + { 'name_id': 100300, 'name': 'MO'}, + { 'name_id': 100300, 'name': 'MOE'}, + { 'name_id': 100300, 'name': 'MOIRA'}, + { 'name_id': 100300, 'name': 'MORLEY'}, + { 'name_id': 100301, 'name': 'MAURICE'}, + { 'name_id': 100301, 'name': 'MAUR'}, + { 'name_id': 100301, 'name': 'MOR'}, + { 'name_id': 100301, 'name': 'MORRICE'}, + { 'name_id': 100301, 'name': 'MORRIS'}, + { 'name_id': 100301, 'name': 'MORRISON'}, + { 'name_id': 100301, 'name': 'MORRYS'}, + { 'name_id': 100301, 'name': 'MORSE'}, + { 'name_id': 100302, 'name': 'MAVIS'}, + { 'name_id': 100302, 'name': 'MAE'}, + { 'name_id': 100302, 'name': 'MAIS'}, + { 'name_id': 100302, 'name': 'MAISI'}, + { 'name_id': 100302, 'name': 'MAIZI'}, + { 'name_id': 100302, 'name': 'MAIZIS'}, + { 'name_id': 100302, 'name': 'MAY'}, + { 'name_id': 100302, 'name': 'MAYE'}, + { 'name_id': 100302, 'name': 'MEAVE'}, + { 'name_id': 100303, 'name': 'MAXINE'}, + { 'name_id': 100303, 'name': 'MAXIMILLIAN'}, + { 'name_id': 100303, 'name': 'MAXWELL'}, + { 'name_id': 100304, 'name': 'MAXWELL'}, + { 'name_id': 100304, 'name': 'MAX'}, + { 'name_id': 100305, 'name': 'MAZEL'}, + { 'name_id': 100305, 'name': 'MAZERELLA'}, + { 'name_id': 100305, 'name': 'MAZERINA'}, + { 'name_id': 100306, 'name': 'MCLAUGHLIN'}, + { 'name_id': 100306, 'name': 'MCLAUGHL'}, + { 'name_id': 100307, 'name': 'MELANIE'}, + { 'name_id': 100307, 'name': 'MEL'}, + { 'name_id': 100307, 'name': 'MELAINA'}, + { 'name_id': 100307, 'name': 'MELAINE'}, + { 'name_id': 100307, 'name': 'MELANE'}, + { 'name_id': 100307, 'name': 'MELANTA'}, + { 'name_id': 100307, 'name': 'MELANTHA'}, + { 'name_id': 100307, 'name': 'MELENA'}, + { 'name_id': 100307, 'name': 'MELINA'}, + { 'name_id': 100307, 'name': 'MELICENT'}, + { 'name_id': 100307, 'name': 'MELISSA'}, + { 'name_id': 100307, 'name': 'MELODY'}, + { 'name_id': 100307, 'name': 'MELVIN'}, + { 'name_id': 100308, 'name': 'MELICENT'}, + { 'name_id': 100308, 'name': 'MELLICENT'}, + { 'name_id': 100308, 'name': 'MILLEY'}, + { 'name_id': 100308, 'name': 'MILLICENT'}, + { 'name_id': 100308, 'name': 'MILLIE'}, + { 'name_id': 100308, 'name': 'MILLIS'}, + { 'name_id': 100308, 'name': 'MILLY'}, + { 'name_id': 100308, 'name': 'MYLLE'}, + { 'name_id': 100309, 'name': 'MELISSA'}, + { 'name_id': 100309, 'name': 'MELISSIA'}, + { 'name_id': 100309, 'name': 'MELITA'}, + { 'name_id': 100309, 'name': 'MELITTA'}, + { 'name_id': 100309, 'name': 'MELLISSIA'}, + { 'name_id': 100310, 'name': 'MELODY'}, + { 'name_id': 100310, 'name': 'MELODIA'}, + { 'name_id': 100310, 'name': 'MELODIE'}, + { 'name_id': 100311, 'name': 'MELVIN'}, + { 'name_id': 100311, 'name': 'MALVIN'}, + { 'name_id': 100311, 'name': 'MALVINA'}, + { 'name_id': 100311, 'name': 'MELL'}, + { 'name_id': 100311, 'name': 'MELVENE'}, + { 'name_id': 100311, 'name': 'MELVA'}, + { 'name_id': 100311, 'name': 'MELVINA'}, + { 'name_id': 100311, 'name': 'MELVILLE'}, + { 'name_id': 100311, 'name': 'MELVYN'}, + { 'name_id': 100312, 'name': 'MERRICK'}, + { 'name_id': 100312, 'name': 'MEYRICK'}, + { 'name_id': 100313, 'name': 'MERVIN'}, + { 'name_id': 100313, 'name': 'MERVYN'}, + { 'name_id': 100313, 'name': 'MERWIN'}, + { 'name_id': 100313, 'name': 'MERWYN'}, + { 'name_id': 100314, 'name': 'MEYER'}, + { 'name_id': 100314, 'name': 'MYER'}, + { 'name_id': 100315, 'name': 'MEYERS'}, + { 'name_id': 100315, 'name': 'MYERS'}, + { 'name_id': 100316, 'name': 'MICHAEL'}, + { 'name_id': 100316, 'name': 'MICK'}, + { 'name_id': 100316, 'name': 'MIK'}, + { 'name_id': 100316, 'name': 'MIC'}, + { 'name_id': 100316, 'name': 'MICA'}, + { 'name_id': 100316, 'name': 'MICHELINE'}, + { 'name_id': 100316, 'name': 'MIGUEL'}, + { 'name_id': 100316, 'name': 'MISHA'}, + { 'name_id': 100316, 'name': 'MISHKA'}, + { 'name_id': 100316, 'name': 'MYCALA'}, + { 'name_id': 100316, 'name': 'MYKEL'}, + { 'name_id': 100316, 'name': 'MYKELA'}, + { 'name_id': 100317, 'name': 'MILES'}, + { 'name_id': 100317, 'name': 'MILO'}, + { 'name_id': 100317, 'name': 'MYLES'}, + { 'name_id': 100318, 'name': 'MIRA'}, + { 'name_id': 100318, 'name': 'MYRA'}, + { 'name_id': 100318, 'name': 'MYRETTE'}, + { 'name_id': 100319, 'name': 'MIRANDA'}, + { 'name_id': 100319, 'name': 'MERANDA'}, + { 'name_id': 100319, 'name': 'MIRADA'}, + { 'name_id': 100320, 'name': 'MIRELLA'}, + { 'name_id': 100320, 'name': 'MIRABEL'}, + { 'name_id': 100320, 'name': 'MIRABELLA'}, + { 'name_id': 100320, 'name': 'MIRABELLE'}, + { 'name_id': 100321, 'name': 'MISSY'}, + { 'name_id': 100321, 'name': 'MISA'}, + { 'name_id': 100322, 'name': 'MITCHELL'}, + { 'name_id': 100322, 'name': 'MITCH'}, + { 'name_id': 100323, 'name': 'MOHAMMAD'}, + { 'name_id': 100323, 'name': 'MOHD'}, + { 'name_id': 100324, 'name': 'MOIRA'}, + { 'name_id': 100324, 'name': 'MHORA'}, + { 'name_id': 100324, 'name': 'MOIR'}, + { 'name_id': 100324, 'name': 'MORAG'}, + { 'name_id': 100324, 'name': 'MOYA'}, + { 'name_id': 100324, 'name': 'MOYR'}, + { 'name_id': 100324, 'name': 'MOYRA'}, + { 'name_id': 100325, 'name': 'MONICA'}, + { 'name_id': 100325, 'name': 'MONIQUE'}, + { 'name_id': 100326, 'name': 'MONTGOMERY'}, + { 'name_id': 100326, 'name': 'MONT'}, + { 'name_id': 100327, 'name': 'MORTIMER'}, + { 'name_id': 100327, 'name': 'MORT'}, + { 'name_id': 100327, 'name': 'MORTY'}, + { 'name_id': 100328, 'name': 'MURIEL'}, + { 'name_id': 100328, 'name': 'MERIS'}, + { 'name_id': 100328, 'name': 'MERRIE'}, + { 'name_id': 100328, 'name': 'MERRIS'}, + { 'name_id': 100328, 'name': 'MERRY'}, + { 'name_id': 100328, 'name': 'MERRYN'}, + { 'name_id': 100328, 'name': 'MERYL'}, + { 'name_id': 100328, 'name': 'MYRL'}, + { 'name_id': 100329, 'name': 'MURTAGH'}, + { 'name_id': 100329, 'name': 'MURDACH'}, + { 'name_id': 100329, 'name': 'MURDO'}, + { 'name_id': 100330, 'name': 'NADINE'}, + { 'name_id': 100330, 'name': 'NADA'}, + { 'name_id': 100330, 'name': 'NADIA'}, + { 'name_id': 100330, 'name': 'NADYA'}, + { 'name_id': 100331, 'name': 'NANCY'}, + { 'name_id': 100331, 'name': 'NAN'}, + { 'name_id': 100331, 'name': 'NANCE'}, + { 'name_id': 100331, 'name': 'NANCIE'}, + { 'name_id': 100331, 'name': 'NANI'}, + { 'name_id': 100331, 'name': 'NANINE'}, + { 'name_id': 100331, 'name': 'NANETTE'}, + { 'name_id': 100331, 'name': 'NANNETTE'}, + { 'name_id': 100331, 'name': 'NINETTA'}, + { 'name_id': 100331, 'name': 'NINETTE'}, + { 'name_id': 100331, 'name': 'NINKA'}, + { 'name_id': 100332, 'name': 'NATALIE'}, + { 'name_id': 100332, 'name': 'NAT'}, + { 'name_id': 100332, 'name': 'NATA'}, + { 'name_id': 100332, 'name': 'NATACHA'}, + { 'name_id': 100332, 'name': 'NATASHA'}, + { 'name_id': 100332, 'name': 'NATE'}, + { 'name_id': 100332, 'name': 'NATHAN'}, + { 'name_id': 100332, 'name': 'NATHANIEL'}, + { 'name_id': 100332, 'name': 'TACHA'}, + { 'name_id': 100332, 'name': 'TASHA'}, + { 'name_id': 100332, 'name': 'TASHIA'}, + { 'name_id': 100333, 'name': 'NEIL'}, + { 'name_id': 100333, 'name': 'CORNELIA'}, + { 'name_id': 100333, 'name': 'CORNELIUS'}, + { 'name_id': 100333, 'name': 'CORNEY'}, + { 'name_id': 100333, 'name': 'NEAL'}, + { 'name_id': 100333, 'name': 'NEILSON'}, + { 'name_id': 100333, 'name': 'NIELSON'}, + { 'name_id': 100333, 'name': 'NILS'}, + { 'name_id': 100334, 'name': 'NERISSA'}, + { 'name_id': 100334, 'name': 'NERIDA'}, + { 'name_id': 100334, 'name': 'NERITA'}, + { 'name_id': 100335, 'name': 'NEVILLE'}, + { 'name_id': 100335, 'name': 'NEVYL'}, + { 'name_id': 100336, 'name': 'NICHOLAS'}, + { 'name_id': 100336, 'name': 'NIC'}, + { 'name_id': 100336, 'name': 'NICK'}, + { 'name_id': 100336, 'name': 'NIK'}, + { 'name_id': 100336, 'name': 'NICOLAS'}, + { 'name_id': 100336, 'name': 'NICOLETTA'}, + { 'name_id': 100336, 'name': 'NICOLETTE'}, + { 'name_id': 100337, 'name': 'NILA'}, + { 'name_id': 100337, 'name': 'NYLA'}, + { 'name_id': 100338, 'name': 'NIVEN'}, + { 'name_id': 100338, 'name': 'NEVIN'}, + { 'name_id': 100339, 'name': 'NOELLA'}, + { 'name_id': 100339, 'name': 'NOELEEN'}, + { 'name_id': 100339, 'name': 'NOELINE'}, + { 'name_id': 100339, 'name': 'NOLEEN'}, + { 'name_id': 100340, 'name': 'NOLAN'}, + { 'name_id': 100340, 'name': 'NOLA'}, + { 'name_id': 100341, 'name': 'NORMAN'}, + { 'name_id': 100341, 'name': 'NORM'}, + { 'name_id': 100341, 'name': 'NORRIE'}, + { 'name_id': 100342, 'name': 'OAKLEY'}, + { 'name_id': 100342, 'name': 'OAKLEIGH'}, + { 'name_id': 100343, 'name': 'OBERON'}, + { 'name_id': 100343, 'name': 'AUBERON'}, + { 'name_id': 100344, 'name': 'OCEAN'}, + { 'name_id': 100344, 'name': 'OCEA'}, + { 'name_id': 100345, 'name': 'OCTAVIAN'}, + { 'name_id': 100345, 'name': 'OCTAVIA'}, + { 'name_id': 100345, 'name': 'OCTAVIANO'}, + { 'name_id': 100345, 'name': 'OCTAVIO'}, + { 'name_id': 100345, 'name': 'OCTAVIUS'}, + { 'name_id': 100346, 'name': 'OLEH'}, + { 'name_id': 100346, 'name': 'OLE'}, + { 'name_id': 100347, 'name': 'OLIVIA'}, + { 'name_id': 100347, 'name': 'LIV'}, + { 'name_id': 100347, 'name': 'OL'}, + { 'name_id': 100347, 'name': 'OLIV'}, + { 'name_id': 100347, 'name': 'OLIVE'}, + { 'name_id': 100348, 'name': 'OLWEN'}, + { 'name_id': 100348, 'name': 'ALWEN'}, + { 'name_id': 100348, 'name': 'OLWYN'}, + { 'name_id': 100349, 'name': 'OSWALD'}, + { 'name_id': 100349, 'name': 'OS'}, + { 'name_id': 100349, 'name': 'OZ'}, + { 'name_id': 100349, 'name': 'OSBERT'}, + { 'name_id': 100349, 'name': 'OSBORN'}, + { 'name_id': 100349, 'name': 'OSCAR'}, + { 'name_id': 100349, 'name': 'OSMOND'}, + { 'name_id': 100349, 'name': 'OZORA'}, + { 'name_id': 100350, 'name': 'OTTILIA'}, + { 'name_id': 100350, 'name': 'OTT'}, + { 'name_id': 100350, 'name': 'OTHAN'}, + { 'name_id': 100350, 'name': 'OTTAVIO'}, + { 'name_id': 100350, 'name': 'OTTAVIUS'}, + { 'name_id': 100350, 'name': 'OTTOLINA'}, + { 'name_id': 100350, 'name': 'OTTONE'}, + { 'name_id': 100350, 'name': 'OTTORINO'}, + { 'name_id': 100351, 'name': 'PAMELA'}, + { 'name_id': 100351, 'name': 'PAM'}, + { 'name_id': 100352, 'name': 'PATRICIA'}, + { 'name_id': 100352, 'name': 'LATISHA'}, + { 'name_id': 100352, 'name': 'LETITIA'}, + { 'name_id': 100352, 'name': 'LETTICE'}, + { 'name_id': 100352, 'name': 'LETTY'}, + { 'name_id': 100352, 'name': 'PADDINA'}, + { 'name_id': 100352, 'name': 'PATIA'}, + { 'name_id': 100352, 'name': 'PATIENCE'}, + { 'name_id': 100352, 'name': 'PATSY'}, + { 'name_id': 100352, 'name': 'PATRICE'}, + { 'name_id': 100352, 'name': 'PATRISHA'}, + { 'name_id': 100352, 'name': 'TISH'}, + { 'name_id': 100352, 'name': 'TISHA'}, + { 'name_id': 100352, 'name': 'TRECIA'}, + { 'name_id': 100352, 'name': 'TRICIA'}, + { 'name_id': 100352, 'name': 'TRISH'}, + { 'name_id': 100352, 'name': 'TRISHA'}, + { 'name_id': 100352, 'name': 'TRYCIA'}, + { 'name_id': 100353, 'name': 'PATRICK'}, + { 'name_id': 100353, 'name': 'PADDIE'}, + { 'name_id': 100353, 'name': 'PADDY'}, + { 'name_id': 100353, 'name': 'PADRAIG'}, + { 'name_id': 100353, 'name': 'PAT'}, + { 'name_id': 100353, 'name': 'PATRICIA'}, + { 'name_id': 100353, 'name': 'PATRIK'}, + { 'name_id': 100353, 'name': 'PATRIKA'}, + { 'name_id': 100353, 'name': 'PATTI'}, + { 'name_id': 100353, 'name': 'PATTIE'}, + { 'name_id': 100353, 'name': 'PATTY'}, + { 'name_id': 100354, 'name': 'PAULINE'}, + { 'name_id': 100354, 'name': 'PAULA'}, + { 'name_id': 100354, 'name': 'PAULETTE'}, + { 'name_id': 100355, 'name': 'PEARCE'}, + { 'name_id': 100355, 'name': 'PEARSON'}, + { 'name_id': 100355, 'name': 'PIERS'}, + { 'name_id': 100356, 'name': 'PENELOPE'}, + { 'name_id': 100356, 'name': 'PEN'}, + { 'name_id': 100357, 'name': 'PERCIVAL'}, + { 'name_id': 100357, 'name': 'PERCY'}, + { 'name_id': 100357, 'name': 'PERZY'}, + { 'name_id': 100358, 'name': 'PETER'}, + { 'name_id': 100358, 'name': 'PEDRO'}, + { 'name_id': 100358, 'name': 'PEDROE'}, + { 'name_id': 100358, 'name': 'PEREGRINE'}, + { 'name_id': 100358, 'name': 'PERRINE'}, + { 'name_id': 100358, 'name': 'PERRY'}, + { 'name_id': 100358, 'name': 'PETRA'}, + { 'name_id': 100358, 'name': 'PETRINA'}, + { 'name_id': 100358, 'name': 'PIETRO'}, + { 'name_id': 100359, 'name': 'PHILIP'}, + { 'name_id': 100359, 'name': 'PIP'}, + { 'name_id': 100359, 'name': 'FLIP'}, + { 'name_id': 100359, 'name': 'FLISS'}, + { 'name_id': 100359, 'name': 'PHILIS'}, + { 'name_id': 100359, 'name': 'PHILLIDA'}, + { 'name_id': 100359, 'name': 'PHYLLIDA'}, + { 'name_id': 100001, 'name': 'AARON'}, + { 'name_id': 100204, 'name': 'IZAAK'}, + { 'name_id': 100205, 'name': 'ISABEL'}, + { 'name_id': 100205, 'name': 'ISA'}, + { 'name_id': 100205, 'name': 'ISABELLA'}, + { 'name_id': 100205, 'name': 'ISABELLE'}, + { 'name_id': 100205, 'name': 'ISOPEL'}, + { 'name_id': 100205, 'name': 'ISSIE'}, + { 'name_id': 100205, 'name': 'IZETTA'}, + { 'name_id': 100205, 'name': 'YSABELLA'}, + { 'name_id': 100206, 'name': 'ISADOR'}, + { 'name_id': 100206, 'name': 'IZZY'}, + { 'name_id': 100206, 'name': 'YSIDORA'}, + { 'name_id': 100206, 'name': 'YSIDORE'}, + { 'name_id': 100206, 'name': 'ZADORA'}, + { 'name_id': 100207, 'name': 'IVAN'}, + { 'name_id': 100207, 'name': 'IVA'}, + { 'name_id': 100207, 'name': 'IVAH'}, + { 'name_id': 100207, 'name': 'IVER'}, + { 'name_id': 100207, 'name': 'IVOR'}, + { 'name_id': 100207, 'name': 'YVAN'}, + { 'name_id': 100208, 'name': 'JACOB'}, + { 'name_id': 100208, 'name': 'JACOBS'}, + { 'name_id': 100208, 'name': 'JAKE'}, + { 'name_id': 100208, 'name': 'JAKO'}, + { 'name_id': 100208, 'name': 'JEB'}, + { 'name_id': 100209, 'name': 'JACQUELINE'}, + { 'name_id': 100209, 'name': 'JACK'}, + { 'name_id': 100209, 'name': 'JACALINE'}, + { 'name_id': 100209, 'name': 'JACALYN'}, + { 'name_id': 100209, 'name': 'JACKLENE'}, + { 'name_id': 100209, 'name': 'JACKLYN'}, + { 'name_id': 100209, 'name': 'JACQUELIN'}, + { 'name_id': 100209, 'name': 'JACQUELYN'}, + { 'name_id': 100209, 'name': 'JACQUETTA'}, + { 'name_id': 100209, 'name': 'JACQUI'}, + { 'name_id': 100209, 'name': 'JACQUIE'}, + { 'name_id': 100209, 'name': 'JAQUELINE'}, + { 'name_id': 100209, 'name': 'JAQUETTA'}, + { 'name_id': 100210, 'name': 'JAMISON'}, + { 'name_id': 100210, 'name': 'JAM'}, + { 'name_id': 100210, 'name': 'JIM'}, + { 'name_id': 100210, 'name': 'JAIME'}, + { 'name_id': 100210, 'name': 'JAMES'}, + { 'name_id': 100210, 'name': 'JAMESINA'}, + { 'name_id': 100210, 'name': 'JAMIESON'}, + { 'name_id': 100210, 'name': 'JAMISINA'}, + { 'name_id': 100210, 'name': 'JAS'}, + { 'name_id': 100210, 'name': 'JAYME'}, + { 'name_id': 100210, 'name': 'JEMIMA'}, + { 'name_id': 100211, 'name': 'JANET'}, + { 'name_id': 100211, 'name': 'JAN'}, + { 'name_id': 100211, 'name': 'JAINE'}, + { 'name_id': 100211, 'name': 'JANERETTA'}, + { 'name_id': 100211, 'name': 'JANERETTE'}, + { 'name_id': 100211, 'name': 'JANICE'}, + { 'name_id': 100211, 'name': 'JANSEN'}, + { 'name_id': 100211, 'name': 'JANSON'}, + { 'name_id': 100211, 'name': 'JANUARY'}, + { 'name_id': 100211, 'name': 'JAYNE'}, + { 'name_id': 100212, 'name': 'JANICE'}, + { 'name_id': 100212, 'name': 'JANCY'}, + { 'name_id': 100212, 'name': 'JANES'}, + { 'name_id': 100212, 'name': 'JANEZ'}, + { 'name_id': 100212, 'name': 'JANIS'}, + { 'name_id': 100212, 'name': 'JANYCE'}, + { 'name_id': 100212, 'name': 'JENESSA'}, + { 'name_id': 100212, 'name': 'JENISE'}, + { 'name_id': 100212, 'name': 'JONCY'}, + { 'name_id': 100212, 'name': 'JONSY'}, + { 'name_id': 100213, 'name': 'JAPHET'}, + { 'name_id': 100213, 'name': 'YAPHET'}, + { 'name_id': 100214, 'name': 'JARED'}, + { 'name_id': 100214, 'name': 'JARRY'}, + { 'name_id': 100215, 'name': 'JASON'}, + { 'name_id': 100215, 'name': 'JACE'}, + { 'name_id': 100215, 'name': 'JAY'}, + { 'name_id': 100215, 'name': 'JAYSON'}, + { 'name_id': 100216, 'name': 'JEAN'}, + { 'name_id': 100216, 'name': 'JEANA'}, + { 'name_id': 100216, 'name': 'JEANE'}, + { 'name_id': 100216, 'name': 'JEANIE'}, + { 'name_id': 100216, 'name': 'JEANETT'}, + { 'name_id': 100216, 'name': 'JEANETTE'}, + { 'name_id': 100216, 'name': 'JEANINE'}, + { 'name_id': 100216, 'name': 'JEANNA'}, + { 'name_id': 100216, 'name': 'JEANNE'}, + { 'name_id': 100216, 'name': 'JEANNI'}, + { 'name_id': 100216, 'name': 'JEANNIE'}, + { 'name_id': 100216, 'name': 'JEANNY'}, + { 'name_id': 100216, 'name': 'JEANNETTA'}, + { 'name_id': 100216, 'name': 'JEANNETTE'}, + { 'name_id': 100216, 'name': 'JEANNINE'}, + { 'name_id': 100216, 'name': 'JENELLA'}, + { 'name_id': 100216, 'name': 'JENET'}, + { 'name_id': 100216, 'name': 'JENETTA'}, + { 'name_id': 100216, 'name': 'JENNET'}, + { 'name_id': 100217, 'name': 'JEDIDIAH'}, + { 'name_id': 100217, 'name': 'GED'}, + { 'name_id': 100217, 'name': 'JED'}, + { 'name_id': 100218, 'name': 'JEFFREY'}, + { 'name_id': 100218, 'name': 'JEF'}, + { 'name_id': 100218, 'name': 'JEFF'}, + { 'name_id': 100218, 'name': 'JEFFERSON'}, + { 'name_id': 100218, 'name': 'JEFFERY'}, + { 'name_id': 100219, 'name': 'JEMIMA'}, + { 'name_id': 100219, 'name': 'GEM'}, + { 'name_id': 100219, 'name': 'GEMMA'}, + { 'name_id': 100219, 'name': 'JEM'}, + { 'name_id': 100219, 'name': 'JEMMA'}, + { 'name_id': 100219, 'name': 'JEMMY'}, + { 'name_id': 100219, 'name': 'MIMA'}, + { 'name_id': 100220, 'name': 'JENIFFER'}, + { 'name_id': 100220, 'name': 'JEN'}, + { 'name_id': 100220, 'name': 'JEFFIE'}, + { 'name_id': 100220, 'name': 'JENYTH'}, + { 'name_id': 100221, 'name': 'JERARD'}, + { 'name_id': 100221, 'name': 'GARRARD'}, + { 'name_id': 100221, 'name': 'GERARD'}, + { 'name_id': 100221, 'name': 'GERRARD'}, + { 'name_id': 100222, 'name': 'JEREMY'}, + { 'name_id': 100222, 'name': 'GEREMY'}, + { 'name_id': 100222, 'name': 'JEREMIAH'}, + { 'name_id': 100222, 'name': 'JERMYN'}, + { 'name_id': 100223, 'name': 'JESSICA'}, + { 'name_id': 100223, 'name': 'JES'}, + { 'name_id': 100223, 'name': 'YESSICA'}, + { 'name_id': 100224, 'name': 'JOANNE'}, + { 'name_id': 100224, 'name': 'JANNA'}, + { 'name_id': 100224, 'name': 'JANNAH'}, + { 'name_id': 100224, 'name': 'JOAN'}, + { 'name_id': 100224, 'name': 'JOANIE'}, + { 'name_id': 100224, 'name': 'JOANN'}, + { 'name_id': 100224, 'name': 'JOANNA'}, + { 'name_id': 100224, 'name': 'JOANNIE'}, + { 'name_id': 100224, 'name': 'JOANY'}, + { 'name_id': 100224, 'name': 'JOHANNA'}, + { 'name_id': 100224, 'name': 'JOHANNE'}, + { 'name_id': 100225, 'name': 'JOB'}, + { 'name_id': 100225, 'name': 'JOBINA'}, + { 'name_id': 100226, 'name': 'JOCELYN'}, + { 'name_id': 100226, 'name': 'JOSCELINE'}, + { 'name_id': 100226, 'name': 'JOSCELYN'}, + { 'name_id': 100226, 'name': 'JOSLIN'}, + { 'name_id': 100226, 'name': 'JOSLYN'}, + { 'name_id': 100226, 'name': 'JOSSLYN'}, + { 'name_id': 100227, 'name': 'JODY'}, + { 'name_id': 100227, 'name': 'JOD'}, + { 'name_id': 100227, 'name': 'JODETTE'}, + { 'name_id': 100228, 'name': 'JOLANDA'}, + { 'name_id': 100228, 'name': 'YOLA'}, + { 'name_id': 100228, 'name': 'YOLANTA'}, + { 'name_id': 100229, 'name': 'JOLENE'}, + { 'name_id': 100229, 'name': 'JOLIE'}, + { 'name_id': 100229, 'name': 'JOLYN'}, + { 'name_id': 100229, 'name': 'JOLYNE'}, + { 'name_id': 100230, 'name': 'JONAS'}, + { 'name_id': 100230, 'name': 'JONAH'}, + { 'name_id': 100230, 'name': 'YONA'}, + { 'name_id': 100231, 'name': 'JONATHAN'}, + { 'name_id': 100231, 'name': 'JACK'}, + { 'name_id': 100231, 'name': 'JACKIE'}, + { 'name_id': 100231, 'name': 'JACKY'}, + { 'name_id': 100231, 'name': 'JACQUES'}, + { 'name_id': 100231, 'name': 'JANITA'}, + { 'name_id': 100231, 'name': 'JEAN'}, + { 'name_id': 100231, 'name': 'JENITA'}, + { 'name_id': 100231, 'name': 'JOANNE'}, + { 'name_id': 100231, 'name': 'JOCK'}, + { 'name_id': 100231, 'name': 'JOHANN'}, + { 'name_id': 100231, 'name': 'JOHN'}, + { 'name_id': 100231, 'name': 'JOHNATHON'}, + { 'name_id': 100231, 'name': 'JOHNETTE'}, + { 'name_id': 100231, 'name': 'JOHNNEY'}, + { 'name_id': 100231, 'name': 'JOHNNIE'}, + { 'name_id': 100231, 'name': 'JOHNNY'}, + { 'name_id': 100231, 'name': 'JONATHAN'}, + { 'name_id': 100231, 'name': 'JONATHON'}, + { 'name_id': 100231, 'name': 'JONETTE'}, + { 'name_id': 100231, 'name': 'JONI'}, + { 'name_id': 100231, 'name': 'JONIE'}, + { 'name_id': 100231, 'name': 'JONNEY'}, + { 'name_id': 100231, 'name': 'JONNI'}, + { 'name_id': 100231, 'name': 'JONNIE'}, + { 'name_id': 100231, 'name': 'JONNY'}, + { 'name_id': 100231, 'name': 'JONY'}, + { 'name_id': 100231, 'name': 'JOSEPH'}, + { 'name_id': 100231, 'name': 'JUAN'}, + { 'name_id': 100231, 'name': 'JUANA'}, + { 'name_id': 100231, 'name': 'JUANITA'}, + { 'name_id': 100231, 'name': 'JUANITO'}, + { 'name_id': 100232, 'name': 'JOSE'}, + { 'name_id': 100232, 'name': 'YOSE'}, + { 'name_id': 100233, 'name': 'JOSEPH'}, + { 'name_id': 100233, 'name': 'JO'}, + { 'name_id': 100233, 'name': 'JOE'}, + { 'name_id': 100233, 'name': 'JOELLE'}, + { 'name_id': 100233, 'name': 'JOEY'}, + { 'name_id': 100233, 'name': 'JOSE'}, + { 'name_id': 100233, 'name': 'JOSEF'}, + { 'name_id': 100233, 'name': 'JOSEPHINE'}, + { 'name_id': 100233, 'name': 'JOSETTE'}, + { 'name_id': 100233, 'name': 'JOSIE'}, + { 'name_id': 100233, 'name': 'JOSY'}, + { 'name_id': 100234, 'name': 'JOSHUA'}, + { 'name_id': 100234, 'name': 'JOSH'}, + { 'name_id': 100234, 'name': 'JOSIAH'}, + { 'name_id': 100235, 'name': 'JOY'}, + { 'name_id': 100235, 'name': 'JOI'}, + { 'name_id': 100235, 'name': 'JOIA'}, + { 'name_id': 100235, 'name': 'JOIE'}, + { 'name_id': 100236, 'name': 'JUDITH'}, + { 'name_id': 100236, 'name': 'JUD'}, + { 'name_id': 100236, 'name': 'JODY'}, + { 'name_id': 100236, 'name': 'JORDAN'}, + { 'name_id': 100236, 'name': 'JUDAH'}, + { 'name_id': 100236, 'name': 'JUDAS'}, + { 'name_id': 100236, 'name': 'JUDSON'}, + { 'name_id': 100236, 'name': 'UTA'}, + { 'name_id': 100236, 'name': 'YUTA'}, + { 'name_id': 100236, 'name': 'YUTTA'}, + { 'name_id': 100237, 'name': 'JULIA'}, + { 'name_id': 100237, 'name': 'GULIA'}, + { 'name_id': 100238, 'name': 'JULIAN'}, + { 'name_id': 100238, 'name': 'GILES'}, + { 'name_id': 100238, 'name': 'GILLIAN'}, + { 'name_id': 100238, 'name': 'GILLY'}, + { 'name_id': 100238, 'name': 'GYLES'}, + { 'name_id': 100238, 'name': 'JILL'}, + { 'name_id': 100238, 'name': 'JILLY'}, + { 'name_id': 100238, 'name': 'JOLYAN'}, + { 'name_id': 100238, 'name': 'JULE'}, + { 'name_id': 100238, 'name': 'JULES'}, + { 'name_id': 100238, 'name': 'JULIA'}, + { 'name_id': 100238, 'name': 'JULIE'}, + { 'name_id': 100238, 'name': 'JULIES'}, + { 'name_id': 100238, 'name': 'JULY'}, + { 'name_id': 100239, 'name': 'JUSTIN'}, + { 'name_id': 100239, 'name': 'JUSTYN'}, + { 'name_id': 100240, 'name': 'KAREN'}, + { 'name_id': 100240, 'name': 'CARYN'}, + { 'name_id': 100240, 'name': 'KARIN'}, + { 'name_id': 100240, 'name': 'KARYN'}, + { 'name_id': 100240, 'name': 'KERYN'}, + { 'name_id': 100241, 'name': 'KAY'}, + { 'name_id': 100241, 'name': 'KAYE'}, + { 'name_id': 100242, 'name': 'KAYLE'}, + { 'name_id': 100242, 'name': 'KAILE'}, + { 'name_id': 100242, 'name': 'KELILA'}, + { 'name_id': 100243, 'name': 'KEANE'}, + { 'name_id': 100243, 'name': 'KEENAN'}, + { 'name_id': 100244, 'name': 'KELLY'}, + { 'name_id': 100244, 'name': 'KEL'}, + { 'name_id': 100244, 'name': 'KALEY'}, + { 'name_id': 100244, 'name': 'KAYLAY'}, + { 'name_id': 100244, 'name': 'KAYLEIGH'}, + { 'name_id': 100244, 'name': 'KEELEY'}, + { 'name_id': 100244, 'name': 'KEELLAH'}, + { 'name_id': 100244, 'name': 'KEELY'}, + { 'name_id': 100244, 'name': 'KELLEYE'}, + { 'name_id': 100245, 'name': 'KENDALL'}, + { 'name_id': 100245, 'name': 'KENITH'}, + { 'name_id': 100245, 'name': 'KENNETH'}, + { 'name_id': 100245, 'name': 'KENNETT'}, + { 'name_id': 100245, 'name': 'KENT'}, + { 'name_id': 100245, 'name': 'KENTON'}, + { 'name_id': 100246, 'name': 'KENNETH'}, + { 'name_id': 100246, 'name': 'KEN'}, + { 'name_id': 100247, 'name': 'KESHISHA'}, + { 'name_id': 100247, 'name': 'KESHA'}, + { 'name_id': 100247, 'name': 'KESHIA'}, + { 'name_id': 100248, 'name': 'KEVIN'}, + { 'name_id': 100248, 'name': 'KEV'}, + { 'name_id': 100248, 'name': 'KEVA'}, + { 'name_id': 100248, 'name': 'KEVERN'}, + { 'name_id': 100248, 'name': 'KEVERNE'}, + { 'name_id': 100249, 'name': 'KIMBERLY'}, + { 'name_id': 100249, 'name': 'KIM'}, + { 'name_id': 100249, 'name': 'KIMBALL'}, + { 'name_id': 100249, 'name': 'KIMBLE'}, + { 'name_id': 100249, 'name': 'KYM'}, + { 'name_id': 100249, 'name': 'KYMBERLY'}, + { 'name_id': 100249, 'name': 'KYMBERLEY'}, + { 'name_id': 100249, 'name': 'KYMBLE'}, + { 'name_id': 100250, 'name': 'KINGSLEY'}, + { 'name_id': 100250, 'name': 'KING'}, + { 'name_id': 100250, 'name': 'KINGSTON'}, + { 'name_id': 100250, 'name': 'KINGSWOOD'}, + { 'name_id': 100251, 'name': 'KIRAN'}, + { 'name_id': 100251, 'name': 'KEIR'}, + { 'name_id': 100251, 'name': 'KEIRA'}, + { 'name_id': 100251, 'name': 'KIERA'}, + { 'name_id': 100251, 'name': 'KYRAN'}, + { 'name_id': 100252, 'name': 'LACEY'}, + { 'name_id': 100252, 'name': 'LACI'}, + { 'name_id': 100253, 'name': 'LANE'}, + { 'name_id': 100253, 'name': 'LAYNE'}, + { 'name_id': 100254, 'name': 'LAURA'}, + { 'name_id': 100254, 'name': 'LARA'}, + { 'name_id': 100254, 'name': 'LAUREN'}, + { 'name_id': 100254, 'name': 'LAURETTA'}, + { 'name_id': 100254, 'name': 'LAURI'}, + { 'name_id': 100254, 'name': 'LAURIE'}, + { 'name_id': 100254, 'name': 'LORA'}, + { 'name_id': 100254, 'name': 'LORETTA'}, + { 'name_id': 100254, 'name': 'LORETTE'}, + { 'name_id': 100254, 'name': 'LORENZO'}, + { 'name_id': 100254, 'name': 'LOREY'}, + { 'name_id': 100254, 'name': 'LORI'}, + { 'name_id': 100254, 'name': 'LORIS'}, + { 'name_id': 100254, 'name': 'LORISSA'}, + { 'name_id': 100254, 'name': 'LORRETTE'}, + { 'name_id': 100254, 'name': 'LORRIE'}, + { 'name_id': 100255, 'name': 'LAUREL'}, + { 'name_id': 100255, 'name': 'LAURELIA'}, + { 'name_id': 100255, 'name': 'LORAL'}, + { 'name_id': 100255, 'name': 'LORELEI'}, + { 'name_id': 100255, 'name': 'LORELL'}, + { 'name_id': 100255, 'name': 'LORELLE'}, + { 'name_id': 100256, 'name': 'LAVERNE'}, + { 'name_id': 100256, 'name': 'VERN'}, + { 'name_id': 100256, 'name': 'VERNE'}, + { 'name_id': 100256, 'name': 'WARREN'}, + { 'name_id': 100256, 'name': 'WARRENE'}, + { 'name_id': 100256, 'name': 'WERNER'}, + { 'name_id': 100257, 'name': 'LAVINA'}, + { 'name_id': 100257, 'name': 'LAVVY'}, + { 'name_id': 100257, 'name': 'VINCE'}, + { 'name_id': 100257, 'name': 'VINCENT'}, + { 'name_id': 100257, 'name': 'VINNIE'}, + { 'name_id': 100257, 'name': 'VINNI'}, + { 'name_id': 100257, 'name': 'VINNY'}, + { 'name_id': 100258, 'name': 'LAWRENCE'}, + { 'name_id': 100258, 'name': 'LARKIN'}, + { 'name_id': 100258, 'name': 'LARRY'}, + { 'name_id': 100258, 'name': 'LAURANCE'}, + { 'name_id': 100258, 'name': 'LAURENCE'}, + { 'name_id': 100258, 'name': 'LAURIER'}, + { 'name_id': 100258, 'name': 'LAWRIE'}, + { 'name_id': 100259, 'name': 'LAYTON'}, + { 'name_id': 100259, 'name': 'LEIGHTON'}, + { 'name_id': 100260, 'name': 'LEIGH'}, + { 'name_id': 100260, 'name': 'ALEAH'}, + { 'name_id': 100260, 'name': 'LEA'}, + { 'name_id': 100260, 'name': 'LEAGH'}, + { 'name_id': 100260, 'name': 'LEAH'}, + { 'name_id': 100260, 'name': 'LEE'}, + { 'name_id': 100260, 'name': 'LEIA'}, + { 'name_id': 100260, 'name': 'LI'}, + { 'name_id': 100260, 'name': 'LIA'}, + { 'name_id': 100260, 'name': 'LY'}, + { 'name_id': 100261, 'name': 'LEILA'}, + { 'name_id': 100261, 'name': 'LAYLA'}, + { 'name_id': 100261, 'name': 'LEYLA'}, + { 'name_id': 100261, 'name': 'LYLA'}, + { 'name_id': 100261, 'name': 'LYLAH'}, + { 'name_id': 100262, 'name': 'LELAND'}, + { 'name_id': 100262, 'name': 'LEYLAND'}, + { 'name_id': 100263, 'name': 'LEMMY'}, + { 'name_id': 100263, 'name': 'LEM'}, + { 'name_id': 100263, 'name': 'LEMUEL'}, + { 'name_id': 100264, 'name': 'LEONARD'}, + { 'name_id': 100264, 'name': 'LEN'}, + { 'name_id': 100264, 'name': 'LENDA'}, + { 'name_id': 100264, 'name': 'LENICE'}, + { 'name_id': 100264, 'name': 'LENIS'}, + { 'name_id': 100264, 'name': 'LEO'}, + { 'name_id': 100264, 'name': 'LEON'}, + { 'name_id': 100264, 'name': 'LEONARDO'}, + { 'name_id': 100264, 'name': 'LEONA'}, + { 'name_id': 100264, 'name': 'LEONE'}, + { 'name_id': 100264, 'name': 'LEONIA'}, + { 'name_id': 100264, 'name': 'LEOPOLD'}, + { 'name_id': 100265, 'name': 'LESLEY'}, + { 'name_id': 100265, 'name': 'LES'}, + { 'name_id': 100265, 'name': 'LESTER'}, + { 'name_id': 100266, 'name': 'LEVIN'}, + { 'name_id': 100266, 'name': 'LEWIN'}, + { 'name_id': 100267, 'name': 'LEWIS'}, + { 'name_id': 100267, 'name': 'LEW'}, + { 'name_id': 100267, 'name': 'LODOVIC'}, + { 'name_id': 100267, 'name': 'LOUIS'}, + { 'name_id': 100267, 'name': 'LOUISA'}, + { 'name_id': 100267, 'name': 'LOUISE'}, + { 'name_id': 100267, 'name': 'LOUIZE'}, + { 'name_id': 100267, 'name': 'LU'}, + { 'name_id': 100267, 'name': 'LUDOVIC'}, + { 'name_id': 100267, 'name': 'LUIS'}, + { 'name_id': 100267, 'name': 'LUIZ'}, + { 'name_id': 100268, 'name': 'LILLIAN'}, + { 'name_id': 100268, 'name': 'LIL'}, + { 'name_id': 100268, 'name': 'LILEA'}, + { 'name_id': 100269, 'name': 'LINDLEY'}, + { 'name_id': 100269, 'name': 'LINDON'}, + { 'name_id': 100269, 'name': 'LINLEY'}, + { 'name_id': 100269, 'name': 'LINTON'}, + { 'name_id': 100269, 'name': 'LYNDON'}, + { 'name_id': 100269, 'name': 'LYNLEE'}, + { 'name_id': 100269, 'name': 'LYNLEY'}, + { 'name_id': 100269, 'name': 'LYNTON'}, + { 'name_id': 100270, 'name': 'LINDSAY'}, + { 'name_id': 100270, 'name': 'LINSAY'}, + { 'name_id': 100270, 'name': 'LINZI'}, + { 'name_id': 100270, 'name': 'LYNDSAY'}, + { 'name_id': 100270, 'name': 'LYNN'}, + { 'name_id': 100270, 'name': 'LYNSAY'}, + { 'name_id': 100270, 'name': 'LYNSEY'}, + { 'name_id': 100271, 'name': 'LLOYD'}, + { 'name_id': 100271, 'name': 'LLOY'}, + { 'name_id': 100272, 'name': 'LORRAINE'}, + { 'name_id': 100272, 'name': 'LAURA'}, + { 'name_id': 100272, 'name': 'LAUREL'}, + { 'name_id': 100272, 'name': 'LAWRENCE'}, + { 'name_id': 100273, 'name': 'LOUIS'}, + { 'name_id': 100273, 'name': 'LOU'}, + { 'name_id': 100274, 'name': 'LOUISE'}, + { 'name_id': 100274, 'name': 'LOES'}, + { 'name_id': 100274, 'name': 'LOIE'}, + { 'name_id': 100274, 'name': 'LOIS'}, + { 'name_id': 100275, 'name': 'LUCAS'}, + { 'name_id': 100275, 'name': 'LUC'}, + { 'name_id': 100275, 'name': 'LUK'}, + { 'name_id': 100275, 'name': 'LUKE'}, + { 'name_id': 100276, 'name': 'LUCIEN'}, + { 'name_id': 100276, 'name': 'CINDY'}, + { 'name_id': 100276, 'name': 'LICIUS'}, + { 'name_id': 100276, 'name': 'LUCIA'}, + { 'name_id': 100276, 'name': 'LUCIE'}, + { 'name_id': 100276, 'name': 'LUCILLA'}, + { 'name_id': 100276, 'name': 'LUCILLE'}, + { 'name_id': 100276, 'name': 'LUCINDA'}, + { 'name_id': 100276, 'name': 'LUCIS'}, + { 'name_id': 100276, 'name': 'LUCY'}, + { 'name_id': 100276, 'name': 'LULA'}, + { 'name_id': 100276, 'name': 'LULU'}, + { 'name_id': 100276, 'name': 'LUZINE'}, + { 'name_id': 100277, 'name': 'LYLE'}, + { 'name_id': 100277, 'name': 'LISLE'}, + { 'name_id': 100001, 'name': 'AHRON'}, + { 'name_id': 100001, 'name': 'ERIN'}, + { 'name_id': 100359, 'name': 'PHYLUS'}, + { 'name_id': 100360, 'name': 'PRECILLA'}, + { 'name_id': 100360, 'name': 'CILLA'}, + { 'name_id': 100360, 'name': 'PRIS'}, + { 'name_id': 100360, 'name': 'PRISCILLA'}, + { 'name_id': 100361, 'name': 'PRICE'}, + { 'name_id': 100361, 'name': 'PRYCE'}, + { 'name_id': 100362, 'name': 'PRUDENCE'}, + { 'name_id': 100362, 'name': 'PRU'}, + { 'name_id': 100362, 'name': 'PRUE'}, + { 'name_id': 100363, 'name': 'QUENTIN'}, + { 'name_id': 100363, 'name': 'QUIN'}, + { 'name_id': 100363, 'name': 'QUINCY'}, + { 'name_id': 100363, 'name': 'QUINDA'}, + { 'name_id': 100363, 'name': 'QUINN'}, + { 'name_id': 100363, 'name': 'QUYNN'}, + { 'name_id': 100364, 'name': 'RACHEL'}, + { 'name_id': 100364, 'name': 'RAE'}, + { 'name_id': 100364, 'name': 'RAQUEL'}, + { 'name_id': 100364, 'name': 'RAYE'}, + { 'name_id': 100365, 'name': 'RAFAEL'}, + { 'name_id': 100365, 'name': 'RAF'}, + { 'name_id': 100365, 'name': 'RAIFE'}, + { 'name_id': 100365, 'name': 'RALF'}, + { 'name_id': 100365, 'name': 'RALPH'}, + { 'name_id': 100365, 'name': 'RALPHINA'}, + { 'name_id': 100366, 'name': 'RALEIGH'}, + { 'name_id': 100366, 'name': 'RAWLEY'}, + { 'name_id': 100366, 'name': 'RAYLEY'}, + { 'name_id': 100367, 'name': 'RALPH'}, + { 'name_id': 100367, 'name': 'RAPH'}, + { 'name_id': 100367, 'name': 'ROLF'}, + { 'name_id': 100368, 'name': 'RANDALL'}, + { 'name_id': 100368, 'name': 'MIRANDA'}, + { 'name_id': 100368, 'name': 'RANDEE'}, + { 'name_id': 100368, 'name': 'RANDI'}, + { 'name_id': 100368, 'name': 'RANDIE'}, + { 'name_id': 100368, 'name': 'RANDLE'}, + { 'name_id': 100368, 'name': 'RANDOLPH'}, + { 'name_id': 100369, 'name': 'RANDOLPH'}, + { 'name_id': 100369, 'name': 'RANDY'}, + { 'name_id': 100370, 'name': 'RAYMOND'}, + { 'name_id': 100370, 'name': 'RAMAN'}, + { 'name_id': 100370, 'name': 'RAMON'}, + { 'name_id': 100370, 'name': 'RAMONA'}, + { 'name_id': 100370, 'name': 'RAMOND'}, + { 'name_id': 100370, 'name': 'RAY'}, + { 'name_id': 100370, 'name': 'RAYBURN'}, + { 'name_id': 100370, 'name': 'RAYFORD'}, + { 'name_id': 100371, 'name': 'RAYNOR'}, + { 'name_id': 100371, 'name': 'RAIN'}, + { 'name_id': 100371, 'name': 'REIN'}, + { 'name_id': 100371, 'name': 'RAINER'}, + { 'name_id': 100371, 'name': 'RANA'}, + { 'name_id': 100372, 'name': 'REBECCA'}, + { 'name_id': 100372, 'name': 'BECK'}, + { 'name_id': 100372, 'name': 'BEKI'}, + { 'name_id': 100372, 'name': 'REB'}, + { 'name_id': 100372, 'name': 'REBA'}, + { 'name_id': 100373, 'name': 'REESE'}, + { 'name_id': 100373, 'name': 'REECE'}, + { 'name_id': 100373, 'name': 'REES'}, + { 'name_id': 100373, 'name': 'RHYS'}, + { 'name_id': 100374, 'name': 'REGINA'}, + { 'name_id': 100374, 'name': 'GIA'}, + { 'name_id': 100374, 'name': 'REGINE'}, + { 'name_id': 100375, 'name': 'REGINALD'}, + { 'name_id': 100375, 'name': 'REG'}, + { 'name_id': 100375, 'name': 'REG'}, + { 'name_id': 100375, 'name': 'REGGIE'}, + { 'name_id': 100375, 'name': 'REGIS'}, + { 'name_id': 100376, 'name': 'REMY'}, + { 'name_id': 100376, 'name': 'REMI'}, + { 'name_id': 100377, 'name': 'RENEE'}, + { 'name_id': 100377, 'name': 'IRANA'}, + { 'name_id': 100377, 'name': 'IRENA'}, + { 'name_id': 100377, 'name': 'IRENE'}, + { 'name_id': 100377, 'name': 'IRINA'}, + { 'name_id': 100377, 'name': 'RENA'}, + { 'name_id': 100377, 'name': 'RENATA'}, + { 'name_id': 100377, 'name': 'RENE'}, + { 'name_id': 100377, 'name': 'RENIE'}, + { 'name_id': 100377, 'name': 'RENNIE'}, + { 'name_id': 100377, 'name': 'RENNY'}, + { 'name_id': 100377, 'name': 'RINA'}, + { 'name_id': 100378, 'name': 'RHIAN'}, + { 'name_id': 100378, 'name': 'RHIANNON'}, + { 'name_id': 100378, 'name': 'RYAN'}, + { 'name_id': 100379, 'name': 'RICHARD'}, + { 'name_id': 100379, 'name': 'DICK'}, + { 'name_id': 100379, 'name': 'RIC'}, + { 'name_id': 100379, 'name': 'RICH'}, + { 'name_id': 100379, 'name': 'RICK'}, + { 'name_id': 100379, 'name': 'RIK'}, + { 'name_id': 100379, 'name': 'RITCH'}, + { 'name_id': 100379, 'name': 'DICKENS'}, + { 'name_id': 100379, 'name': 'DICKON'}, + { 'name_id': 100379, 'name': 'DICKSON'}, + { 'name_id': 100379, 'name': 'DIKKEN'}, + { 'name_id': 100379, 'name': 'RICCARDO'}, + { 'name_id': 100379, 'name': 'RICARDA'}, + { 'name_id': 100379, 'name': 'RICARDO'}, + { 'name_id': 100379, 'name': 'RICHANDA'}, + { 'name_id': 100379, 'name': 'RICHENDA'}, + { 'name_id': 100379, 'name': 'RITCHARD'}, + { 'name_id': 100380, 'name': 'ROBERT'}, + { 'name_id': 100380, 'name': 'BOB'}, + { 'name_id': 100380, 'name': 'ROB'}, + { 'name_id': 100380, 'name': 'RABBIE'}, + { 'name_id': 100380, 'name': 'ROBBIN'}, + { 'name_id': 100380, 'name': 'ROBERTA'}, + { 'name_id': 100380, 'name': 'ROBERTO'}, + { 'name_id': 100380, 'name': 'ROBERTSON'}, + { 'name_id': 100380, 'name': 'ROBIN'}, + { 'name_id': 100380, 'name': 'ROBINA'}, + { 'name_id': 100380, 'name': 'ROBINSON'}, + { 'name_id': 100380, 'name': 'ROBSON'}, + { 'name_id': 100380, 'name': 'ROBYN'}, + { 'name_id': 100381, 'name': 'ROCKLIN'}, + { 'name_id': 100381, 'name': 'ROC'}, + { 'name_id': 100381, 'name': 'ROCK'}, + { 'name_id': 100381, 'name': 'ROCKNEY'}, + { 'name_id': 100381, 'name': 'ROCKWELL'}, + { 'name_id': 100381, 'name': 'ROK'}, + { 'name_id': 100382, 'name': 'RODERICK'}, + { 'name_id': 100382, 'name': 'ROD'}, + { 'name_id': 100382, 'name': 'RODNEY'}, + { 'name_id': 100382, 'name': 'RODRICK'}, + { 'name_id': 100382, 'name': 'RORIE'}, + { 'name_id': 100382, 'name': 'RORY'}, + { 'name_id': 100383, 'name': 'ROGER'}, + { 'name_id': 100383, 'name': 'RODGER'}, + { 'name_id': 100384, 'name': 'ROLAND'}, + { 'name_id': 100384, 'name': 'RO'}, + { 'name_id': 100384, 'name': 'ROLLO'}, + { 'name_id': 100384, 'name': 'ROLYND'}, + { 'name_id': 100385, 'name': 'ROMAN'}, + { 'name_id': 100385, 'name': 'ROMA'}, + { 'name_id': 100386, 'name': 'RONALD'}, + { 'name_id': 100386, 'name': 'RANALD'}, + { 'name_id': 100386, 'name': 'RON'}, + { 'name_id': 100386, 'name': 'RONALDA'}, + { 'name_id': 100386, 'name': 'RONALDO'}, + { 'name_id': 100386, 'name': 'RONETTE'}, + { 'name_id': 100386, 'name': 'RONICA'}, + { 'name_id': 100386, 'name': 'RONNA'}, + { 'name_id': 100386, 'name': 'RONNIE'}, + { 'name_id': 100386, 'name': 'RONNY'}, + { 'name_id': 100386, 'name': 'VERON'}, + { 'name_id': 100386, 'name': 'VERONA'}, + { 'name_id': 100386, 'name': 'VERONICA'}, + { 'name_id': 100386, 'name': 'VERONIKA'}, + { 'name_id': 100386, 'name': 'VERONYKA'}, + { 'name_id': 100387, 'name': 'ROSALYN'}, + { 'name_id': 100387, 'name': 'ROS'}, + { 'name_id': 100387, 'name': 'ROSAL'}, + { 'name_id': 100387, 'name': 'ROSEL'}, + { 'name_id': 100387, 'name': 'ROZ'}, + { 'name_id': 100387, 'name': 'ROMI'}, + { 'name_id': 100387, 'name': 'ROMIE'}, + { 'name_id': 100387, 'name': 'ROMY'}, + { 'name_id': 100387, 'name': 'ROSALIND'}, + { 'name_id': 100387, 'name': 'ROSALINDA'}, + { 'name_id': 100387, 'name': 'ROSAMOND'}, + { 'name_id': 100387, 'name': 'ROSAMUND'}, + { 'name_id': 100387, 'name': 'ROSAY'}, + { 'name_id': 100387, 'name': 'ROSELIND'}, + { 'name_id': 100387, 'name': 'ROSELINE'}, + { 'name_id': 100387, 'name': 'ROSEMARY'}, + { 'name_id': 100387, 'name': 'ROSEN'}, + { 'name_id': 100387, 'name': 'ROSETTA'}, + { 'name_id': 100387, 'name': 'ROZENA'}, + { 'name_id': 100387, 'name': 'ROZINA'}, + { 'name_id': 100388, 'name': 'ROXANNE'}, + { 'name_id': 100388, 'name': 'ROXI'}, + { 'name_id': 100388, 'name': 'ROXY'}, + { 'name_id': 100389, 'name': 'RUDOLPH'}, + { 'name_id': 100389, 'name': 'RUD'}, + { 'name_id': 100389, 'name': 'ROLF'}, + { 'name_id': 100389, 'name': 'ROLFE'}, + { 'name_id': 100389, 'name': 'ROLPH'}, + { 'name_id': 100390, 'name': 'RUEBEN'}, + { 'name_id': 100390, 'name': 'RUB'}, + { 'name_id': 100390, 'name': 'REUB'}, + { 'name_id': 100391, 'name': 'RUSSEL'}, + { 'name_id': 100391, 'name': 'RUSS'}, + { 'name_id': 100392, 'name': 'RUTH'}, + { 'name_id': 100392, 'name': 'RUTH'}, + { 'name_id': 100393, 'name': 'RYAN'}, + { 'name_id': 100393, 'name': 'RUY'}, + { 'name_id': 100393, 'name': 'RY'}, + { 'name_id': 100393, 'name': 'RYE'}, + { 'name_id': 100393, 'name': 'RYON'}, + { 'name_id': 100394, 'name': 'SABINE'}, + { 'name_id': 100394, 'name': 'SAVINA'}, + { 'name_id': 100395, 'name': 'SABRINA'}, + { 'name_id': 100395, 'name': 'ZABRINA'}, + { 'name_id': 100396, 'name': 'SAED'}, + { 'name_id': 100396, 'name': 'SAEID'}, + { 'name_id': 100396, 'name': 'SAHID'}, + { 'name_id': 100396, 'name': 'SAIE'}, + { 'name_id': 100396, 'name': 'SAYED'}, + { 'name_id': 100396, 'name': 'SAYEED'}, + { 'name_id': 100397, 'name': 'SALINA'}, + { 'name_id': 100397, 'name': 'CELENA'}, + { 'name_id': 100397, 'name': 'CELENE'}, + { 'name_id': 100397, 'name': 'CELINA'}, + { 'name_id': 100397, 'name': 'CELINE'}, + { 'name_id': 100398, 'name': 'SAMUEL'}, + { 'name_id': 100398, 'name': 'SAM'}, + { 'name_id': 100398, 'name': 'SAMANTHA'}, + { 'name_id': 100398, 'name': 'SAMMI'}, + { 'name_id': 100398, 'name': 'SAMMIE'}, + { 'name_id': 100398, 'name': 'SAMMY'}, + { 'name_id': 100398, 'name': 'SAMPSON'}, + { 'name_id': 100398, 'name': 'SAMSON'}, + { 'name_id': 100398, 'name': 'SAMUELA'}, + { 'name_id': 100399, 'name': 'SANDRA'}, + { 'name_id': 100399, 'name': 'SANDI'}, + { 'name_id': 100399, 'name': 'SANDIE'}, + { 'name_id': 100399, 'name': 'SANDY'}, + { 'name_id': 100400, 'name': 'SAPHIRE'}, + { 'name_id': 100400, 'name': 'SAPPHIRA'}, + { 'name_id': 100400, 'name': 'SAPPHIRE'}, + { 'name_id': 100400, 'name': 'SAPPHYRE'}, + { 'name_id': 100401, 'name': 'SARAH'}, + { 'name_id': 100401, 'name': 'SAL'}, + { 'name_id': 100401, 'name': 'SADIE'}, + { 'name_id': 100401, 'name': 'SARAN'}, + { 'name_id': 100401, 'name': 'SARETTA'}, + { 'name_id': 100401, 'name': 'SARETTE'}, + { 'name_id': 100401, 'name': 'SARINA'}, + { 'name_id': 100401, 'name': 'SARITA'}, + { 'name_id': 100401, 'name': 'ZAHRA'}, + { 'name_id': 100401, 'name': 'ZARINA'}, + { 'name_id': 100401, 'name': 'ZARITA'}, + { 'name_id': 100402, 'name': 'SCIROCCO'}, + { 'name_id': 100402, 'name': 'SIROCCO'}, + { 'name_id': 100403, 'name': 'SEARLE'}, + { 'name_id': 100403, 'name': 'SEAR'}, + { 'name_id': 100404, 'name': 'SEBASTIAN'}, + { 'name_id': 100404, 'name': 'SEB'}, + { 'name_id': 100405, 'name': 'SELIG'}, + { 'name_id': 100405, 'name': 'ZELICK'}, + { 'name_id': 100405, 'name': 'ZELIG'}, + { 'name_id': 100406, 'name': 'SELWIN'}, + { 'name_id': 100406, 'name': 'SELWYN'}, + { 'name_id': 100407, 'name': 'SERAFINE'}, + { 'name_id': 100407, 'name': 'SERAPHIA'}, + { 'name_id': 100408, 'name': 'SEYMOUR'}, + { 'name_id': 100408, 'name': 'SEAMOUR'}, + { 'name_id': 100409, 'name': 'SHANELLE'}, + { 'name_id': 100409, 'name': 'CHANEL'}, + { 'name_id': 100410, 'name': 'SHANTELLE'}, + { 'name_id': 100410, 'name': 'CHANTAL'}, + { 'name_id': 100411, 'name': 'SHARON'}, + { 'name_id': 100411, 'name': 'SHER'}, + { 'name_id': 100411, 'name': 'SHARI'}, + { 'name_id': 100411, 'name': 'SHARYN'}, + { 'name_id': 100412, 'name': 'SHAUN'}, + { 'name_id': 100412, 'name': 'SHAUNIE'}, + { 'name_id': 100412, 'name': 'SHAWNEE'}, + { 'name_id': 100412, 'name': 'SHAYNE'}, + { 'name_id': 100413, 'name': 'SHAVONNE'}, + { 'name_id': 100413, 'name': 'CHAVONNE'}, + { 'name_id': 100413, 'name': 'SHEVAUN'}, + { 'name_id': 100413, 'name': 'SHEVON'}, + { 'name_id': 100413, 'name': 'SHEVONNE'}, + { 'name_id': 100413, 'name': 'SIOBAN'}, + { 'name_id': 100413, 'name': 'SIOBHAN'}, + { 'name_id': 100413, 'name': 'SIOBHANA'}, + { 'name_id': 100414, 'name': 'SHAY'}, + { 'name_id': 100414, 'name': 'SHAE'}, + { 'name_id': 100414, 'name': 'SHAINA'}, + { 'name_id': 100414, 'name': 'SHAYNA'}, + { 'name_id': 100415, 'name': 'SHEENA'}, + { 'name_id': 100415, 'name': 'SHEENAGH'}, + { 'name_id': 100416, 'name': 'SHEILA'}, + { 'name_id': 100416, 'name': 'SHAYLA'}, + { 'name_id': 100416, 'name': 'SHEELAGH'}, + { 'name_id': 100416, 'name': 'SHEILAGH'}, + { 'name_id': 100416, 'name': 'SHELAGH'}, + { 'name_id': 100416, 'name': 'SHEYLA'}, + { 'name_id': 100417, 'name': 'SHELLY'}, + { 'name_id': 100417, 'name': 'SHELLI'}, + { 'name_id': 100418, 'name': 'SHERMAN'}, + { 'name_id': 100418, 'name': 'SHERM'}, + { 'name_id': 100419, 'name': 'SHERWIN'}, + { 'name_id': 100419, 'name': 'SHERWYN'}, + { 'name_id': 100420, 'name': 'SHIRLEEN'}, + { 'name_id': 100420, 'name': 'SHERL'}, + { 'name_id': 100420, 'name': 'SHIRL'}, + { 'name_id': 100420, 'name': 'SHIREEN'}, + { 'name_id': 100420, 'name': 'SHIRENE'}, + { 'name_id': 100420, 'name': 'SHIRIN'}, + { 'name_id': 100421, 'name': 'SHUNA'}, + { 'name_id': 100421, 'name': 'SHULA'}, + { 'name_id': 100421, 'name': 'SHULIE'}, + { 'name_id': 100421, 'name': 'SHUNIE'}, + { 'name_id': 100421, 'name': 'SHUNG'}, + { 'name_id': 100422, 'name': 'SIDNEY'}, + { 'name_id': 100422, 'name': 'SID'}, + { 'name_id': 100422, 'name': 'SIDNE'}, + { 'name_id': 100422, 'name': 'SYD'}, + { 'name_id': 100422, 'name': 'SYDNEY'}, + { 'name_id': 100423, 'name': 'SIGMUND'}, + { 'name_id': 100423, 'name': 'SIG'}, + { 'name_id': 100423, 'name': 'ZIG'}, + { 'name_id': 100423, 'name': 'SIGBERT'}, + { 'name_id': 100423, 'name': 'SIGFREDO'}, + { 'name_id': 100423, 'name': 'SIGFRIED'}, + { 'name_id': 100423, 'name': 'SIGNE'}, + { 'name_id': 100423, 'name': 'SIGRID'}, + { 'name_id': 100423, 'name': 'SIGRUN'}, + { 'name_id': 100423, 'name': 'SIGUART'}, + { 'name_id': 100423, 'name': 'SIGUR'}, + { 'name_id': 100423, 'name': 'SIGURD'}, + { 'name_id': 100423, 'name': 'SIGVALT'}, + { 'name_id': 100423, 'name': 'SIGVART'}, + { 'name_id': 100424, 'name': 'SILVAN'}, + { 'name_id': 100424, 'name': 'SILV'}, + { 'name_id': 100424, 'name': 'SYLV'}, + { 'name_id': 100424, 'name': 'SILVEO'}, + { 'name_id': 100424, 'name': 'SILVER'}, + { 'name_id': 100424, 'name': 'SILVERIO'}, + { 'name_id': 100424, 'name': 'SILVIO'}, + { 'name_id': 100424, 'name': 'SYLVAIN'}, + { 'name_id': 100424, 'name': 'SYLVAN'}, + { 'name_id': 100424, 'name': 'SYLVETTE'}, + { 'name_id': 100424, 'name': 'SYLVIO'}, + { 'name_id': 100424, 'name': 'SYLVONIA'}, + { 'name_id': 100424, 'name': 'XYLLA'}, + { 'name_id': 100424, 'name': 'XYLVIA'}, + { 'name_id': 100425, 'name': 'SILVER'}, + { 'name_id': 100425, 'name': 'SYLVER'}, + { 'name_id': 100426, 'name': 'SILVESTER'}, + { 'name_id': 100426, 'name': 'SLY'}, + { 'name_id': 100426, 'name': 'SYLVESTER'}, + { 'name_id': 100427, 'name': 'SIMON'}, + { 'name_id': 100427, 'name': 'SI'}, + { 'name_id': 100427, 'name': 'SILAS'}, + { 'name_id': 100427, 'name': 'SIM'}, + { 'name_id': 100427, 'name': 'SYMON'}, + { 'name_id': 100428, 'name': 'SKIPPER'}, + { 'name_id': 100428, 'name': 'SKIP'}, + { 'name_id': 100429, 'name': 'SMITH'}, + { 'name_id': 100429, 'name': 'SMYTH'}, + { 'name_id': 100429, 'name': 'SMYTHE'}, + { 'name_id': 100430, 'name': 'SOLACE'}, + { 'name_id': 100430, 'name': 'SOLAS'}, + { 'name_id': 100431, 'name': 'SOLAIRE'}, + { 'name_id': 100431, 'name': 'SOLAYRE'}, + { 'name_id': 100432, 'name': 'SOLOMON'}, + { 'name_id': 100432, 'name': 'SOL'}, + { 'name_id': 100432, 'name': 'ZOL'}, + { 'name_id': 100433, 'name': 'SONYA'}, + { 'name_id': 100433, 'name': 'SONIA'}, + { 'name_id': 100433, 'name': 'SONJA'}, + { 'name_id': 100433, 'name': 'ZONIA'}, + { 'name_id': 100434, 'name': 'SORSHA'}, + { 'name_id': 100434, 'name': 'SORSCHA'}, + { 'name_id': 100435, 'name': 'SPENCER'}, + { 'name_id': 100435, 'name': 'SPENCE'}, + { 'name_id': 100436, 'name': 'SPRINGFIELD'}, + { 'name_id': 100436, 'name': 'SPRING'}, + { 'name_id': 100436, 'name': 'SPRYNG'}, + { 'name_id': 100437, 'name': 'STAFANIE'}, + { 'name_id': 100437, 'name': 'STEPHANIE'}, + { 'name_id': 100437, 'name': 'STEPHANY'}, + { 'name_id': 100442, 'name': 'STEPHEN'}, + { 'name_id': 100437, 'name': 'STEPHENA'}, + { 'name_id': 100437, 'name': 'STEPHENE'}, + { 'name_id': 100437, 'name': 'STEPHENS'}, + { 'name_id': 100438, 'name': 'STANLEY'}, + { 'name_id': 100438, 'name': 'STAN'}, + { 'name_id': 100438, 'name': 'STANDFORD'}, + { 'name_id': 100438, 'name': 'STANDISH'}, + { 'name_id': 100438, 'name': 'STANFIELD'}, + { 'name_id': 100438, 'name': 'STANFORD'}, + { 'name_id': 100438, 'name': 'STANHOPE'}, + { 'name_id': 100438, 'name': 'STANILY'}, + { 'name_id': 100438, 'name': 'STANISLAS'}, + { 'name_id': 100438, 'name': 'STANISLAU'}, + { 'name_id': 100438, 'name': 'STANISLAW'}, + { 'name_id': 100438, 'name': 'STANNARD'}, + { 'name_id': 100438, 'name': 'STANTON'}, + { 'name_id': 100439, 'name': 'STARCHILD'}, + { 'name_id': 100439, 'name': 'STAR'}, + { 'name_id': 100439, 'name': 'STARR'}, + { 'name_id': 100439, 'name': 'STARLIGHT'}, + { 'name_id': 100439, 'name': 'STARLYTE'}, + { 'name_id': 100440, 'name': 'STEFANIE'}, + { 'name_id': 100440, 'name': 'STEF'}, + { 'name_id': 100440, 'name': 'STEFAN'}, + { 'name_id': 100440, 'name': 'STEFANEE'}, + { 'name_id': 100440, 'name': 'STEFANELLE'}, + { 'name_id': 100440, 'name': 'STEFANI'}, + { 'name_id': 100440, 'name': 'STEFANIUK'}, + { 'name_id': 100440, 'name': 'STEFANY'}, + { 'name_id': 100440, 'name': 'STEFF'}, + { 'name_id': 100440, 'name': 'STEFFI'}, + { 'name_id': 100440, 'name': 'STEFFIE'}, + { 'name_id': 100440, 'name': 'STEFFY'}, + { 'name_id': 100440, 'name': 'STEFI'}, + { 'name_id': 100440, 'name': 'STEFY'}, + { 'name_id': 100440, 'name': 'STEPHAN'}, + { 'name_id': 100441, 'name': 'STEJOHN'}, + { 'name_id': 100441, 'name': 'SINJON'}, + { 'name_id': 100441, 'name': 'SINJUN'}, + { 'name_id': 100442, 'name': 'STEVEN'}, + { 'name_id': 100442, 'name': 'STEVE'}, + { 'name_id': 100442, 'name': 'STEVENS'}, + { 'name_id': 100442, 'name': 'STEVIE'}, + { 'name_id': 100443, 'name': 'STRAUSS'}, + { 'name_id': 100443, 'name': 'STRAUSE'}, + { 'name_id': 100444, 'name': 'STUART'}, + { 'name_id': 100444, 'name': 'STEW'}, + { 'name_id': 100444, 'name': 'STU'}, + { 'name_id': 100445, 'name': 'SUDIE'}, + { 'name_id': 100445, 'name': 'SUDI'}, + { 'name_id': 100446, 'name': 'SUNSHINE'}, + { 'name_id': 100446, 'name': 'SON'}, + { 'name_id': 100446, 'name': 'SUN'}, + { 'name_id': 100447, 'name': 'SUSAN'}, + { 'name_id': 100447, 'name': 'SUK'}, + { 'name_id': 100447, 'name': 'SUS'}, + { 'name_id': 100447, 'name': 'SUZ'}, + { 'name_id': 100447, 'name': 'SOOZI'}, + { 'name_id': 100447, 'name': 'SUE'}, + { 'name_id': 100447, 'name': 'SUSETTA'}, + { 'name_id': 100447, 'name': 'SUSETTE'}, + { 'name_id': 100447, 'name': 'SUZETTA'}, + { 'name_id': 100447, 'name': 'SUZETTE'}, + { 'name_id': 100448, 'name': 'SYKIE'}, + { 'name_id': 100448, 'name': 'PSYCHE'}, + { 'name_id': 100449, 'name': 'TABATHA'}, + { 'name_id': 100449, 'name': 'TAB'}, + { 'name_id': 100450, 'name': 'TACEY'}, + { 'name_id': 100450, 'name': 'TACE'}, + { 'name_id': 100450, 'name': 'TACITA'}, + { 'name_id': 100451, 'name': 'TALICIA'}, + { 'name_id': 100451, 'name': 'TALISHA'}, + { 'name_id': 100451, 'name': 'TALITHA'}, + { 'name_id': 100452, 'name': 'TAMATHA'}, + { 'name_id': 100452, 'name': 'TAMASHA'}, + { 'name_id': 100453, 'name': 'TAMSIN'}, + { 'name_id': 100453, 'name': 'TAM'}, + { 'name_id': 100453, 'name': 'TAMAR'}, + { 'name_id': 100453, 'name': 'TAMARA'}, + { 'name_id': 100453, 'name': 'TAMOR'}, + { 'name_id': 100453, 'name': 'TAMORA'}, + { 'name_id': 100453, 'name': 'THAMAR'}, + { 'name_id': 100454, 'name': 'TANGERINE'}, + { 'name_id': 100454, 'name': 'TANGERYNE'}, + { 'name_id': 100455, 'name': 'TANIS'}, + { 'name_id': 100455, 'name': 'TANYS'}, + { 'name_id': 100456, 'name': 'TANITH'}, + { 'name_id': 100456, 'name': 'TANITA'}, + { 'name_id': 100457, 'name': 'TARIN'}, + { 'name_id': 100457, 'name': 'TARNIA'}, + { 'name_id': 100457, 'name': 'TARYNA'}, + { 'name_id': 100458, 'name': 'TATANYA'}, + { 'name_id': 100458, 'name': 'TATIANA'}, + { 'name_id': 100458, 'name': 'TATIANIA'}, + { 'name_id': 100458, 'name': 'TATTANIA'}, + { 'name_id': 100458, 'name': 'TITANIA'}, + { 'name_id': 100459, 'name': 'TATUM'}, + { 'name_id': 100459, 'name': 'TATE'}, + { 'name_id': 100460, 'name': 'TAVITA'}, + { 'name_id': 100460, 'name': 'TAV'}, + { 'name_id': 100460, 'name': 'TAVIS'}, + { 'name_id': 100461, 'name': 'TAYLOR'}, + { 'name_id': 100461, 'name': 'TAY'}, + { 'name_id': 100462, 'name': 'TENNYSON'}, + { 'name_id': 100462, 'name': 'TENNY'}, + { 'name_id': 100463, 'name': 'TERRENCE'}, + { 'name_id': 100463, 'name': 'TERALL'}, + { 'name_id': 100463, 'name': 'TERI'}, + { 'name_id': 100463, 'name': 'TERRI'}, + { 'name_id': 100463, 'name': 'TERRIE'}, + { 'name_id': 100463, 'name': 'TERRIL'}, + { 'name_id': 100463, 'name': 'TERRY'}, + { 'name_id': 100463, 'name': 'TERRYL'}, + { 'name_id': 100463, 'name': 'TERY'}, + { 'name_id': 100463, 'name': 'THERENCE'}, + { 'name_id': 100463, 'name': 'THERESA'}, + { 'name_id': 100463, 'name': 'THERI'}, + { 'name_id': 100464, 'name': 'THADDEUS'}, + { 'name_id': 100464, 'name': 'TAD'}, + { 'name_id': 100464, 'name': 'THAD'}, + { 'name_id': 100465, 'name': 'THANI'}, + { 'name_id': 100465, 'name': 'THANA'}, + { 'name_id': 100465, 'name': 'THANIA'}, + { 'name_id': 100466, 'name': 'THECLA'}, + { 'name_id': 100466, 'name': 'THEKLA'}, + { 'name_id': 100467, 'name': 'THERESA'}, + { 'name_id': 100467, 'name': 'TERESA'}, + { 'name_id': 100467, 'name': 'TERESITA'}, + { 'name_id': 100467, 'name': 'TERETTA'}, + { 'name_id': 100467, 'name': 'TEREZA'}, + { 'name_id': 100467, 'name': 'TESHA'}, + { 'name_id': 100467, 'name': 'TESS'}, + { 'name_id': 100467, 'name': 'TESSA'}, + { 'name_id': 100467, 'name': 'TESSIE'}, + { 'name_id': 100467, 'name': 'THERESSA'}, + { 'name_id': 100467, 'name': 'TRACEY'}, + { 'name_id': 100467, 'name': 'TRACI'}, + { 'name_id': 100467, 'name': 'TRACIE'}, + { 'name_id': 100467, 'name': 'TRACY'}, + { 'name_id': 100467, 'name': 'TRESA'}, + { 'name_id': 100467, 'name': 'TREZA'}, + { 'name_id': 100468, 'name': 'THIRZA'}, + { 'name_id': 100468, 'name': 'THIRSA'}, + { 'name_id': 100468, 'name': 'THYRZA'}, + { 'name_id': 100468, 'name': 'TIRZAH'}, + { 'name_id': 100469, 'name': 'THOMAS'}, + { 'name_id': 100469, 'name': 'TOM'}, + { 'name_id': 100469, 'name': 'THOMASIN'}, + { 'name_id': 100469, 'name': 'THOMASINA'}, + { 'name_id': 100469, 'name': 'THOMASINE'}, + { 'name_id': 100469, 'name': 'THOMASON'}, + { 'name_id': 100469, 'name': 'THOMAZIN'}, + { 'name_id': 100469, 'name': 'THOMPSON'}, + { 'name_id': 100469, 'name': 'THOS'}, + { 'name_id': 100469, 'name': 'TOMMINA'}, + { 'name_id': 100469, 'name': 'TOMOS'}, + { 'name_id': 100470, 'name': 'THORSTON'}, + { 'name_id': 100470, 'name': 'THOR'}, + { 'name_id': 100470, 'name': 'THORA'}, + { 'name_id': 100470, 'name': 'THOREN'}, + { 'name_id': 100470, 'name': 'THORIN'}, + { 'name_id': 100470, 'name': 'THORNE'}, + { 'name_id': 100470, 'name': 'THORUN'}, + { 'name_id': 100471, 'name': 'TIMOTHY'}, + { 'name_id': 100471, 'name': 'TIM'}, + { 'name_id': 100471, 'name': 'TIMMITH'}, + { 'name_id': 100471, 'name': 'TIMMONS'}, + { 'name_id': 100471, 'name': 'TIMON'}, + { 'name_id': 100471, 'name': 'TIMONTHY'}, + { 'name_id': 100471, 'name': 'TIMORA'}, + { 'name_id': 100471, 'name': 'TYM'}, + { 'name_id': 100471, 'name': 'TYMON'}, + { 'name_id': 100472, 'name': 'TIVON'}, + { 'name_id': 100472, 'name': 'TIBON'}, + { 'name_id': 100473, 'name': 'TORRANCE'}, + { 'name_id': 100473, 'name': 'TORAN'}, + { 'name_id': 100473, 'name': 'TORN'}, + { 'name_id': 100474, 'name': 'TRAVIS'}, + { 'name_id': 100474, 'name': 'TRAV'}, + { 'name_id': 100474, 'name': 'TRAVERS'}, + { 'name_id': 100475, 'name': 'TRENTON'}, + { 'name_id': 100475, 'name': 'TRENT'}, + { 'name_id': 100476, 'name': 'TREVOR'}, + { 'name_id': 100476, 'name': 'TREF'}, + { 'name_id': 100476, 'name': 'TREFOR'}, + { 'name_id': 100476, 'name': 'TREV'}, + { 'name_id': 100477, 'name': 'TRINITY'}, + { 'name_id': 100477, 'name': 'TRINITA'}, + { 'name_id': 100478, 'name': 'TRISTAN'}, + { 'name_id': 100478, 'name': 'TRIS'}, + { 'name_id': 100478, 'name': 'TRISTA'}, + { 'name_id': 100478, 'name': 'TRISTO'}, + { 'name_id': 100478, 'name': 'TRYSTAN'}, + { 'name_id': 100479, 'name': 'TULLY'}, + { 'name_id': 100479, 'name': 'TULLIS'}, + { 'name_id': 100480, 'name': 'TYRONE'}, + { 'name_id': 100480, 'name': 'TY'}, + { 'name_id': 100480, 'name': 'TYLER'}, + { 'name_id': 100480, 'name': 'TYSON'}, + { 'name_id': 100481, 'name': 'ULRICH'}, + { 'name_id': 100481, 'name': 'UFFA'}, + { 'name_id': 100481, 'name': 'ULFA'}, + { 'name_id': 100482, 'name': 'UNA'}, + { 'name_id': 100482, 'name': 'OONA'}, + { 'name_id': 100482, 'name': 'OONAGH'}, + { 'name_id': 100483, 'name': 'UNDINE'}, + { 'name_id': 100483, 'name': 'ONDINE'}, + { 'name_id': 100484, 'name': 'UNITY'}, + { 'name_id': 100484, 'name': 'UNITA'}, + { 'name_id': 100485, 'name': 'URSULA'}, + { 'name_id': 100485, 'name': 'ULI'}, + { 'name_id': 100485, 'name': 'URSA'}, + { 'name_id': 100486, 'name': 'VALERIE'}, + { 'name_id': 100486, 'name': 'VAL'}, + { 'name_id': 100486, 'name': 'VALENTIN'}, + { 'name_id': 100486, 'name': 'VALENTINA'}, + { 'name_id': 100486, 'name': 'VALENTINE'}, + { 'name_id': 100486, 'name': 'VALENTINO'}, + { 'name_id': 100486, 'name': 'VALERIA'}, + { 'name_id': 100486, 'name': 'VALERIAN'}, + { 'name_id': 100487, 'name': 'VANDA'}, + { 'name_id': 100487, 'name': 'VONA'}, + { 'name_id': 100487, 'name': 'WANDA'}, + { 'name_id': 100487, 'name': 'WENDA'}, + { 'name_id': 100487, 'name': 'ZWANDA'}, + { 'name_id': 100488, 'name': 'VANESSA'}, + { 'name_id': 100488, 'name': 'VANECIA'}, + { 'name_id': 100488, 'name': 'VANETTA'}, + { 'name_id': 100488, 'name': 'VANETTE'}, + { 'name_id': 100488, 'name': 'VANNETTA'}, + { 'name_id': 100488, 'name': 'VENESSA'}, + { 'name_id': 100489, 'name': 'VASSILY'}, + { 'name_id': 100489, 'name': 'VASHTI'}, + { 'name_id': 100489, 'name': 'VASSY'}, + { 'name_id': 100490, 'name': 'VEIGH'}, + { 'name_id': 100490, 'name': 'VAY'}, + { 'name_id': 100491, 'name': 'VERENA'}, + { 'name_id': 100491, 'name': 'VERITA'}, + { 'name_id': 100491, 'name': 'VERITY'}, + { 'name_id': 100492, 'name': 'VERNETTA'}, + { 'name_id': 100492, 'name': 'VERNA'}, + { 'name_id': 100493, 'name': 'VICTOR'}, + { 'name_id': 100493, 'name': 'VIC'}, + { 'name_id': 100493, 'name': 'VICK'}, + { 'name_id': 100493, 'name': 'VIK'}, + { 'name_id': 100493, 'name': 'VICTORINE'}, + { 'name_id': 100493, 'name': 'WIKTOR'}, + { 'name_id': 100494, 'name': 'VILETTE'}, + { 'name_id': 100494, 'name': 'VILA'}, + { 'name_id': 100495, 'name': 'VIOLET'}, + { 'name_id': 100495, 'name': 'VI'}, + { 'name_id': 100495, 'name': 'VIOLA'}, + { 'name_id': 100496, 'name': 'VIVIAN'}, + { 'name_id': 100496, 'name': 'OCTAVIAN'}, + { 'name_id': 100496, 'name': 'VIAN'}, + { 'name_id': 100496, 'name': 'VIV'}, + { 'name_id': 100496, 'name': 'VIVEY'}, + { 'name_id': 100496, 'name': 'VIVIE'}, + { 'name_id': 100496, 'name': 'VIVY'}, + { 'name_id': 100496, 'name': 'VIVYAN'}, + { 'name_id': 100496, 'name': 'VYVEY'}, + { 'name_id': 100496, 'name': 'VYVIAN'}, + { 'name_id': 100496, 'name': 'VYVIE'}, + { 'name_id': 100496, 'name': 'VYVYAN'}, + { 'name_id': 100497, 'name': 'WALLACE'}, + { 'name_id': 100497, 'name': 'WAL'}, + { 'name_id': 100497, 'name': 'WALLIS'}, + { 'name_id': 100497, 'name': 'WALT'}, + { 'name_id': 100497, 'name': 'WALTER'}, + { 'name_id': 100497, 'name': 'WAT'}, + { 'name_id': 100497, 'name': 'WATS'}, + { 'name_id': 100498, 'name': 'WAYLAND'}, + { 'name_id': 100498, 'name': 'WAYLON'}, + { 'name_id': 100499, 'name': 'WENDY'}, + { 'name_id': 100499, 'name': 'WEND'}, + { 'name_id': 100499, 'name': 'WENDYL'}, + { 'name_id': 100500, 'name': 'WESLEY'}, + { 'name_id': 100500, 'name': 'WES'}, + { 'name_id': 100500, 'name': 'WESTLEIGH'}, + { 'name_id': 100501, 'name': 'WHITNEY'}, + { 'name_id': 100501, 'name': 'WHEATLEY'}, + { 'name_id': 100501, 'name': 'WHETLEY'}, + { 'name_id': 100501, 'name': 'WHIT'}, + { 'name_id': 100502, 'name': 'WILBER'}, + { 'name_id': 100502, 'name': 'WILBY'}, + { 'name_id': 100503, 'name': 'WILFRED'}, + { 'name_id': 100503, 'name': 'WILF'}, + { 'name_id': 100503, 'name': 'WILFED'}, + { 'name_id': 100503, 'name': 'WILFOD'}, + { 'name_id': 100503, 'name': 'WILFORD'}, + { 'name_id': 100503, 'name': 'WILFRYD'}, + { 'name_id': 100504, 'name': 'WILHELMINA'}, + { 'name_id': 100504, 'name': 'HILMA'}, + { 'name_id': 100504, 'name': 'MINETTE'}, + { 'name_id': 100504, 'name': 'MINIE'}, + { 'name_id': 100504, 'name': 'MINNETTE'}, + { 'name_id': 100504, 'name': 'MINNIE'}, + { 'name_id': 100504, 'name': 'VELMA'}, + { 'name_id': 100504, 'name': 'VILHMA'}, + { 'name_id': 100504, 'name': 'VILMA'}, + { 'name_id': 100504, 'name': 'WILMA'}, + { 'name_id': 100505, 'name': 'WILLIAM'}, + { 'name_id': 100505, 'name': 'BIL'}, + { 'name_id': 100505, 'name': 'WIL'}, + { 'name_id': 100505, 'name': 'WILHELM'}, + { 'name_id': 100505, 'name': 'WILHELMAS'}, + { 'name_id': 100505, 'name': 'WILHELMUS'}, + { 'name_id': 100505, 'name': 'WILLHELMET'}, + { 'name_id': 100505, 'name': 'WILLHELMUT'}, + { 'name_id': 100505, 'name': 'WM'}, + { 'name_id': 100506, 'name': 'WINNIFRED'}, + { 'name_id': 100506, 'name': 'ERWIN'}, + { 'name_id': 100506, 'name': 'FREDA'}, + { 'name_id': 100506, 'name': 'FREIDA'}, + { 'name_id': 100506, 'name': 'FRIEDA'}, + { 'name_id': 100506, 'name': 'FRIDA'}, + { 'name_id': 100506, 'name': 'WIM'}, + { 'name_id': 100506, 'name': 'WIN'}, + { 'name_id': 100506, 'name': 'WINNIE'}, + { 'name_id': 100507, 'name': 'WOODROW'}, + { 'name_id': 100507, 'name': 'ELWOOD'}, + { 'name_id': 100507, 'name': 'WOODY'}, + { 'name_id': 100508, 'name': 'WYMOND'}, + { 'name_id': 100508, 'name': 'WYMAN'}, + { 'name_id': 100509, 'name': 'WYNFORD'}, + { 'name_id': 100509, 'name': 'WENFORD'}, + { 'name_id': 100510, 'name': 'XANTHE'}, + { 'name_id': 100510, 'name': 'XAN'}, + { 'name_id': 100511, 'name': 'XAVIER'}, + { 'name_id': 100511, 'name': 'ZAVIER'}, + { 'name_id': 100511, 'name': 'ZAVIERA'}, + { 'name_id': 100512, 'name': 'YASMINE'}, + { 'name_id': 100512, 'name': 'JASMIN'}, + { 'name_id': 100512, 'name': 'JASMINE'}, + { 'name_id': 100512, 'name': 'JASSAMINE'}, + { 'name_id': 100512, 'name': 'JASSAMYN'}, + { 'name_id': 100513, 'name': 'YURI'}, + { 'name_id': 100513, 'name': 'URIAH'}, + { 'name_id': 100514, 'name': 'YVETTE'}, + { 'name_id': 100514, 'name': 'EVETTE'}, + { 'name_id': 100514, 'name': 'IVETTE'}, + { 'name_id': 100514, 'name': 'VETTE'}, + { 'name_id': 100515, 'name': 'YVONNE'}, + { 'name_id': 100515, 'name': 'EVA'}, + { 'name_id': 100515, 'name': 'EVE'}, + { 'name_id': 100515, 'name': 'EVIE'}, + { 'name_id': 100515, 'name': 'EVY'}, + { 'name_id': 100515, 'name': 'EVELYN'}, + { 'name_id': 100515, 'name': 'EVON'}, + { 'name_id': 100515, 'name': 'EVONNE'}, + { 'name_id': 100515, 'name': 'IVANA'}, + { 'name_id': 100515, 'name': 'IVONA'}, + { 'name_id': 100515, 'name': 'IVONE'}, + { 'name_id': 100515, 'name': 'IVONI'}, + { 'name_id': 100515, 'name': 'IVONNE'}, + { 'name_id': 100515, 'name': 'LAVONNE'}, + { 'name_id': 100515, 'name': 'VONNE'}, + { 'name_id': 100515, 'name': 'VONNIE'}, + { 'name_id': 100515, 'name': 'VONNY'}, + { 'name_id': 100516, 'name': 'ZACHARY'}, + { 'name_id': 100516, 'name': 'ZAC'}, + { 'name_id': 100516, 'name': 'ZACCHAEUS'}, + { 'name_id': 100516, 'name': 'ZAK'}, + { 'name_id': 100516, 'name': 'ZEEK'}, + { 'name_id': 100516, 'name': 'ZEKE'}, + { 'name_id': 100517, 'name': 'ZADOK'}, + { 'name_id': 100517, 'name': 'ZADOC'}, + { 'name_id': 100518, 'name': 'ZEBEDIAH'}, + { 'name_id': 100518, 'name': 'ZEB'}, + { 'name_id': 100519, 'name': 'ZELDA'}, + { 'name_id': 100519, 'name': 'GRISELDA'}, + { 'name_id': 100520, 'name': 'ZELINA'}, + { 'name_id': 100520, 'name': 'ZELIA'}, + { 'name_id': 100520, 'name': 'ZELLA'}, + { 'name_id': 100520, 'name': 'ZELLY'}, + { 'name_id': 100520, 'name': 'ZERLINA'}, + { 'name_id': 100521, 'name': 'ZELINDA'}, + { 'name_id': 100521, 'name': 'ZERLINDA'}, + { 'name_id': 100522, 'name': 'ZEMIRA'}, + { 'name_id': 100522, 'name': 'ZEMA'}, + { 'name_id': 100523, 'name': 'ZENA'}, + { 'name_id': 100523, 'name': 'ZENAIDE'}, + { 'name_id': 100524, 'name': 'ZETTA'}, + { 'name_id': 100524, 'name': 'ZETAN'}, + { 'name_id': 100525, 'name': 'ZION'}, + { 'name_id': 100525, 'name': 'ZEONA'}, + { 'name_id': 100525, 'name': 'ZIO'}, + { 'name_id': 100526, 'name': 'ZYLA'}, + { 'name_id': 100526, 'name': 'ZILPAH'}, + { 'name_id': 100526, 'name': 'ZYLPHA'}, + { 'name_id': 100380, 'name': 'BOBBY'}, + { 'name_id': 100380, 'name': 'BOBBIE'}, + { 'name_id': 100380, 'name': 'ROBBIE'}, + { 'name_id': 100316, 'name': 'MIKE'}, + { 'name_id': 100505, 'name': 'BILL'}, + { 'name_id': 100505, 'name': 'WILL'}, + { 'name_id': 100505, 'name': 'BILLIE'}, + { 'name_id': 100505, 'name': 'BILLY'}, + { 'name_id': 100505, 'name': 'WILLIE'}, + { 'name_id': 100505, 'name': 'WILLY'}, + { 'name_id': 100143, 'name': 'BETTY'}, + { 'name_id': 100143, 'name': 'LISA'}, + { 'name_id': 100379, 'name': 'ERIC'}, + { 'name_id': 100379, 'name': 'RICHIE'}, + { 'name_id': 100379, 'name': 'RITCHIE'}, + { 'name_id': 100379, 'name': 'RICKIE'}, + { 'name_id': 100379, 'name': 'RICKY'}, + { 'name_id': 100143, 'name': 'ELISABETH'}, + { 'name_id': 100527, 'name': 'CONTRACTOR'}, + { 'name_id': 100527, 'name': 'CONSTRUCTION'} + ] + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + public_searchkey_vehicle = PGFunction( + schema="public", + signature="searchkey_vehicle(serial_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(25);\n v_vin VARCHAR(25);\n v_digits VARCHAR(25);\n v_length_digits integer;\n v_last_digit_index integer;\n BEGIN\n v_search_key := UPPER(REGEXP_REPLACE(serial_number,'[^0-9A-Za-z]','','gi'));\n v_digits := regexp_replace(v_search_key, '[^0-9]', '', 'g');\n v_length_digits := length(v_digits);\n v_vin := '';\n IF (v_length_digits > 0) THEN\n v_last_digit_index := length(v_search_key) - length(regexp_replace(v_search_key, '.*' || RIGHT(v_digits, 1),'', 'g'));\n ELSE\n v_last_digit_index := 0;\n END IF;\n \n SELECT \n CASE \n WHEN v_length_digits = 0 THEN '000000'\n WHEN v_length_digits = 1 THEN LPAD(v_digits, 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN '0' AND '9' THEN LPAD(RIGHT(v_search_key, LEAST(LENGTH(v_search_key), 6)), 6, '0')\n WHEN RIGHT(v_search_key, 1) IN ('B','C','G','H','I','L','S','O','Y','Z') AND \n LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' THEN LPAD(RIGHT(v_search_key, 6), 6, '0')\n WHEN RIGHT(v_search_key, 1) NOT IN ('B','C','G','H','I','L','S','O','Y','Z') AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN '0' AND '9' AND\n LENGTH(v_search_key) > 6 THEN LEFT(RIGHT(v_search_key, 7), 6)\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) < 6 THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' AND\n v_last_digit_index BETWEEN 1 AND 5\n THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) > 6\n -- This does not appear to always work correctly.\n THEN LPAD(SUBSTR(v_search_key, (v_last_digit_index - 5), 5), 6, '0')\n WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND \n LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND\n LENGTH(v_search_key) > 6\n -- This does not appear to always work correctly.\n THEN SUBSTR(v_search_key, (v_last_digit_index - 5), 6)\n END\n INTO v_vin;\n\n IF (LENGTH(v_vin) > 0) THEN\n v_search_key := v_vin;\n END IF;\n IF (LENGTH(v_search_key) > 6) THEN\n v_search_key := RIGHT(v_search_key, 6);\n END IF;\n\n v_search_key := REGEXP_REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(\n REPLACE(v_search_key,'I','1'),\n 'L','1'),\n 'Z','2'),\n 'H','4'),\n 'Y','4'),\n 'S','5'),\n 'C','6'),\n 'G','6'),\n 'B','8'),\n 'O','0'),\n '[A-Za-z]','0'); \n\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_vehicle) + + public_searchkey_mhr = PGFunction( + schema="public", + signature="searchkey_mhr(mhr_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(6);\n BEGIN\n v_search_key := TRIM(REGEXP_REPLACE(mhr_number,'[^0-9A-Za-z]','','gi'));\n v_search_key := LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','0'),6,'0');\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_mhr) + + public_searchkey_last_name = PGFunction( + schema="public", + signature="searchkey_last_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(60);\n BEGIN\n -- Remove prefixes\n v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi');\n -- Remove suffixes\n v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi');\n v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi');\n -- Remove internal extra space characters\n v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g'));\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_last_name) + + public_searchkey_first_name = PGFunction( + schema="public", + signature="searchkey_first_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(92);\n BEGIN\n -- Remove prefixes\n v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi');\n -- Remove suffixes\n v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi');\n v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi');\n -- Remove internal extra space characters\n v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g'));\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_first_name) + + public_searchkey_business_name = PGFunction( + schema="public", + signature="searchkey_business_name(actual_name IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(150);\n BEGIN\n v_search_key :=\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(\n REGEXP_REPLACE(actual_name,'^0000|^000|^00|^0|^THE | THE |\\([^()]*\\)',''),\n 'CORPORATION|CORP|COMPANY|CO\\.|LTD|INCORPORATED|INC$|INC.|INCORPOREE|LIMITED|LIMITEE|LTEE|LTD|ASSOCIATION$|ASSOC$|ASSN$|NON PERSONAL LIABILITY$|UNLIMITED LIABILITY COMPANY|N P L$|NPL$|PARTNERSHIP|SOCIETY$|SOC$',''),\n 'BRITISH COLUMBIA|BRITISHCOLUMBIA','BC'),\n '&','AND'),\n '#','NUMBER'),\n '1','ONE'),\n '2','TWO'),\n '3','THREE'),\n '4','FOUR'),\n '5','FIVE'),\n '6','SIX'),\n '7','SEVEN'),\n '8','EIGHT'),\n '9','NINE'),\n '0','ZERO'),\n 'TEN','ONEZERO'),\n 'TWENTY','TWOZERO'),\n 'THIRTY','THREEERO'),\n 'FORTY','FOURZERO'),\n 'FOURTY','FOURZERO'),\n 'FIFTY','FIVEZERO'),\n 'SIXTY','SIXZERO'),\n 'SEVENTY','SEVENZERO'),\n 'EIGHTY','EIGHTZERO'),\n 'NINETY','NINEZERO'),\n '[^0-9A-Za-z]','','gi');\n RETURN UPPER(v_search_key);\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_business_name) + + public_searchkey_aircraft = PGFunction( + schema="public", + signature="searchkey_aircraft(aircraft_number IN VARCHAR)", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n DECLARE\n v_search_key VARCHAR(25);\n BEGIN\n v_search_key := TRIM(REGEXP_REPLACE(aircraft_number,'\\s|-','','gi'));\n IF (LENGTH(v_search_key) > 6) THEN\n v_search_key := RIGHT(v_search_key, 6);\n END IF;\n RETURN v_search_key;\n END\n ; \n $$" + ) + op.drop_entity(public_searchkey_aircraft) + + public_match_individual_name = PGFunction( + schema="public", + signature="match_individual_name(lastname IN VARCHAR, firstname IN VARCHAR)", + definition=""" + RETURNS int[] + LANGUAGE plpgsql + AS + $$ + -- Debtor individual name matching comparison is between party.last_name_key and a key generated from lastname, and + -- between party.first_name_key and a key generated from the firstname parameter. + -- For matching, a last name key may have 2 names separated by a space character. + -- For matching, a first name key may have 3 names separated by a space character. + -- In all cases, first name matching is a cartesian cross product on either exact name or nickname. + -- Cases from Oracle PL/SQL: + -- 1. Match last name by keys on algorithm and first name by either algorithm, name, or nickname. + -- 2. Match last name by exact match on party.last_name_key second name and lastname first name; first name by either name or nickname. + -- 3. Match last name by exact match on party.last_name_key first name and lastname second name; first name by either name or nickname. + -- 4. Match last name by exact match on party.last_name_key second name and lastname second name; first name by either name or nickname. + -- As any of 2, 3 and 4 is a hit they are collapsed to the same condition below. + -- Performance should improve if split names are stored as separate columns in the party table and indexed or stored in a separate table. + DECLARE + v_ids integer ARRAY; + v_lastname_key VARCHAR(50); + v_last1 VARCHAR(50); + v_last2 VARCHAR(50); + v_firstname_key VARCHAR(50); + v_first1 VARCHAR(50); + v_first2 VARCHAR(50); + v_first3 VARCHAR(50); + BEGIN + v_lastname_key := searchkey_last_name(lastname); + v_last1 = split_part(v_lastname_key, ' ', 1); + v_last2 = split_part(v_lastname_key, ' ', 2); -- May be null + v_firstname_key := searchkey_first_name(firstname); + v_first1 = split_part(v_firstname_key, ' ', 1); + v_first2 = split_part(v_firstname_key, ' ', 2); -- May be null + v_first3 = split_part(v_firstname_key, ' ', 3); -- May be null + + -- Replace where clause: Oracle uses UTL_MATCH.JARO_WINKLER_SIMILARITY + SELECT array_agg(id) + INTO v_ids + FROM parties p + WHERE registration_id_end IS NULL AND + party_type = 'DI' AND + ((levenshtein(p.last_name_key, v_lastname_key) <= 2 AND + (levenshtein(p.first_name_key, v_firstname_key) <= 2 OR + searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0)) OR + -- This looks like a full party table scan + (searchkey_name_match(p.last_name_key, v_last1, v_last2, null) > 0 AND + (searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0))); + + RETURN v_ids; + END + ; + $$; + """ + ) + op.drop_entity(public_match_individual_name) + + public_get_registration_num = PGFunction( + schema="public", + signature="get_registration_num()", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n BEGIN\n RETURN trim(to_char(nextval('registration_num_seq'), '000000')) || 'B';\n END\n ; \n $$" + ) + op.drop_entity(public_get_registration_num) + + public_get_draft_document_number = PGFunction( + schema="public", + signature="get_draft_document_number()", + definition="RETURNS VARCHAR\n LANGUAGE plpgsql\n AS\n $$\n BEGIN\n RETURN 'D' || trim(to_char(nextval('document_number_seq'), '0000000'));\n END\n ; \n $$" + ) + op.drop_entity(public_get_draft_document_number) + + public_searchkey_nickname_match = PGFunction( + schema="public", + signature="searchkey_nickname_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on nickname: search key may have up to 3 names, a nickname match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + SELECT COUNT(name_id) + INTO v_match_count + FROM nicknames n1 + WHERE (name = v_name1 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name2 IS NOT NULL AND + name = v_name2 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name3 IS NOT NULL AND + name = v_name3 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))); + + RETURN v_match_count; + END + ; + $$; + """ + ) + op.drop_entity(public_searchkey_nickname_match) + + public_searchkey_name_match = PGFunction( + schema="public", + signature="searchkey_name_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on name: search key may have up to 3 names, an exact match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + IF (v_name1 = name1 OR (name2 IS NOT NULL AND v_name1 = name2) OR (name3 IS NOT NULL AND v_name1 = name3)) THEN + v_match_count := 1; + ELSIF (v_name2 IS NOT NULL AND v_name2 = name1 OR (name2 IS NOT NULL AND v_name2 = name2) OR (name3 IS NOT NULL AND v_name2 = name3)) THEN + v_match_count := 1; + ELSIF (v_name3 IS NOT NULL AND v_name3 = name1 OR (name2 IS NOT NULL AND v_name3 = name2) OR (name3 IS NOT NULL AND v_name3 = name3)) THEN + v_match_count := 1; + END IF; + + RETURN v_match_count; + END + ; + $$; + """ + ) + op.drop_entity(public_searchkey_name_match) + + op.drop_index(op.f('ix_nickname_name_id'), table_name='nicknames') + op.drop_index(op.f('ix_nickname_name'), table_name='nicknames') + op.drop_table('nicknames') + op.drop_index(op.f('ix_parties_last_name_key'), table_name='parties') + op.drop_index(op.f('ix_parties_first_name_key'), table_name='parties') + op.drop_index(op.f('ix_parties_business_srch_key'), table_name='parties') + op.drop_index(op.f('ix_parties_business_name'), table_name='parties') + op.drop_table('parties') + op.drop_table('trust_indentures') + op.drop_index(op.f('ix_serial_collateral_srch_vin'), table_name='serial_collateral') + op.drop_table('serial_collateral') + op.drop_table('general_collateral') + op.drop_table('court_orders') + op.drop_index(op.f('ix_client_codes_name'), table_name='client_codes') + op.drop_index(op.f('ix_client_codes_head_id'), table_name='client_codes') + op.drop_table('search_results') + op.drop_table('user_profiles') + op.drop_index(op.f('ix_search_requests_search_ts'), table_name='search_requests') + op.drop_index(op.f('ix_search_requests_account_id'), table_name='search_requests') + op.drop_table('search_requests') + op.drop_index(op.f('ix_client_codes_historical_name'), table_name='client_codes_historical') + op.drop_index(op.f('ix_client_codes_historical_head_id'), table_name='client_codes_historical') + op.drop_table('client_codes_historical') + op.drop_table('client_codes') + op.drop_table('addresses') + op.drop_index(op.f('ix_registrations_registration_ts'), table_name='registrations') + op.drop_index(op.f('ix_registrations_registration_number'), table_name='registrations') + op.drop_index(op.f('ix_registrations_base_reg_number'), table_name='registrations') + op.drop_index(op.f('ix_registrations_account_id'), table_name='registrations') + op.drop_table('registrations') + op.drop_table('financing_statements') + op.drop_index(op.f('ix_drafts_create_ts'), table_name='drafts') + op.drop_index(op.f('ix_drafts_account_id'), table_name='drafts') + op.drop_table('drafts') + op.drop_index(op.f('ix_users_username'), table_name='users') + op.drop_table('users') + op.drop_table('state_types') + op.drop_table('serial_types') + op.drop_table('search_types') + op.drop_table('registration_types') + op.drop_table('registration_type_classes') + op.drop_table('party_types') + op.drop_table('province_types') + op.drop_table('country_types') + + # Manually added drop sequence commands ### + op.execute(DropSequence(Sequence('address_id_seq'))) + op.execute(DropSequence(Sequence('code_branch_id_seq'))) + op.execute(DropSequence(Sequence('court_order_id_seq'))) + op.execute(DropSequence(Sequence('draft_id_seq'))) + op.execute(DropSequence(Sequence('financing_id_seq'))) + op.execute(DropSequence(Sequence('general_id_seq'))) + op.execute(DropSequence(Sequence('historical_head_id_seq'))) + op.execute(DropSequence(Sequence('party_id_seq'))) + op.execute(DropSequence(Sequence('registration_id_seq'))) + op.execute(DropSequence(Sequence('search_id_seq'))) + op.execute(DropSequence(Sequence('trust_id_seq'))) + op.execute(DropSequence(Sequence('vehicle_id_seq'))) + op.execute(DropSequence(Sequence('word_id_seq'))) + op.execute(DropSequence(Sequence('name_id_seq'))) + op.execute(DropSequence(Sequence('user_id_seq'))) + op.execute(DropSequence(Sequence('document_number_seq'))) + op.execute(DropSequence(Sequence('registration_num_seq'))) + # ### end Alembic commands ### diff --git a/ppr-api/requirements.txt b/ppr-api/requirements.txt old mode 100755 new mode 100644 index 0cfcc164e..07b515ab9 --- a/ppr-api/requirements.txt +++ b/ppr-api/requirements.txt @@ -13,6 +13,7 @@ SQLAlchemy-Utils==0.36.3 SQLAlchemy==1.3.16 Werkzeug==0.16.1 alembic==1.4.2 +alembic-utils==0.6.0 aniso8601==8.0.0 asyncio-nats-client==0.10.0 asyncio-nats-streaming==0.4.0 diff --git a/ppr-api/src/database/__init__.py b/ppr-api/src/database/__init__.py new file mode 100644 index 000000000..0ea311d6a --- /dev/null +++ b/ppr-api/src/database/__init__.py @@ -0,0 +1,14 @@ +# Copyright © 2019 Province of British Columbia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""This module holds non-standard database object definitions managed by Alembic.""" diff --git a/ppr-api/src/database/postgres_functions/__init__.py b/ppr-api/src/database/postgres_functions/__init__.py new file mode 100644 index 000000000..804a6ac7d --- /dev/null +++ b/ppr-api/src/database/postgres_functions/__init__.py @@ -0,0 +1,26 @@ +# Copyright © 2019 Province of British Columbia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Export all of the Postgres db functions.""" +from .get_draft_document_number import get_draft_document_number +from .get_registration_num import get_registration_num +from .match_individual_name import match_individual_name +from .searchkey_aircraft import searchkey_aircraft +from .searchkey_business_name import searchkey_business_name +from .searchkey_first_name import searchkey_first_name +from .searchkey_last_name import searchkey_last_name +from .searchkey_mhr import searchkey_mhr +from .searchkey_name_match import searchkey_name_match +from .searchkey_nickname_match import searchkey_nickname_match +from .searchkey_vehicle import searchkey_vehicle diff --git a/ppr-api/src/database/postgres_functions/get_draft_document_number.py b/ppr-api/src/database/postgres_functions/get_draft_document_number.py new file mode 100644 index 000000000..4e4a70bf5 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/get_draft_document_number.py @@ -0,0 +1,19 @@ +"""Maintain db function get_draft_document_number here.""" +from alembic_utils.pg_function import PGFunction + + +get_draft_document_number = PGFunction( + schema="public", + signature="get_draft_document_number()", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + BEGIN + RETURN 'D' || trim(to_char(nextval('document_number_seq'), '0000000')); + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/get_registration_num.py b/ppr-api/src/database/postgres_functions/get_registration_num.py new file mode 100644 index 000000000..dd258d5ba --- /dev/null +++ b/ppr-api/src/database/postgres_functions/get_registration_num.py @@ -0,0 +1,19 @@ +"""Maintain db function get_registration_num here.""" +from alembic_utils.pg_function import PGFunction + + +get_registration_num = PGFunction( + schema="public", + signature="get_registration_num()", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + BEGIN + RETURN trim(to_char(nextval('registration_num_seq'), '000000')) || 'B'; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/match_individual_name.py b/ppr-api/src/database/postgres_functions/match_individual_name.py new file mode 100644 index 000000000..16a664085 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/match_individual_name.py @@ -0,0 +1,64 @@ +"""Maintain db function match_individual_name here.""" +from alembic_utils.pg_function import PGFunction + + +# Incomplete +match_individual_name = PGFunction( + schema="public", + signature="match_individual_name(lastname IN VARCHAR, firstname IN VARCHAR)", + definition=""" + RETURNS int[] + LANGUAGE plpgsql + AS + $$ + -- Debtor individual name matching comparison is between party.last_name_key and a key generated from lastname, and + -- between party.first_name_key and a key generated from the firstname parameter. + -- For matching, a last name key may have 2 names separated by a space character. + -- For matching, a first name key may have 3 names separated by a space character. + -- In all cases, first name matching is a cartesian cross product on either exact name or nickname. + -- Cases from Oracle PL/SQL: + -- 1. Match last name by keys on algorithm and first name by either algorithm, name, or nickname. + -- 2. Match last name by exact match on party.last_name_key second name and lastname first name; first name by either name or nickname. + -- 3. Match last name by exact match on party.last_name_key first name and lastname second name; first name by either name or nickname. + -- 4. Match last name by exact match on party.last_name_key second name and lastname second name; first name by either name or nickname. + -- As any of 2, 3 and 4 is a hit they are collapsed to the same condition below. + -- Performance should improve if split names are stored as separate columns in the party table and indexed or stored in a separate table. + DECLARE + v_ids integer ARRAY; + v_lastname_key VARCHAR(50); + v_last1 VARCHAR(50); + v_last2 VARCHAR(50); + v_firstname_key VARCHAR(50); + v_first1 VARCHAR(50); + v_first2 VARCHAR(50); + v_first3 VARCHAR(50); + BEGIN + v_lastname_key := searchkey_last_name(lastname); + v_last1 = split_part(v_lastname_key, ' ', 1); + v_last2 = split_part(v_lastname_key, ' ', 2); -- May be null + v_firstname_key := searchkey_first_name(firstname); + v_first1 = split_part(v_firstname_key, ' ', 1); + v_first2 = split_part(v_firstname_key, ' ', 2); -- May be null + v_first3 = split_part(v_firstname_key, ' ', 3); -- May be null + + -- Replace where clause: Oracle uses UTL_MATCH.JARO_WINKLER_SIMILARITY + SELECT array_agg(id) + INTO v_ids + FROM parties p + WHERE registration_id_end IS NULL AND + party_type = 'DI' AND + ((levenshtein(p.last_name_key, v_lastname_key) <= 2 AND + (levenshtein(p.first_name_key, v_firstname_key) <= 2 OR + searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0)) OR + -- This looks like a full party table scan + (searchkey_name_match(p.last_name_key, v_last1, v_last2, null) > 0 AND + (searchkey_name_match(p.first_name_key, v_first1, v_first2, v_first3) > 0 OR + searchkey_nickname_match(p.first_name_key, v_first1, v_first2, v_first3) > 0))); + + RETURN v_ids; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_aircraft.py b/ppr-api/src/database/postgres_functions/searchkey_aircraft.py new file mode 100644 index 000000000..42a6c811a --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_aircraft.py @@ -0,0 +1,25 @@ +"""Maintain db function searchkey_aircraft here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_aircraft = PGFunction( + schema="public", + signature="searchkey_aircraft(aircraft_number IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(25); + BEGIN + v_search_key := TRIM(REGEXP_REPLACE(aircraft_number,'\s|-','','gi')); + IF (LENGTH(v_search_key) > 6) THEN + v_search_key := RIGHT(v_search_key, 6); + END IF; + RETURN v_search_key; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_business_name.py b/ppr-api/src/database/postgres_functions/searchkey_business_name.py new file mode 100644 index 000000000..7e199d2ff --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_business_name.py @@ -0,0 +1,73 @@ +"""Maintain db function searchkey_business_name here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_business_name = PGFunction( + schema="public", + signature="searchkey_business_name(actual_name IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(150); + BEGIN + v_search_key := + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE( + REGEXP_REPLACE(actual_name,'^0000|^000|^00|^0|^THE | THE |\([^()]*\)',''), + 'CORPORATION|CORP|COMPANY|CO\.|LTD|INCORPORATED|INC$|INC.|INCORPOREE|LIMITED|LIMITEE|LTEE|LTD|ASSOCIATION$|ASSOC$|ASSN$|NON PERSONAL LIABILITY$|UNLIMITED LIABILITY COMPANY|N P L$|NPL$|PARTNERSHIP|SOCIETY$|SOC$',''), + 'BRITISH COLUMBIA|BRITISHCOLUMBIA','BC'), + '&','AND'), + '#','NUMBER'), + '1','ONE'), + '2','TWO'), + '3','THREE'), + '4','FOUR'), + '5','FIVE'), + '6','SIX'), + '7','SEVEN'), + '8','EIGHT'), + '9','NINE'), + '0','ZERO'), + 'TEN','ONEZERO'), + 'TWENTY','TWOZERO'), + 'THIRTY','THREEERO'), + 'FORTY','FOURZERO'), + 'FOURTY','FOURZERO'), + 'FIFTY','FIVEZERO'), + 'SIXTY','SIXZERO'), + 'SEVENTY','SEVENZERO'), + 'EIGHTY','EIGHTZERO'), + 'NINETY','NINEZERO'), + '[^0-9A-Za-z]','','gi'); + RETURN UPPER(v_search_key); + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_first_name.py b/ppr-api/src/database/postgres_functions/searchkey_first_name.py new file mode 100644 index 000000000..e74703d63 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_first_name.py @@ -0,0 +1,28 @@ +"""Maintain db function searchkey_first_name here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_first_name = PGFunction( + schema="public", + signature="searchkey_first_name(actual_name IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(92); + BEGIN + -- Remove prefixes + v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi'); + -- Remove suffixes + v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi'); + v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi'); + -- Remove internal extra space characters + v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g')); + RETURN UPPER(v_search_key); + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_last_name.py b/ppr-api/src/database/postgres_functions/searchkey_last_name.py new file mode 100644 index 000000000..17643252e --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_last_name.py @@ -0,0 +1,28 @@ +"""Maintain db function searchkey_last_name here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_last_name = PGFunction( + schema="public", + signature="searchkey_last_name(actual_name IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(60); + BEGIN + -- Remove prefixes + v_search_key := REGEXP_REPLACE(actual_name,'^DR |^DR.|^DR. |^MR |^MR.|^MR. |^MRS |^MRS.|^MRS. |^MS |^MS.|^MS. ','','gi'); + -- Remove suffixes + v_search_key := REGEXP_REPLACE(v_search_key,' JR$| JR.$| JR. $| SR$| SR $| SR.$| SR. $','','gi'); + v_search_key := REGEXP_REPLACE(v_search_key,'[^0-9A-Za-z]',' ','gi'); + -- Remove internal extra space characters + v_search_key := TRIM(REGEXP_REPLACE(v_search_key,'( ){2,}',' ','g')); + RETURN UPPER(v_search_key); + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_mhr.py b/ppr-api/src/database/postgres_functions/searchkey_mhr.py new file mode 100644 index 000000000..73e84d7f3 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_mhr.py @@ -0,0 +1,23 @@ +"""Maintain db function searchkey_mhr here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_mhr = PGFunction( + schema="public", + signature="searchkey_mhr(mhr_number IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(6); + BEGIN + v_search_key := TRIM(REGEXP_REPLACE(mhr_number,'[^0-9A-Za-z]','','gi')); + v_search_key := LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','0'),6,'0'); + RETURN v_search_key; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_name_match.py b/ppr-api/src/database/postgres_functions/searchkey_name_match.py new file mode 100644 index 000000000..424e1cdc2 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_name_match.py @@ -0,0 +1,39 @@ +"""Maintain db function searchkey_name_match here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_name_match = PGFunction( + schema="public", + signature="searchkey_name_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on name: search key may have up to 3 names, an exact match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + IF (v_name1 = name1 OR (name2 IS NOT NULL AND v_name1 = name2) OR (name3 IS NOT NULL AND v_name1 = name3)) THEN + v_match_count := 1; + ELSIF (v_name2 IS NOT NULL AND v_name2 = name1 OR (name2 IS NOT NULL AND v_name2 = name2) OR (name3 IS NOT NULL AND v_name2 = name3)) THEN + v_match_count := 1; + ELSIF (v_name3 IS NOT NULL AND v_name3 = name1 OR (name2 IS NOT NULL AND v_name3 = name2) OR (name3 IS NOT NULL AND v_name3 = name3)) THEN + v_match_count := 1; + END IF; + + RETURN v_match_count; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_nickname_match.py b/ppr-api/src/database/postgres_functions/searchkey_nickname_match.py new file mode 100644 index 000000000..9a54c5c04 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_nickname_match.py @@ -0,0 +1,49 @@ +"""Maintain db function searchkey_nickname_match here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_nickname_match = PGFunction( + schema="public", + signature="searchkey_nickname_match(search_key IN VARCHAR, name1 IN VARCHAR, name2 IN VARCHAR, name3 IN varchar)", + definition=""" + RETURNS int + LANGUAGE plpgsql + AS + $$ + -- Cartesion cross-product on nickname: search key may have up to 3 names, a nickname match on any name is a hit. + -- search_key is party.first_name_key to match on: may be 3 names separated by a space character. + -- name1, name2, name3 are names already parsed from the search criteria: name2 and name3 may be null. + DECLARE + v_name1 VARCHAR(50); + v_name2 VARCHAR(50); + v_name3 VARCHAR(50); + v_match_count integer; + BEGIN + v_match_count := 0; + v_name1 = split_part(search_key, ' ', 1); + v_name2 = split_part(search_key, ' ', 2); -- May be null + v_name3 = split_part(search_key, ' ', 3); -- May be null + SELECT COUNT(name_id) + INTO v_match_count + FROM nicknames n1 + WHERE (name = v_name1 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name2 IS NOT NULL AND + name = v_name2 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))) OR + (v_name3 IS NOT NULL AND + name = v_name3 AND + n1.name_id IN (SELECT n2.name_id + FROM nicknames n2 + WHERE n2.name IN (name1, name2, name3))); + + RETURN v_match_count; + END + ; + $$; + """ +) diff --git a/ppr-api/src/database/postgres_functions/searchkey_vehicle.py b/ppr-api/src/database/postgres_functions/searchkey_vehicle.py new file mode 100644 index 000000000..3ffc8a522 --- /dev/null +++ b/ppr-api/src/database/postgres_functions/searchkey_vehicle.py @@ -0,0 +1,94 @@ +"""Maintain db function searchkey_vehicle here.""" +from alembic_utils.pg_function import PGFunction + + +searchkey_vehicle = PGFunction( + schema="public", + signature="searchkey_vehicle(serial_number IN VARCHAR)", + definition=""" + RETURNS VARCHAR + LANGUAGE plpgsql + AS + $$ + DECLARE + v_search_key VARCHAR(25); + v_vin VARCHAR(25); + v_digits VARCHAR(25); + v_length_digits integer; + v_last_digit_index integer; + BEGIN + v_search_key := UPPER(REGEXP_REPLACE(serial_number,'[^0-9A-Za-z]','','gi')); + v_digits := regexp_replace(v_search_key, '[^0-9]', '', 'g'); + v_length_digits := length(v_digits); + v_vin := ''; + IF (v_length_digits > 0) THEN + v_last_digit_index := length(v_search_key) - length(regexp_replace(v_search_key, '.*' || RIGHT(v_digits, 1),'', 'g')); + ELSE + v_last_digit_index := 0; + END IF; + + SELECT + CASE + WHEN v_length_digits = 0 THEN '000000' + WHEN v_length_digits = 1 THEN LPAD(v_digits, 6, '0') + WHEN RIGHT(v_search_key, 1) BETWEEN '0' AND '9' THEN LPAD(RIGHT(v_search_key, LEAST(LENGTH(v_search_key), 6)), 6, '0') + WHEN RIGHT(v_search_key, 1) IN ('B','C','G','H','I','L','S','O','Y','Z') AND + LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' THEN LPAD(RIGHT(v_search_key, 6), 6, '0') + WHEN RIGHT(v_search_key, 1) NOT IN ('B','C','G','H','I','L','S','O','Y','Z') AND + LEFT(RIGHT(v_search_key, 2), 1) BETWEEN '0' AND '9' AND + LENGTH(v_search_key) > 6 THEN LEFT(RIGHT(v_search_key, 7), 6) + WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND + LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND + LENGTH(v_search_key) < 6 THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0') + WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND + LEFT(RIGHT(v_search_key, 2), 1) NOT BETWEEN 'A' AND 'Z' AND + v_last_digit_index BETWEEN 1 AND 5 + THEN LPAD(REGEXP_REPLACE(v_search_key,'[$A-Za-z]','', 'g'), 6, '0') + WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND + LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND + LENGTH(v_search_key) > 6 + -- This does not appear to always work correctly. + THEN LPAD(SUBSTR(v_search_key, (v_last_digit_index - 5), 5), 6, '0') + WHEN RIGHT(v_search_key, 1) BETWEEN 'A' AND 'Z' AND + LEFT(RIGHT(v_search_key, 2), 1) BETWEEN 'A' AND 'Z' AND + LENGTH(v_search_key) > 6 + -- This does not appear to always work correctly. + THEN SUBSTR(v_search_key, (v_last_digit_index - 5), 6) + END + INTO v_vin; + + IF (LENGTH(v_vin) > 0) THEN + v_search_key := v_vin; + END IF; + IF (LENGTH(v_search_key) > 6) THEN + v_search_key := RIGHT(v_search_key, 6); + END IF; + + v_search_key := REGEXP_REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE(v_search_key,'I','1'), + 'L','1'), + 'Z','2'), + 'H','4'), + 'Y','4'), + 'S','5'), + 'C','6'), + 'G','6'), + 'B','8'), + 'O','0'), + '[A-Za-z]','0'); + + RETURN v_search_key; + END + ; + $$; + """ +) diff --git a/ppr-api/src/ppr_api/config.py b/ppr-api/src/ppr_api/config.py index 1db617975..09b31c96d 100644 --- a/ppr-api/src/ppr_api/config.py +++ b/ppr-api/src/ppr_api/config.py @@ -74,23 +74,31 @@ class _Config(): # pylint: disable=too-few-public-methods # SECRET_KEY = 'a secret' SQLALCHEMY_TRACK_MODIFICATIONS = False -# ALEMBIC_INI = 'migrations/alembic.ini' - # POSTGRESQL + ALEMBIC_INI = 'migrations/alembic.ini' + DB_USER = os.getenv('DATABASE_USERNAME', '') DB_PASSWORD = os.getenv('DATABASE_PASSWORD', '') DB_NAME = os.getenv('DATABASE_NAME', '') DB_HOST = os.getenv('DATABASE_HOST', '') -# DB_PORT = os.getenv('DATABASE_PORT', '5432') - DB_PORT = os.getenv('DATABASE_PORT', '1521') - # Don't need a configured URI: using oracle connection pool configured in resources/db.py using above settings. -# SQLALCHEMY_DATABASE_URI = 'postgresql://{user}:{password}@{host}:{port}/{name}'.format( - SQLALCHEMY_DATABASE_URI = 'oracle+cx_oracle://{user}:{password}@{host}:{port}/{name}'.format( + DB_PORT = os.getenv('DATABASE_PORT', '5432') # POSTGRESQL + # POSTGRESQL + SQLALCHEMY_DATABASE_URI = 'postgresql://{user}:{password}@{host}:{port}/{name}'.format( user=DB_USER, password=DB_PASSWORD, host=DB_HOST, port=int(DB_PORT), name=DB_NAME, ) + + # ORACLE + # SQLALCHEMY_DATABASE_URI = 'oracle+cx_oracle://{user}:{password}@{host}:{port}/{name}'.format( + # user=DB_USER, + # password=DB_PASSWORD, + # host=DB_HOST, + # port=int(DB_PORT), + # name=DB_NAME, + # ) + # Connection pool settings DB_MIN_POOL_SIZE = os.getenv('DATABASE_MIN_POOL_SIZE', '5') DB_MAX_POOL_SIZE = os.getenv('DATABASE_MAX_POOL_SIZE', '5') diff --git a/ppr-api/src/ppr_api/models/__init__.py b/ppr-api/src/ppr_api/models/__init__.py index ee5444221..55d7bf0eb 100644 --- a/ppr-api/src/ppr_api/models/__init__.py +++ b/ppr-api/src/ppr_api/models/__init__.py @@ -23,7 +23,7 @@ from .general_collateral import GeneralCollateral from .party import Party from .registration import Registration -from .search_client import SearchClient +from .search_request import SearchRequest from .search_result import SearchResult from .trust_indenture import TrustIndenture from .type_tables import ( @@ -44,5 +44,5 @@ __all__ = ('db', 'Address', 'ClientCode', 'ClientCodeHistorical', 'CountryType', 'CourtOrder', 'Draft', 'FinancingStatement', 'GeneralCollateral', 'Party', 'PartyType', 'ProvinceType', 'Registration', 'RegistrationType', - 'RegistrationTypeClass', 'SearchClient', 'SearchResult', 'SearchType', 'StateType', 'SerialType', + 'RegistrationTypeClass', 'SearchRequest', 'SearchResult', 'SearchType', 'StateType', 'SerialType', 'TrustIndenture', 'User', 'UserProfile', 'VehicleCollateral') diff --git a/ppr-api/src/ppr_api/models/address.py b/ppr-api/src/ppr_api/models/address.py index c35f9e7a7..10e914adf 100644 --- a/ppr-api/src/ppr_api/models/address.py +++ b/ppr-api/src/ppr_api/models/address.py @@ -20,18 +20,17 @@ class Address(db.Model): # pylint: disable=too-many-instance-attributes """This class manages all of the registry addresses.""" - __tablename__ = 'address_ppr' - - address_id = db.Column('address_id', db.Integer, db.Sequence('address_id_seq'), primary_key=True) - street = db.Column('street_line_1', db.String(50), nullable=False) # index=True) - street_additional = db.Column('street_line_2', db.String(50), nullable=True) - city = db.Column('city', db.String(30), nullable=False) - region = db.Column('province_type_cd', db.String(2), - db.ForeignKey('province_types.province_type_cd'), nullable=False) - postal_code = db.Column('postal_cd', db.String(15), nullable=False) - country = db.Column('country_type_cd', db.String(2), - db.ForeignKey('country_types.country_type_cd'), nullable=True) -# delivery_instructions = db.Column('delivery_instructions', db.String(4096)) + __tablename__ = 'addresses' + + id = db.Column('id', db.Integer, db.Sequence('address_id_seq'), primary_key=True) + street = db.Column('street', db.String(50), nullable=False) # index=True) + street_additional = db.Column('street_additional', db.String(50), nullable=True) + city = db.Column('city', db.String(40), nullable=False) + region = db.Column('region', db.String(2), + db.ForeignKey('province_types.province_type'), nullable=False) + postal_code = db.Column('postal_code', db.String(15), nullable=False) + country = db.Column('country', db.String(2), + db.ForeignKey('country_types.country_type'), nullable=True) # parent keys diff --git a/ppr-api/src/ppr_api/models/client_code.py b/ppr-api/src/ppr_api/models/client_code.py index 458196808..fc5d75a96 100644 --- a/ppr-api/src/ppr_api/models/client_code.py +++ b/ppr-api/src/ppr_api/models/client_code.py @@ -25,9 +25,9 @@ class ClientCode(db.Model): # pylint: disable=too-many-instance-attributes """This class maintains client party information (registering and secured parties).""" - __tablename__ = 'client_code' + __tablename__ = 'client_codes' # key value is generated from a db function tbd. ,default=db.func.get_code_branch_id() - branch_id = db.Column('branch_id', db.Integer, primary_key=True, nullable=False) + id = db.Column('id', db.Integer, primary_key=True, nullable=False) head_id = db.Column('head_id', db.Integer, index=True, nullable=False) name = db.Column('name', db.String(150), index=True, nullable=False) bconline_account = db.Column('bconline_account', db.Integer, nullable=True) @@ -40,8 +40,8 @@ class ClientCode(db.Model): # pylint: disable=too-many-instance-attributes date_ts = db.Column('date_ts', db.DateTime, nullable=True) # parent keys - address_id = db.Column('address_id', db.Integer, db.ForeignKey('address_ppr.address_id'), nullable=False) - id = db.Column('id', db.Integer, db.ForeignKey('users.id'), nullable=True) + address_id = db.Column('address_id', db.Integer, db.ForeignKey('addresses.id'), nullable=False) + users_id = db.Column('users_id', db.Integer, db.ForeignKey('users.id'), nullable=True) # Relationships address = db.relationship('Address', foreign_keys=[address_id], uselist=False, @@ -53,7 +53,7 @@ class ClientCode(db.Model): # pylint: disable=too-many-instance-attributes def json(self) -> dict: """Return the client party branch as a json object.""" party = { - 'code': str(self.branch_id), + 'code': str(self.id), 'businessName': self.name, 'contact': { 'name': self.contact_name, @@ -75,7 +75,7 @@ def find_by_code(cls, code: str = None): """Return a client party branch json object by client code.""" party = None if code: - party = db.session.query(ClientCode).filter(ClientCode.branch_id == int(code)).one_or_none() + party = db.session.query(ClientCode).filter(ClientCode.id == int(code)).one_or_none() if party: return party.json diff --git a/ppr-api/src/ppr_api/models/client_code_historical.py b/ppr-api/src/ppr_api/models/client_code_historical.py index 2d91d8d70..87f70dd5f 100644 --- a/ppr-api/src/ppr_api/models/client_code_historical.py +++ b/ppr-api/src/ppr_api/models/client_code_historical.py @@ -34,12 +34,11 @@ class HistoricalTypes(Enum): BOTH = 'B' NAME = 'N' - __tablename__ = 'client_code_historical' - historical_head_id = db.Column('historical_head_id', db.Integer, - db.Sequence('historical_head_id_seq'), primary_key=True) + __tablename__ = 'client_codes_historical' + id = db.Column('id', db.Integer, db.Sequence('historical_head_id_seq'), primary_key=True) head_id = db.Column('head_id', db.Integer, index=True, nullable=False) name = db.Column('name', db.String(150), index=True, nullable=False) - historical_type_cd = db.Column('historical_type_cd', db.String(1), nullable=False) + historical_type = db.Column('historical_type', db.String(1), nullable=False) bconline_account = db.Column('bconline_account', db.Integer, nullable=True) # contact info contact_name = db.Column('contact_name', db.String(100), nullable=False) @@ -50,9 +49,9 @@ class HistoricalTypes(Enum): date_ts = db.Column('date_ts', db.DateTime, nullable=True) # parent keys - branch_id = db.Column('branch_id', db.Integer, db.ForeignKey('client_code.branch_id'), nullable=False) - address_id = db.Column('address_id', db.Integer, db.ForeignKey('address_ppr.address_id'), nullable=False) - id = db.Column('id', db.Integer, db.ForeignKey('users.id'), nullable=True) + branch_id = db.Column('branch_id', db.Integer, db.ForeignKey('client_codes.id'), nullable=False) + address_id = db.Column('address_id', db.Integer, db.ForeignKey('addresses.id'), nullable=False) + users_id = db.Column('users_id', db.Integer, db.ForeignKey('users.id'), nullable=True) # Relationships address = db.relationship('Address', foreign_keys=[address_id], uselist=False, @@ -87,7 +86,7 @@ def find_by_id(cls, historical_id: int = None): party = None if historical_id: party = db.session.query(ClientCodeHistorical).\ - filter(ClientCodeHistorical.historical_head_id == historical_id).\ + filter(ClientCodeHistorical.id == historical_id).\ one_or_none() if party: diff --git a/ppr-api/src/ppr_api/models/court_order.py b/ppr-api/src/ppr_api/models/court_order.py index bcd965af1..93998834a 100644 --- a/ppr-api/src/ppr_api/models/court_order.py +++ b/ppr-api/src/ppr_api/models/court_order.py @@ -21,19 +21,17 @@ class CourtOrder(db.Model): # pylint: disable=too-many-instance-attributes """This class manages all of the amendment, renewal statement court order information.""" - __tablename__ = 'court_order' + __tablename__ = 'court_orders' - court_order_id = db.Column('court_order_id', db.Integer, - db.Sequence('court_order_id_seq'), primary_key=True) - court_date = db.Column('court_date', db.DateTime, nullable=False) + id = db.Column('id', db.Integer, db.Sequence('court_order_id_seq'), primary_key=True) + order_date = db.Column('order_date', db.DateTime, nullable=False) court_name = db.Column('court_name', db.String(256), nullable=False) court_registry = db.Column('court_registry', db.String(64), nullable=False) file_number = db.Column('file_number', db.String(20), nullable=False) effect_of_order = db.Column('effect_of_order', db.String(512), nullable=True) # parent keys - registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=False) + registration_id = db.Column('registration_id', db.Integer, db.ForeignKey('registrations.id'), nullable=False) # Relationships - Registration registration = db.relationship('Registration', foreign_keys=[registration_id], @@ -46,7 +44,7 @@ def json(self) -> dict: 'courtName': self.court_name, 'courtRegistry': self.court_registry, 'fileNumber': self.file_number, - 'orderDate': format_ts(self.court_date) + 'orderDate': format_ts(self.order_date) } if self.effect_of_order: court_order['effectOfOrder'] = self.effect_of_order @@ -81,7 +79,7 @@ def create_from_json(json_data, registration_id: int = None): court_order.court_name = json_data['courtName'] court_order.court_registry = json_data['courtRegistry'] court_order.file_number = json_data['fileNumber'] - court_order.court_date = ts_from_date_iso_format(json_data['orderDate']) + court_order.order_date = ts_from_date_iso_format(json_data['orderDate']) if 'effectOfOrder' in json_data: court_order.effect_of_order = json_data['effectOfOrder'] diff --git a/ppr-api/src/ppr_api/models/draft.py b/ppr-api/src/ppr_api/models/draft.py index 34156073c..9ac52a824 100644 --- a/ppr-api/src/ppr_api/models/draft.py +++ b/ppr-api/src/ppr_api/models/draft.py @@ -19,7 +19,6 @@ from enum import Enum from http import HTTPStatus -import json from ppr_api.exceptions import BusinessException from ppr_api.models import utils as model_utils @@ -27,6 +26,14 @@ from .db import db +ACCOUNT_QUERY = """ +SELECT d.create_ts, d.registration_type_cl, d.registration_type, d.document_number, d.registration_number + FROM drafts d + WHERE d.account_id = '?' + AND NOT EXISTS (SELECT r.draft_id FROM registrations r WHERE r.draft_id = d.id) +""" + + class Draft(db.Model): # pylint: disable=too-many-instance-attributes """This class maintains draft statement information.""" @@ -40,32 +47,30 @@ class DraftTypes(Enum): REG_CLASS_DISCHARGE = 'DISCHARGE' REG_CLASS_RENEWAL = 'RENEWAL' - __tablename__ = 'draft' + __tablename__ = 'drafts' -# draft_id = db.Column('draft_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - draft_id = db.Column('draft_id', db.Integer, db.Sequence('draft_id_seq'), primary_key=True) + id = db.Column('id', db.Integer, db.Sequence('draft_id_seq'), primary_key=True) document_number = db.Column('document_number', db.String(10), nullable=False, unique=True, default=db.func.get_draft_document_number()) account_id = db.Column('account_id', db.String(20), nullable=False, index=True) create_ts = db.Column('create_ts', db.DateTime, nullable=False, index=True) - registration_type_cl = db.Column('registration_type_cl', db.String(10), nullable=False) - registration_type_cd = db.Column('registration_type_cd', db.String(2), nullable=False) - draft = db.Column('draft', db.Text, nullable=False) + draft = db.Column('draft', db.JSON, nullable=False) registration_number = db.Column('registration_number', db.String(10), nullable=True) update_ts = db.Column('update_ts', db.DateTime, nullable=True) # parent keys - registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=True) + registration_type = db.Column('registration_type', db.String(2), + db.ForeignKey('registration_types.registration_type'), nullable=False) + registration_type_cl = db.Column('registration_type_cl', db.String(10), + db.ForeignKey('registration_type_classes.registration_type_cl'), nullable=False) # Relationships - Registration - registration = db.relationship('Registration', foreign_keys=[registration_id], - back_populates='draft', uselist=False) + registration = db.relationship('Registration', back_populates='draft', uselist=False) @property def json(self) -> dict: """Return the draft as a json object.""" - draft = json.loads(self.draft) + draft = self.draft draft['createDateTime'] = model_utils.format_ts(self.create_ts) if self.update_ts: @@ -83,36 +88,28 @@ def json(self) -> dict: @classmethod def find_all_by_account_id(cls, account_id: str = None): """Return a summary list of drafts belonging to an account.""" - draft_list = None - if account_id: - draft_list = db.session.query(Draft.create_ts, Draft.registration_type_cl, - Draft.registration_type_cd, Draft.document_number, - Draft.registration_number). \ - filter(Draft.account_id == account_id, - Draft.registration_id == None).order_by(Draft.draft_id).all() # noqa: E711 - drafts_json = [] - if not draft_list: - return drafts_json - # raise BusinessException( - # error=f'No Draft Statements found for Account ID {account_id}.', - # status_code=HTTPStatus.NOT_FOUND - # ) - - for draft in draft_list: - draft_json = { - 'createDateTime': model_utils.format_ts(draft.create_ts), - 'documentId': draft.document_number, - 'registrationType': draft.registration_type_cd, - 'path': '/api/v1/drafts/' + draft.document_number - } - draft_json['type'] = model_utils.REG_CLASS_TO_DRAFT_TYPE[draft.registration_type_cl] - if draft.registration_type_cl in (model_utils.REG_CLASS_AMEND, - model_utils.REG_CLASS_AMEND_COURT, - model_utils.REG_CLASS_CHANGE): - draft_json['baseRegistrationNumber'] = draft.registration_number - - drafts_json.append(draft_json) + if account_id: + query = ACCOUNT_QUERY.replace('?', account_id) + result = db.session.execute(query) + rows = result.fetchall() + if rows is not None: + for row in rows: + values = row.values() + draft_json = { + 'createDateTime': model_utils.format_ts(values[0]), + 'documentId': str(values[3]), + 'registrationType': str(values[2]), + 'path': '/api/v1/drafts/' + str(values[3]) + } + reg_class = str(values[1]) + draft_json['type'] = model_utils.REG_CLASS_TO_DRAFT_TYPE[reg_class] + if reg_class in (model_utils.REG_CLASS_AMEND, + model_utils.REG_CLASS_AMEND_COURT, + model_utils.REG_CLASS_CHANGE): + draft_json['baseRegistrationNumber'] = str(values[4]) + + drafts_json.append(draft_json) return drafts_json @@ -169,22 +166,22 @@ def update(cls, request_json, document_number: str = None): if draft: draft.update_ts = model_utils.now_ts() - draft.draft = json.dumps(request_json) + draft.draft = request_json if request_json['type'] == 'AMENDMENT_STATEMENT': if 'courtOrderInformation' in request_json: draft.registration_type_cl = 'COURTORDER' else: draft.registration_type_cl = 'AMENDMENT' - draft.registration_type_cd = request_json['amendmentStatement']['changeType'] + draft.registration_type = request_json['amendmentStatement']['changeType'] draft.registration_number = request_json['amendmentStatement']['baseRegistrationNumber'] elif request_json['type'] == 'CHANGE_STATEMENT': draft.registration_type_cl = 'CHANGE' - draft.registration_type_cd = request_json['changeStatement']['changeType'] + draft.registration_type = request_json['changeStatement']['changeType'] draft.registration_number = request_json['changeStatement']['baseRegistrationNumber'] else: draft.registration_type_cl = 'PPSALIEN' - draft.registration_type_cd = request_json['financingStatement']['type'] + draft.registration_type = request_json['financingStatement']['type'] return draft @@ -198,19 +195,19 @@ def create_from_json(json_data, account_id: str): if 'amendmentStatement' in json_data and 'courtOrderInformation' in json_data['amendmentStatement']: draft.registration_type_cl = model_utils.REG_CLASS_AMEND_COURT if draft_type == model_utils.DRAFT_TYPE_AMENDMENT: - draft.registration_type_cd = json_data['amendmentStatement']['changeType'] + draft.registration_type = json_data['amendmentStatement']['changeType'] draft.registration_number = json_data['amendmentStatement']['baseRegistrationNumber'] elif draft_type == model_utils.DRAFT_TYPE_CHANGE: - draft.registration_type_cd = json_data['changeStatement']['changeType'] + draft.registration_type = json_data['changeStatement']['changeType'] draft.registration_number = json_data['changeStatement']['baseRegistrationNumber'] else: - draft.registration_type_cd = json_data['financingStatement']['type'] + draft.registration_type = json_data['financingStatement']['type'] # Not null constraint: should be removed if staff can submit requests without an account id. if not account_id: draft.account_id = 'NA' - draft.draft = json.dumps(json_data) + draft.draft = json_data return draft @@ -223,8 +220,8 @@ def create_from_registration(registration, json_data): draft.registration_number = registration.registration_num draft.document_number = registration.document_number draft.registration_type_cl = registration.registration_type_cl - draft.registration_type_cd = registration.registration_type_cd - draft.draft = json.dumps(json_data) + draft.registration_type = registration.registration_type + draft.draft = json_data # Not null constraint: should be removed. if not draft.account_id: draft.account_id = 'NA' diff --git a/ppr-api/src/ppr_api/models/financing_statement.py b/ppr-api/src/ppr_api/models/financing_statement.py index 10c247a04..f66eea13b 100644 --- a/ppr-api/src/ppr_api/models/financing_statement.py +++ b/ppr-api/src/ppr_api/models/financing_statement.py @@ -48,13 +48,10 @@ class FinancingTypes(Enum): FORESTRY_SUBCONTRACTOR_LIEN = 'FS' MISCELLANEOUS = 'MR' - __tablename__ = 'financing_statement' + __tablename__ = 'financing_statements' -# financing_id = db.Column('financing_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - financing_id = db.Column('financing_id', db.Integer, - db.Sequence('financing_id_seq'), primary_key=True) - state_type_cd = db.Column('state_type_cd', db.String(3), db.ForeignKey('state_type.state_type_cd'), nullable=False) - registration_num = db.Column('registration_number', db.String(10), nullable=False) + id = db.Column('id', db.Integer, db.Sequence('financing_id_seq'), primary_key=True) + state_type = db.Column('state_type', db.String(3), db.ForeignKey('state_types.state_type'), nullable=False) life = db.Column('life', db.Integer, nullable=True) expire_date = db.Column('expire_date', db.DateTime, nullable=True) discharged = db.Column('discharged', db.String(1), nullable=True) @@ -63,30 +60,23 @@ class FinancingTypes(Enum): type_claim = db.Column('type_claim', db.String(2), nullable=True) crown_charge_type = db.Column('crown_charge_type', db.String(2), nullable=True) crown_charge_other = db.Column('crown_charge_other', db.String(70), nullable=True) - prev_reg_type = db.Column('prev_reg_type', db.String(30), nullable=True) - prev_reg_cr_nbr = db.Column('prev_reg_cr_nbr', db.String(7), nullable=True) - prev_reg_cr_date = db.Column('prev_reg_cr_date', db.String(7), nullable=True) - prev_reg_cb_nbr = db.Column('prev_reg_cb_nbr', db.String(10), nullable=True) - prev_reg_cb_date = db.Column('prev_reg_cb_date', db.String(7), nullable=True) - prev_reg_mh_nbr = db.Column('prev_reg_mh_nbr', db.String(7), nullable=True) - prev_reg_mh_date = db.Column('prev_reg_mh_date', db.String(7), nullable=True) # Parent keys # Relationships registration = db.relationship('Registration', order_by='asc(Registration.registration_ts)', back_populates='financing_statement') - parties = db.relationship('Party', order_by='asc(Party.party_id)', back_populates='financing_statement') + parties = db.relationship('Party', order_by='asc(Party.id)', back_populates='financing_statement') vehicle_collateral = db.relationship('VehicleCollateral', - order_by='asc(VehicleCollateral.vehicle_id)', + order_by='asc(VehicleCollateral.id)', back_populates='financing_statement') general_collateral = db.relationship('GeneralCollateral', - order_by='asc(GeneralCollateral.collateral_id)', + order_by='asc(GeneralCollateral.id)', back_populates='financing_statement') trust_indenture = db.relationship('TrustIndenture', back_populates='financing_statement') # Relationships - StateType - state_type = db.relationship('StateType', foreign_keys=[state_type_cd], - back_populates='financing_statement', cascade='all, delete', uselist=False) + fin_state_type = db.relationship('StateType', foreign_keys=[state_type], + back_populates='financing_statement', cascade='all, delete', uselist=False) # Use to indicate if a party or collateral is not in the original financing statement. mark_update_json = False @@ -97,20 +87,20 @@ class FinancingTypes(Enum): def json(self) -> dict: """Return the financing statement as a json object.""" statement = { - 'statusType': self.state_type_cd + 'statusType': self.state_type } - if self.state_type_cd == 'HDC': + if self.state_type == 'HDC': index = len(self.registration) - 1 statement['dischargedDateTime'] = model_utils.format_ts(self.registration[index].registration_ts) if self.registration and self.registration[0]: reg = self.registration[0] - registration_id = reg.registration_id - statement['type'] = reg.registration_type_cd + registration_id = reg.id + statement['type'] = reg.registration_type statement['baseRegistrationNumber'] = reg.registration_num if reg.registration_type: - statement['registrationDescription'] = reg.registration_type.registration_desc - statement['registrationAct'] = reg.registration_type.registration_act + statement['registrationDescription'] = reg.reg_type.registration_desc + statement['registrationAct'] = reg.reg_type.registration_act statement['createDateTime'] = model_utils.format_ts(reg.registration_ts) @@ -132,7 +122,7 @@ def json(self) -> dict: if vehicle_collateral: statement['vehicleCollateral'] = vehicle_collateral - if reg.registration_type_cd == model_utils.REG_TYPE_REPAIRER_LIEN: + if reg.registration_type == model_utils.REG_TYPE_REPAIRER_LIEN: if reg.lien_value: statement['lienAmount'] = reg.lien_value if reg.surrender_date: @@ -157,7 +147,7 @@ def json(self) -> dict: statement['expiryDate'] = model_utils.format_ts(self.expire_date) self.set_court_order_json(statement) - return statement + return self.set_changes_json(statement) def set_court_order_json(self, statement): """Add court order info to the statement json if generating the current view and court order info exists.""" @@ -166,11 +156,24 @@ def set_court_order_json(self, statement): if registration.court_order: statement['courtOrderInformation'] = registration.court_order.json + def set_changes_json(self, statement): + """Add history of changes in reverse chronological order to financing statement json.""" + if self.registration and len(self.registration) > 1: + changes = [] + for reg in reversed(self.registration): + if reg.registration_type_cl not in ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN'): + statement_json = reg.json + statement_json['statementType'] = \ + model_utils.REG_CLASS_TO_STATEMENT_TYPE[reg.registration_type_cl] + changes.append(statement_json) + statement['changes'] = changes + return statement + def party_json(self, party_type, registration_id): """Build party JSON: current_view_json determines if current or original data is included.""" if party_type == Party.PartyTypes.REGISTERING_PARTY.value: for party in self.parties: - if party.party_type_cd == party_type and registration_id == party.registration_id: + if party.party_type == party_type and registration_id == party.registration_id: return party.json # No registering party record: legacy data. return {} @@ -178,9 +181,9 @@ def party_json(self, party_type, registration_id): parties = [] for party in self.parties: party_json = None - if party.party_type_cd == party_type or \ + if party.party_type == party_type or \ (party_type == Party.PartyTypes.DEBTOR_COMPANY.value and - party.party_type_cd == Party.PartyTypes.DEBTOR_INDIVIDUAL.value): + party.party_type == Party.PartyTypes.DEBTOR_INDIVIDUAL.value): if not self.current_view_json and party.registration_id == registration_id: party_json = party.json elif self.current_view_json and not party.registration_id_end: @@ -257,7 +260,7 @@ def validate_base_debtor(self, base_debtor_json, staff: bool = False): if self.parties: for party in self.parties: - if (party.party_type_cd == 'DB' or party.party_type_cd == 'DI') and \ + if (party.party_type == 'DB' or party.party_type == 'DI') and \ not party.registration_id_end: if bus_name and party.business_name and \ bus_name == party.business_name.upper(): @@ -265,8 +268,8 @@ def validate_base_debtor(self, base_debtor_json, staff: bool = False): else: last_match = (last and party.last_name and last == party.last_name.upper()) first_match = (first and party.first_name and first == party.first_name.upper()) - middle_match = (not middle and not party.middle_name) or \ - (middle and party.middle_name and middle == party.middle_name.upper()) + middle_match = (not middle and not party.middle_initial) or \ + (middle and party.middle_initial and middle == party.middle_initial.upper()) if last_match and first_match and middle_match: valid = True @@ -277,9 +280,8 @@ def save(self): db.session.add(self) db.session.commit() - # Now save draft.registration_id + # Now save draft draft = self.registration[0].draft - draft.registration_id = self.registration[0].registration_id db.session.add(draft) db.session.commit() @@ -292,23 +294,23 @@ def find_all_by_account_id(cls, account_id: str = None, staff: bool = False): if staff: statement_list = db.session.query(Registration.registration_ts, Registration.registration_num, - Registration.registration_type_cd, - FinancingStatement.state_type_cd).\ - filter(FinancingStatement.financing_id == Registration.financing_id, + Registration.registration_type, + FinancingStatement.state_type).\ + filter(FinancingStatement.id == Registration.financing_id, Registration.account_id == account_id, Registration.registration_type_cl.in_(['PPSALIEN', 'MISCLIEN', 'CROWNLIEN'])).\ - order_by(FinancingStatement.financing_id).all() + order_by(FinancingStatement.id).all() else: days_ago = model_utils.now_ts_offset(10, False) statement_list = db.session.query(Registration.registration_ts, Registration.registration_num, - Registration.registration_type_cd, - FinancingStatement.state_type_cd).\ - filter(FinancingStatement.financing_id == Registration.financing_id, + Registration.registration_type, + FinancingStatement.state_type).\ + filter(FinancingStatement.id == Registration.financing_id, Registration.account_id == account_id, Registration.registration_type_cl.in_(['PPSALIEN', 'MISCLIEN', 'CROWNLIEN']), Registration.registration_ts > days_ago).\ - order_by(FinancingStatement.financing_id).all() + order_by(FinancingStatement.id).all() results_json = [] if not statement_list: @@ -319,12 +321,12 @@ def find_all_by_account_id(cls, account_id: str = None, staff: bool = False): # ) for statement in statement_list: - if staff or statement.state_type_cd == model_utils.STATE_ACTIVE: + if staff or statement.state_type == model_utils.STATE_ACTIVE: statement_json = { 'matchType': 'EXACT', 'createDateTime': model_utils.format_ts(statement.registration_ts), 'baseRegistrationNumber': statement.registration_num, - 'registrationType': statement.registration_type_cd + 'registrationType': statement.registration_type } results_json.append(statement_json) @@ -341,9 +343,8 @@ def find_by_id(cls, financing_id: int = None): """Return a financing statement object by financing ID.""" statement = None if financing_id: - # statement = cls.query.get(financing_id) statement = db.session.query(FinancingStatement).\ - filter(FinancingStatement.financing_id == financing_id).one_or_none() + filter(FinancingStatement.id == financing_id).one_or_none() return statement @@ -354,11 +355,8 @@ def find_by_registration_number(cls, registration_num: str = None, """Return a financing statement by registration number.""" statement = None if registration_num: - # statement = cls.query.filter(FinancingStatement.financing_id == Registration.financing_id, - # Registration.registration_num == registration_num, - # Registration.registration_type_cl.in_(['PPSALIEN', 'MISCLIEN'])).one_or_none() statement = db.session.query(FinancingStatement).\ - filter(FinancingStatement.financing_id == Registration.financing_id, + filter(FinancingStatement.id == Registration.financing_id, Registration.registration_num == registration_num, Registration.registration_type_cl.in_(['PPSALIEN', 'MISCLIEN', 'CROWNLIEN'])).\ one_or_none() @@ -369,7 +367,7 @@ def find_by_registration_number(cls, registration_num: str = None, status_code=HTTPStatus.NOT_FOUND ) - if not allow_historical and not staff and statement.state_type_cd != model_utils.STATE_ACTIVE: + if not allow_historical and not staff and statement.state_type != model_utils.STATE_ACTIVE: raise BusinessException( error=f'The Financing Statement for registration number {registration_num} has been discharged.', status_code=HTTPStatus.BAD_REQUEST @@ -382,22 +380,20 @@ def find_by_financing_id(cls, financing_id: int = None): """Return a financing statement by financing statement ID.""" statement = None if financing_id: - # statement = cls.query.filter(FinancingStatement.financing_id == Registration.financing_id, - # FinancingStatement.financing_id == financing_id).one_or_none() statement = db.session.query(FinancingStatement).\ - filter(FinancingStatement.financing_id == Registration.financing_id, - FinancingStatement.financing_id == financing_id).one_or_none() + filter(FinancingStatement.id == Registration.financing_id, + FinancingStatement.id == financing_id).one_or_none() return statement @staticmethod def create_from_json(json_data, account_id: str): - """Create a draft object from a json Draft schema object: map json to db.""" + """Create a financing statement object from a json Financing Statement schema object: map json to db.""" # Perform all addtional data validation checks. FinancingStatement.validate(json_data) statement = FinancingStatement() - statement.state_type_cd = model_utils.STATE_ACTIVE + statement.state_type = model_utils.STATE_ACTIVE # Do this early as it also checks the party codes and may throw an exception statement.parties = Party.create_from_financing_json(json_data, None) @@ -417,8 +413,8 @@ def create_from_json(json_data, account_id: str): statement.expire_date = model_utils.expiry_ts_from_iso_format(json_data['expiryDate']) statement.registration = [Registration.create_financing_from_json(json_data, account_id)] - statement.registration_num = statement.registration[0].registration_num - registration_id = statement.registration[0].registration_id + # statement.registration_num = statement.registration[0].registration_num + registration_id = statement.registration[0].id statement.trust_indenture = TrustIndenture.create_from_json(json_data, registration_id) if 'vehicleCollateral' in json_data: statement.vehicle_collateral = VehicleCollateral.create_from_financing_json(json_data, registration_id) diff --git a/ppr-api/src/ppr_api/models/general_collateral.py b/ppr-api/src/ppr_api/models/general_collateral.py index 294ba7e59..40bd6925f 100644 --- a/ppr-api/src/ppr_api/models/general_collateral.py +++ b/ppr-api/src/ppr_api/models/general_collateral.py @@ -22,19 +22,16 @@ class GeneralCollateral(db.Model): # pylint: disable=too-many-instance-attribut __tablename__ = 'general_collateral' -# collateral_id = db.Column('general_collateral_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - collateral_id = db.Column('general_collateral_id', db.Integer, - db.Sequence('general_id_seq'), - primary_key=True) + id = db.Column('id', db.Integer, db.Sequence('general_id_seq'), primary_key=True) description = db.Column('description', db.String(4000), nullable=False) # Legacy only status = db.Column('status', db.String(1), nullable=True) # parent keys registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=False) + db.ForeignKey('registrations.id'), nullable=False) financing_id = db.Column('financing_id', db.Integer, - db.ForeignKey('financing_statement.financing_id'), nullable=False) + db.ForeignKey('financing_statements.id'), nullable=False) registration_id_end = db.Column('registration_id_end', db.Integer, nullable=True) # db.ForeignKey('registration.registration_id'), nullable=True) @@ -50,7 +47,7 @@ class GeneralCollateral(db.Model): # pylint: disable=too-many-instance-attribut def json(self) -> dict: """Return the genreal collateral as a json object.""" return { - 'collateralId': self.collateral_id, + 'collateralId': self.id, 'description': self.description } @@ -69,7 +66,7 @@ def find_by_registration_id(cls, registration_id: int = None): collateral = None if registration_id: collateral = cls.query.filter(GeneralCollateral.registration_id == registration_id) \ - .order_by(GeneralCollateral.collateral_id).all() + .order_by(GeneralCollateral.id).all() return collateral @@ -79,7 +76,7 @@ def find_by_financing_id(cls, financing_id: int = None): collateral = None if financing_id: collateral = cls.query.filter(GeneralCollateral.financing_id == financing_id) \ - .order_by(GeneralCollateral.collateral_id).all() + .order_by(GeneralCollateral.id).all() return collateral diff --git a/ppr-api/src/ppr_api/models/nickname.py b/ppr-api/src/ppr_api/models/nickname.py new file mode 100644 index 000000000..2130344ca --- /dev/null +++ b/ppr-api/src/ppr_api/models/nickname.py @@ -0,0 +1,51 @@ +# Copyright © 2019 Province of British Columbia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""This module holds data for the debtor individual name search nickname table.""" + +from .db import db + + +class Nickname(db.Model): + """This class manages all of name search nicknames referenced by a database function. Managed by Alembic.""" + + __tablename__ = 'nicknames' + + name_id = db.Column('name_id', db.Integer, nullable=False, index=True) + name = db.Column('name', db.String(25), nullable=False, index=True) + + # parent keys + + # relationships + + def save(self): + """Save the object to the database immediately. Only used for unit testing.""" + db.session.add(self) + db.session.commit() + + @classmethod + def find_by_id(cls, name_id: int): + """Return the nickname matching the id.""" + nickname = None + if name_id: + nickname = cls.query.get(name_id) + return nickname + + @property + def json(self): + """Return a dict of this object, with keys in JSON format.""" + nickname = { + 'name_id': self.name_id, + 'name': self.name + } + return nickname diff --git a/ppr-api/src/ppr_api/models/party.py b/ppr-api/src/ppr_api/models/party.py index 752dd23f2..5b4d9f176 100644 --- a/ppr-api/src/ppr_api/models/party.py +++ b/ppr-api/src/ppr_api/models/party.py @@ -25,9 +25,9 @@ from .client_code import ClientCode # noqa: F401 pylint: disable=unused-import -BUS_SEARCH_KEY_SP = "select search_key_pkg.businame('?') from dual" -FIRST_NAME_KEY_SP = "select search_key_pkg.firstname('?') from dual" -LAST_NAME_KEY_SP = "select search_key_pkg.lastname('?') from dual" +BUS_SEARCH_KEY_SP = "select searchkey_business_name('?')" +FIRST_NAME_KEY_SP = "select searchkey_first_name('?')" +LAST_NAME_KEY_SP = "select searchkey_last_name('?')" class Party(db.Model): # pylint: disable=too-many-instance-attributes @@ -41,15 +41,13 @@ class PartyTypes(Enum): REGISTERING_PARTY = 'RG' SECURED_PARTY = 'SP' - __tablename__ = 'party' + __tablename__ = 'parties' - -# party_id = db.Column('party_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - party_id = db.Column('party_id', db.Integer, db.Sequence('party_id_seq'), primary_key=True) - party_type_cd = db.Column('party_type_cd', db.String(3), db.ForeignKey('party_type.party_type_cd'), nullable=False) + id = db.Column('id', db.Integer, db.Sequence('party_id_seq'), primary_key=True) + party_type = db.Column('party_type', db.String(30), db.ForeignKey('party_types.party_type'), nullable=False) # party person first_name = db.Column('first_name', db.String(50), nullable=True) - middle_name = db.Column('middle_name', db.String(50), nullable=True) + middle_initial = db.Column('middle_initial', db.String(50), nullable=True) last_name = db.Column('last_name', db.String(50), nullable=True) # or party business business_name = db.Column('business_name', db.String(150), index=True, nullable=True) @@ -58,16 +56,12 @@ class PartyTypes(Enum): first_name_key = db.Column('first_name_key', db.String(50), nullable=True, index=True) last_name_key = db.Column('last_name_key', db.String(50), nullable=True, index=True) business_search_key = db.Column('business_srch_key', db.String(150), nullable=True, index=True) - # Legacy only - block_number = db.Column('block_number', db.Integer, nullable=True) # parent keys - address_id = db.Column('address_id', db.Integer, db.ForeignKey('address_ppr.address_id'), nullable=True) - branch_id = db.Column('branch_id', db.Integer, db.ForeignKey('client_code.branch_id'), nullable=True) - registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=False) - financing_id = db.Column('financing_id', db.Integer, - db.ForeignKey('financing_statement.financing_id'), nullable=False) + address_id = db.Column('address_id', db.Integer, db.ForeignKey('addresses.id'), nullable=True) + branch_id = db.Column('branch_id', db.Integer, db.ForeignKey('client_codes.id'), nullable=True) + registration_id = db.Column('registration_id', db.Integer, db.ForeignKey('registrations.id'), nullable=False) + financing_id = db.Column('financing_id', db.Integer, db.ForeignKey('financing_statements.id'), nullable=False) registration_id_end = db.Column('registration_id_end', db.Integer, nullable=True) # db.ForeignKey('registration.registration_id'), nullable=True) @@ -87,16 +81,16 @@ class PartyTypes(Enum): back_populates='parties', cascade='all, delete', uselist=False) # Relationships - PartyType - party_type = db.relationship('PartyType', foreign_keys=[party_type_cd], - back_populates='party', cascade='all, delete', uselist=False) + party_types = db.relationship('PartyType', foreign_keys=[party_type], + back_populates='party', cascade='all, delete', uselist=False) @property def json(self) -> dict: """Return the party as a json object.""" party = { } - if self.party_type_cd != model_utils.PARTY_REGISTERING: - party['partyId'] = self.party_id + if self.party_type != model_utils.PARTY_REGISTERING: + party['partyId'] = self.id if self.client_code and self.branch_id: party['code'] = str(self.branch_id) @@ -117,8 +111,8 @@ def json(self) -> dict: 'first': self.first_name, 'last': self.last_name } - if self.middle_name: - person_name['middle'] = self.middle_name + if self.middle_initial: + person_name['middle'] = self.middle_initial party['personName'] = person_name if self.address: @@ -137,8 +131,8 @@ def json(self) -> dict: def name(self) -> str: """Return the full name of the party for comparison.""" if self.last_name: - if self.middle_name: - return ' '.join((self.first_name, self.middle_name, self.last_name)).strip().upper() + if self.middle_initial: + return ' '.join((self.first_name, self.middle_initial, self.last_name)).strip().upper() return ' '.join((self.first_name, self.last_name)).strip().upper() return self.business_name.strip().upper() @@ -157,7 +151,7 @@ def find_by_registration_id(cls, registration_id: int = None): parties = None if registration_id: parties = cls.query.filter(Party.registration_id == registration_id) \ - .order_by(Party.party_id).all() + .order_by(Party.id).all() return parties @@ -167,7 +161,7 @@ def find_by_financing_id(cls, financing_id: int = None): parties = None if financing_id: parties = cls.query.filter(Party.financing_id == financing_id) \ - .order_by(Party.party_id).all() + .order_by(Party.id).all() return parties @@ -176,11 +170,11 @@ def create_from_json(json_data, party_type: str, registration_id: int = None): """Create a party object from a json schema object: map json to db.""" party = Party() if party_type != model_utils.PARTY_DEBTOR_BUS: - party.party_type_cd = party_type + party.party_type = party_type elif 'businessName' in json_data: - party.party_type_cd = party_type + party.party_type = party_type else: - party.party_type_cd = model_utils.PARTY_DEBTOR_IND + party.party_type = model_utils.PARTY_DEBTOR_IND if party_type != model_utils.PARTY_DEBTOR_BUS and 'code' in json_data: party.branch_id = int(json_data['code']) @@ -193,7 +187,7 @@ def create_from_json(json_data, party_type: str, registration_id: int = None): party.last_name = json_data['personName']['last'].strip().upper() party.first_name = json_data['personName']['first'].strip().upper() if 'middle' in json_data['personName']: - party.middle_name = json_data['personName']['middle'].strip().upper() + party.middle_initial = json_data['personName']['middle'].strip().upper() # if 'emailAddress' in json_data: # party.email_id = json_data['emailAddress'] @@ -270,10 +264,10 @@ def verify_party_code(code: str): @event.listens_for(Party, 'before_insert') def party_before_insert_listener(mapper, connection, target): # pylint: disable=unused-argument; don't use mapper """Conditionally set debtor search key values.""" - if target.party_type_cd == target.PartyTypes.DEBTOR_COMPANY.value: + if target.party_type == target.PartyTypes.DEBTOR_COMPANY.value: sp_call = BUS_SEARCH_KEY_SP.replace('?', target.business_name) target.business_search_key = connection.scalar(sp_call) - elif target.party_type_cd == target.PartyTypes.DEBTOR_INDIVIDUAL.value: + elif target.party_type == target.PartyTypes.DEBTOR_INDIVIDUAL.value: sp_call_firstname = FIRST_NAME_KEY_SP.replace('?', target.first_name) sp_call_lastname = LAST_NAME_KEY_SP.replace('?', target.last_name) target.first_name_key = connection.scalar(sp_call_firstname) diff --git a/ppr-api/src/ppr_api/models/registration.py b/ppr-api/src/ppr_api/models/registration.py index 2eea22b07..65c580a36 100644 --- a/ppr-api/src/ppr_api/models/registration.py +++ b/ppr-api/src/ppr_api/models/registration.py @@ -43,14 +43,10 @@ class RegistrationTypes(Enum): REG_CLASS_DISCHARGE = 'DISCHARGE' REG_CLASS_RENEWAL = 'RENEWAL' - __tablename__ = 'registration' + __tablename__ = 'registrations' -# registration_id = db.Column('registration_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) -# registration_id = db.Column('registration_id', db.Integer, db.Sequence('registration_id_seq'), primary_key=True) # Always use get_generated_values() to generate PK. - registration_id = db.Column('registration_id', db.Integer, primary_key=True) - registration_type_cl = db.Column('registration_type_cl', db.String(10), nullable=False) -# db.ForeignKey('registration_type.registration_type_class')) + id = db.Column('id', db.Integer, primary_key=True) registration_ts = db.Column('registration_ts', db.DateTime, nullable=False, index=True) registration_num = db.Column('registration_number', db.String(10), nullable=False, index=True, default=db.func.get_registration_num()) @@ -66,30 +62,30 @@ class RegistrationTypes(Enum): user_id = db.Column('user_id', db.String(1000), nullable=True) detail_description = db.Column('detail_description', db.String(180), nullable=True) - sp_number = db.Column('sp_number', db.Integer, nullable=True) - de_number = db.Column('de_number', db.Integer, nullable=True) - ve_number = db.Column('ve_number', db.Integer, nullable=True) # parent keys financing_id = db.Column('financing_id', db.Integer, - db.ForeignKey('financing_statement.financing_id'), nullable=False) - document_number = db.Column('document_number', db.String(10), - db.ForeignKey('draft.document_number'), nullable=False) - registration_type_cd = db.Column('registration_type_cd', db.String(2), - db.ForeignKey('registration_type.registration_type_cd'), nullable=False) + db.ForeignKey('financing_statements.id'), nullable=False) + draft_id = db.Column('draft_id', db.Integer, db.ForeignKey('drafts.id'), nullable=False) + registration_type = db.Column('registration_type', db.String(2), + db.ForeignKey('registration_types.registration_type'), nullable=False) + registration_type_cl = db.Column('registration_type_cl', db.String(10), + db.ForeignKey('registration_type_classes.registration_type_cl'), nullable=False) # relationships financing_statement = db.relationship('FinancingStatement', foreign_keys=[financing_id], back_populates='registration', cascade='all, delete', uselist=False) - registration_type = db.relationship('RegistrationType', foreign_keys=[registration_type_cd], - back_populates='registration', cascade='all, delete', uselist=False) + reg_type = db.relationship('RegistrationType', foreign_keys=[registration_type], + back_populates='registration', cascade='all, delete', uselist=False) parties = db.relationship('Party', back_populates='registration') general_collateral = db.relationship('GeneralCollateral', back_populates='registration') vehicle_collateral = db.relationship('VehicleCollateral', back_populates='registration') - draft = db.relationship('Draft', foreign_keys=[document_number], uselist=False) + draft = db.relationship('Draft', foreign_keys=[draft_id], uselist=False) trust_indenture = db.relationship('TrustIndenture', back_populates='registration', uselist=False) court_order = db.relationship('CourtOrder', back_populates='registration', uselist=False) + document_number: str = None + @property def json(self) -> dict: """Return the registration as a json object.""" @@ -97,37 +93,37 @@ def json(self) -> dict: 'baseRegistrationNumber': self.base_registration_num, 'createDateTime': model_utils.format_ts(self.registration_ts) } - if self.registration_type_cd == model_utils.REG_TYPE_DISCHARGE: + if self.registration_type == model_utils.REG_TYPE_DISCHARGE: registration['dischargeRegistrationNumber'] = self.registration_num - elif self.registration_type_cd == model_utils.REG_TYPE_RENEWAL: + elif self.registration_type == model_utils.REG_TYPE_RENEWAL: registration['renewalRegistrationNumber'] = self.registration_num - elif self.registration_type_cd in (model_utils.REG_TYPE_AMEND, model_utils.REG_TYPE_AMEND_COURT): + elif self.registration_type in (model_utils.REG_TYPE_AMEND, model_utils.REG_TYPE_AMEND_COURT): registration['amendmentRegistrationNumber'] = self.registration_num if self.detail_description: registration['description'] = self.detail_description else: registration['changeRegistrationNumber'] = self.registration_num -# if self.registration_type_cd != model_utils.REG_TYPE_DISCHARGE and \ -# self.registration_type_cd != model_utils.REG_TYPE_RENEWAL: -# registration['documentId'] = self.document_number +# if self.draft and self.registration_type != model_utils.REG_TYPE_DISCHARGE and \ +# self.registration_type != model_utils.REG_TYPE_RENEWAL: +# registration['documentId'] = self.draft.document_number if self.registration_type_cl in (model_utils.REG_CLASS_AMEND, model_utils.REG_CLASS_AMEND_COURT, model_utils.REG_CLASS_CHANGE): - registration['changeType'] = self.registration_type_cd + registration['changeType'] = self.registration_type if self.client_reference_id: registration['clientReferenceId'] = self.client_reference_id - registration_id = self.registration_id + registration_id = self.id if self.parties: for party in self.parties: - if party.party_type_cd == model_utils.PARTY_REGISTERING and \ + if party.party_type == model_utils.PARTY_REGISTERING and \ party.registration_id == registration_id: registration['registeringParty'] = party.json - if self.registration_type_cd == model_utils.REG_TYPE_RENEWAL and \ + if self.registration_type == model_utils.REG_TYPE_RENEWAL and \ self.financing_statement.expire_date: registration['expiryDate'] = model_utils.format_ts(self.financing_statement.expire_date) if self.life is not None: @@ -144,10 +140,10 @@ def json(self) -> dict: secured = [] debtors = [] for party in self.parties: - if party.party_type_cd in (model_utils.PARTY_DEBTOR_BUS, model_utils.PARTY_DEBTOR_IND) and \ + if party.party_type in (model_utils.PARTY_DEBTOR_BUS, model_utils.PARTY_DEBTOR_IND) and \ party.registration_id == registration_id: debtors.append(party.json) - elif party.party_type_cd == model_utils.PARTY_SECURED and party.registration_id == registration_id: + elif party.party_type == model_utils.PARTY_SECURED and party.registration_id == registration_id: secured.append(party.json) if debtors: @@ -163,10 +159,10 @@ def json(self) -> dict: secured = [] debtors = [] for party in self.financing_statement.parties: - if party.party_type_cd in (model_utils.PARTY_DEBTOR_BUS, model_utils.PARTY_DEBTOR_IND) and \ + if party.party_type in (model_utils.PARTY_DEBTOR_BUS, model_utils.PARTY_DEBTOR_IND) and \ party.registration_id_end == registration_id: debtors.append(party.json) - elif party.party_type_cd == model_utils.PARTY_SECURED and party.registration_id_end == registration_id: + elif party.party_type == model_utils.PARTY_SECURED and party.registration_id_end == registration_id: secured.append(party.json) if debtors: @@ -229,9 +225,8 @@ def save(self): db.session.add(self) db.session.commit() - # Now save draft.registration_id + # Now save draft draft = self.draft - draft.registration_id = self.registration_id db.session.add(draft) db.session.commit() @@ -266,35 +261,33 @@ def create_from_json(json_data, draft = Registration.find_draft(json_data, None, None) reg_vals = Registration.get_generated_values(draft) registration = Registration() - registration.registration_id = reg_vals.registration_id + registration.id = reg_vals.id # pylint: disable=invalid-name; allow name of id. registration.registration_num = reg_vals.registration_num registration.registration_ts = model_utils.now_ts() - registration.financing_id = financing_statement.financing_id + registration.financing_id = financing_statement.id registration.financing_statement = financing_statement registration.account_id = account_id if not draft: registration.document_number = reg_vals.document_number draft = Draft.create_from_registration(registration, json_data) - else: - registration.document_number = draft.document_number registration.draft = draft registration.registration_type_cl = registration_type_cl if registration_type_cl in (model_utils.REG_CLASS_AMEND, model_utils.REG_CLASS_AMEND_COURT, model_utils.REG_CLASS_CHANGE): - registration.registration_type_cd = json_data['changeType'] - if registration.registration_type_cd == model_utils.REG_TYPE_AMEND_COURT: + registration.registration_type = json_data['changeType'] + if registration.registration_type == model_utils.REG_TYPE_AMEND_COURT: registration.registration_type_cl = model_utils.REG_CLASS_AMEND_COURT if 'description' in json_data: registration.detail_description = json_data['description'] if registration_type_cl == model_utils.REG_CLASS_RENEWAL: - registration.registration_type_cd = model_utils.REG_TYPE_RENEWAL + registration.registration_type = model_utils.REG_TYPE_RENEWAL elif registration_type_cl == model_utils.REG_CLASS_DISCHARGE: - registration.registration_type_cd = model_utils.REG_TYPE_DISCHARGE + registration.registration_type = model_utils.REG_TYPE_DISCHARGE registration.base_registration_num = base_registration_num registration.ver_bypassed = 'Y' - registration.draft.registration_type_cd = registration.registration_type_cd + registration.draft.registration_type = registration.registration_type registration.draft.registration_type_cl = registration.registration_type_cl if 'clientReferenceId' in json_data: @@ -306,10 +299,10 @@ def create_from_json(json_data, registration.financing_id) # If get to here all data should be valid: get reg id to close out updated entities. - registration_id = registration.registration_id - financing_reg_type = registration.financing_statement.registration[0].registration_type_cd + registration_id = registration.id + financing_reg_type = registration.financing_statement.registration[0].registration_type if registration_type_cl == model_utils.REG_CLASS_DISCHARGE: - registration.financing_statement.state_type_cd = model_utils.STATE_DISCHARGED + registration.financing_statement.state_type = model_utils.STATE_DISCHARGED registration.financing_statement.discharged = 'Y' elif registration_type_cl == model_utils.REG_CLASS_RENEWAL: if financing_reg_type == model_utils.REG_TYPE_REPAIRER_LIEN: @@ -317,6 +310,9 @@ def create_from_json(json_data, registration.financing_statement.expire_date = \ model_utils.now_ts_offset(model_utils.REPAIRER_LIEN_DAYS, True) else: + if 'lifeInfinite' in json_data and json_data['lifeInfinite']: + registration.life = model_utils.LIFE_INFINITE + registration.financing_statement.expire_date = None if 'lifeYears' in json_data: registration.life = json_data['lifeYears'] registration.financing_statement.expire_date = model_utils.expiry_dt_from_years(registration.life) @@ -329,8 +325,8 @@ def create_from_json(json_data, registration.financing_statement.life = registration.life # Repairer's lien renewal or amendment can have court order information. - if (registration.registration_type_cd == model_utils.REG_TYPE_AMEND_COURT or - registration.registration_type_cd == model_utils.REG_TYPE_RENEWAL) and \ + if (registration.registration_type == model_utils.REG_TYPE_AMEND_COURT or + registration.registration_type == model_utils.REG_TYPE_RENEWAL) and \ 'courtOrderInformation' in json_data: registration.court_order = CourtOrder.create_from_json(json_data['courtOrderInformation'], registration_id) @@ -359,7 +355,7 @@ def create_financing_from_json(json_data, account_id: str = None): registration.registration_ts = model_utils.now_ts() reg_type = json_data['type'] registration.registration_type_cl = model_utils.REG_TYPE_TO_REG_CLASS[reg_type] - registration.registration_type_cd = reg_type + registration.registration_type = reg_type registration.ver_bypassed = 'Y' if reg_type == model_utils.REG_TYPE_REPAIRER_LIEN: @@ -379,13 +375,11 @@ def create_financing_from_json(json_data, account_id: str = None): # Create or update draft. draft = Registration.find_draft(json_data, registration.registration_type_cl, reg_type) reg_vals = Registration.get_generated_values(draft) - registration.registration_id = reg_vals.registration_id + registration.id = reg_vals.id registration.registration_num = reg_vals.registration_num if not draft: registration.document_number = reg_vals.document_number draft = Draft.create_from_registration(registration, json_data) - else: - registration.document_number = draft.document_number registration.draft = draft return registration @@ -399,7 +393,7 @@ def delete_from_json(json_data, registration, financing_statement): model_utils.PARTY_DEBTOR_BUS, financing_statement.parties) if existing: - existing.registration_id_end = registration.registration_id + existing.registration_id_end = registration.id if 'deleteSecuredParties' in json_data and json_data['deleteSecuredParties']: for party in json_data['deleteSecuredParties']: @@ -407,21 +401,21 @@ def delete_from_json(json_data, registration, financing_statement): model_utils.PARTY_SECURED, financing_statement.parties) if existing: - existing.registration_id_end = registration.registration_id + existing.registration_id_end = registration.id if 'deleteGeneralCollateral' in json_data and json_data['deleteGeneralCollateral']: for gen_c in json_data['deleteGeneralCollateral']: collateral = Registration.find_general_collateral_by_id(gen_c['collateralId'], financing_statement.general_collateral) if collateral: - collateral.registration_id_end = registration.registration_id + collateral.registration_id_end = registration.id if 'deleteVehicleCollateral' in json_data and json_data['deleteVehicleCollateral']: for vehicle_c in json_data['deleteVehicleCollateral']: collateral = Registration.find_vehicle_collateral_by_id(vehicle_c['vehicleId'], financing_statement.vehicle_collateral) if collateral: - collateral.registration_id_end = registration.registration_id + collateral.registration_id_end = registration.id @staticmethod def validate(json_data, financing_statement, registration_type_cl: str): @@ -520,11 +514,11 @@ def find_party_by_id(party_id: int, party_type: str, parties): if party_id and party_type and parties: for eval_party in parties: - if eval_party.party_id == party_id and party_type == eval_party.party_type_cd and \ + if eval_party.id == party_id and party_type == eval_party.party_type and \ not eval_party.registration_id_end: party = eval_party - elif eval_party.party_id == party_id and party_type == model_utils.PARTY_DEBTOR_BUS and \ - eval_party.party_type_cd == model_utils.PARTY_DEBTOR_IND and \ + elif eval_party.id == party_id and party_type == model_utils.PARTY_DEBTOR_BUS and \ + eval_party.party_type == model_utils.PARTY_DEBTOR_IND and \ not eval_party.registration_id_end: party = eval_party @@ -537,7 +531,7 @@ def find_vehicle_collateral_by_id(vehicle_id: int, vehicle_collateral): if vehicle_id and vehicle_collateral: for v_collateral in vehicle_collateral: - if v_collateral.vehicle_id == vehicle_id and not v_collateral.registration_id_end: + if v_collateral.id == vehicle_id and not v_collateral.registration_id_end: collateral = v_collateral return collateral @@ -549,7 +543,7 @@ def find_general_collateral_by_id(collateral_id: int, general_collateral): if collateral_id and general_collateral: for g_collateral in general_collateral: - if g_collateral.collateral_id == collateral_id and not g_collateral.registration_id_end: + if g_collateral.id == collateral_id and not g_collateral.registration_id_end: collateral = g_collateral return collateral @@ -571,7 +565,7 @@ def find_draft(json_data, registration_class: str, registration_type: str): draft.document_number = doc_id draft.draft = json.dumps(json_data) draft.registration_type_cl = registration_class - draft.registration_type_cd = registration_type + draft.registration_type = registration_type except BusinessException: draft = None @@ -586,14 +580,14 @@ def get_generated_values(draft): registration = Registration() # generate reg id, reg number. If not existing draft also generate doc number - query = 'select registration_id_seq.nextval, get_registration_num(), get_draft_document_number() from dual' + query = "select nextval('registration_id_seq'), get_registration_num(), get_draft_document_number()" if draft: - query = 'select registration_id_seq.nextval, get_registration_num() from dual' + query = "select nextval('registration_id_seq'), get_registration_num()" result = db.session.execute(query) row = result.first() values = row.values() - registration.registration_id = int(values[0]) + registration.id = int(values[0]) registration.registration_num = str(values[1]) if not draft: registration.document_number = str(values[2]) diff --git a/ppr-api/src/ppr_api/models/search_client.py b/ppr-api/src/ppr_api/models/search_request.py similarity index 86% rename from ppr-api/src/ppr_api/models/search_client.py rename to ppr-api/src/ppr_api/models/search_request.py index 327d7c8c0..49c5abdfa 100644 --- a/ppr-api/src/ppr_api/models/search_client.py +++ b/ppr-api/src/ppr_api/models/search_request.py @@ -20,7 +20,6 @@ from enum import Enum from http import HTTPStatus -import json from flask import current_app @@ -31,7 +30,7 @@ from .db import db -class SearchClient(db.Model): # pylint: disable=too-many-instance-attributes +class SearchRequest(db.Model): # pylint: disable=too-many-instance-attributes """This class maintains search query (search step 1) information.""" class SearchTypes(Enum): @@ -44,16 +43,15 @@ class SearchTypes(Enum): SERIAL_NUM = 'SS' MANUFACTURED_HOME_NUM = 'MH' - __tablename__ = 'search_client' + __tablename__ = 'search_requests' -# search_id = db.Column('search_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - search_id = db.Column('search_id', db.Integer, db.Sequence('search_id_seq'), primary_key=True) + id = db.Column('id', db.Integer, db.Sequence('search_id_seq'), primary_key=True) search_ts = db.Column('search_ts', db.DateTime, nullable=False, index=True) - search_type_cd = db.Column('search_type_cd', db.String(2), - db.ForeignKey('search_type.search_type_cd'), nullable=False) - search_criteria = db.Column('api_criteria', db.String(1000), nullable=False) - search_response = db.Column('search_response', db.Text, nullable=True) + search_type = db.Column('search_type', db.String(2), + db.ForeignKey('search_types.search_type'), nullable=False) + search_criteria = db.Column('api_criteria', db.JSON, nullable=False) + search_response = db.Column('search_response', db.JSON, nullable=True) account_id = db.Column('account_id', db.String(20), nullable=True, index=True) client_reference_id = db.Column('client_reference_id', db.String(20), nullable=True) total_results_size = db.Column('total_results_size', db.Integer, nullable=True) @@ -67,8 +65,8 @@ class SearchTypes(Enum): # Relationships - SearchResult search_result = db.relationship('SearchResult', back_populates='search', uselist=False) # Relationships - SearchType - search_type = db.relationship('SearchType', foreign_keys=[search_type_cd], - back_populates='search_client', cascade='all, delete', uselist=False) + search_request_type = db.relationship('SearchType', foreign_keys=[search_type], + back_populates='search_request', cascade='all, delete', uselist=False) request_json = {} @@ -76,15 +74,15 @@ class SearchTypes(Enum): def json(self) -> dict: """Return the search query results as a json object.""" result = { - 'searchId': str(self.search_id), + 'searchId': str(self.id), 'searchDateTime': model_utils.format_ts(self.search_ts), 'totalResultsSize': self.total_results_size, 'returnedResultsSize': self.returned_results_size, 'maxResultsSize': search_utils.SEARCH_RESULTS_MAX_SIZE, - 'searchQuery': json.loads(self.search_criteria) + 'searchQuery': self.search_criteria } if self.search_response: - result['results'] = json.loads(self.search_response) + result['results'] = self.search_response if self.pay_invoice_id and self.pay_path: payment = { @@ -109,7 +107,7 @@ def save(self): def update_search_selection(self, search_json): """Support UI search selection autosave: replace search response.""" - self.search_response = json.dumps(search_json) + self.search_response = search_json self.save() def search_by_registration_number(self): @@ -134,7 +132,7 @@ def search_by_registration_number(self): self.returned_results_size = 1 self.total_results_size = 1 - self.search_response = json.dumps(result_json) + self.search_response = result_json else: self.returned_results_size = 0 self.total_results_size = 0 @@ -143,10 +141,10 @@ def search_by_serial_type(self): """Execute a search query for either an aircraft DOT, MHR number, or serial number search type.""" search_value = self.request_json['criteria']['value'] query = search_utils.SERIAL_NUM_QUERY - if self.search_type_cd == 'MH': + if self.search_type == 'MH': query = search_utils.MHR_NUM_QUERY - query = query.replace('DECODE(serial_number', 'DECODE(mhr_number') - elif self.search_type_cd == 'AC': + query = query.replace('CASE WHEN serial_number', 'CASE WHEN mhr_number') + elif self.search_type == 'AC': query = search_utils.AIRCRAFT_DOT_QUERY query = query.replace('?', search_value) @@ -172,7 +170,7 @@ def search_by_serial_type(self): if value is not None: collateral['model'] = str(value) match_type = str(values[8]) - if self.search_type_cd == 'MH': + if self.search_type == 'MH': collateral['manufacturedHomeRegistrationNumber'] = str(values[12]) result_json = { 'baseRegistrationNumber': str(values[7]), @@ -186,7 +184,7 @@ def search_by_serial_type(self): self.returned_results_size = len(results_json) self.total_results_size = self.returned_results_size if self.returned_results_size > 0: - self.search_response = json.dumps(results_json) + self.search_response = results_json else: self.returned_results_size = 0 self.total_results_size = 0 @@ -219,7 +217,7 @@ def search_by_business_name(self): self.returned_results_size = len(results_json) self.total_results_size = self.returned_results_size if self.returned_results_size > 0: - self.search_response = json.dumps(results_json) + self.search_response = results_json else: self.returned_results_size = 0 self.total_results_size = 0 @@ -261,19 +259,19 @@ def search_by_individual_name(self): self.returned_results_size = len(results_json) self.total_results_size = self.returned_results_size if self.returned_results_size > 0: - self.search_response = json.dumps(results_json) + self.search_response = results_json else: self.returned_results_size = 0 self.total_results_size = 0 def get_total_count(self): """Execute a search to get the total match count for the search criteria. Only call if limit reached.""" - count_query = search_utils.COUNT_QUERY_FROM_SEARCH_TYPE[self.search_type_cd] + count_query = search_utils.COUNT_QUERY_FROM_SEARCH_TYPE[self.search_type] if count_query: - if self.search_type_cd == self.SearchTypes.BUSINESS_DEBTOR.value: + if self.search_type == self.SearchTypes.BUSINESS_DEBTOR.value: search_value = self.request_json['criteria']['debtorName']['business'] count_query = count_query.replace('?', search_value.strip().upper()) - elif self.search_type_cd == self.SearchTypes.INDIVIDUAL_DEBTOR.value: + elif self.search_type == self.SearchTypes.INDIVIDUAL_DEBTOR.value: last_name = self.request_json['criteria']['debtorName']['last'] first_name = self.request_json['criteria']['debtorName']['first'] count_query = count_query.replace('LNAME?', last_name.strip().upper()) @@ -288,13 +286,13 @@ def get_total_count(self): def search(self): """Execute a search with the previously set search type and criteria.""" - if self.search_type_cd == self.SearchTypes.REGISTRATION_NUM.value: + if self.search_type == self.SearchTypes.REGISTRATION_NUM.value: self.search_by_registration_number() - elif self.search_type_cd in (self.SearchTypes.SERIAL_NUM.value, - self.SearchTypes.MANUFACTURED_HOME_NUM.value, - self.SearchTypes.AIRCRAFT_AIRFRAME_DOT.value): + elif self.search_type in (self.SearchTypes.SERIAL_NUM.value, + self.SearchTypes.MANUFACTURED_HOME_NUM.value, + self.SearchTypes.AIRCRAFT_AIRFRAME_DOT.value): self.search_by_serial_type() - elif self.search_type_cd == self.SearchTypes.BUSINESS_DEBTOR.value: + elif self.search_type == self.SearchTypes.BUSINESS_DEBTOR.value: self.search_by_business_name() else: self.search_by_individual_name() @@ -310,8 +308,7 @@ def find_by_id(cls, search_id: int): """Return the search query matching the id.""" search = None if search_id: - # search = cls.query.get(search_id) - search = db.session.query(SearchClient).filter(SearchClient.search_id == search_id).one_or_none() + search = db.session.query(SearchRequest).filter(SearchRequest.id == search_id).one_or_none() return search @classmethod @@ -331,7 +328,7 @@ def find_all_by_account_id(cls, account_id: str = None): search = { 'searchId': str(values[0]), 'searchDateTime': model_utils.format_ts(values[1]), - 'searchQuery': json.loads(values[2]), + 'searchQuery': values[2], 'totalResultsSize': int(values[3]), 'returnedResultsSize': int(values[4]) } @@ -357,11 +354,11 @@ def find_all_by_account_id(cls, account_id: str = None): def create_from_json(search_json, account_id: str = None): """Create a search object from dict/json.""" - new_search = SearchClient() + new_search = SearchRequest() new_search.request_json = search_json search_type = search_json['type'] - new_search.search_type_cd = model_utils.TO_DB_SEARCH_TYPE[search_type] - new_search.search_criteria = json.dumps(search_json) + new_search.search_type = model_utils.TO_DB_SEARCH_TYPE[search_type] + new_search.search_criteria = search_json new_search.search_ts = model_utils.now_ts() if account_id: new_search.account_id = account_id diff --git a/ppr-api/src/ppr_api/models/search_result.py b/ppr-api/src/ppr_api/models/search_result.py index d5f145c27..b8d7ef395 100644 --- a/ppr-api/src/ppr_api/models/search_result.py +++ b/ppr-api/src/ppr_api/models/search_result.py @@ -16,7 +16,6 @@ from __future__ import annotations from http import HTTPStatus -import json from flask import current_app @@ -31,23 +30,20 @@ class SearchResult(db.Model): # pylint: disable=too-many-instance-attributes """This class maintains search results detail (search step 2) information.""" - __tablename__ = 'search_result' + __tablename__ = 'search_results' - search_id = db.Column('search_id', db.Integer, db.ForeignKey('search_client.search_id'), + search_id = db.Column('search_id', db.Integer, db.ForeignKey('search_requests.id'), primary_key=True, nullable=False) - search_select = db.Column('api_result', db.Text, nullable=False) - search_response = db.Column('registrations', db.Text, nullable=False) - jaro = db.Column('jaro', db.Integer, nullable=True) - match = db.Column('match', db.String(1), nullable=True) - result_id = db.Column('result_id', db.Integer, nullable=True) - result = db.Column('result', db.String(150), nullable=True) + search_select = db.Column('api_result', db.JSON, nullable=True) + search_response = db.Column('registrations', db.JSON, nullable=False) + score = db.Column('score', db.Integer, nullable=True) exact_match_count = db.Column('exact_match_count', db.Integer, nullable=True) similar_match_count = db.Column('similar_match_count', db.Integer, nullable=True) # parent keys # Relationships - Search - search = db.relationship('SearchClient', foreign_keys=[search_id], + search = db.relationship('SearchRequest', foreign_keys=[search_id], back_populates='search_result', cascade='all, delete', uselist=False) @property @@ -55,9 +51,9 @@ def json(self) -> dict: """Return the search query results as a json object.""" result = None if self.search_response: - result = json.loads(self.search_response) + result = self.search_response if self.search_select: - result['selected'] = json.loads(self.search_select) + result['selected'] = self.search_select return result def save(self): @@ -86,7 +82,7 @@ def update_selection(self, search_select): 'searchDateTime': model_utils.format_ts(self.search.search_ts), 'exactResultsSize': self.exact_match_count, 'similarResultsSize': self.similar_match_count, - 'searchQuery': json.loads(self.search.search_criteria), + 'searchQuery': self.search.search_criteria, 'details': [] } if self.search.pay_invoice_id and self.search.pay_path: @@ -96,7 +92,7 @@ def update_selection(self, search_select): } detail_response['payment'] = payment - results = json.loads(self.search_response) + results = self.search_response new_results = [] exact_count = 0 similar_count = 0 @@ -117,7 +113,7 @@ def update_selection(self, search_select): new_results.append(result) # current_app.logger.debug('exact_count=' + str(exact_count) + ' similar_count=' + str(similar_count)) - self.search_select = json.dumps(search_select) + self.search_select = search_select self.exact_match_count = exact_count self.similar_match_count = similar_count # current_app.logger.debug('saving updates') @@ -126,7 +122,7 @@ def update_selection(self, search_select): detail_response['similarResultsSize'] = self.similar_match_count detail_response['totalResultsSize'] = (self.exact_match_count + self.similar_match_count) detail_response['details'] = new_results - self.search_response = json.dumps(detail_response) + self.search_response = detail_response self.save() @classmethod @@ -135,11 +131,9 @@ def find_by_search_id(cls, search_id: int, limit_by_date: bool = False): search_detail = None error_msg = '' if search_id and not limit_by_date: - # search_detail = cls.query.filter(SearchResult.search_id == search_id).one_or_none() search_detail = db.session.query(SearchResult).filter(SearchResult.search_id == search_id).one_or_none() elif search_id and limit_by_date: min_allowed_date = model_utils.today_ts_offset(GET_DETAIL_DAYS_LIMIT, False) - # search_detail = cls.query.filter(SearchResult.search_id == search_id).one_or_none() search_detail = db.session.query(SearchResult).filter(SearchResult.search_id == search_id).one_or_none() if search_detail and search_detail.search and \ search_detail.search.search_ts.timestamp() < min_allowed_date.timestamp(): @@ -157,13 +151,13 @@ def find_by_search_id(cls, search_id: int, limit_by_date: bool = False): @staticmethod def create_from_search_query_no_results(search_query): """Create a search detail object from the inital search query which retured no results.""" - search_result = SearchResult(search_id=search_query.search_id, exact_match_count=0, similar_match_count=0) + search_result = SearchResult(search_id=search_query.id, exact_match_count=0, similar_match_count=0) detail_response = { 'searchDateTime': model_utils.format_ts(search_query.search_ts), 'exactResultsSize': search_result.exact_match_count, 'similarResultsSize': search_result.similar_match_count, 'totalResultsSize': 0, - 'searchQuery': json.loads(search_query.search_criteria) + 'searchQuery': search_query.search_criteria } if search_query.pay_invoice_id and search_query.pay_path: payment = { @@ -171,7 +165,7 @@ def create_from_search_query_no_results(search_query): 'receipt': search_query.pay_path } detail_response['payment'] = payment - search_result.search_response = json.dumps(detail_response) + search_result.search_response = detail_response return search_result @staticmethod @@ -180,8 +174,8 @@ def create_from_search_query(search_query, mark_added: bool = True): if search_query.total_results_size == 0: # A search query with no results: build minimal details. return SearchResult.create_from_search_query_no_results(search_query) - search_result = SearchResult(search_id=search_query.search_id, exact_match_count=0, similar_match_count=0) - query_results = json.loads(search_query.search_response) + search_result = SearchResult(search_id=search_query.id, exact_match_count=0, similar_match_count=0) + query_results = search_query.search_response detail_results = [] for result in query_results: reg_num = result['baseRegistrationNumber'] @@ -205,7 +199,7 @@ def create_from_search_query(search_query, mark_added: bool = True): changes = [] if financing.registration: for reg in reversed(financing.registration): - if reg.registration_num != financing.registration_num: + if reg.registration_type_cl not in ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN'): statement_json = reg.json statement_json['statementType'] = \ model_utils.REG_CLASS_TO_STATEMENT_TYPE[reg.registration_type_cl] @@ -218,7 +212,7 @@ def create_from_search_query(search_query, mark_added: bool = True): else: search_result.similar_match_count += 1 - search_result.search_response = json.dumps(detail_results) + search_result.search_response = detail_results return search_result @staticmethod @@ -226,7 +220,7 @@ def create_from_json(search_json, search_id: int): """Create a search detail object from dict/json specifying the search selection.""" search = SearchResult() search.search_id = search_id - search.search_select = json.dumps(search_json) + search.search_select = search_json detail_results = [] for result in search_json: reg_num = result['baseRegistrationNumber'] @@ -249,7 +243,7 @@ def create_from_json(search_json, search_id: int): if changes: financing_json['financingStatement']['changes'] = changes detail_results.append(financing_json) - search.search_response = json.dumps(detail_results) + search.search_response = detail_results return search diff --git a/ppr-api/src/ppr_api/models/search_utils.py b/ppr-api/src/ppr_api/models/search_utils.py index 04ed4565b..5c8e6a74b 100644 --- a/ppr-api/src/ppr_api/models/search_utils.py +++ b/ppr-api/src/ppr_api/models/search_utils.py @@ -34,181 +34,186 @@ # Serial number search base where clause SERIAL_SEARCH_BASE = """ -SELECT r.registration_type_cd,r.registration_ts AS base_registration_ts, - sc.serial_type_cd,sc.serial_number,sc.year,sc.make,sc.model, +SELECT r.registration_type,r.registration_ts AS base_registration_ts, + sc.serial_type,sc.serial_number,sc.year,sc.make,sc.model, r.registration_number AS base_registration_num, - DECODE(serial_number, '?', 'EXACT', 'SIMILAR') AS match_type, - fs.expire_date,fs.state_type_cd,sc.serial_id AS vehicle_id, sc.mhr_number - FROM registration r, financing_statement fs, serial_collateral sc - WHERE r.financing_id = fs.financing_id + CASE WHEN serial_number = '?' THEN 'EXACT' ELSE 'SIMILAR' END match_type, + fs.expire_date,fs.state_type,sc.id AS vehicle_id, sc.mhr_number + FROM registrations r, financing_statements fs, serial_collateral sc + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND sc.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND sc.financing_id = fs.id AND sc.registration_id_end IS NULL """ # Equivalent logic as DB view search_by_reg_num_vw, but API determines the where clause. REG_NUM_QUERY = """ -SELECT r.registration_type_cd,r.registration_ts AS base_registration_ts, +SELECT r.registration_type,r.registration_ts AS base_registration_ts, r.registration_number AS base_registration_num, - 'EXACT' AS match_type,fs.state_type_cd, fs.expire_date - FROM registration r, financing_statement fs, registration r2 + 'EXACT' AS match_type,fs.state_type, fs.expire_date + FROM registrations r, financing_statements fs, registrations r2 WHERE r2.financing_id = r.financing_id - AND r.financing_id = fs.financing_id + AND r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) AND r2.registration_number = '?' """ # Equivalent logic as DB view search_by_mhr_num_vw, but API determines the where clause. MHR_NUM_QUERY = SERIAL_SEARCH_BASE + \ - " AND sc.serial_type_cd = 'MH' " + \ - "AND sc.srch_vin = search_key_pkg.mhr('?') " + \ + " AND sc.serial_type = 'MH' " + \ + "AND sc.srch_vin = searchkey_mhr('?') " + \ "ORDER BY match_type, r.registration_ts ASC " + RESULTS_SIZE_LIMIT_CLAUSE # Equivalent logic as DB view search_by_serial_num_vw, but API determines the where clause. SERIAL_NUM_QUERY = SERIAL_SEARCH_BASE + \ - " AND sc.serial_type_cd NOT IN ('AC', 'AF', 'AP') " + \ - "AND sc.srch_vin = search_key_pkg.vehicle('?') " + \ + " AND sc.serial_type NOT IN ('AC', 'AF', 'AP') " + \ + "AND sc.srch_vin = searchkey_vehicle('?') " + \ "ORDER BY match_type, sc.serial_number " + RESULTS_SIZE_LIMIT_CLAUSE # Equivalent logic as DB view search_by_aircraft_dot_vw, but API determines the where clause. AIRCRAFT_DOT_QUERY = SERIAL_SEARCH_BASE + \ - " AND sc.serial_type_cd IN ('AC', 'AF', 'AP') " + \ - "AND sc.srch_vin = search_key_pkg.aircraft('?') " + \ + " AND sc.serial_type IN ('AC', 'AF', 'AP') " + \ + "AND sc.srch_vin = searchkey_aircraft('?') " + \ "ORDER BY match_type, sc.serial_number " + RESULTS_SIZE_LIMIT_CLAUSE BUSINESS_NAME_QUERY = """ -SELECT r.registration_type_cd,r.registration_ts AS base_registration_ts, +SELECT r.registration_type,r.registration_ts AS base_registration_ts, p.business_name, r.registration_number AS base_registration_num, - DECODE(p.business_name, '?', 'EXACT', 'SIMILAR') AS match_type, - fs.expire_date,fs.state_type_cd,p.party_id - FROM registration r, financing_statement fs, party p - WHERE r.financing_id = fs.financing_id + CASE WHEN p.business_name = '?' THEN 'EXACT' ELSE 'SIMILAR' END match_type, + fs.expire_date,fs.state_type,p.id + FROM registrations r, financing_statements fs, parties p + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND p.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND p.financing_id = fs.id AND p.registration_id_end IS NULL - AND p.party_type_cd = 'DB' - AND UTL_MATCH.JARO_WINKLER_SIMILARITY(p.business_srch_key, SEARCH_KEY_PKG.businame('?')) >= - NVL((SELECT MAX(JARO_VALUE) - FROM THESAURUS A, JARO B - WHERE REGEXP_LIKE(SEARCH_KEY_PKG.businame('?'),WORD,'i') - AND A.WORD_ID = B.WORD_ID), 85) + AND p.party_type = 'DB' + AND p.business_srch_key = searchkey_business_name('?') ORDER BY match_type, p.business_name """ + RESULTS_SIZE_LIMIT_CLAUSE +# Replace with POSTGRES algorithm when available +# AND UTL_MATCH.JARO_WINKLER_SIMILARITY(p.business_srch_key, searchkey_business_name('?')) >= +# NVL((SELECT MAX(JARO_VALUE) +# FROM THESAURUS A, JARO B +# WHERE REGEXP_LIKE(searchkey_business_name('?'),WORD,'i') +# AND A.WORD_ID = B.WORD_ID), 85) + INDIVIDUAL_NAME_QUERY = """ -SELECT r.registration_type_cd,r.registration_ts AS base_registration_ts, - p.last_name,p.first_name,p.middle_name,p.party_id, +SELECT r.registration_type,r.registration_ts AS base_registration_ts, + p.last_name,p.first_name,p.middle_initial,p.id, r.registration_number AS base_registration_num, - DECODE(p.last_name, 'LNAME?', - DECODE(p.first_name, 'FNAME?', 'EXACT', 'SIMILAR'), 'SIMILAR') AS match_type, - fs.expire_date,fs.state_type_cd - FROM registration r, financing_statement fs, party p - WHERE r.financing_id = fs.financing_id + CASE WHEN p.last_name = 'LNAME?' AND p.first_name = 'FNAME?' THEN 'EXACT' ELSE 'SIMILAR' END match_type, + fs.expire_date,fs.state_type + FROM registrations r, financing_statements fs, parties p + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND p.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND p.financing_id = fs.id AND p.registration_id_end IS NULL - AND p.party_type_cd = 'DI' - AND p.party_id IN (SELECT * FROM match_individual_name('LNAME?', 'FNAME?')) + AND p.party_type = 'DI' + AND p.id IN (SELECT * FROM unnest(match_individual_name('LNAME?', 'FNAME?'))) ORDER BY match_type, p.last_name, p.first_name """ + RESULTS_SIZE_LIMIT_CLAUSE # Total result count queries for serial number, debtor name searches: BUSINESS_NAME_TOTAL_COUNT = """ -SELECT COUNT(r.registration_id) - FROM registration r, financing_statement fs, party p - WHERE r.financing_id = fs.financing_id +SELECT COUNT(r.id) + FROM registrations r, financing_statements fs, parties p + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND p.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND p.financing_id = fs.id AND p.registration_id_end IS NULL - AND p.party_type_cd = 'DB' - AND UTL_MATCH.JARO_WINKLER_SIMILARITY(p.business_srch_key, SEARCH_KEY_PKG.businame('?')) >= - NVL((SELECT MAX(JARO_VALUE) - FROM THESAURUS A, JARO B - WHERE REGEXP_LIKE(SEARCH_KEY_PKG.businame('?'),WORD,'i') - AND A.WORD_ID = B.WORD_ID), 85) + AND p.party_type = 'DB' + AND p.business_srch_key = searchkey_business_name('?') """ +# Replace in POSTGRES when available +# AND UTL_MATCH.JARO_WINKLER_SIMILARITY(p.business_srch_key, searchkey_business_name('?')) >= +# NVL((SELECT MAX(JARO_VALUE) +# FROM THESAURUS A, JARO B +# WHERE REGEXP_LIKE(searchkey_business_name('?'),WORD,'i') +# AND A.WORD_ID = B.WORD_ID), 85) + INDIVIDUAL_NAME_TOTAL_COUNT = """ -SELECT COUNT(r.registration_id) - FROM registration r, financing_statement fs, party p - WHERE r.financing_id = fs.financing_id +SELECT COUNT(r.id) + FROM registrations r, financing_statements fs, parties p + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND p.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND p.financing_id = fs.id AND p.registration_id_end IS NULL - AND p.party_type_cd = 'DI' - AND p.party_id IN (SELECT * FROM match_individual_name('LNAME?', 'FNAME?')) + AND p.party_type = 'DI' + AND p.id IN (SELECT * FROM unnest(match_individual_name('LNAME?', 'FNAME?'))) """ SERIAL_SEARCH_COUNT_BASE = """ -SELECT COUNT(r.registration_id) - FROM registration r, financing_statement fs, serial_collateral sc - WHERE r.financing_id = fs.financing_id +SELECT COUNT(r.id) + FROM registrations r, financing_statements fs, serial_collateral sc + WHERE r.financing_id = fs.id AND r.registration_type_cl IN ('PPSALIEN', 'MISCLIEN', 'CROWNLIEN') AND r.base_reg_number IS NULL - AND (fs.expire_date IS NULL OR fs.expire_date > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND NOT EXISTS (SELECT r3.registration_id - FROM registration r3 - WHERE r3.financing_id = fs.financing_id + AND (fs.expire_date IS NULL OR fs.expire_date > ((now() at time zone 'utc') - interval '30 days')) + AND NOT EXISTS (SELECT r3.id + FROM registrations r3 + WHERE r3.financing_id = fs.id AND r3.registration_type_cl = 'DISCHARGE' - AND r3.registration_ts < ((SYSTIMESTAMP AT TIME ZONE 'UTC') - 30)) - AND sc.financing_id = fs.financing_id + AND r3.registration_ts < ((now() at time zone 'utc') - interval '30 days')) + AND sc.financing_id = fs.id AND sc.registration_id_end IS NULL """ MHR_NUM_TOTAL_COUNT = SERIAL_SEARCH_COUNT_BASE + \ - " AND sc.serial_type_cd = 'MH' " + \ - "AND sc.srch_vin = search_key_pkg.mhr('?')" + " AND sc.serial_type = 'MH' " + \ + "AND sc.srch_vin = searchkey_mhr('?')" SERIAL_NUM_TOTAL_COUNT = SERIAL_SEARCH_COUNT_BASE + \ - " AND sc.serial_type_cd NOT IN ('AC', 'AF') " + \ - "AND sc.srch_vin = search_key_pkg.vehicle('?')" + " AND sc.serial_type NOT IN ('AC', 'AF') " + \ + "AND sc.srch_vin = searchkey_vehicle('?')" AIRCRAFT_DOT_TOTAL_COUNT = SERIAL_SEARCH_COUNT_BASE + \ - " AND sc.serial_type_cd IN ('AC', 'AF') " + \ - "AND sc.srch_vin = search_key_pkg.aircraft('?')" + " AND sc.serial_type IN ('AC', 'AF') " + \ + "AND sc.srch_vin = searchkey_aircraft('?')" COUNT_QUERY_FROM_SEARCH_TYPE = { 'AC': AIRCRAFT_DOT_TOTAL_COUNT, @@ -219,20 +224,20 @@ } ACCOUNT_SEARCH_HISTORY_DATE_QUERY = \ -'SELECT sc.search_id, sc.search_ts, sc.api_criteria, sc.total_results_size, sc.returned_results_size,' + \ +'SELECT sc.id, sc.search_ts, sc.api_criteria, sc.total_results_size, sc.returned_results_size,' + \ 'sr.exact_match_count, sr.similar_match_count ' + \ - 'FROM search_client sc, search_result sr ' + \ - 'WHERE sc.search_id = sr.search_id ' + \ + 'FROM search_requests sc, search_results sr ' + \ + 'WHERE sc.id = sr.search_id ' + \ "AND sc.account_id = '?' " + \ - "AND sc.search_ts > ((SYSTIMESTAMP AT TIME ZONE 'UTC') - " + str(GET_HISTORY_DAYS_LIMIT) + ') ' + \ + "AND sc.search_ts > ((now() at time zone 'utc') - interval '" + str(GET_HISTORY_DAYS_LIMIT) + " days') " + \ 'ORDER BY sc.search_ts DESC ' + \ 'FETCH FIRST ' + str(ACCOUNT_SEARCH_HISTORY_MAX_SIZE) + ' ROWS ONLY' ACCOUNT_SEARCH_HISTORY_QUERY = \ -'SELECT sc.search_id, sc.search_ts, sc.api_criteria, sc.total_results_size, sc.returned_results_size,' + \ +'SELECT sc.id, sc.search_ts, sc.api_criteria, sc.total_results_size, sc.returned_results_size,' + \ 'sr.exact_match_count, sr.similar_match_count ' + \ - 'FROM search_client sc, search_result sr ' + \ - 'WHERE sc.search_id = sr.search_id ' + \ + 'FROM search_requests sc, search_results sr ' + \ + 'WHERE sc.id = sr.search_id ' + \ "AND sc.account_id = '?' " + \ 'ORDER BY sc.search_ts DESC ' + \ 'FETCH FIRST ' + str(ACCOUNT_SEARCH_HISTORY_MAX_SIZE) + ' ROWS ONLY' diff --git a/ppr-api/src/ppr_api/models/trust_indenture.py b/ppr-api/src/ppr_api/models/trust_indenture.py index eb7ae5883..580cf5087 100644 --- a/ppr-api/src/ppr_api/models/trust_indenture.py +++ b/ppr-api/src/ppr_api/models/trust_indenture.py @@ -22,17 +22,14 @@ class TrustIndenture(db.Model): # pylint: disable=too-many-instance-attributes """This class manages all of the financing statement trust indenture information.""" - __tablename__ = 'trust_indenture' + __tablename__ = 'trust_indentures' -# trust_id = db.Column('trust_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - trust_id = db.Column('trust_id', db.Integer, db.Sequence('trust_id_seq'), primary_key=True) + id = db.Column('id', db.Integer, db.Sequence('trust_id_seq'), primary_key=True) trust_indenture = db.Column('trust_indenture', db.String(1), nullable=False) # parent keys - registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=False) - financing_id = db.Column('financing_id', db.Integer, - db.ForeignKey('financing_statement.financing_id'), nullable=False) + registration_id = db.Column('registration_id', db.Integer, db.ForeignKey('registrations.id'), nullable=False) + financing_id = db.Column('financing_id', db.Integer, db.ForeignKey('financing_statements.id'), nullable=False) registration_id_end = db.Column('registration_id_end', db.Integer, nullable=True) # db.ForeignKey('registration.registration_id'), nullable=True) @@ -59,9 +56,9 @@ def find_by_registration_number(cls, registration_num: str = None): """Return a list of trust indenture objects by registration number.""" trust_indenture = None if registration_num: - trust_indenture = cls.query.filter(TrustIndenture.registration_id == Registration.registration_id, + trust_indenture = cls.query.filter(TrustIndenture.registration_id == Registration.id, Registration.registration_num == registration_num) \ - .order_by(TrustIndenture.trust_id).all() + .order_by(TrustIndenture.id).all() return trust_indenture @@ -71,7 +68,7 @@ def find_by_financing_id(cls, financing_id: int = None): trust_indenture = None if financing_id: trust_indenture = cls.query.filter(TrustIndenture.financing_id == financing_id) \ - .order_by(TrustIndenture.trust_id).all() + .order_by(TrustIndenture.id).all() return trust_indenture diff --git a/ppr-api/src/ppr_api/models/type_tables.py b/ppr-api/src/ppr_api/models/type_tables.py index f4aa72170..c0ab518c9 100644 --- a/ppr-api/src/ppr_api/models/type_tables.py +++ b/ppr-api/src/ppr_api/models/type_tables.py @@ -23,7 +23,7 @@ class CountryType(db.Model): # pylint: disable=too-few-public-methods __tablename__ = 'country_types' - country_type_cd = db.Column('country_type_cd', db.String(2), primary_key=True) + country_type = db.Column('country_type', db.String(2), primary_key=True) country_desc = db.Column('country_desc', db.String(75), nullable=False) # parent keys @@ -37,9 +37,9 @@ class ProvinceType(db.Model): # pylint: disable=too-few-public-methods __tablename__ = 'province_types' - province_type_cd = db.Column('province_type_cd', db.String(2), primary_key=True) - country_type_cd = db.Column('country_type_cd', db.String(2), - db.ForeignKey('country_types.country_type_cd'), nullable=False) + province_type = db.Column('province_type', db.String(2), primary_key=True) + country_type = db.Column('country_type', db.String(2), + db.ForeignKey('country_types.country_type'), nullable=False) province_desc = db.Column('province_desc', db.String(75), nullable=False) # parent keys @@ -51,21 +51,21 @@ class ProvinceType(db.Model): # pylint: disable=too-few-public-methods class PartyType(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the party_type table.""" - __tablename__ = 'party_type' + __tablename__ = 'party_types' - party_type_cd = db.Column('party_type_cd', db.String(2), primary_key=True) + party_type = db.Column('party_type', db.String(2), primary_key=True) party_type_desc = db.Column('party_type_desc', db.String(30), nullable=False) # parent keys # Relationships - Party - party = db.relationship('Party', back_populates='party_type') + party = db.relationship('Party', back_populates='party_types') class RegistrationTypeClass(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the registration_type_class table.""" - __tablename__ = 'registration_type_class' + __tablename__ = 'registration_type_classes' registration_type_cl = db.Column('registration_type_cl', db.String(10), primary_key=True) registration_desc = db.Column('registration_desc', db.String(100), nullable=False) @@ -78,54 +78,54 @@ class RegistrationTypeClass(db.Model): # pylint: disable=too-few-public-methods class RegistrationType(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the registration_type table.""" - __tablename__ = 'registration_type' + __tablename__ = 'registration_types' - registration_type_cd = db.Column('registration_type_cd', db.String(2), primary_key=True) + registration_type = db.Column('registration_type', db.String(2), primary_key=True) registration_type_cl = db.Column('registration_type_cl', db.String(10), - db.ForeignKey('registration_type_class.registration_type_cl'), nullable=False) + db.ForeignKey('registration_type_classes.registration_type_cl'), nullable=False) registration_desc = db.Column('registration_desc', db.String(100), nullable=False) registration_act = db.Column('registration_act', db.String(60), nullable=False) # parent keys # Relationships - Registration - registration = db.relationship('Registration', back_populates='registration_type') + registration = db.relationship('Registration', back_populates='reg_type') class SearchType(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the search_type table.""" - __tablename__ = 'search_type' + __tablename__ = 'search_types' - search_type_cd = db.Column('search_type_cd', db.String(2), primary_key=True) + search_type = db.Column('search_type', db.String(2), primary_key=True) search_type_desc = db.Column('search_type_desc', db.String(60), nullable=False) # parent keys - # Relationships - SearchClient - search_client = db.relationship('SearchClient', back_populates='search_type') + # Relationships - SearchRequest + search_request = db.relationship('SearchRequest', back_populates='search_request_type') class StateType(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the state_type table.""" - __tablename__ = 'state_type' + __tablename__ = 'state_types' - state_type_cd = db.Column('state_type_cd', db.String(2), primary_key=True) + state_type = db.Column('state_type', db.String(3), primary_key=True) state_type_desc = db.Column('state_type_desc', db.String(30), nullable=False) # parent keys # Relationships - FinancingStatement - financing_statement = db.relationship('FinancingStatement', back_populates='state_type') + financing_statement = db.relationship('FinancingStatement', back_populates='fin_state_type') class SerialType(db.Model): # pylint: disable=too-few-public-methods """This class defines the model for the serial_type table.""" - __tablename__ = 'serial_type' + __tablename__ = 'serial_types' - serial_type_cd = db.Column('serial_type_cd', db.String(2), primary_key=True) + serial_type = db.Column('serial_type', db.String(2), primary_key=True) serial_type_desc = db.Column('serial_type_desc', db.String(30), nullable=False) # parent keys diff --git a/ppr-api/src/ppr_api/models/user.py b/ppr-api/src/ppr_api/models/user.py index 806d65f83..65d0949c3 100644 --- a/ppr-api/src/ppr_api/models/user.py +++ b/ppr-api/src/ppr_api/models/user.py @@ -34,7 +34,7 @@ class User(db.Model): creation_date = db.Column(db.DateTime, nullable=False) username = db.Column(db.String(1000), index=True, nullable=False) sub = db.Column(db.String(36), unique=True, nullable=False) - account_id = db.Column(db.String(20), nullable=False) + account_id = db.Column(db.String(20), nullable=True) firstname = db.Column(db.String(1000), nullable=True) lastname = db.Column(db.String(1000), nullable=True) email = db.Column(db.String(1024), nullable=True) diff --git a/ppr-api/src/ppr_api/models/user_profile.py b/ppr-api/src/ppr_api/models/user_profile.py index dca16e791..89be3441e 100644 --- a/ppr-api/src/ppr_api/models/user_profile.py +++ b/ppr-api/src/ppr_api/models/user_profile.py @@ -34,7 +34,7 @@ class UserProfile(db.Model): """This class maintains user profile UI settings.""" - __tablename__ = 'user_profile' + __tablename__ = 'user_profiles' id = db.Column(db.Integer, db.ForeignKey('users.id'), primary_key=True, nullable=False) payment_confirmation = db.Column(db.String(1), nullable=False) diff --git a/ppr-api/src/ppr_api/models/utils.py b/ppr-api/src/ppr_api/models/utils.py index 1945da95e..f77ab0522 100644 --- a/ppr-api/src/ppr_api/models/utils.py +++ b/ppr-api/src/ppr_api/models/utils.py @@ -59,7 +59,7 @@ # Financing statement, registraiton constants LIFE_INFINITE = -99 REPAIRER_LIEN_DAYS = 180 -REPAIRER_LIEN_YEARS = 0 +REPAIRER_LIEN_YEARS = 1 # Mapping from API draft type to DB registration class DRAFT_TYPE_TO_REG_CLASS = { diff --git a/ppr-api/src/ppr_api/models/vehicle_collateral.py b/ppr-api/src/ppr_api/models/vehicle_collateral.py index 16814e343..c283a6d2f 100644 --- a/ppr-api/src/ppr_api/models/vehicle_collateral.py +++ b/ppr-api/src/ppr_api/models/vehicle_collateral.py @@ -19,9 +19,9 @@ from .db import db -SEARCH_VIN_STATEMENT = "SELECT search_key_pkg.vehicle('?') FROM DUAL" # noqa: Q000 -SEARCH_VIN_STATEMENT_AC = "SELECT search_key_pkg.aircraft('?') FROM DUAL" # noqa: Q000 -SEARCH_VIN_STATEMENT_MH = "SELECT search_key_pkg.mhr('?') FROM DUAL" # noqa: Q000 +SEARCH_VIN_STATEMENT = "SELECT searchkey_vehicle('?')" # noqa: Q000 +SEARCH_VIN_STATEMENT_AC = "SELECT searchkey_aircraft('?')" # noqa: Q000 +SEARCH_VIN_STATEMENT_MH = "SELECT searchkey_mhr('?')" # noqa: Q000 class VehicleCollateral(db.Model): # pylint: disable=too-many-instance-attributes @@ -42,27 +42,21 @@ class SerialTypes(Enum): __tablename__ = 'serial_collateral' - -# vehicle_id = db.Column('serial_id', db.Integer, primary_key=True, server_default=db.FetchedValue()) - vehicle_id = db.Column('serial_id', db.Integer, - db.Sequence('vehicle_id_seq'), - primary_key=True) - vehicle_type_cd = db.Column('serial_type_cd', db.String(2), - db.ForeignKey('serial_type.serial_type_cd'), nullable=False) + id = db.Column('id', db.Integer, db.Sequence('vehicle_id_seq'), primary_key=True) + vehicle_type = db.Column('serial_type', db.String(2), + db.ForeignKey('serial_types.serial_type'), nullable=False) year = db.Column('year', db.Integer, nullable=True) make = db.Column('make', db.String(60), nullable=True) model = db.Column('model', db.String(60), nullable=True) serial_number = db.Column('serial_number', db.String(30), nullable=True) - mhr_number = db.Column('mhr_number', db.String(7), nullable=True) + mhr_number = db.Column('mhr_number', db.String(6), nullable=True) search_vin = db.Column('srch_vin', db.String(6), nullable=True, index=True) - # Legacy only - block_number = db.Column('block_number', db.Integer, nullable=True) # parent keys registration_id = db.Column('registration_id', db.Integer, - db.ForeignKey('registration.registration_id'), nullable=False) + db.ForeignKey('registrations.id'), nullable=False) financing_id = db.Column('financing_id', db.Integer, - db.ForeignKey('financing_statement.financing_id'), nullable=False) + db.ForeignKey('financing_statements.id'), nullable=False) registration_id_end = db.Column('registration_id_end', db.Integer, nullable=True) # db.ForeignKey('registration.registration_id'), nullable=True) @@ -77,7 +71,7 @@ class SerialTypes(Enum): back_populates='vehicle_collateral', cascade='all, delete', uselist=False) # Relationships - SerialType - serial_type = db.relationship('SerialType', foreign_keys=[vehicle_type_cd], + serial_type = db.relationship('SerialType', foreign_keys=[vehicle_type], back_populates='vehicle_collateral', cascade='all, delete', uselist=False) def save(self): @@ -89,8 +83,8 @@ def save(self): def json(self) -> dict: """Return the genreal collateral as a json object.""" collateral = { - 'vehicleId': self.vehicle_id, - 'type': self.vehicle_type_cd + 'vehicleId': self.id, + 'type': self.vehicle_type } if self.year: collateral['year'] = self.year @@ -120,7 +114,7 @@ def find_by_registration_id(cls, registration_id: int = None): collateral = None if registration_id: collateral = cls.query.filter(VehicleCollateral.registration_id == registration_id) \ - .order_by(VehicleCollateral.vehicle_id).all() + .order_by(VehicleCollateral.id).all() return collateral @@ -130,7 +124,7 @@ def find_by_financing_id(cls, financing_id: int = None): collateral = None if financing_id: collateral = cls.query.filter(VehicleCollateral.financing_id == financing_id) \ - .order_by(VehicleCollateral.vehicle_id).all() + .order_by(VehicleCollateral.id).all() return collateral @@ -139,7 +133,7 @@ def create_from_json(json_data, registration_id: int = None): """Create a vehicle collateral object from a json schema object: map json to db.""" collateral = VehicleCollateral() collateral.registration_id = registration_id - collateral.vehicle_type_cd = json_data['type'] + collateral.vehicle_type = json_data['type'] collateral.serial_number = json_data['serialNumber'] if 'year' in json_data: collateral.year = json_data['year'] @@ -148,12 +142,12 @@ def create_from_json(json_data, registration_id: int = None): if 'model' in json_data: collateral.model = json_data['model'] if 'manufacturedHomeRegistrationNumber' in json_data and \ - collateral.vehicle_type_cd == VehicleCollateral.SerialTypes.MANUFACTURED_HOME.value: + collateral.vehicle_type == VehicleCollateral.SerialTypes.MANUFACTURED_HOME.value: collateral.mhr_number = json_data['manufacturedHomeRegistrationNumber'] - collateral.search_vin = VehicleCollateral.get_search_vin(collateral.vehicle_type_cd, + collateral.search_vin = VehicleCollateral.get_search_vin(collateral.vehicle_type, collateral.mhr_number) elif collateral.serial_number: - collateral.search_vin = VehicleCollateral.get_search_vin(collateral.vehicle_type_cd, + collateral.search_vin = VehicleCollateral.get_search_vin(collateral.vehicle_type, collateral.serial_number) return collateral @@ -191,8 +185,7 @@ def get_search_vin(vehicle_type: str, serial_number: str): return None statement = SEARCH_VIN_STATEMENT.replace('?', serial_number) - if vehicle_type in (VehicleCollateral.SerialTypes.AIRCRAFT.value, - VehicleCollateral.SerialTypes.AIRCRAFT_AIRFRAME.value): + if vehicle_type == VehicleCollateral.SerialTypes.AIRCRAFT.value: statement = SEARCH_VIN_STATEMENT_AC.replace('?', serial_number) elif vehicle_type == VehicleCollateral.SerialTypes.MANUFACTURED_HOME.value: statement = SEARCH_VIN_STATEMENT_MH.replace('?', serial_number) diff --git a/ppr-api/src/ppr_api/resources/financing_statements.py b/ppr-api/src/ppr_api/resources/financing_statements.py index d1e12ee05..0298ed5a4 100644 --- a/ppr-api/src/ppr_api/resources/financing_statements.py +++ b/ppr-api/src/ppr_api/resources/financing_statements.py @@ -21,16 +21,17 @@ from flask_restx import Namespace, Resource, cors from registry_schemas import utils as schema_utils +from ppr_api.exceptions import BusinessException +from ppr_api.models import FinancingStatement, Registration +from ppr_api.models import utils as model_utils +from ppr_api.resources import utils as resource_utils +from ppr_api.services.authz import authorized, is_staff +from ppr_api.services.payment.exceptions import SBCPaymentException from ppr_api.utils.auth import jwt from ppr_api.utils.util import cors_preflight -from ppr_api.exceptions import BusinessException -from ppr_api.services.authz import is_staff, authorized -from ppr_api.models import Registration, FinancingStatement, utils as model_utils -from .utils import get_account_id, account_required_response, validation_error_response, \ - business_exception_response, default_exception_response -from .utils import unauthorized_error_response, path_param_error_response -from .utils import path_data_mismatch_error_response, base_debtor_invalid_response + +# from ppr_api.services.payment.payment import Payment, TransactionTypes API = Namespace('financing-statements', description='Endpoints for maintaining financing statements and updates.') @@ -55,13 +56,13 @@ def get(): try: # Quick check: must provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) # Try to fetch financing statement list for account ID statement_list = FinancingStatement.find_all_by_account_id(account_id, is_staff(jwt)) @@ -69,9 +70,9 @@ def get(): return jsonify(statement_list), HTTPStatus.OK except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @staticmethod @cors.crossdomain(origin='*') @@ -81,32 +82,42 @@ def post(): try: # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) request_json = request.get_json(silent=True) # Validate request data against the schema. valid_format, errors = schema_utils.validate(request_json, 'financingStatement', 'ppr') if not valid_format: - return validation_error_response(errors, VAL_ERROR) + return resource_utils.validation_error_response(errors, VAL_ERROR) - # TODO: charge a fee. + # Charge a fee. + statement = FinancingStatement.create_from_json(request_json, account_id) + # if account_id: + # fee_code = TransactionTypes.FINANCING_LIFE_YEAR.value + # fee_quantity = 1 + # payment = Payment(jwt=jwt.get_token_auth_header(), account_id=account_id) + # pay_ref = payment.create_payment(fee_code, fee_quantity, None, statement.client_reference_id) + # invoice_id = pay_ref['invoiceId'] + # statement.pay_invoice_id = int(invoice_id) + # statement.pay_path = pay_ref['receipt'] # Try to save the financing statement: failure throws a business exception. - statement = FinancingStatement.create_from_json(request_json, account_id) statement.save() return statement.json, HTTPStatus.CREATED + except SBCPaymentException as pay_exception: + return resource_utils.pay_exception_response(pay_exception) except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @cors_preflight('GET,OPTIONS') @@ -121,16 +132,16 @@ def get(registration_num): """Get a financing statement by registration number.""" try: if registration_num is None: - return path_param_error_response('registration number') + return resource_utils.path_param_error_response('registration number') # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) # Try to fetch financing statement by registration number # Not found or non-staff historical throws a business exception. @@ -139,9 +150,9 @@ def get(registration_num): return statement.json, HTTPStatus.OK except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @cors_preflight('POST,OPTIONS') @@ -156,28 +167,28 @@ def post(registration_num): """Amend a financing statement by registration number.""" try: if registration_num is None: - return path_param_error_response('registration number') + return resource_utils.path_param_error_response('registration number') # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) request_json = request.get_json(silent=True) # Validate request data against the schema. valid_format, errors = schema_utils.validate(request_json, 'amendmentStatement', 'ppr') if not valid_format: - return validation_error_response(errors, VAL_ERROR_AMEND) + return resource_utils.validation_error_response(errors, VAL_ERROR_AMEND) # payload base registration number must match path registration number if registration_num != request_json['baseRegistrationNumber']: - return path_data_mismatch_error_response(registration_num, - 'base registration number', - request_json['baseRegistrationNumber']) + return resource_utils.path_data_mismatch_error_response(registration_num, + 'base registration number', + request_json['baseRegistrationNumber']) # Fetch base registration information: business exception thrown if not # found or historical. @@ -185,7 +196,7 @@ def post(registration_num): # Verify base debtor (bypassed for staff) if not statement.validate_base_debtor(request_json['baseDebtor'], is_staff(jwt)): - return base_debtor_invalid_response() + return resource_utils.base_debtor_invalid_response() # TODO: charge a fee. @@ -197,12 +208,14 @@ def post(registration_num): account_id) statement.save() - return statement.json, HTTPStatus.OK + return statement.json, HTTPStatus.OK # CREATED + except SBCPaymentException as pay_exception: + return resource_utils.pay_exception_response(pay_exception) except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @cors_preflight('POST,OPTIONS') @@ -217,28 +230,28 @@ def post(registration_num): """Change a financing statement by registration number.""" try: if registration_num is None: - return path_param_error_response('registration number') + return resource_utils.path_param_error_response('registration number') # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) request_json = request.get_json(silent=True) # Validate request data against the schema. valid_format, errors = schema_utils.validate(request_json, 'changeStatement', 'ppr') if not valid_format: - return validation_error_response(errors, VAL_ERROR_CHANGE) + return resource_utils.validation_error_response(errors, VAL_ERROR_CHANGE) # payload base registration number must match path registration number if registration_num != request_json['baseRegistrationNumber']: - return path_data_mismatch_error_response(registration_num, - 'base registration number', - request_json['baseRegistrationNumber']) + return resource_utils.path_data_mismatch_error_response(registration_num, + 'base registration number', + request_json['baseRegistrationNumber']) # Fetch base registration information: business exception thrown if not # found or historical. @@ -246,7 +259,7 @@ def post(registration_num): # Verify base debtor (bypassed for staff) if not statement.validate_base_debtor(request_json['baseDebtor'], is_staff(jwt)): - return base_debtor_invalid_response() + return resource_utils.base_debtor_invalid_response() # TODO: charge a fee. @@ -258,12 +271,14 @@ def post(registration_num): account_id) statement.save() - return statement.json, HTTPStatus.OK + return statement.json, HTTPStatus.OK # CREATED + except SBCPaymentException as pay_exception: + return resource_utils.pay_exception_response(pay_exception) except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @cors_preflight('POST,OPTIONS') @@ -278,28 +293,28 @@ def post(registration_num): """Renew a financing statement by registration number.""" try: if registration_num is None: - return path_param_error_response('registration number') + return resource_utils.path_param_error_response('registration number') # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) request_json = request.get_json(silent=True) # Validate request data against the schema. valid_format, errors = schema_utils.validate(request_json, 'renewalStatement', 'ppr') if not valid_format: - return validation_error_response(errors, VAL_ERROR_RENEWAL) + return resource_utils.validation_error_response(errors, VAL_ERROR_RENEWAL) # payload base registration number must match path registration number if registration_num != request_json['baseRegistrationNumber']: - return path_data_mismatch_error_response(registration_num, - 'base registration number', - request_json['baseRegistrationNumber']) + return resource_utils.path_data_mismatch_error_response(registration_num, + 'base registration number', + request_json['baseRegistrationNumber']) # Fetch base registration information: business exception thrown if not # found or historical. @@ -307,7 +322,7 @@ def post(registration_num): # Verify base debtor (bypassed for staff) if not statement.validate_base_debtor(request_json['baseDebtor'], is_staff(jwt)): - return base_debtor_invalid_response() + return resource_utils.base_debtor_invalid_response() # TODO: charge a fee. @@ -319,12 +334,14 @@ def post(registration_num): account_id) statement.save() - return statement.json, HTTPStatus.OK + return statement.json, HTTPStatus.OK # CREATED + except SBCPaymentException as pay_exception: + return resource_utils.pay_exception_response(pay_exception) except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) @cors_preflight('POST,OPTIONS') @@ -339,28 +356,28 @@ def post(registration_num): """Discharge a financing statement by registration number.""" try: if registration_num is None: - return path_param_error_response('registration number') + return resource_utils.path_param_error_response('registration number') # Quick check: must be staff or provide an account ID. - account_id = get_account_id(request) + account_id = resource_utils.get_account_id(request) if not is_staff(jwt) and account_id is None: - return account_required_response() + return resource_utils.account_required_response() # Verify request JWT and account ID if not authorized(account_id, jwt): - return unauthorized_error_response(account_id) + return resource_utils.unauthorized_error_response(account_id) request_json = request.get_json(silent=True) # Validate request data against the schema. valid_format, errors = schema_utils.validate(request_json, 'dischargeStatement', 'ppr') if not valid_format: - return validation_error_response(errors, VAL_ERROR_DISCHARGE) + return resource_utils.validation_error_response(errors, VAL_ERROR_DISCHARGE) # payload base registration number must match path registration number if registration_num != request_json['baseRegistrationNumber']: - return path_data_mismatch_error_response(registration_num, - 'base registration number', - request_json['baseRegistrationNumber']) + return resource_utils.path_data_mismatch_error_response(registration_num, + 'base registration number', + request_json['baseRegistrationNumber']) # Fetch base registration information: business exception thrown if not # found or historical. @@ -368,9 +385,9 @@ def post(registration_num): # Verify base debtor (bypassed for staff) if not statement.validate_base_debtor(request_json['baseDebtor'], is_staff(jwt)): - return base_debtor_invalid_response() + return resource_utils.base_debtor_invalid_response() - # TODO: charge a fee. + # No fee for a discharge. # Try to save the discharge statement: failure throws a business exception. statement = Registration.create_from_json(request_json, @@ -379,9 +396,9 @@ def post(registration_num): registration_num, account_id) statement.save() - return statement.json, HTTPStatus.OK + return statement.json, HTTPStatus.OK # CREATED except BusinessException as exception: - return business_exception_response(exception) + return resource_utils.business_exception_response(exception) except Exception as default_exception: # noqa: B902; return nicer default error - return default_exception_response(default_exception) + return resource_utils.default_exception_response(default_exception) diff --git a/ppr-api/src/ppr_api/resources/ops.py b/ppr-api/src/ppr_api/resources/ops.py index 5bd261329..c763786b3 100644 --- a/ppr-api/src/ppr_api/resources/ops.py +++ b/ppr-api/src/ppr_api/resources/ops.py @@ -21,7 +21,7 @@ API = Namespace('OPS', description='Service - OPS checks') -SQL = text('select 1 from dual') +SQL = text('select 1') @API.route('healthz') diff --git a/ppr-api/src/ppr_api/resources/search_history.py b/ppr-api/src/ppr_api/resources/search_history.py index 43aba6722..a5462e0cb 100644 --- a/ppr-api/src/ppr_api/resources/search_history.py +++ b/ppr-api/src/ppr_api/resources/search_history.py @@ -24,7 +24,7 @@ from ppr_api.utils.util import cors_preflight from ppr_api.exceptions import BusinessException from ppr_api.services.authz import authorized -from ppr_api.models import SearchClient +from ppr_api.models import SearchRequest from ppr_api.resources import utils as resource_utils @@ -55,7 +55,7 @@ def get(): # Try to fetch search history by account id. # No results throws a not found business exception. current_app.logger.info(f'Fetching search history for {account_id}.') - history = SearchClient.find_all_by_account_id(account_id) + history = SearchRequest.find_all_by_account_id(account_id) return jsonify(history), HTTPStatus.OK except BusinessException as exception: diff --git a/ppr-api/src/ppr_api/resources/searches.py b/ppr-api/src/ppr_api/resources/searches.py index 30f92b15a..b39352006 100644 --- a/ppr-api/src/ppr_api/resources/searches.py +++ b/ppr-api/src/ppr_api/resources/searches.py @@ -16,7 +16,6 @@ # pylint: disable=too-many-return-statements from http import HTTPStatus -import json from flask import request, current_app, jsonify from flask_restx import Namespace, Resource, cors @@ -26,7 +25,7 @@ from ppr_api.utils.util import cors_preflight from ppr_api.exceptions import BusinessException from ppr_api.services.authz import is_staff, authorized -from ppr_api.models import SearchClient, SearchResult +from ppr_api.models import SearchRequest, SearchResult from ppr_api.services.payment.exceptions import SBCPaymentException from ppr_api.services.payment.payment import Payment, TransactionTypes from ppr_api.resources import utils as resource_utils @@ -64,8 +63,8 @@ def post(): if not valid_format: return resource_utils.validation_error_response(errors, VAL_ERROR) # Perform any extra data validation such as start and end dates here - SearchClient.validate_query(request_json) - query = SearchClient.create_from_json(request_json, account_id) + SearchRequest.validate_query(request_json) + query = SearchRequest.create_from_json(request_json, account_id) # Charge a search fee. if account_id: @@ -137,13 +136,13 @@ def put(search_id): if not valid_format: return resource_utils.validation_error_response(errors, VAL_ERROR) - search_client = SearchClient.find_by_id(search_id) - if not search_client: + search_request = SearchRequest.find_by_id(search_id) + if not search_request: return resource_utils.not_found_error_response('searchId', search_id) # Save the updated search selection. - search_client.update_search_selection(request_json) - return jsonify(json.loads(search_client.search_response)), HTTPStatus.ACCEPTED + search_request.update_search_selection(request_json) + return jsonify(search_request.search_response), HTTPStatus.ACCEPTED except BusinessException as exception: return resource_utils.business_exception_response(exception) diff --git a/ppr-api/test_data/create_test_data.py b/ppr-api/test_data/create_test_data.py index 1c2d61cbe..9118b137c 100644 --- a/ppr-api/test_data/create_test_data.py +++ b/ppr-api/test_data/create_test_data.py @@ -63,13 +63,11 @@ def execute_script(session, file_name): options = dict(bind=conn, binds={}) session = db.create_scoped_session(options=options) - execute_script(session, 'test_data/test_reset.sql') - execute_script(session, 'test_data/create_first.sql') - filenames = os.listdir(os.path.join(os.getcwd(), 'test_data/data_files')) + execute_script(session, 'test_data/postgres_test_reset.sql') + execute_script(session, 'test_data/postgres_create_first.sql') + filenames = os.listdir(os.path.join(os.getcwd(), 'test_data/postgres_data_files')) sorted_names = sorted(filenames) for filename in sorted_names: - execute_script(session, os.path.join(os.getcwd(), ('test_data/data_files/' + filename))) + execute_script(session, os.path.join(os.getcwd(), ('test_data/postgres_data_files/' + filename))) conn.close() - - diff --git a/ppr-api/test_data/postgres_create_first.sql b/ppr-api/test_data/postgres_create_first.sql new file mode 100644 index 000000000..c75459b1c --- /dev/null +++ b/ppr-api/test_data/postgres_create_first.sql @@ -0,0 +1,46 @@ +-- Intended to run after test_reset.sql. Put any statements that should run first here if sequence matters. + +-- Client Party Addresses +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000000, 'TEST 200000000', 'line 2', 'city', 'BC', 'V8R3A5', 'CA'); +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000001, 'TEST 200000001', 'line 2', 'city', 'BC', 'V8R3A5', 'CA'); + +-- Client Party code names and addresses +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (200000000,200000000,200000000,'TEST PARTY CODE 1', 12345,'TEST SP CONTACT NAME','604','2171234', + 'test-sp-client@gmail.com',null,'SPUSER',null); +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (200000001,200000001,200000001,'TEST PARTY CODE 2',12345,'TEST RP CONTACT NAME','604','2171234', + 'test-rp-client@gmail.com',null,'RPUSER',null); + +-- Add code_historical when Bob provides examples of how name/address changes work. + +-- Spec example royal bank +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(99990001, '1079 Douglas St', null, 'Victoria', 'BC', 'V8W2C5', 'CA'); +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(99990002, '1625 Hillside Ave', null, 'Victoria', 'BC', 'V8T2C3', 'CA'); +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(99990003, '3541 Blanshard St', null, 'Victoria', 'BC', 'V8Z0B9', 'CA'); +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(99990004, '1153 Esquimalt Rd', null, 'Victoria', 'BC', 'V9A3N7', 'CA'); + +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (9999,99990001,99990001,'RBC ROYAL BANK',12345,'TEST BRANCH 1 CONTACT NAME','250', + '3564500','test-1@test-rbc.com',null,null,null); +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (9999,99990002,99990002,'RBC ROYAL BANK',12345,'TEST BRANCH 2 CONTACT NAME','250','3564660', + 'test-2@test-rbc.com',null,null,null); +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (9999,99990003,99990003,'RBC ROYAL BANK',12345,'TEST BRANCH 3 CONTACT NAME','250','2208424', + 'test-3@test-rbc.com',null,null,null); +INSERT INTO client_codes(HEAD_ID, ID, ADDRESS_ID, NAME, BCONLINE_ACCOUNT, CONTACT_NAME,CONTACT_AREA_CD, + CONTACT_PHONE_NUMBER, EMAIL_ADDRESS, USERS_ID, USER_ID, DATE_TS) + VALUES (9999,99990004,99990004,'RBC ROYAL BANK',12345,'TEST BRANCH 4 CONTACT NAME','250','3564670', + 'test-4@test-rbc.com',null,null,null); diff --git a/ppr-api/test_data/postgres_data_files/test0001.sql b/ppr-api/test_data/postgres_data_files/test0001.sql new file mode 100755 index 000000000..1491cfa9f --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0001.sql @@ -0,0 +1,62 @@ +-- TEST0001 financing statement security agreement base test +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000000, 'D-T-0001', 'PS12345', current_timestamp, 'PPSALIEN', 'SA', 'TEST0001', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000000, 'ACT', current_timestamp + interval '730 days', 2, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000000, 200000000, 'TEST0001', null, 'SA', 'PPSALIEN', current_timestamp, 200000000, 2, + null, null, 'PS12345', 'TEST-SA-0001', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000000, 200000000, 200000000, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000002, 'TEST-0001', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000000, 'RG', 200000000, 200000000, null, null, 'TEST', '1', 'REGISTERING', null, + null, 200000002) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000001, 'DI', 200000000, 200000000, null, null, 'TEST IND', '1', 'DEBTOR', null, + null, 200000002, searchkey_first_name('TEST IND'), searchkey_last_name('DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000002, 'DB', 200000000, 200000000, null, null, null, null, null, 'TEST BUS 2 DEBTOR', + null, 200000002, searchkey_business_name('TEST BUS 2 DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000003, 'SP', 200000000, 200000000, null, null, null, null, null, 'TEST 1 SECURED PARTY', + null, 200000002) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000004, 'SP', 200000000, 200000000, null, 200000000, null, null, null, null, + null, 200000002) +; +INSERT INTO general_collateral(id, registration_id, financing_id, registration_id_end, description) + VALUES(200000000, 200000000, 200000000, null, 'TEST0001 GC 1') +; +INSERT INTO general_collateral(id, registration_id, financing_id, registration_id_end, description) + VALUES(200000001, 200000000, 200000000, null, 'TEST0001 GC 2') +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000000, 'MV', 200000000, 200000000, null, 2018, 'HYUNDAI', 'TUSCON', 'KM8J3CA46JU622994', null, + searchkey_vehicle('KM8J3CA46JU622994')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000001, 'MH', 200000000, 200000000, null, 2001, 'HOMCO IND. LTD DIPLOMAT', null, '9407', '21324', + searchkey_mhr('9407')) +; +-- TEST0001 end diff --git a/ppr-api/test_data/postgres_data_files/test0002.sql b/ppr-api/test_data/postgres_data_files/test0002.sql new file mode 100644 index 000000000..ddf6bb423 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0002.sql @@ -0,0 +1,38 @@ +-- TEST0002 financing statement repairer's lien base test +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000001, 'D-T-0002', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'RL', 'TEST0002', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000001, 'ACT', CURRENT_TIMESTAMP + interval '90 days', 0, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000001, 200000001, 'TEST0002', null, 'RL', 'PPSALIEN', CURRENT_TIMESTAMP, 200000001, 2, + '2000.00', CURRENT_TIMESTAMP + interval '90 days', 'PS12345', 'TEST-RL-0001', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000003, 'TEST-0002', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000005, 'RG', 200000001, 200000001, null, null, 'TEST', '2', 'REGISTERING', null, + null, 200000003) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000006, 'DB', 200000001, 200000001, null, null, null, null, null, 'TEST BUS 2 DEBTOR', + null, 200000003, searchkey_business_name('TEST BUS 2 DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000007, 'SP', 200000001, 200000001, null, 200000000, null, null, null, null, + null, 200000003) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000002, 'MV', 200000001, 200000001, null, 2014, 'HYUNDAI', 'TUSCON', 'KX8J3CA46JU622994', null, + searchkey_vehicle('KX8J3CA46JU622994')) +; +-- TEST0002 end diff --git a/ppr-api/test_data/postgres_data_files/test0003.sql b/ppr-api/test_data/postgres_data_files/test0003.sql new file mode 100644 index 000000000..e64c8f61b --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0003.sql @@ -0,0 +1,38 @@ +-- TEST0003 Historical/discharged financing statement base test +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000002, 'D-T-0003', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'RL', 'TEST0003', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000002, 'HDC', CURRENT_TIMESTAMP + interval '90 days', 0, 'Y' , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000002, 200000002, 'TEST0003', null, 'RL', 'PPSALIEN', CURRENT_TIMESTAMP, 200000002, 2, + '2000.00', CURRENT_TIMESTAMP - interval '10 days', 'PS12345', 'TEST-RL-0002', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000004, 'TEST-0002', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000008, 'RG', 200000002, 200000002, null, null, 'TEST', '3', 'REGISTERING', null, + null, 200000004) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000009, 'DB', 200000002, 200000002, null, null, null, null, null, 'TEST BUS 3 DEBTOR', + null, 200000004, searchkey_business_name('TEST BUS 3 DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000010, 'SP', 200000002, 200000002, null, 200000000, null, null, null, null, + null, 200000004) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000003, 'MV', 200000002, 200000002, null, 2014, 'HYUNDAI', 'TUSCON', 'KX8J3CA46JU622994', null, + searchkey_vehicle('KX8J3CA46JU622994')) +; +-- TEST0003 end diff --git a/ppr-api/test_data/postgres_data_files/test0004.sql b/ppr-api/test_data/postgres_data_files/test0004.sql new file mode 100644 index 000000000..020a1d7a9 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0004.sql @@ -0,0 +1,63 @@ +-- TEST0004 discharge financing statement base test: create financing statement, then discharge statement +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000006, 'D-T-0004', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0004', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000003, 'ACT', CURRENT_TIMESTAMP + interval '730 days', 2, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000003, 200000003, 'TEST0004', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000006, 2, + null, null, 'PS12345', 'TEST-SA-0004', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000001, 200000003, 200000003, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000005, 'TEST-0004', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000011, 'RG', 200000003, 200000003, null, null, 'TEST', '4', 'REGISTERING', null, + null, 200000005) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000012, 'DI', 200000003, 200000003, null, null, 'TEST IND', '4', 'DEBTOR', null, + null, 200000005, searchkey_first_name('TEST IND'), searchkey_last_name('DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000013, 'SP', 200000003, 200000003, null, null, null, null, null, 'TEST 4 SECURED PARTY', + null, 200000005) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000004, 'MV', 200000003, 200000003, null, 2018, 'HONDA', 'CIVIC', 'JU622994', null, + searchkey_vehicle('JU622994')) +; +-- Create discharge +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000007, 'D-T-00D4', 'PS12345', CURRENT_TIMESTAMP, 'DISCHARGE', 'DC', 'TEST0004', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000004, 200000003, 'TEST00D4', 'TEST0004', 'DC', 'DISCHARGE', CURRENT_TIMESTAMP + interval '1 day', 200000007, 0, + null, null, 'PS12345', 'TEST-DIS-0004', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000006, 'TEST-00D4', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000014, 'RG', 200000004, 200000003, null, null, 'TEST-DISCHARGE', '4', 'REGISTERING', null, + null, 200000006) +; +UPDATE financing_statements + SET state_type = 'HDC', discharged = 'Y' + WHERE id = 200000003 +; +-- TEST0004 end diff --git a/ppr-api/test_data/postgres_data_files/test0005.sql b/ppr-api/test_data/postgres_data_files/test0005.sql new file mode 100644 index 000000000..6dfabab13 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0005.sql @@ -0,0 +1,63 @@ +-- TEST0005 renewal statement base test: create financing statement, then renewal statement +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000008, 'D-T-0005', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0005', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000004, 'ACT', CURRENT_TIMESTAMP + interval '365 days', 1, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000005, 200000004, 'TEST0005', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000008, 1, + null, null, 'PS12345', 'TEST-SA-0005', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000002, 200000005, 200000003, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000007, 'TEST-0005', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000015, 'RG', 200000005, 200000004, null, null, 'TEST', '5', 'REGISTERING', null, + null, 200000007) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000016, 'DI', 200000005, 200000004, null, null, 'TEST IND', '5', 'DEBTOR', null, + null, 200000007, searchkey_first_name('TEST IND'), searchkey_last_name('DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000017, 'SP', 200000005, 200000004, null, null, null, null, null, 'TEST 5 SECURED PARTY', + null, 200000007) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000005, 'MV', 200000005, 200000004, null, 2018, 'TESLA', 'MODEL 3', 'YJ46JU622994', null, + searchkey_vehicle('YJ46JU622994')) +; +-- Create renewal +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000009, 'D-T-00R5', 'PS12345', CURRENT_TIMESTAMP, 'RENEWAL', 'RE', 'TEST0005', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000006, 200000004, 'TEST00R5', 'TEST0005', 'RE', 'RENEWAL', CURRENT_TIMESTAMP + interval '5 minutes', 200000009, 2, + null, null, 'PS12345', 'TEST-REN-0005', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000008, 'TEST-00R5', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000018, 'RG', 200000006, 200000004, null, null, 'TEST-RENEWAL', '5', 'REGISTERING', null, + null, 200000008) +; +UPDATE financing_statements + SET expire_date = CURRENT_TIMESTAMP + interval '730 days', life = 2 + WHERE id = 200000004 +; +-- TEST0005 end diff --git a/ppr-api/test_data/postgres_data_files/test0006.sql b/ppr-api/test_data/postgres_data_files/test0006.sql new file mode 100644 index 000000000..0a277d76e --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0006.sql @@ -0,0 +1,29 @@ +-- TEST0006 renewal statement on repairer's lien financing statement TEST0002 +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000010, 'D-T-00R6', 'PS12345', CURRENT_TIMESTAMP, 'RENEWAL', 'RE', 'TEST0002', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000007, 200000001, 'TEST00R6', 'TEST0002', 'RE', 'RENEWAL', CURRENT_TIMESTAMP + interval '5 minutes', 200000010, 0, + null, null, 'PS12345', 'TEST-REN-0006', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000009, 'TEST-00R6', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000019, 'RG', 200000007, 200000001, null, null, 'TEST-RENEWAL-RL', '6', 'REGISTERING', null, + null, 200000009) +; +INSERT INTO court_orders(id, registration_id, order_date, court_name, court_registry, file_number, effect_of_order) + VALUES(200000000, 200000007, CURRENT_TIMESTAMP + interval '200 days', 'Supreme Court of British Columbia', 'Victoria', 'BC123495', + 'Court Order to renew Repairer''s Lien.') +; + +UPDATE financing_statements + SET expire_date = CURRENT_TIMESTAMP + interval '90 days', life = 0 + WHERE id = 200000001 +; +-- TEST0006 end diff --git a/ppr-api/test_data/postgres_data_files/test0007.sql b/ppr-api/test_data/postgres_data_files/test0007.sql new file mode 100644 index 000000000..f82168a56 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0007.sql @@ -0,0 +1,53 @@ +-- TEST0007 Amendment on TEST0001. Update all possible entities. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000011, 'D-T-00A7', 'PS12345', CURRENT_TIMESTAMP, 'AMENDMENT', 'CO', 'TEST0001', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path, detail_description) + VALUES(200000008, 200000000, 'TEST0007', 'TEST0001', 'CO', 'AMENDMENT', CURRENT_TIMESTAMP + interval '5 minutes', 200000011, null, + null, null, 'PS12345', 'TEST-AM-0007', null, null, 'Description of court order.') +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000010, 'TEST-00A7', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000020, 'RG', 200000008, 200000000, null, null, 'TEST-AMEND-CO', '7', 'REGISTERING', null, + null, 200000010) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000021, 'DB', 200000008, 200000000, null, null, null, null, null, 'TEST 7 AMEND DEBTOR', + null, 200000010, searchkey_business_name('TEST 7 AMEND DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000022, 'SP', 200000008, 200000000, null, null, null, null, null, 'TEST 7 AMEND SECURED PARTY', + null, 200000010) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000006, 'MV', 200000008, 200000000, null, 2018, 'FORD', 'FIESTA', 'T346JU622994', null, + searchkey_vehicle('T346JU622994')) +; +INSERT INTO general_collateral(id, registration_id, financing_id, registration_id_end, description) + VALUES(200000002, 200000008, 200000000, null, 'TEST GENERAL COLLATERAL AMEND ADD.') +; +INSERT INTO court_orders(id, registration_id, order_date, court_name, court_registry, file_number, effect_of_order) + VALUES(200000001, 200000008, CURRENT_TIMESTAMP + interval '200 days', 'Supreme Court of British Columbia', 'Victoria', 'BC123495', + 'Court Order to change something.') +; +UPDATE parties + SET registration_id_end = 200000008 + WHERE id IN (200000001, 200000003) +; +UPDATE general_collateral + SET registration_id_end = 200000008 +WHERE id = 200000001 +; +UPDATE serial_collateral + SET registration_id_end = 200000008 +WHERE id = 200000001 +; +-- TEST0007 end diff --git a/ppr-api/test_data/postgres_data_files/test0008.sql b/ppr-api/test_data/postgres_data_files/test0008.sql new file mode 100644 index 000000000..6a6744391 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0008.sql @@ -0,0 +1,29 @@ +-- TEST0008 Change Statement debtor transfer on TEST0001. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000012, 'D-T-00C8', 'PS12345', CURRENT_TIMESTAMP, 'CHANGE', 'DT', 'TEST0001', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000009, 200000000, 'TEST0008', 'TEST0001', 'DT', 'CHANGE', CURRENT_TIMESTAMP + interval '10 minutes', 200000012, null, + null, null, 'PS12345', 'TEST-CH-0008', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000011, 'TEST-00C8', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000023, 'RG', 200000009, 200000000, null, null, 'TEST-CHANGE-DT', '8', 'REGISTERING', null, + null, 200000011) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000024, 'DB', 200000009, 200000000, null, null, null, null, null, 'TEST 8 TRANSFER DEBTOR', + null, 200000011, searchkey_business_name('TEST 8 TRANSFER DEBTOR')) +; +UPDATE parties + SET registration_id_end = 200000009 + WHERE id = 200000021 + AND party_type = 'DB' +; +-- TEST0008 end diff --git a/ppr-api/test_data/postgres_data_files/test0009.sql b/ppr-api/test_data/postgres_data_files/test0009.sql new file mode 100644 index 000000000..b4c613e22 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0009.sql @@ -0,0 +1,29 @@ +-- TEST0009 Change Statement secured party transfer on TEST0001. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000013, 'D-T-00C9', 'PS12345', CURRENT_TIMESTAMP, 'CHANGE', 'ST', 'TEST0001', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000010, 200000000, 'TEST0009', 'TEST0001', 'ST', 'CHANGE', CURRENT_TIMESTAMP + interval '15 minutes', 200000013, null, + null, null, 'PS12345', 'TEST-CH-0009', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000012, 'TEST-00C9', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000025, 'RG', 200000010, 200000000, null, null, 'TEST-CHANGE-DT', '9', 'REGISTERING', null, + null, 200000012) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000026, 'SP', 200000010, 200000000, null, null, null, null, null, 'TEST 9 CHANGE TRANSFER SECURED PARTY', + null, 200000012) +; +UPDATE parties + SET registration_id_end = 200000010 + WHERE id = 200000022 + AND party_type = 'SP' +; +-- TEST0009 end diff --git a/ppr-api/test_data/postgres_data_files/test0010.sql b/ppr-api/test_data/postgres_data_files/test0010.sql new file mode 100644 index 000000000..961b36123 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0010.sql @@ -0,0 +1,40 @@ +-- TEST0010 Change Statement collateral subsitution on TEST0001. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000014, 'D-T-0010', 'PS12345', CURRENT_TIMESTAMP, 'CHANGE', 'SU', 'TEST0001', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000011, 200000000, 'TEST0010', 'TEST0001', 'SU', 'CHANGE', CURRENT_TIMESTAMP, 200000014, null, + null, null, 'PS12345', 'TEST-CH-0010', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000013, 'TEST-0010', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000027, 'RG', 200000011, 200000000, null, null, 'TEST-CHANGE-SU', '10', 'REGISTERING', null, + null, 200000013) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000007, 'MV', 200000011, 200000000, null, 2014, 'BMW', 'Z4', 'JU622994', null, + searchkey_vehicle('JU622994')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000008, 'MH', 200000011, 200000000, null, 2012, 'HOMCO IND. LTD DIPLOMAT', null, '999999', '220000', + searchkey_mhr('220000')) +; +INSERT INTO general_collateral(id, registration_id, financing_id, registration_id_end, description) + VALUES(200000003, 200000011, 200000000, null, 'TEST GENERAL COLLATERAL CHANGE ADD.') +; +UPDATE general_collateral + SET registration_id_end = 200000011 +WHERE id = 200000002 +; +UPDATE serial_collateral + SET registration_id_end = 200000011 +WHERE id = 200000006 +; +-- TEST0010 end diff --git a/ppr-api/test_data/postgres_data_files/test0011.sql b/ppr-api/test_data/postgres_data_files/test0011.sql new file mode 100644 index 000000000..8d3c010b0 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0011.sql @@ -0,0 +1,46 @@ +-- TEST0011 serial number MHR, AC test match data: +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000015, 'D-T-0011', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0011', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000005, 'ACT', CURRENT_TIMESTAMP + interval '365 days', 1, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000012, 200000005, 'TEST0011', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000015, 1, + null, null, 'PS12345', 'TEST-SA-0011', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000003, 200000012, 200000005, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000014, 'TEST-0011', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000028, 'RG', 200000012, 200000005, null, null, 'TEST', '11', 'REGISTERING', null, + null, 200000014) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000029, 'DI', 200000012, 200000005, null, null, 'TEST IND', '11', 'DEBTOR', null, + null, 200000014, searchkey_first_name('TEST IND'),searchkey_last_name('DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000030, 'SP', 200000012, 200000005, null, null, null, null, null, 'TEST 11 SECURED PARTY', + null, 200000014) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000009, 'MH', 200000012, 200000005, null, 2012, 'HOMCO IND. LTD DIPLOMAT', null, '999999', '220000', + searchkey_mhr('220000')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000010, 'AC', 200000012, 200000005, null, 1998, 'CESSNA', '172R SKYHAWK', 'CFYXW', null, + searchkey_aircraft('CFYXW')) +; +-- TEST0011 end diff --git a/ppr-api/test_data/postgres_data_files/test0012.sql b/ppr-api/test_data/postgres_data_files/test0012.sql new file mode 100644 index 000000000..3b4013bfd --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0012.sql @@ -0,0 +1,51 @@ +-- TEST0012 serial number MHR almost match, AC test match data: +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000016, 'D-T-0012', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0012', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000006, 'ACT', CURRENT_TIMESTAMP + interval '365 days', 1, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000013, 200000006, 'TEST0012', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000016, 1, + null, null, 'PS12345', 'TEST-SA-0012', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000004, 200000013, 200000006, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000015, 'TEST-0012', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000031, 'RG', 200000013, 200000006, null, null, 'TEST', '12', 'REGISTERING', null, + null, 200000015) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000032, 'DI', 200000013, 200000006, null, null, 'TEST IND', '12', 'DEBTOR', null, + null, 200000015, searchkey_first_name('TEST IND'), searchkey_last_name('DEBTOR')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000033, 'SP', 200000013, 200000006, null, null, null, null, null, 'TEST 12 SECURED PARTY', + null, 200000015) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000011, 'MH', 200000013, 200000006, null, 2012, 'HOMCO IND. LTD DIPLOMAT', null, '9999', '22000', + searchkey_mhr('22000')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000012, 'AC', 200000013, 200000006, null, 1998, 'CESSNA', '172R SKYHAWK', 'CFYX', null, + searchkey_aircraft('CFYX')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000013, 'AF', 200000013, 200000006, null, 1998, 'AIRFRAME make', 'AIRFRAME model', 'AF16031', null, + searchkey_aircraft('AF16031')) +; +-- TEST0012 end diff --git a/ppr-api/test_data/postgres_data_files/test0013.sql b/ppr-api/test_data/postgres_data_files/test0013.sql new file mode 100644 index 000000000..59c3e9680 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0013.sql @@ -0,0 +1,61 @@ +-- TEST0013 expired more than 30 days excluded search test on all search types. +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000017, 'D-T-0013', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0013', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000007, 'HEX', CURRENT_TIMESTAMP - interval '100 days', 1, null , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000014, 200000007, 'TEST0013', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000017, 1, + null, null, 'PS12345', 'TEST-SA-0013', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000005, 200000014, 200000007, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000016, 'TEST-0013', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000034, 'RG', 200000014, 200000007, null, null, 'TEST', '13', 'REGISTERING', null, + null, 200000016) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000035, 'DI', 200000014, 200000007, null, null, 'TEST IND DEBTOR', '13', 'XXXXX99', null, + null, 200000016, searchkey_first_name('TEST IND DEBTOR'), searchkey_last_name('XXXXX99')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000036, 'DB', 200000014, 200000007, null, null, null, null, null, 'XXXXX99', + null, 200000016, searchkey_business_name('XXXXX99')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000037, 'SP', 200000014, 200000007, null, null, null, null, null, 'TEST 13 SECURED PARTY', + null, 200000016) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000014, 'MV', 200000014, 200000007, null, 2012, 'EXPIRED MV', 'MODEL', 'XXXXX999999', null, + searchkey_vehicle('XXXXX999999')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000015, 'MH', 200000014, 200000007, null, 2012, 'EXPIRED MH', 'MODEL', 'XXXXX999999', '299999', + searchkey_mhr('299999')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000016, 'AC', 200000014, 200000007, null, 2012, 'EXPIRED AC', 'MODEL', 'XXXXX999999', null, + searchkey_aircraft('XXXXX999999')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000017, 'AF', 200000014, 200000007, null, 2012, 'EXPIRED AF', 'MODEL', 'XXXXX999999', null, + searchkey_aircraft('XXXXX999999')) +; +-- TEST0013 end diff --git a/ppr-api/test_data/postgres_data_files/test0014.sql b/ppr-api/test_data/postgres_data_files/test0014.sql new file mode 100644 index 000000000..9dffe5abb --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0014.sql @@ -0,0 +1,74 @@ +-- TEST0014 discharged more than 30 days excluded search test on all search types. +-- draft statement CLOB empty for testing. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000018, 'D-T-0014', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0014', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000008, 'HDC', CURRENT_TIMESTAMP + interval '1500 days', 5, 'Y' , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000015, 200000008, 'TEST0014', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP - interval '60 days', 200000018, 1, + null, null, 'PS12345', 'TEST-SA-0014', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000006, 200000015, 200000008, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000017, 'TEST-0014', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000038, 'RG', 200000015, 200000008, null, null, 'TEST', '14', 'REGISTERING', null, + null, 200000017) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, first_name_key, last_name_key) + VALUES(200000039, 'DI', 200000015, 200000008, null, null, 'TEST IND DEBTOR', '14', 'ZZZZZ99', null, + null, 200000017, searchkey_first_name('TEST IND DEBTOR'), searchkey_last_name('ZZZZZ99')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000040, 'DB', 200000015, 200000008, null, null, null, null, null, 'ZZZZZ99', + null, 200000017, searchkey_business_name('ZZZZZ99')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000041, 'SP', 200000015, 200000008, null, null, null, null, null, 'TEST 14 SECURED PARTY', + null, 200000017) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000018, 'MV', 200000015, 200000008, null, 2012, 'DISCHARGED MV', 'MODEL', 'ZZZZZ999999', null, + searchkey_vehicle('ZZZZZ999999')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000019, 'MH', 200000015, 200000008, null, 2012, 'DISCHARGED MH', 'MODEL', 'ZZZZZ999999', '399999', + searchkey_mhr('399999')) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000020, 'AC', 200000015, 200000008, null, 2012, 'DISCHARGED AC', 'MODEL', 'ZZZZZ999999', null, + searchkey_aircraft('ZZZZZ999999')) +; +-- Create discharge +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000019, 'D-T-0D14', 'PS12345', CURRENT_TIMESTAMP, 'DISCHARGE', 'DC', 'TEST0D14', null, '{}'); +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000016, 200000008, 'TEST0D14', 'TEST0014', 'DC', 'DISCHARGE', CURRENT_TIMESTAMP - interval '45 days', 200000019, 0, + null, null, 'PS12345', 'TEST-DIS-0014', null, null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000018, 'TEST-0D14', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000042, 'RG', 200000016, 200000008, null, null, 'TEST-DISCHARGE', '14', 'REGISTERING', null, + null, 200000018) +; +-- TEST0014 end diff --git a/ppr-api/test_data/postgres_data_files/test0015.sql b/ppr-api/test_data/postgres_data_files/test0015.sql new file mode 100644 index 000000000..d6034a18e --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test0015.sql @@ -0,0 +1,46 @@ +-- TEST0015 duplicate business name registraton number test. Only one registration should be returned +-- in the search detail results for two matches on the same registration. +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000020, 'D-T-0015', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'TEST0015', null, '{}'); +INSERT INTO financing_statements(id, state_type, expire_date, life, discharged, renewed) + VALUES(200000009, 'ACT', CURRENT_TIMESTAMP + interval '1500 days', 5, 'Y' , null) +; +INSERT INTO registrations(id, financing_id, registration_number, base_reg_number, registration_type, + registration_type_cl, registration_ts, draft_id, life, lien_value, + surrender_date, account_id, client_reference_id, pay_invoice_id, pay_path) + VALUES(200000017, 200000009, 'TEST0015', null, 'SA', 'PPSALIEN', CURRENT_TIMESTAMP, 200000020, 1, + null, null, 'PS12345', 'TEST-SA-0015', null, null) +; +INSERT INTO trust_indentures(id, registration_id, financing_id, trust_indenture, registration_id_end) + VALUES(200000007, 200000017, 200000009, 'Y', null) +; +INSERT INTO addresses(id, street, street_additional, city, region, postal_code, country) + VALUES(200000019, 'TEST-0015', 'line 2', 'city', 'BC', 'V8R3A5', 'CA') +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000043, 'RG', 200000017, 200000009, null, null, 'TEST', '14', 'REGISTERING', null, + null, 200000019) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000044, 'DB', 200000017, 200000009, null, null, null, null, null, 'DUPLICATE NAME', + null, 200000019, searchkey_business_name('DUPLICATE NAME')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id, business_srch_key) + VALUES(200000045, 'DB', 200000017, 200000009, null, null, null, null, null, 'DUPLICATE NAME', + null, 200000019, searchkey_business_name('DUPLICATE NAME')) +; +INSERT INTO parties(id, party_type, registration_id, financing_id, registration_id_end, branch_id, first_name, + middle_initial, last_name, business_name, birth_date, address_id) + VALUES(200000046, 'SP', 200000017, 200000009, null, null, null, null, null, 'TEST 14 SECURED PARTY', + null, 200000019) +; +INSERT INTO serial_collateral(id, serial_type, registration_id, financing_id, registration_id_end, + year, make, model, serial_number, mhr_number, srch_vin) + VALUES(200000021, 'MV', 200000017, 200000009, null, 2012, 'JAGUAR', 'F-TYPE', 'VIN123434322', null, + searchkey_vehicle('VIN123434322')) +; +-- TEST0015 end diff --git a/ppr-api/test_data/postgres_data_files/test_drafts.sql b/ppr-api/test_data/postgres_data_files/test_drafts.sql new file mode 100644 index 000000000..19af0b5d0 --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test_drafts.sql @@ -0,0 +1,153 @@ +-- Unregistered draft financing statement +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000003, 'D-T-FS01', 'PS12345', CURRENT_TIMESTAMP, 'PPSALIEN', 'SA', 'NA', null, +'{ + "type": "FINANCING_STATEMENT", + "financingStatement": { + "type": "SA", + "clientReferenceId": "A-00000402", + "registeringParty": { + "businessName": "ABC SEARCHING COMPANY", + "address": { + "street": "222 SUMMER STREET", + "city": "VICTORIA", + "region": "BC", + "country": "CA", + "postalCode": "V8W 2V8" + }, + "emailAddress": "bsmith@abc-search.com" + }, + "debtors": [ + { + "businessName": "Debtor 1 Inc.", + "address": { + "street": "721 Debtor Ave", + "city": "Victoria", + "region": "BC", + "country": "CA", + "postalCode": "A1A 1A1" + }, + "birthDate": "1990-06-15", + "emailAddress": "dsmith@debtor1.com" + } + ], + "vehicleCollateral": [ + { + "type": "MV", + "serialNumber": "KM8J3CA46JU622994", + "year": 2018, + "make": "HYUNDAI", + "model": "TUCSON" + } + ], + "lifeYears": 5, + "securedParties": [ + { + "businessName": "BANK OF BRITISH COLUMBIA", + "address": { + "street": "3721 BEACON AVENUE", + "city": "SIDNEY", + "region": "BC", + "country": "CA", + "postalCode": "V7R 1R7" + }, + "emailAddress": "asmith@bobc.com" + } + ] + } +}'); + +-- Unregistered draft amendment statement +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000004, 'D-T-AM01', 'PS12345', CURRENT_TIMESTAMP, 'AMENDMENT', 'AM', 'TEST0001', null, +'{ + "type": "AMENDMENT_STATEMENT", + "amendmentStatement": { + "baseRegistrationNumber": "023003B", + "documentId": "D0034002", + "description": "Amendment to correct spelling mistake in debtor name. Name changed from \"Brawn\" to \"Brown\".", + "changeType": "AM", + "clientReferenceId": "A-00000402", + "baseDebtor": { + "businessName": "DEBTOR 1 INC." + }, + "registeringParty": { + "businessName": "ABC SEARCHING COMPANY", + "address": { + "street": "222 SUMMER STREET", + "city": "VICTORIA", + "region": "BC", + "country": "CA", + "postalCode": "V8W 2V8" + }, + "emailAddress": "bsmith@abc-search.com" + }, + "deleteDebtors": [ + { + "businessName": "Brawn Window Cleaning Inc.", + "partyId": 1321065 + } + ], + "addDebtors": [ + { + "businessName": "Brown Window Cleaning Inc.", + "address": { + "street": "1234 Blanshard St", + "city": "Victoria", + "region": "BC", + "country": "CA", + "postalCode": "V8S 3J5" + }, + "emailAddress": "csmith@bwc.com" + } + ] + } +}'); + +-- Unregistered draft change statement +INSERT INTO drafts(id, document_number, account_id, create_ts, registration_type_cl, registration_type, + registration_number, update_ts, draft) + VALUES(200000005, 'D-T-CH01', 'PS12345', CURRENT_TIMESTAMP, 'CHANGE', 'DT', 'TEST0001', null, +'{ + "type": "CHANGE_STATEMENT", + "changeStatement": { + "baseRegistrationNumber": "023010B", + "documentId": "D0034003", + "changeType": "DT", + "baseDebtor": { + "businessName": "DEBTOR 1 INC." + }, + "registeringParty": { + "businessName": "ABC SEARCHING COMPANY", + "address": { + "street": "222 SUMMER STREET", + "city": "VICTORIA", + "region": "BC", + "country": "CA", + "postalCode": "V8W 2V8" + }, + "emailAddress": "bsmith@abc-search.com" + }, + "addDebtors": [ + { + "businessName": "Brown Window Cleaning Inc.", + "address": { + "street": "1234 Blanshard St", + "city": "Victoria", + "region": "BC", + "country": "CA", + "postalCode": "V8S 3J5" + }, + "emailAddress": "csmith@bwc.com" + } + ], + "deleteDebtors": [ + { + "businessName": "Brawn Window Cleaning Inc.", + "partyId": 1321065 + } + ] + } +}'); diff --git a/ppr-api/test_data/postgres_data_files/test_searches.sql b/ppr-api/test_data/postgres_data_files/test_searches.sql new file mode 100644 index 000000000..a8526beff --- /dev/null +++ b/ppr-api/test_data/postgres_data_files/test_searches.sql @@ -0,0 +1,243 @@ +-- Existing completed registration number search on TEST0001 (search step 1 and 2) +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000000, CURRENT_TIMESTAMP, 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0001"}, "clientReferenceId": "T-S-RG-001"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0001", "baseRegistrationNumber": "TEST0001", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'UT-SQ-RG-001', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000000, 1, 0, +'[{"baseRegistrationNumber": "TEST0001", "matchType": "EXACT", "registrationType": "SA"}]', +'[]') +; + +-- Existing incomplete registration number search on TEST0001 (search step only) +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000001, CURRENT_TIMESTAMP, 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0001"}, "clientReferenceId": "T-S-RG-002"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0001", "baseRegistrationNumber": "TEST0001", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'UT-SQ-RG-002', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000001, 1, 0, null, +'[{"matchType": "EXACT", "financingStatement": {"type": "SA", "baseRegistrationNumber": "TEST0001", "registrationDescription": "PPSA SECURITY AGREEMENT", "registrationAct": "PPSA SECURITY ACT", "createDateTime": "2021-03-12T01:48:53+00:00", "clientReferenceId": "TEST-SA-0001", "registeringParty": {"personName": {"first": "TEST", "last": "REGISTERING", "middle": "1"}, "address": {"street": "TEST-0001", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, "securedParties": [{"partyId": 200000004, "code": "200000000", "businessName": "TEST SECURED PARTY", "address": {"street": "TEST 200000000", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}, "emailAddress": "test-sp-client@gmail.com"}, {"partyId": 200000026, "businessName": "TEST 9 CHANGE TRANSFER SECURED PARTY", "address": {"street": "TEST-00C9", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}], "debtors": [{"partyId": 200000002, "businessName": "TEST BUS 2 DEBTOR", "address": {"street": "TEST-0001", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, {"partyId": 200000024, "businessName": "TEST 8 TRANSFER DEBTOR", "address": {"street": "TEST-00C8", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}], "generalCollateral": [{"collateralId": 200000003, "description": "TEST GENERAL COLLATERAL CHANGE ADD."}, {"collateralId": 200000000, "description": "TEST0001 GC 1"}], "vehicleCollateral": [{"vehicleId": 200000007, "type": "MV", "year": 2014, "make": "BMW", "model": "Z4", "serialNumber": "JU622994"}, {"vehicleId": 200000008, "type": "MH", "year": 2012, "make": "HOMCO IND. LTD DIPLOMAT", "serialNumber": "999999", "manufacturedHomeRegistrationNumber": "220000"}, {"vehicleId": 200000000, "type": "MV", "year": 2018, "make": "HYUNDAI", "model": "TUSCON", "serialNumber": "KM8J3CA46JU622994"}], "trustIndenture": true, "lifeYears": 2, "expiryDate": "2023-03-12T01:48:53+00:00", "changes": [{"baseRegistrationNumber": "TEST0001", "createDateTime": "2021-03-12T01:48:54+00:00", "changeRegistrationNumber": "TEST0010", "changeType": "SU", "clientReferenceId": "TEST-CH-0010", "registeringParty": {"personName": {"first": "TEST-CHANGE-SU", "last": "REGISTERING", "middle": "10"}, "address": {"street": "TEST-0010", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, "addGeneralCollateral": [{"collateralId": 200000003, "description": "TEST GENERAL COLLATERAL CHANGE ADD."}], "deleteGeneralCollateral": [{"collateralId": 200000002, "description": "TEST GENERAL COLLATERAL AMEND ADD."}], "addVehicleCollateral": [{"vehicleId": 200000007, "type": "MV", "year": 2014, "make": "BMW", "model": "Z4", "serialNumber": "JU622994"}, {"vehicleId": 200000008, "type": "MH", "year": 2012, "make": "HOMCO IND. LTD DIPLOMAT", "serialNumber": "999999", "manufacturedHomeRegistrationNumber": "220000"}], "deleteVehicleCollateral": [{"vehicleId": 200000006, "type": "MV", "year": 2018, "make": "FORD", "model": "FIESTA", "serialNumber": "T346JU622994"}], "statementType": "CHANGE_STATEMENT"}]}}]') +; + +-- Existing registration number search on TEST0012 (search step only). A financing statement with no other registrations +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000002, CURRENT_TIMESTAMP, 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0012"}, "clientReferenceId": "T-S-RG-003"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0012", "baseRegistrationNumber": "TEST0012", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'UT-SQ-RG-003', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000002, 1, 0, null, +'[{"matchType": "EXACT", "financingStatement": {"type": "SA", "baseRegistrationNumber": "TEST0012", "registrationDescription": "PPSA SECURITY AGREEMENT", "registrationAct": "PPSA SECURITY ACT", "createDateTime": "2021-03-12T01:48:54+00:00", "clientReferenceId": "TEST-SA-0012", "registeringParty": {"personName": {"first": "TEST", "last": "REGISTERING", "middle": "12"}, "address": {"street": "TEST-0012", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, "securedParties": [{"partyId": 200000033, "businessName": "TEST 12 SECURED PARTY", "address": {"street": "TEST-0012", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}], "debtors": [{"partyId": 200000032, "personName": {"first": "TEST IND", "last": "DEBTOR", "middle": "12"}, "address": {"street": "TEST-0012", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}], "vehicleCollateral": [{"vehicleId": 200000011, "type": "MH", "year": 2012, "make": "HOMCO IND. LTD DIPLOMAT", "serialNumber": "9999", "manufacturedHomeRegistrationNumber": "22000"}, {"vehicleId": 200000012, "type": "AC", "year": 1998, "make": "CESSNA", "model": "172R SKYHAWK", "serialNumber": "CFYX"}, {"vehicleId": 200000013, "type": "AF", "year": 1998, "make": "AIRFRAME make", "model": "AIRFRAME model", "serialNumber": "AF16031"}], "trustIndenture": true, "lifeYears": 1, "expiryDate": "2022-03-12T01:48:54+00:00"}}]') +; + +-- Existing registration number search on TEST0002 (search step only). A financing statement with a renewal. +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000003, CURRENT_TIMESTAMP, 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0002"}, "clientReferenceId": "T-S-RG-004"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0002", "baseRegistrationNumber": "TEST0002", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'UT-SQ-RG-004', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000003, 1, 0, null, +'[{"matchType": "EXACT", "financingStatement": {"type": "RL", "baseRegistrationNumber": "TEST0002", "registrationDescription": "REPAIRERS LIEN", "registrationAct": "REPAIRERS LIEN ACT", "createDateTime": "2021-03-12T01:48:53+00:00", "clientReferenceId": "TEST-RL-0001", "registeringParty": {"personName": {"first": "TEST", "last": "REGISTERING", "middle": "2"}, "address": {"street": "TEST-0002", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, "securedParties": [{"partyId": 200000007, "code": "200000000", "businessName": "TEST SECURED PARTY", "address": {"street": "TEST 200000000", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}, "emailAddress": "test-sp-client@gmail.com"}], "debtors": [{"partyId": 200000006, "businessName": "TEST BUS 2 DEBTOR", "address": {"street": "TEST-0002", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}], "vehicleCollateral": [{"vehicleId": 200000002, "type": "MV", "year": 2014, "make": "HYUNDAI", "model": "TUSCON", "serialNumber": "KX8J3CA46JU622994"}], "lienAmount": "2000.00", "surrenderDate": "2021-06-10T01:48:53+00:00", "trustIndenture": false, "expiryDate": "2021-06-10T01:48:54+00:00", "changes": [{"baseRegistrationNumber": "TEST0002", "createDateTime": "2021-03-12T01:53:54+00:00", "renewalRegistrationNumber": "TEST00R6", "clientReferenceId": "TEST-REN-0006", "registeringParty": {"personName": {"first": "TEST-RENEWAL-RL", "last": "REGISTERING", "middle": "6"}, "address": {"street": "TEST-00R6", "city": "city", "region": "BC", "country": "CA", "postalCode": "V8R3A5", "streetAdditional": "line 2"}}, "expiryDate": "2021-06-10T01:48:54+00:00", "courtOrderInformation": {"courtName": "Supreme Court of British Columbia", "courtRegistry": "Victoria", "fileNumber": "BC123495", "orderDate": "2021-09-28T01:48:54+00:00", "effectOfOrder": "Court Order to renew Repairers Lien."}, "statementType": "RENEWAL_STATEMENT"}]}}]') +; + + +-- Existing Business debtor search for autosave search selection update testing. +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000004, CURRENT_TIMESTAMP, 'BS', + '{"type": "BUSINESS_DEBTOR", "criteria": {"debtorName": {"business": "TEST BUS 2 DEBTOR"}}, "clientReferenceId": "T-S-DB-001"}', + '[{"baseRegistrationNumber": "TEST0001", "matchType": "EXACT", "createDateTime": "2021-03-02T22:46:43+00:00", "registrationType": "SA", "debtor": {"businessName": "TEST BUS 2 DEBTOR", "partyId": 200000002}}, {"baseRegistrationNumber": "TEST0002", "matchType": "EXACT", "createDateTime": "2021-03-02T22:46:43+00:00", "registrationType": "RL", "debtor": {"businessName": "TEST BUS 2 DEBTOR", "partyId": 200000006}}, {"baseRegistrationNumber": "TEST0003", "matchType": "SIMILAR", "createDateTime": "2021-03-02T22:46:43+00:00", "registrationType": "RL", "debtor": {"businessName": "TEST BUS 3 DEBTOR", "partyId": 200000009}}]', + 'PS12345', null, null, 'UT-SQ-MH-005', 1, 1) +; + + +-- Completed registration number search on TEST0012 to test get details: search ts in the future. +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000005, CURRENT_TIMESTAMP + interval '365 days', 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0012"}, "clientReferenceId": "T-S-RG-003"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0012", "baseRegistrationNumber": "TEST0012", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'T-S-RG-003', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000005, 1, 0, +'[{"matchType": "EXACT", "registrationNumber": "TEST0012", "baseRegistrationNumber": "TEST0012", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', +'{ + "searchDateTime": "2021-03-12T19:46:46+00:00", + "exactResultsSize": 1, + "similarResultsSize": 0, + "totalResultsSize": 1, + "searchQuery": { + "type": "REGISTRATION_NUMBER", + "criteria": {"value": "JU622994"}, + "clientReferenceId": "T-SR-SS-1001" + }, + "details": [ { + "baseRegistrationNumber": "TEST0001", + "clientReferenceId": "T-API-DL-001", + "createDateTime": "2021-03-09T22:59:10+00:00", + "debtors": [ + { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "A1A 1A1", + "region": "BC", + "street": "721 DEBTOR AVE" + }, + "businessName": "MY COMPANY INC", + "partyId": 1118 + }, + { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "V8S 2V4", + "region": "BC", + "street": "520 JOHNSON ST" + }, + "birthDate": "1986-12-02T03:20:20+00:00", + "partyId": 1119, + "personName": { + "first": "MICHAEL", + "last": "SMITH", + "middle": "J" + } + } + ], + "expiryDate": "2026-03-09T23:59:59+00:00", + "lifeYears": 5, + "registeringParty": { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "V8W 2V8", + "region": "BC", + "street": "222 SUMMER STREET" + }, + "businessName": "ABC SEARCHING COMPANY" + }, + "securedParties": [ + { + "address": { + "city": "SIDNEY", + "country": "CA", + "postalCode": "V7R 1R7", + "region": "BC", + "street": "3721 BEACON AVENUE" + }, + "businessName": "BANK OF BRITISH COLUMBIA", + "partyId": 1117 + } + ], + "trustIndenture": false, + "type": "SA", + "vehicleCollateral": [ + { + "make": "HYUNDAI", + "model": "TUCSON", + "serialNumber": "KM8J3CA46JU622994", + "type": "MV", + "vehicleId": 417, + "year": 2018 + } + ] +} ] } +') +; + + +-- Completed registration number search on TEST0012 to test get details: search ts too far in the past. +INSERT INTO search_requests(id, search_ts, search_type, api_criteria, search_response, + account_id, pay_invoice_id, pay_path, client_reference_id, total_results_size, returned_results_size) + VALUES(200000006, CURRENT_TIMESTAMP - interval '32 days', 'RG', + '{"type": "REGISTRATION_NUMBER", "criteria": {"value": "TEST0012"}, "clientReferenceId": "T-S-RG-003"}', + '[{"matchType": "EXACT", "registrationNumber": "TEST0012", "baseRegistrationNumber": "TEST0012", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', + 'PS12345', null, null, 'T-S-RG-003', 1, 1) +; +INSERT INTO search_results(search_id, exact_match_count, similar_match_count, api_result, registrations) + VALUES(200000006, 1, 1, +'[{"matchType": "EXACT", "registrationNumber": "TEST0012", "baseRegistrationNumber": "TEST0012", "createDateTime": "2021-01-06T11:35:57+00:00", "registrationType": "SA"}]', +'{ + "baseRegistrationNumber": "TEST0001", + "clientReferenceId": "T-API-DL-001", + "createDateTime": "2021-03-09T22:59:10+00:00", + "debtors": [ + { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "A1A 1A1", + "region": "BC", + "street": "721 DEBTOR AVE" + }, + "businessName": "MY COMPANY INC", + "partyId": 1118 + }, + { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "V8S 2V4", + "region": "BC", + "street": "520 JOHNSON ST" + }, + "birthDate": "1986-12-02T03:20:20+00:00", + "partyId": 1119, + "personName": { + "first": "MICHAEL", + "last": "SMITH", + "middle": "J" + } + } + ], + "expiryDate": "2026-03-09T23:59:59+00:00", + "lifeYears": 5, + "registeringParty": { + "address": { + "city": "VICTORIA", + "country": "CA", + "postalCode": "V8W 2V8", + "region": "BC", + "street": "222 SUMMER STREET" + }, + "businessName": "ABC SEARCHING COMPANY" + }, + "securedParties": [ + { + "address": { + "city": "SIDNEY", + "country": "CA", + "postalCode": "V7R 1R7", + "region": "BC", + "street": "3721 BEACON AVENUE" + }, + "businessName": "BANK OF BRITISH COLUMBIA", + "partyId": 1117 + } + ], + "trustIndenture": false, + "type": "SA", + "vehicleCollateral": [ + { + "make": "HYUNDAI", + "model": "TUCSON", + "serialNumber": "KM8J3CA46JU622994", + "type": "MV", + "vehicleId": 417, + "year": 2018 + } + ] +}') +; diff --git a/ppr-api/test_data/postgres_test_reset.sql b/ppr-api/test_data/postgres_test_reset.sql new file mode 100644 index 000000000..3c779fc48 --- /dev/null +++ b/ppr-api/test_data/postgres_test_reset.sql @@ -0,0 +1,32 @@ +-- Delete all test data created with the scripts in this directory. +DELETE FROM search_results + WHERE search_id >= 200000000; +DELETE FROM search_requests + WHERE id >= 200000000; +DELETE FROM serial_collateral + WHERE financing_id >= 200000000; +DELETE FROM general_collateral + WHERE financing_id >= 200000000; +DELETE FROM parties + WHERE financing_id >= 200000000; +DELETE FROM trust_indentures + WHERE financing_id >= 200000000; +DELETE FROM court_orders + WHERE registration_id >= 200000000; +DELETE FROM registrations + WHERE financing_id >= 200000000; +DELETE FROM financing_statements + WHERE id >= 200000000; +DELETE FROM drafts + WHERE id >= 200000000; +DELETE FROM client_codes_historical + WHERE id >= 200000000; +DELETE FROM client_codes + WHERE id >= 200000000; +DELETE FROM addresses + WHERE id >= 200000000; +DELETE FROM client_codes + WHERE id BETWEEN 99990001 AND 99990004; +DELETE FROM addresses + WHERE id BETWEEN 99990001 AND 99990004; +-- Delete test data end \ No newline at end of file diff --git a/ppr-api/test_data/run_one_file.py b/ppr-api/test_data/run_one_file.py index 3cd22ff56..0736cfe9a 100755 --- a/ppr-api/test_data/run_one_file.py +++ b/ppr-api/test_data/run_one_file.py @@ -58,7 +58,7 @@ def execute_file(session, file_name): options = dict(bind=conn, binds={}) session = db.create_scoped_session(options=options) - execute_file(session, 'test_data/data_files/test0001.sql') + execute_file(session, 'test_data/postgres_test_reset.sql') conn.close() diff --git a/ppr-api/tests/unit/models/test_address.py b/ppr-api/tests/unit/models/test_address.py index 5a06e95f5..39fcb800e 100644 --- a/ppr-api/tests/unit/models/test_address.py +++ b/ppr-api/tests/unit/models/test_address.py @@ -23,7 +23,7 @@ def test_find_by_id(session): """Assert that find address by id contains all expected elements.""" address = Address.find_by_id(200000000) assert address - assert address.address_id + assert address.id if address: json_data = address.json assert json_data['street'] @@ -46,7 +46,7 @@ def test_save(session): } address = Address.create_from_json(address_json) address.save() - assert address.address_id + assert address.id def test_address_json(session): diff --git a/ppr-api/tests/unit/models/test_client_code.py b/ppr-api/tests/unit/models/test_client_code.py index b8b698861..3f1def7ba 100644 --- a/ppr-api/tests/unit/models/test_client_code.py +++ b/ppr-api/tests/unit/models/test_client_code.py @@ -86,7 +86,7 @@ def test_find_head_office_codes(session, desc, results_size, search_value, fuzzy def test_client_party_json(session): """Assert that the client party model renders to a json format correctly.""" party = ClientCode( - branch_id=1000, + id=1000, name='BUSINESS NAME', contact_name='CONTACT', contact_area_cd='250', diff --git a/ppr-api/tests/unit/models/test_court_order.py b/ppr-api/tests/unit/models/test_court_order.py index 23cd015e5..0221f6d84 100644 --- a/ppr-api/tests/unit/models/test_court_order.py +++ b/ppr-api/tests/unit/models/test_court_order.py @@ -28,10 +28,10 @@ def test_find_by_id(session): """Assert that find court order by court order ID contains all expected elements.""" court_order = CourtOrder.find_by_id(200000000) assert court_order - assert court_order.court_order_id == 200000000 + assert court_order.id == 200000000 assert court_order.court_name assert court_order.court_registry - assert court_order.court_date + assert court_order.order_date assert court_order.file_number assert court_order.effect_of_order @@ -40,10 +40,10 @@ def test_find_by_registration_id(session): """Assert that find court order by registration id contains all expected elements.""" court_order = CourtOrder.find_by_registration_id(200000007) assert court_order - assert court_order.court_order_id == 200000000 + assert court_order.id == 200000000 assert court_order.court_name assert court_order.court_registry - assert court_order.court_date + assert court_order.order_date assert court_order.file_number assert court_order.effect_of_order @@ -63,19 +63,19 @@ def test_find_by_reg_id_invalid(session): def test_court_order_json(session): """Assert that the court order model renders to a json format correctly.""" court_order = CourtOrder( - court_order_id=1000, + id=1000, court_name='name', court_registry='registry', file_number='file', effect_of_order='effect', - court_date=now_ts() + order_date=now_ts() ) court_json = { 'courtName': court_order.court_name, 'courtRegistry': court_order.court_registry, 'fileNumber': court_order.file_number, - 'orderDate': format_ts(court_order.court_date), + 'orderDate': format_ts(court_order.order_date), 'effectOfOrder': court_order.effect_of_order } @@ -91,6 +91,6 @@ def test_create_from_renewal_json(session): assert court_order.registration_id == 12345 assert court_order.court_name assert court_order.court_registry - assert court_order.court_date + assert court_order.order_date assert court_order.file_number assert court_order.effect_of_order diff --git a/ppr-api/tests/unit/models/test_drafts.py b/ppr-api/tests/unit/models/test_drafts.py index f3c3f64e6..48c235da3 100644 --- a/ppr-api/tests/unit/models/test_drafts.py +++ b/ppr-api/tests/unit/models/test_drafts.py @@ -17,7 +17,6 @@ Test-Suite to ensure that the Draft Model is working as expected. """ from http import HTTPStatus -import json import copy import pytest @@ -36,6 +35,8 @@ def test_find_all_by_account_id(session): assert draft_list[0]['registrationType'] assert draft_list[0]['path'] assert draft_list[0]['createDateTime'] + for draft in draft_list: + assert draft['documentId'] != 'D-T-0001' def test_find_by_document_id_financing(session): @@ -161,9 +162,9 @@ def test_draft_json(session): document_number='TEST1234', account_id='PS12345', create_ts=now_ts(), - registration_type_cd=json_data['changeStatement']['changeType'], + registration_type=json_data['changeStatement']['changeType'], registration_type_cl='CHANGE', - draft=json.dumps(json_data), + draft=json_data, # json.dumps(json_data), registration_number=json_data['changeStatement']['baseRegistrationNumber'] ) @@ -180,7 +181,7 @@ def test_draft_create_from_json(session): assert draft.draft assert draft.account_id == 'PS12345' assert draft.registration_type_cl == 'CHANGE' - assert draft.registration_type_cd == json_data['changeStatement']['changeType'] + assert draft.registration_type == json_data['changeStatement']['changeType'] assert draft.registration_number == json_data['changeStatement']['baseRegistrationNumber'] json_data = copy.deepcopy(DRAFT_AMENDMENT_STATEMENT) @@ -189,5 +190,5 @@ def test_draft_create_from_json(session): assert draft.draft assert draft.account_id == 'PS12345' assert draft.registration_type_cl == 'COURTORDER' - assert draft.registration_type_cd == 'CO' + assert draft.registration_type == 'CO' assert draft.registration_number == json_data['amendmentStatement']['baseRegistrationNumber'] diff --git a/ppr-api/tests/unit/models/test_financing_statement.py b/ppr-api/tests/unit/models/test_financing_statement.py index f94596f0f..2d885df90 100644 --- a/ppr-api/tests/unit/models/test_financing_statement.py +++ b/ppr-api/tests/unit/models/test_financing_statement.py @@ -62,7 +62,7 @@ def test_save(session, reg_type, account_id, create_draft): statement = FinancingStatement.create_from_json(json_data, account_id) statement.save() - assert statement.financing_id + assert statement.id result = statement.json assert result @@ -121,7 +121,7 @@ def test_find_by_id(session): """Assert that find financing statement by ID contains all expected elements.""" result = FinancingStatement.find_by_id(200000000) assert result - assert result.registration_num + assert result.id if result: json_data = result.json assert json_data['type'] == 'SA' @@ -138,7 +138,7 @@ def test_find_by_financing_id(session): """Assert that find financing statement by financing statement ID contains all expected elements.""" result = FinancingStatement.find_by_financing_id(200000000) assert result - assert result.registration_num + assert result.id if result: result.mark_update_json = True json_data = result.json diff --git a/ppr-api/tests/unit/models/test_general_collateral.py b/ppr-api/tests/unit/models/test_general_collateral.py index fe4ec8a4f..addb8ebeb 100644 --- a/ppr-api/tests/unit/models/test_general_collateral.py +++ b/ppr-api/tests/unit/models/test_general_collateral.py @@ -27,7 +27,7 @@ def test_find_by_id(session): """Assert that find general collateral by collateral ID contains all expected elements.""" collateral = GeneralCollateral.find_by_id(200000000) assert collateral - assert collateral.collateral_id == 200000000 + assert collateral.id == 200000000 assert collateral.registration_id == 200000000 assert collateral.financing_id == 200000000 assert collateral.description @@ -42,11 +42,11 @@ def test_find_by_registration_id(session): collateral = GeneralCollateral.find_by_registration_id(200000000) assert collateral assert len(collateral) == 2 - assert collateral[0].collateral_id + assert collateral[0].id assert collateral[0].registration_id assert collateral[0].financing_id assert collateral[0].description - assert collateral[1].collateral_id + assert collateral[1].id assert collateral[1].registration_id assert collateral[1].financing_id assert collateral[1].description @@ -57,11 +57,11 @@ def test_find_by_financing_id(session): collateral = GeneralCollateral.find_by_financing_id(200000000) assert collateral assert len(collateral) >= 2 - assert collateral[0].collateral_id + assert collateral[0].id assert collateral[0].registration_id assert collateral[0].financing_id assert collateral[0].description - assert collateral[1].collateral_id + assert collateral[1].id assert collateral[1].registration_id assert collateral[1].financing_id assert collateral[1].description @@ -88,12 +88,12 @@ def test_find_by_reg_id_invalid(session): def test_general_collateral_json(session): """Assert that the general collateral model renders to a json format correctly.""" collateral = GeneralCollateral( - collateral_id=1000, + id=1000, description='TEST' ) collateral_json = { - 'collateralId': collateral.collateral_id, + 'collateralId': collateral.id, 'description': collateral.description } diff --git a/ppr-api/tests/unit/models/test_party.py b/ppr-api/tests/unit/models/test_party.py index 18417ca07..cb7c47a93 100644 --- a/ppr-api/tests/unit/models/test_party.py +++ b/ppr-api/tests/unit/models/test_party.py @@ -27,11 +27,11 @@ def test_find_by_id(session): """Assert that find party by party ID contains all expected elements.""" party = Party.find_by_id(200000000) assert party - assert party.party_id == 200000000 + assert party.id == 200000000 assert party.address_id - assert party.party_type_cd == 'RG' + assert party.party_type == 'RG' assert party.first_name - assert party.middle_name + assert party.middle_initial assert party.last_name assert party.registration_id assert not party.branch_id @@ -44,11 +44,11 @@ def test_find_by_id_client(session): """Assert that find party by party ID for a client party contains all expected elements.""" party = Party.find_by_id(200000004) assert party - assert party.party_type_cd == 'SP' - assert party.party_id == 200000004 + assert party.party_type == 'SP' + assert party.id == 200000004 assert party.registration_id assert not party.first_name - assert not party.middle_name + assert not party.middle_initial assert not party.last_name assert not party.birth_date assert not party.registration_id_end @@ -64,11 +64,11 @@ def test_find_by_financing_id(session): parties = Party.find_by_financing_id(200000000) assert parties assert len(parties) >= 5 - assert parties[0].party_type_cd == 'RG' - assert parties[1].party_type_cd == 'DI' - assert parties[2].party_type_cd == 'DB' - assert parties[3].party_type_cd == 'SP' - assert parties[4].party_type_cd == 'SP' + assert parties[0].party_type == 'RG' + assert parties[1].party_type == 'DI' + assert parties[2].party_type == 'DB' + assert parties[3].party_type == 'SP' + assert parties[4].party_type == 'SP' def test_find_by_registration_id(session): @@ -76,11 +76,11 @@ def test_find_by_registration_id(session): parties = Party.find_by_registration_id(200000000) assert parties assert len(parties) == 5 - assert parties[0].party_type_cd == 'RG' - assert parties[1].party_type_cd == 'DI' - assert parties[2].party_type_cd == 'DB' - assert parties[3].party_type_cd == 'SP' - assert parties[4].party_type_cd == 'SP' + assert parties[0].party_type == 'RG' + assert parties[1].party_type == 'DI' + assert parties[2].party_type == 'DB' + assert parties[3].party_type == 'SP' + assert parties[4].party_type == 'SP' def test_find_by_id_invalid(session): @@ -104,9 +104,9 @@ def test_find_by_reg_id_invalid(session): def test_party_json(session): """Assert that the party model renders to a json format correctly.""" party = Party( - party_id=1000, + id=1000, first_name='FIRST', - middle_name='MIDDLE', + middle_initial='MIDDLE', last_name='LAST', business_name='BUSINESS', registration_id=1000, @@ -114,12 +114,12 @@ def test_party_json(session): ) party_json = { - 'partyId': party.party_id, + 'partyId': party.id, 'businessName': party.business_name, 'personName': { 'first': party.first_name, 'last': party.last_name, - 'middle': party.middle_name + 'middle': party.middle_initial } } @@ -161,7 +161,7 @@ def test_create_from_json(session): party_bus = Party.create_from_json(party_bus_json, 'SP', 1234) assert party_bus.registration_id - assert party_bus.party_type_cd == 'SP' + assert party_bus.party_type == 'SP' assert party_bus.business_name assert party_bus.address assert party_bus.address.street @@ -174,10 +174,10 @@ def test_create_from_json(session): party_ind = Party.create_from_json(party_ind_json, 'DB', 1234) assert party_ind.registration_id - assert party_ind.party_type_cd == 'DI' + assert party_ind.party_type == 'DI' assert party_ind.last_name assert party_ind.first_name - assert party_ind.middle_name + assert party_ind.middle_initial assert party_ind.address assert party_ind.address.street assert party_ind.address.street_additional @@ -202,7 +202,7 @@ def test_create_from_financing_json(session): assert parties assert len(parties) == 3 for party in parties: - assert party.party_type_cd + assert party.party_type if not party.branch_id: assert party.address diff --git a/ppr-api/tests/unit/models/test_registration.py b/ppr-api/tests/unit/models/test_registration.py index 23b433376..7be5e08e2 100644 --- a/ppr-api/tests/unit/models/test_registration.py +++ b/ppr-api/tests/unit/models/test_registration.py @@ -32,9 +32,9 @@ def test_find_by_id(session): """Assert that find registration by ID contains all expected elements.""" registration = Registration.find_by_id(200000000) assert registration - assert registration.registration_id == 200000000 + assert registration.id == 200000000 assert registration.registration_num == 'TEST0001' - assert registration.registration_type_cd + assert registration.registration_type assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -44,9 +44,9 @@ def test_find_by_id_as(session): """Assert that find an amemdment registration by ID contains all expected elements.""" registration = Registration.find_by_id(200000008) assert registration - assert registration.registration_id == 200000008 + assert registration.id == 200000008 assert registration.registration_num - assert registration.registration_type_cd == 'CO' + assert registration.registration_type == 'CO' assert registration.financing_id json_data = registration.json assert json_data['changeType'] == 'CO' @@ -74,9 +74,9 @@ def test_find_by_id_cs_dt(session): """Assert that find an change registration DT by ID contains all expected elements.""" registration = Registration.find_by_id(200000009) assert registration - assert registration.registration_id == 200000009 + assert registration.id == 200000009 assert registration.registration_num - assert registration.registration_type_cd == 'DT' + assert registration.registration_type == 'DT' assert registration.financing_id json_data = registration.json assert json_data['changeType'] == 'DT' @@ -97,9 +97,9 @@ def test_find_by_id_cs_st(session): """Assert that find an change registration ST by ID contains all expected elements.""" registration = Registration.find_by_id(200000010) assert registration - assert registration.registration_id == 200000010 + assert registration.id == 200000010 assert registration.registration_num - assert registration.registration_type_cd == 'ST' + assert registration.registration_type == 'ST' assert registration.financing_id json_data = registration.json assert json_data['changeType'] == 'ST' @@ -119,9 +119,9 @@ def test_find_by_id_cs_su(session): """Assert that find an change registration SU by ID contains all expected elements.""" registration = Registration.find_by_id(200000011) assert registration - assert registration.registration_id == 200000011 + assert registration.id == 200000011 assert registration.registration_num - assert registration.registration_type_cd == 'SU' + assert registration.registration_type == 'SU' assert registration.financing_id json_data = registration.json assert json_data['changeType'] == 'SU' @@ -143,9 +143,9 @@ def test_find_by_registration_num_fs(session): """Assert that find a financing statement by registration number contains all expected elements.""" registration = Registration.find_by_registration_number('TEST0001') assert registration - assert registration.registration_id == 200000000 + assert registration.id == 200000000 assert registration.registration_num == 'TEST0001' - assert registration.registration_type_cd + assert registration.registration_type assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -155,9 +155,9 @@ def test_find_by_registration_num_ds(session): """Assert that find a discharge statement by registration number contains all expected elements.""" registration = Registration.find_by_registration_number('TEST00D4') assert registration - assert registration.registration_id == 200000004 + assert registration.id == 200000004 assert registration.registration_num == 'TEST00D4' - assert registration.registration_type_cd == 'DC' + assert registration.registration_type == 'DC' assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -198,15 +198,15 @@ def test_save_discharge(session): financing_statement, 'TEST0003', 'PS12345') - print(str(registration.registration_id)) - print(registration.document_number) - print(registration.registration_num) -# print(registration.json) + # print(str(registration.id)) + # print(registration.document_number) + # print(registration.registration_num) + # print(registration.json) registration.save() assert registration.financing_id == 200000003 - assert registration.registration_id + assert registration.id assert registration.registration_num - assert registration.registration_type_cd + assert registration.registration_type assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -239,9 +239,9 @@ def test_save_renewal(session): # print(registration.json) registration.save() assert registration.financing_id == 200000004 - assert registration.registration_id + assert registration.id assert registration.registration_num - assert registration.registration_type_cd + assert registration.registration_type assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -274,9 +274,9 @@ def test_save_renewal_rl(session): # print(registration.json) registration.save() assert registration.financing_id == 200000001 - assert registration.registration_id + assert registration.id assert registration.registration_num - assert registration.registration_type_cd + assert registration.registration_type assert registration.registration_ts assert registration.account_id assert registration.client_reference_id @@ -303,18 +303,18 @@ def test_save_amendment(session): assert financing_statement for party in financing_statement.parties: if party.registration_id != 200000000 and not party.registration_id_end: - if party.party_type_cd == 'DB' or party.party_type_cd == 'DI': - json_data['deleteDebtors'][0]['partyId'] = party.party_id - elif party.party_type_cd == 'SP': - json_data['deleteSecuredParties'][0]['partyId'] = party.party_id + if party.party_type == 'DB' or party.party_type == 'DI': + json_data['deleteDebtors'][0]['partyId'] = party.id + elif party.party_type == 'SP': + json_data['deleteSecuredParties'][0]['partyId'] = party.id for gc in financing_statement.general_collateral: if gc.registration_id != 200000000 and not gc.registration_id_end: - json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.collateral_id + json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.id for vc in financing_statement.vehicle_collateral: if vc.registration_id != 200000000 and not vc.registration_id_end: - json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.vehicle_id + json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.id registration = Registration.create_from_json(json_data, 'AMENDMENT', @@ -356,18 +356,18 @@ def test_save_amendment_from_draft(session): assert financing_statement for party in financing_statement.parties: if party.registration_id != 200000000 and not party.registration_id_end: - if party.party_type_cd == 'DB' or party.party_type_cd == 'DI': - json_data['deleteDebtors'][0]['partyId'] = party.party_id - elif party.party_type_cd == 'SP': - json_data['deleteSecuredParties'][0]['partyId'] = party.party_id + if party.party_type == 'DB' or party.party_type == 'DI': + json_data['deleteDebtors'][0]['partyId'] = party.id + elif party.party_type == 'SP': + json_data['deleteSecuredParties'][0]['partyId'] = party.id for gc in financing_statement.general_collateral: if gc.registration_id != 200000000 and not gc.registration_id_end: - json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.collateral_id + json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.id for vc in financing_statement.vehicle_collateral: if vc.registration_id != 200000000 and not vc.registration_id_end: - json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.vehicle_id + json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.id # Now create a draft amendment draft_json = copy.deepcopy(DRAFT_AMENDMENT_STATEMENT) @@ -400,18 +400,18 @@ def test_save_change(session): assert financing_statement for party in financing_statement.parties: if party.registration_id != 200000000 and not party.registration_id_end: - if party.party_type_cd == 'DB' or party.party_type_cd == 'DI': - json_data['deleteDebtors'][0]['partyId'] = party.party_id - elif party.party_type_cd == 'SP': - json_data['deleteSecuredParties'][0]['partyId'] = party.party_id + if party.party_type == 'DB' or party.party_type == 'DI': + json_data['deleteDebtors'][0]['partyId'] = party.id + elif party.party_type == 'SP': + json_data['deleteSecuredParties'][0]['partyId'] = party.id for gc in financing_statement.general_collateral: if gc.registration_id != 200000000 and not gc.registration_id_end: - json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.collateral_id + json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.id for vc in financing_statement.vehicle_collateral: if vc.registration_id != 200000000 and not vc.registration_id_end: - json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.vehicle_id + json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.id registration = Registration.create_from_json(json_data, 'CHANGE', @@ -450,18 +450,18 @@ def test_save_change_from_draft(session): assert financing_statement for party in financing_statement.parties: if party.registration_id != 200000000 and not party.registration_id_end: - if party.party_type_cd == 'DB' or party.party_type_cd == 'DI': - json_data['deleteDebtors'][0]['partyId'] = party.party_id - elif party.party_type_cd == 'SP': - json_data['deleteSecuredParties'][0]['partyId'] = party.party_id + if party.party_type == 'DB' or party.party_type == 'DI': + json_data['deleteDebtors'][0]['partyId'] = party.id + elif party.party_type == 'SP': + json_data['deleteSecuredParties'][0]['partyId'] = party.id for gc in financing_statement.general_collateral: if gc.registration_id != 200000000 and not gc.registration_id_end: - json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.collateral_id + json_data['deleteGeneralCollateral'][0]['collateralId'] = gc.id for vc in financing_statement.vehicle_collateral: if vc.registration_id != 200000000 and not vc.registration_id_end: - json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.vehicle_id + json_data['deleteVehicleCollateral'][0]['vehicleId'] = vc.id # Now create a draft change draft_json = copy.deepcopy(DRAFT_CHANGE_STATEMENT) diff --git a/ppr-api/tests/unit/models/test_search_client.py b/ppr-api/tests/unit/models/test_search_request.py similarity index 94% rename from ppr-api/tests/unit/models/test_search_client.py rename to ppr-api/tests/unit/models/test_search_request.py index d43fee177..0c50ff55f 100644 --- a/ppr-api/tests/unit/models/test_search_client.py +++ b/ppr-api/tests/unit/models/test_search_request.py @@ -17,11 +17,11 @@ Test-Suite to ensure that the Search Model is working as expected. """ from http import HTTPStatus -import json +import copy import pytest -from ppr_api.models import SearchClient +from ppr_api.models import SearchRequest from ppr_api.models.utils import now_ts_offset, format_ts from ppr_api.exceptions import BusinessException @@ -326,7 +326,7 @@ # testdata pattern is ({search type}, {JSON data}, {expected # of results}) TEST_VALID_DATA_COUNT = [ - ('SS', SERIAL_NUMBER_JSON, 7), + ('SS', SERIAL_NUMBER_JSON, 6), ('IS', INDIVIDUAL_DEBTOR_JSON, 4), ('BS', BUSINESS_DEBTOR_JSON, 2) ] @@ -361,22 +361,22 @@ def test_search_no_account(session): }, 'clientReferenceId': 'T-SQ-RG-4' } - query = SearchClient.create_from_json(json_data, None) + query = SearchRequest.create_from_json(json_data, None) query.search() - assert query.search_id + assert query.id assert query.search_response @pytest.mark.parametrize('search_type,json_data', TEST_VALID_DATA) def test_search_valid(session, search_type, json_data): """Assert that a valid search returns the expected search type result.""" - query = SearchClient.create_from_json(json_data, None) + query = SearchRequest.create_from_json(json_data, None) query.search() result = query.json # print(result) - assert query.search_id + assert query.id assert query.search_response assert result['searchId'] assert result['searchQuery'] @@ -425,10 +425,10 @@ def test_search_valid(session, search_type, json_data): @pytest.mark.parametrize('search_type,json_data', TEST_NONE_DATA) def test_search_no_results(session, search_type, json_data): """Assert that a search query with no results returns the expected result.""" - query = SearchClient.create_from_json(json_data, None) + query = SearchRequest.create_from_json(json_data, None) query.search() - assert query.search_id + assert query.id assert not query.search_response assert query.returned_results_size == 0 @@ -436,7 +436,7 @@ def test_search_no_results(session, search_type, json_data): @pytest.mark.parametrize('search_type,json_data,excluded_match', TEST_EXPIRED_DATA) def test_search_expired(session, search_type, json_data, excluded_match): """Assert that an expired financing statement is excluded from the search results.""" - query = SearchClient.create_from_json(json_data, None) + query = SearchRequest.create_from_json(json_data, None) query.search() result = query.json @@ -457,7 +457,7 @@ def test_search_expired(session, search_type, json_data, excluded_match): @pytest.mark.parametrize('search_type,json_data,excluded_match', TEST_DISCHARGED_DATA) def test_search_discharged(session, search_type, json_data, excluded_match): """Assert that a discharged financing statement is excluded from the search results.""" - query = SearchClient.create_from_json(json_data, None) + query = SearchRequest.create_from_json(json_data, None) query.search() result = query.json @@ -491,7 +491,7 @@ def test_search_startdatetime_invalid(session, client, jwt): # test with pytest.raises(BusinessException) as bad_request_err: - SearchClient.validate_query(json_data) + SearchRequest.validate_query(json_data) # check assert bad_request_err @@ -515,7 +515,7 @@ def test_search_enddatatetime_invalid(session, client, jwt): # test with pytest.raises(BusinessException) as bad_request_err: - SearchClient.validate_query(json_data) + SearchRequest.validate_query(json_data) # check assert bad_request_err @@ -525,7 +525,7 @@ def test_search_enddatatetime_invalid(session, client, jwt): def test_find_by_account_id(session): """Assert that the account search history list first item contains all expected elements.""" - history = SearchClient.find_all_by_account_id('PS12345') + history = SearchRequest.find_all_by_account_id('PS12345') # print(history) assert history assert history[0]['searchId'] @@ -540,7 +540,7 @@ def test_find_by_account_id(session): def test_find_by_account_id_no_result(session): """Assert that the find search history by invalid account ID returns the expected result.""" - history = SearchClient.find_all_by_account_id('XXXX345') + history = SearchRequest.find_all_by_account_id('XXXX345') # check assert len(history) == 0 @@ -554,10 +554,10 @@ def test_create_from_json(session): }, 'clientReferenceId': 'T-SQ-SS-1' } - search_client = SearchClient.create_from_json(json_data, 'PS12345') + search_client = SearchRequest.create_from_json(json_data, 'PS12345') assert search_client.account_id == 'PS12345' - assert search_client.search_type_cd == 'SS' + assert search_client.search_type == 'SS' assert search_client.client_reference_id == 'T-SQ-SS-1' assert search_client.search_ts assert search_client.search_criteria @@ -565,9 +565,9 @@ def test_create_from_json(session): def test_search_autosave(session): """Assert that a valid search query selection update works as expected.""" - query = SearchClient.find_by_id(200000000) + query = SearchRequest.find_by_id(200000000) assert query.search_response - update_data = json.loads(query.search_response) + update_data = copy.deepcopy(query.search_response) # json.loads(query.search_response) if update_data[0]['matchType'] == 'EXACT': update_data[0]['matchType'] = 'SIMILAR' else: @@ -583,7 +583,7 @@ def test_search_invalid_criteria_400(session, client, jwt, search_type, json_dat """Assert that validation of a search request with invalid criteria throws a BusinessException.""" # test with pytest.raises(BusinessException) as bad_request_err: - SearchClient.validate_query(json_data) + SearchRequest.validate_query(json_data) # check assert bad_request_err @@ -594,7 +594,7 @@ def test_search_invalid_criteria_400(session, client, jwt, search_type, json_dat @pytest.mark.parametrize('search_type,json_data,result_size', TEST_VALID_DATA_COUNT) def test_get_total_count(session, search_type, json_data, result_size): """Assert that the get total count function works as expected.""" - search_client = SearchClient.create_from_json(json_data, 'PS12345') + search_client = SearchRequest.create_from_json(json_data, 'PS12345') search_client.get_total_count() # print('test_total_count ' + search_type + ' actual results size=' + str(search_client.total_results_size)) assert search_client.total_results_size >= result_size diff --git a/ppr-api/tests/unit/models/test_search_result.py b/ppr-api/tests/unit/models/test_search_result.py index e521fa6eb..84077be51 100644 --- a/ppr-api/tests/unit/models/test_search_result.py +++ b/ppr-api/tests/unit/models/test_search_result.py @@ -21,7 +21,7 @@ import pytest -from ppr_api.models import SearchResult, SearchClient +from ppr_api.models import SearchResult, SearchRequest from ppr_api.exceptions import BusinessException @@ -133,7 +133,7 @@ def test_search_detail_full_create(session, client, jwt): }, 'clientReferenceId': 'T-SR-SS-1001' } - search_query = SearchClient.create_from_json(json_data, 'PS12345') + search_query = SearchRequest.create_from_json(json_data, 'PS12345') # test search_query.search() @@ -143,7 +143,7 @@ def test_search_detail_full_create(session, client, jwt): search_detail.save() # check - assert search_detail.search_id == search_query.search_id + assert search_detail.search_id == search_query.id assert not search_detail.search_select assert search_detail.exact_match_count > 0 assert search_detail.similar_match_count > 0 @@ -184,7 +184,7 @@ def test_search_history_sort(session, client, jwt): 'value': 'TEST0001' } } - search_query = SearchClient.create_from_json(json_data, 'PS12345') + search_query = SearchRequest.create_from_json(json_data, 'PS12345') # test search_query.search() @@ -192,7 +192,7 @@ def test_search_history_sort(session, client, jwt): search_detail.save() # check - assert search_detail.search_id == search_query.search_id + assert search_detail.search_id == search_query.id result = search_detail.json # print(details_json) history = result[0]['financingStatement']['changes'] diff --git a/ppr-api/tests/unit/models/test_trust_indenture.py b/ppr-api/tests/unit/models/test_trust_indenture.py index 343d77bcd..a69d344ff 100644 --- a/ppr-api/tests/unit/models/test_trust_indenture.py +++ b/ppr-api/tests/unit/models/test_trust_indenture.py @@ -27,7 +27,7 @@ def test_find_by_id(session): """Assert that find trust indenture by trust indenture ID contains all expected elements.""" trust_indenture = TrustIndenture.find_by_id(200000000) assert trust_indenture - assert trust_indenture.trust_id == 200000000 + assert trust_indenture.id == 200000000 assert trust_indenture.registration_id == 200000000 assert trust_indenture.financing_id == 200000000 assert trust_indenture.trust_indenture == 'Y' @@ -38,7 +38,7 @@ def test_find_by_registration_num(session): trust_indenture = TrustIndenture.find_by_registration_number('TEST0001') assert trust_indenture assert len(trust_indenture) == 1 - assert trust_indenture[0].trust_id == 200000000 + assert trust_indenture[0].id == 200000000 assert trust_indenture[0].registration_id == 200000000 assert trust_indenture[0].financing_id == 200000000 assert trust_indenture[0].trust_indenture == 'Y' @@ -49,7 +49,7 @@ def test_find_by_financing_id(session): trust_indenture = TrustIndenture.find_by_financing_id(200000000) assert trust_indenture assert len(trust_indenture) == 1 - assert trust_indenture[0].trust_id == 200000000 + assert trust_indenture[0].id == 200000000 assert trust_indenture[0].registration_id == 200000000 assert trust_indenture[0].financing_id == 200000000 assert trust_indenture[0].trust_indenture == 'Y' diff --git a/ppr-api/tests/unit/models/test_vehicle_collateral.py b/ppr-api/tests/unit/models/test_vehicle_collateral.py index a16c617e5..b4754e23e 100644 --- a/ppr-api/tests/unit/models/test_vehicle_collateral.py +++ b/ppr-api/tests/unit/models/test_vehicle_collateral.py @@ -27,10 +27,10 @@ def test_find_by_id(session): """Assert that find vehicle collateral by vehicle collateral ID contains all expected elements.""" collateral = VehicleCollateral.find_by_id(200000000) assert collateral - assert collateral.vehicle_id == 200000000 + assert collateral.id == 200000000 assert collateral.registration_id == 200000000 assert collateral.financing_id == 200000000 - assert collateral.vehicle_type_cd == 'MV' + assert collateral.vehicle_type == 'MV' assert collateral.make assert collateral.model assert collateral.serial_number @@ -43,15 +43,15 @@ def test_find_by_financing_id(session): collateral = VehicleCollateral.find_by_financing_id(200000000) assert collateral assert len(collateral) >= 2 - assert collateral[0].vehicle_id == 200000000 + assert collateral[0].id == 200000000 assert collateral[0].registration_id == 200000000 assert collateral[0].financing_id == 200000000 assert not collateral[0].registration_id_end assert not collateral[0].mhr_number - assert collateral[0].vehicle_type_cd - assert collateral[1].vehicle_id + assert collateral[0].vehicle_type + assert collateral[1].id assert collateral[1].registration_id - assert collateral[1].vehicle_type_cd == 'MH' + assert collateral[1].vehicle_type == 'MH' assert collateral[1].mhr_number @@ -60,12 +60,12 @@ def test_find_by_registration_id(session): collateral = VehicleCollateral.find_by_registration_id(200000000) assert collateral assert len(collateral) == 2 - assert collateral[0].vehicle_id + assert collateral[0].id assert collateral[0].registration_id - assert collateral[0].vehicle_type_cd - assert collateral[1].vehicle_id + assert collateral[0].vehicle_type + assert collateral[1].id assert collateral[1].registration_id - assert collateral[1].vehicle_type_cd == 'MH' + assert collateral[1].vehicle_type == 'MH' assert collateral[1].mhr_number @@ -90,8 +90,8 @@ def test_find_by_reg_id_invalid(session): def test_vehicle_collateral_json(session): """Assert that the general collateral model renders to a json format correctly.""" collateral = VehicleCollateral( - vehicle_id=1000, - vehicle_type_cd='MV', + id=1000, + vehicle_type='MV', year=2004, make='MAKE', model='MODEL', @@ -100,8 +100,8 @@ def test_vehicle_collateral_json(session): ) collateral_json = { - 'vehicleId': collateral.vehicle_id, - 'type': collateral.vehicle_type_cd, + 'vehicleId': collateral.id, + 'type': collateral.vehicle_type, 'year': collateral.year, 'make': collateral.make, 'model': collateral.model, @@ -126,7 +126,7 @@ def test_create_from_json(session): collateral = VehicleCollateral.create_from_json(json_data, 12345) assert collateral assert collateral.registration_id == 12345 - assert collateral.vehicle_type_cd == 'MH' + assert collateral.vehicle_type == 'MH' assert collateral.serial_number == 'SERIAL' assert collateral.year == 2004 assert collateral.make == 'MAKE' @@ -142,7 +142,7 @@ def test_create_from_financing_json(session): assert len(collateral) == 1 for c in collateral: assert c.registration_id == 12345 - assert c.vehicle_type_cd + assert c.vehicle_type assert c.serial_number @@ -155,5 +155,5 @@ def test_create_from_statement_json(session): for c in collateral: assert c.registration_id == 11111 assert c.financing_id == 22222 - assert c.vehicle_type_cd + assert c.vehicle_type assert c.serial_number diff --git a/ppr-api/tests/unit/services/test_payment.py b/ppr-api/tests/unit/services/test_payment.py index 15675732c..2b69afba0 100644 --- a/ppr-api/tests/unit/services/test_payment.py +++ b/ppr-api/tests/unit/services/test_payment.py @@ -128,7 +128,6 @@ def test_client_exception(client, jwt): pay_client.create_payment(TransactionTypes.SEARCH.value, 1, '200000001', 'UT-PAY-SEARCH-01') assert request_err - assert request_err.value.status_code == HTTPStatus.UNAUTHORIZED def test_payment_search_mock(client, jwt): @@ -192,3 +191,17 @@ def test_sa_get_token(client, jwt): # check assert jwt assert len(jwt) > 0 + + +# def test_refund(client, jwt): +# """Assert that a payment refund works as expected: requires a valid invoice id.""" +# # setup +# token = helper_create_jwt(jwt, [PPR_ROLE]) +# pay_client = SBCPaymentClient(jwt=token, account_id='PS12345') +# + # test +# refund_response = pay_client.cancel_payment(9628) +# + # check +# print(refund_response) +# assert refund_response is None