def _alter_audit(**kwargs): """Calls sp in charge of create and edit a audit""" dependency_ids_str = str(set(kwargs['dependency_ids'])) years_str = str(set(kwargs['years'])) sql = """SELECT * FROM alter_audit( {}::integer, '{}'::character varying, '{}'::integer[], '{}'::integer[], {}::integer, {}::integer) AS result( rc integer, msg text )""".format( kwargs["id"], kwargs["title"], dependency_ids_str, years_str, kwargs["org_fiscal_id"], kwargs["direccion_id"], ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("audits", id) return add_audit_data(ent)
def _alter_observation(**kwargs): seguimientos_str = seguimientos_to_comp_type_arr_lit(kwargs['seguimientos']) pras_str = pras_to_comp_type_lit(kwargs['pras']) """Calls database function in charge of creation and edition of an observation (ASF ires)""" sql = """SELECT * FROM alter_observacion_ires_asf( {}::integer, {}::integer, '{}'::character varying, '{}'::date, '{}'::date, '{}'::text, {}::integer, {}::integer, '{}'::character varying, {}::double precision, {}::double precision, {}::double precision, '{}'::date, {}::double precision, {}::boolean, {}::seguimientos_obs_asf[], {}::pras_ires_asf) AS result( rc integer, msg text )""".format( kwargs['id'], kwargs['observacion_pre_id'], kwargs['num_oficio_of'].replace("'", "''"), kwargs['fecha_recibido'], kwargs['fecha_vencimiento'], kwargs['observacion_ir'].replace("'", "''"), kwargs['tipo_observacion_id'], kwargs['accion'], kwargs['clave_accion'].replace("'", "''"), kwargs['monto_observado'], kwargs['monto_a_reintegrar'], kwargs['monto_reintegrado'], kwargs['fecha_reintegro'], kwargs['monto_por_reintegrar'], kwargs['tiene_pras'], seguimientos_str, pras_str, ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observaciones_ires_asf", id) return add_observacion_data(ent)
def _alter_observation(**kwargs): """Calls sp in charge of create and edit a observation""" sql = """SELECT * FROM alter_observation_preliminar( {}::integer, {}::integer, {}::integer, {}::integer, {}::integer, {}::integer, {}::integer, '{}'::text, {}::double precision, {}::double precision, {}::double precision, '{}'::text, '{}'::date, '{}'::date, '{}'::date, '{}'::date, '{}'::date, '{}'::text, '{}'::text, '{}'::text, '{}'::text, '{}'::text, {}::integer, '{}'::text, '{}'::date, '{}'::date, '{}'::date) AS result( rc integer, msg text )""".format( kwargs["id"], kwargs["observation_type_id"], kwargs["observation_code_id"], kwargs["observation_bis_code_id"], kwargs["social_program_id"], kwargs["audit_id"], kwargs["fiscal_id"], kwargs["title"], kwargs["amount_observed"], kwargs["projected"], kwargs["solved"], kwargs["comments"], kwargs["reception_date"], kwargs["expiration_date"], kwargs["doc_a_date"], kwargs["doc_b_date"], kwargs["doc_c_date"], kwargs["doc_a"], kwargs["doc_b"], kwargs["doc_c"], kwargs['dep_response'], kwargs['dep_resp_comments'], kwargs['division_id'], kwargs['hdr_doc'], kwargs['hdr_reception_date'], kwargs['hdr_expiration1_date'], kwargs['hdr_expiration2_date']) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observations", id) return add_observation_amounts(ent)
def _alter_user(**kwargs): """Calls the db function in charge of creating and editing a user""" # Hashing the password if kwargs["id"] != 0 and (kwargs["passwd"] == '' or kwargs["passwd"] is None): passwd = '' else: passwd = hashlib.sha256(kwargs["passwd"].encode("utf-8")).hexdigest() sql = """SELECT * FROM alter_user( {}::integer, '{}'::character varying, '{}'::character varying, {}::integer, {}::integer, {}::boolean, '{}'::character varying, '{}'::character varying, '{}'::integer[]) AS result( rc integer, msg text )""".format( kwargs["id"], kwargs["username"], passwd, kwargs["orgchart_role_id"], kwargs["division_id"], kwargs["disabled"], kwargs["first_name"], kwargs["last_name"], str(set(kwargs["access_vector"])), ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("users", id) return add_user_permissions(ent)
def read(id): ''' Fetches an observation entity ''' ent = fetch_entity("observaciones_pre_asf", id) return add_observacion_data(ent)
def _alter_observation(**kwargs): proyecciones_str = str(set(kwargs['proyecciones'])) """Calls database function in charge of creation and edition of an observation (preliminar ASF)""" sql = """SELECT * FROM alter_observacion_pre_asf( {}::integer, {}::integer, '{}'::date, {}::integer, {}::integer, '{}'::character varying, '{}'::date, '{}'::date, '{}'::character varying, '{}'::text, {}::double precision, '{}'::character varying, '{}'::date, '{}'::date, '{}'::date, '{}'::character varying, '{}'::date, '{}'::text, '{}'::text, {}::integer, '{}'::character varying, '{}'::date, {}::integer, '{}'::integer[]) AS result( rc integer, msg text )""".format( kwargs['id'], kwargs['direccion_id'], kwargs['fecha_captura'], kwargs['programa_social_id'], kwargs['auditoria_id'], kwargs['num_oficio_of'].replace("'", "''"), kwargs['fecha_recibido'], kwargs['fecha_vencimiento_of'], kwargs['num_observacion'].replace("'", "''"), kwargs['observacion'].replace("'", "''"), kwargs['monto_observado'], kwargs['num_oficio_cytg'].replace("'", "''"), kwargs['fecha_oficio_cytg'], kwargs['fecha_recibido_dependencia'], kwargs['fecha_vencimiento'], kwargs['num_oficio_resp_dependencia'].replace("'", "''"), kwargs['fecha_oficio_resp_dependencia'], kwargs['resp_dependencia'].replace("'", "''"), kwargs['comentarios'].replace("'", "''"), kwargs['clasif_final_cytg'], kwargs['num_oficio_org_fiscalizador'].replace("'", "''"), kwargs['fecha_oficio_org_fiscalizador'], kwargs['estatus_criterio_int_id'], proyecciones_str, ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observaciones_pre_asf", id) return add_observacion_data(ent)
def read(id): ''' Fetches a user entity ''' ent = fetch_entity("users", id) return add_user_permissions(ent)
def _alter_observation(**kwargs): seguimientos_str = seguimientos_to_comp_type_arr_lit(kwargs['seguimientos']) """Calls database function in charge of creation and edition of an observation (CyTG)""" sql = """SELECT * FROM alter_observacion_ires_cytg( {}::integer, {}::integer, '{}'::character varying, '{}'::text, {}::integer, {}::integer, '{}'::text, '{}'::text, {}::integer, {}::double precision, {}::double precision, {}::double precision, {}::double precision, '{}'::date, {}::double precision, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::character varying, '{}'::date, {}::seguimientos_obs_cytg[]) AS result( rc integer, msg text )""".format( kwargs['id'], kwargs['observacion_pre_id'], kwargs['num_observacion'].replace("'", "''"), kwargs['observacion'].replace("'", "''"), kwargs['tipo_observacion_id'], kwargs['estatus_info_resultados_id'], kwargs['acciones_preventivas'].replace("'", "''"), kwargs['acciones_correctivas'].replace("'", "''"), kwargs['clasif_final_cytg'], kwargs['monto_solventado'], kwargs['monto_pendiente_solventar'], kwargs['monto_a_reintegrar'], kwargs['monto_reintegrado'], kwargs['fecha_reintegro'], kwargs['monto_por_reintegrar'], kwargs['num_oficio_cytg_aut_invest'].replace("'", "''"), kwargs['fecha_oficio_cytg_aut_invest'], kwargs['num_carpeta_investigacion'].replace("'", "''"), kwargs['num_oficio_vai_municipio'].replace("'", "''"), kwargs['fecha_oficio_vai_municipio'], kwargs['num_oficio_pras_cytg_dependencia'].replace("'", "''"), kwargs['num_oficio_resp_dependencia'].replace("'", "''"), kwargs['fecha_oficio_resp_dependencia'], seguimientos_str, ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observaciones_ires_cytg", id) return add_observacion_data(ent)
def read(id): ''' Fetches an audit entity ''' ent = fetch_entity("audits", id) return add_audit_data(ent)
def read(id): ''' Fetches an observation entity ''' ent = fetch_entity("observations", id) return add_observation_amounts(ent)
def _alter_observation(**kwargs): seguimientos_str = seguimientos_to_comp_type_arr_lit( kwargs['seguimientos']) """Calls database function in charge of creation and edition of an observation (sfp)""" sql = """SELECT * FROM alter_observacion_sfp( {}::integer, {}::integer, '{}'::date, {}::integer, {}::integer, '{}'::character varying, '{}'::date, '{}'::date, '{}'::character varying, '{}'::text, '{}'::character varying, '{}'::character varying, {}::integer, {}::double precision, {}::seguimientos_obs_sfp[], {}::double precision, {}::double precision, '{}'::date, {}::double precision, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::character varying, '{}'::date, {}::integer, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::character varying, '{}'::date) AS result( rc integer, msg text )""".format( kwargs['id'], kwargs['direccion_id'], kwargs['fecha_captura'], kwargs['programa_social_id'], kwargs['auditoria_id'], kwargs['acta_cierre'].replace("'", "''"), kwargs['fecha_firma_acta_cierre'], kwargs['fecha_compromiso'], kwargs['clave_observacion'].replace("'", "''"), kwargs['observacion'].replace("'", "''"), kwargs['acciones_correctivas'].replace("'", "''"), kwargs['acciones_preventivas'].replace("'", "''"), kwargs['tipo_observacion_id'], kwargs['monto_observado'], seguimientos_str, kwargs['monto_a_reintegrar'], kwargs['monto_reintegrado'], kwargs['fecha_reintegro'], kwargs['monto_por_reintegrar'], kwargs['num_oficio_of_vista_cytg'].replace("'", "''"), kwargs['fecha_oficio_of_vista_cytg'], kwargs['num_oficio_cytg_aut_invest'].replace("'", "''"), kwargs['fecha_oficio_cytg_aut_invest'], kwargs['num_carpeta_investigacion'].replace("'", "''"), kwargs['num_oficio_vai_municipio'].replace("'", "''"), kwargs['fecha_oficio_vai_municipio'], kwargs['autoridad_invest_id'], kwargs['num_oficio_pras_of'].replace("'", "''"), kwargs['fecha_oficio_pras_of'], kwargs['num_oficio_pras_cytg_dependencia'].replace("'", "''"), kwargs['num_oficio_resp_dependencia'].replace("'", "''"), kwargs['fecha_oficio_resp_dependencia'], ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observaciones_sfp", id) return add_observacion_data(ent)
def _alter_observation(**kwargs): """Calls database function in charge of creation and edition of an observation (preliminar CyTG)""" sql = """SELECT * FROM alter_observacion_pre_cytg( {}::integer, '{}'::date, '{}'::date, {}::integer, '{}'::date, {}::integer, {}::integer, {}::integer, '{}'::character varying, '{}'::date, '{}'::date, '{}'::character varying, '{}'::date, '{}'::date, '{}'::date, {}::integer, '{}'::character varying, '{}'::text, {}::double precision, '{}'::character varying, '{}'::date, '{}'::date, '{}'::date, {}::boolean, '{}'::character varying, '{}'::date, '{}'::character varying, '{}'::date, '{}'::date, {}::integer, '{}'::character varying, '{}'::date, '{}'::text, '{}'::text, {}::integer) AS result( rc integer, msg text )""".format( kwargs['id'], kwargs['periodo_revision_de'], kwargs['periodo_revision_a'], kwargs['direccion_id'], kwargs['fecha_captura'], kwargs['programa_social_id'], kwargs['auditoria_id'], kwargs['tipo_auditoria_id'], kwargs['num_oficio_inicio'].replace("'", "''"), kwargs['fecha_notificacion_inicio'], kwargs['fecha_vencimiento_nombra_enlace'], kwargs['num_oficio_requerimiento'].replace("'", "''"), kwargs['fecha_notificacion_requerimiento'], kwargs['fecha_vencimiento_requerimiento'], kwargs['fecha_vencimiento_nueva'], kwargs['tipo_observacion_id'], kwargs['num_observacion'].replace("'", "''"), kwargs['observacion'].replace("'", "''"), kwargs['monto_observado'], kwargs['num_oficio_cytg_oic_pre'].replace("'", "''"), kwargs['fecha_oficio_cytg_pre'], kwargs['fecha_recibido_dependencia'], kwargs['fecha_vencimiento_pre'], kwargs['prorroga'], kwargs['num_oficio_solic_prorroga'].replace("'", "''"), kwargs['fecha_oficio_solic_prorroga'], kwargs['num_oficio_contest_prorroga_cytg'].replace("'", "''"), kwargs['fecha_oficio_contest_cytg'], kwargs['fecha_vencimiento_pre_nueva'], kwargs['clasif_pre_cytg'], kwargs['num_oficio_resp_dependencia'].replace("'", "''"), kwargs['fecha_oficio_resp'], kwargs['resp_dependencia'].replace("'", "''"), kwargs['comentarios'].replace("'", "''"), kwargs['estatus_id'], ) rcode, rmsg = run_stored_procedure(sql) if rcode < 1: if kwargs['id'] != 0: raise EmptySetError(rmsg) else: raise Exception(rmsg) else: id = rcode ent = fetch_entity("observaciones_pre_cytg", id) return add_observacion_data(ent)