def to_bool(s):
    if isinstance(s, bool):
        return s
    if isinstance(s, str):
        s = s.lower()
        if s in ['true', '1', 'yes']:
            return True
        elif s in ['false', '0', 'no']:
            return False
        else:
            return False


def get_sucursal_from_request(request):
    return request.user.id_intelisis or 0
