Beispiel #1
0
def create_recipient_object(db_row_dict: dict) -> OrderedDict:
    return OrderedDict([
        (
            "recipient_hash",
            obtain_recipient_uri(
                db_row_dict["_recipient_name"],
                db_row_dict["_recipient_unique_id"],
                db_row_dict["_parent_recipient_unique_id"],
            ),
        ),
        ("recipient_name", db_row_dict["_recipient_name"]),
        ("recipient_unique_id", db_row_dict["_recipient_unique_id"]),
        (
            "parent_recipient_hash",
            obtain_recipient_uri(
                db_row_dict["_parent_recipient_name"],
                db_row_dict["_parent_recipient_unique_id"],
                None,  # parent_recipient_unique_id
                True,  # is_parent_recipient
            ),
        ),
        ("parent_recipient_name", db_row_dict["_parent_recipient_name"]),
        ("parent_recipient_unique_id",
         db_row_dict["_parent_recipient_unique_id"]),
        (
            "business_categories",
            get_business_category_display_names(
                fetch_business_categories_by_transaction_id(
                    db_row_dict["_transaction_id"])),
        ),
        (
            "location",
            OrderedDict([
                ("location_country_code",
                 db_row_dict["_rl_location_country_code"]),
                ("country_name", db_row_dict["_rl_country_name"]),
                ("state_code", db_row_dict["_rl_state_code"]),
                ("state_name", db_row_dict["_rl_state_name"]),
                ("city_name", db_row_dict["_rl_city_name"]
                 or db_row_dict.get("_rl_foreign_city")),
                ("county_code", db_row_dict["_rl_county_code"]),
                ("county_name", db_row_dict["_rl_county_name"]),
                ("address_line1", db_row_dict["_rl_address_line1"]),
                ("address_line2", db_row_dict["_rl_address_line2"]),
                ("address_line3", db_row_dict["_rl_address_line3"]),
                ("congressional_code", db_row_dict["_rl_congressional_code"]),
                ("zip4", db_row_dict.get("_rl_zip_last_4")
                 or db_row_dict.get("_rl_zip4")),
                ("zip5", db_row_dict["_rl_zip5"]),
                ("foreign_postal_code",
                 db_row_dict.get("_rl_foreign_postal_code")),
                ("foreign_province", db_row_dict.get("_rl_foreign_province")),
            ]),
        ),
    ])
Beispiel #2
0
def test_child_recipient_with_name_and_id(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Child Recipient Test",
        "recipient_unique_id": "456",
        "parent_recipient_unique_id": "123"
    }
    expected_result = "f989e299-1f50-2600-f2f7-b6a45d11f367-C"
    assert obtain_recipient_uri(**child_recipient_parameters) == expected_result
Beispiel #3
0
def test_child_recipient_with_name_and_no_id(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Child Recipient Test Without ID",
        "recipient_unique_id": None,
        "parent_recipient_unique_id": "123"
    }
    expected_result = "75c74068-3dd4-8770-52d0-999353d20f67-C"
    assert obtain_recipient_uri(**child_recipient_parameters) == expected_result
Beispiel #4
0
def test_child_recipient_without_name_or_id(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": None,
        "recipient_unique_id": None,
        "parent_recipient_unique_id": "123"
    }
    expected_result = None
    assert obtain_recipient_uri(**child_recipient_parameters) == expected_result
Beispiel #5
0
def test_child_recipient_with_name_and_id(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Child Recipient Test",
        "recipient_unique_id": "456",
        "parent_recipient_unique_id": "123",
    }
    expected_result = "1c4e7c2a-efe3-1b7e-2190-6f4487f808ac-C"
    assert obtain_recipient_uri(
        **child_recipient_parameters) == expected_result
Beispiel #6
0
def test_child_recipient_with_name_and_no_id(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Child Recipient Test Without ID",
        "recipient_unique_id": None,
        "parent_recipient_unique_id": "123",
    }
    expected_result = "b2c8fe8e-b520-c47f-31e3-3620a358ce48-C"
    assert obtain_recipient_uri(
        **child_recipient_parameters) == expected_result
Beispiel #7
0
def test_parent_recipient_with_id_and_name(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Parent Recipient Tester",
        "recipient_unique_id": "123",
        "parent_recipient_unique_id": None,
        "is_parent_recipient": True
    }
    expected_result = "8ec6b128-58cf-3ee5-80bb-e749381dfcdc-P"
    assert obtain_recipient_uri(**child_recipient_parameters) == expected_result
Beispiel #8
0
def test_parent_recipient_with_id_and_name(recipient_lookup):
    child_recipient_parameters = {
        "recipient_name": "Parent Recipient Tester",
        "recipient_unique_id": "123",
        "parent_recipient_unique_id": None,
        "is_parent_recipient": True,
    }
    expected_result = "01c03484-d1bd-41cc-2aca-4b427a2d0611-P"
    assert obtain_recipient_uri(
        **child_recipient_parameters) == expected_result
Beispiel #9
0
def create_recipient_object(db_row_dict):
    return OrderedDict([
        (
            "recipient_hash",
            obtain_recipient_uri(
                db_row_dict["_recipient_name"],
                db_row_dict["_recipient_unique_id"],
                db_row_dict["_parent_recipient_unique_id"],
            ),
        ),
        ("recipient_name", db_row_dict["_recipient_name"]),
        ("recipient_unique_id", db_row_dict["_recipient_unique_id"]),
        ("parent_recipient_unique_id",
         db_row_dict["_parent_recipient_unique_id"]),
        ("parent_recipient_name", db_row_dict["_parent_recipient_name"]),
        ("business_categories",
         fetch_business_categories_by_legal_entity_id(db_row_dict["_lei"])),
        (
            "location",
            OrderedDict([
                ("location_country_code",
                 db_row_dict["_rl_location_country_code"]),
                ("country_name", db_row_dict["_rl_country_name"]),
                ("state_code", db_row_dict["_rl_state_code"]),
                ("city_name", db_row_dict["_rl_city_name"]),
                ("county_name", db_row_dict["_rl_county_name"]),
                ("address_line1", db_row_dict["_rl_address_line1"]),
                ("address_line2", db_row_dict["_rl_address_line2"]),
                ("address_line3", db_row_dict["_rl_address_line3"]),
                ("congressional_code", db_row_dict["_rl_congressional_code"]),
                ("zip4", db_row_dict["_rl_zip4"]),
                ("zip5", db_row_dict["_rl_zip5"]),
                ("foreign_postal_code",
                 db_row_dict.get("_rl_foreign_postal_code")),
                ("foreign_province", db_row_dict.get("_rl_foreign_province")),
            ]),
        ),
    ])