Example #1
0
 def fetch_empdat(usr_id):
     sql = """select upper(EMP.rfc) as rfc, EMP.no_id as no_id
         FROM gral_suc AS SUC
         LEFT JOIN gral_usr_suc AS USR_SUC ON USR_SUC.gral_suc_id = SUC.id
         LEFT JOIN gral_emp AS EMP ON EMP.id = SUC.empresa_id
         WHERE USR_SUC.gral_usr_id="""
     q = "{0}{1}".format(sql, usr_id)
     logger.debug("Performing query: {}".format(q))
     try:
         for row in HelperPg.onfly_query(pt.dbms.pgsql_conn, q):
             return ErrorCode.SUCCESS, dict(rfc=row['rfc'], no_id=row['no_id'])
     except:
         logger.error(dump_exception())
         return ErrorCode.DBMS_SQL_ISSUES, None
Example #2
0
def make_remain_prefacts_up(conn, user_id):
    """deals with the remain prefacts which are opened"""

    q = """SELECT *
        FROM fac_global_make_up( {}::integer )
        AS result( rc integer, msg text )""".format(user_id)

    res = HelperPg.query(conn, q, True)
    if len(res) != 1:
        raise Exception(
            'unexpected result regarding execution of fac_global_make_up')

    rcode, rmsg = res.pop()
    if rcode != 0:
        raise Exception(rmsg)
Example #3
0
def validation(conn, user_id):
    """checks coherency before creation prefactura"""

    q = """SELECT *
        FROM fac_global_validation( {}::integer )
        AS result( rc integer, msg text )""".format(user_id)

    res = HelperPg.query(conn, q, True)
    if len(res) != 1:
        raise Exception(
            'unexpected result regarding execution of fac_global_validation')

    rcode, rmsg = res.pop()
    if rcode != 0:
        raise Exception(rmsg)