def cal_user_location()

in jobs/eam-integrations/scripts/workday_everfi_integration.py [0:0]


def cal_user_location(wd_user, locs, loc_map_table):
    loc = ""
    location_country = wd_user.get("location_country", "")

    if location_country == "Canada":
        loc = loc_map_table.get(wd_user.get("location_province", ""), "")
        if not loc:
            loc = "Federal (Canada)"
    elif location_country == "United States of America":
        # if wd_user.get("location_state", "") == "New York":
        loc = loc_map_table.get(wd_user.get("location_state", ""), "")

        if not loc:
            loc = "United States"
    else:
        loc = "Default"

    id = locs.get(loc)["id"]
    if not id:
        id = locs.get("Default")["Id"]

    logger.debug(
        f"Location id={id} mapped for user {wd_user.get('primary_work_email','')} loc = {loc}"
    )
    return id