diff --git a/source/app/models/main.py b/source/app/models/main.py index 282c944..f9c12a9 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -1703,6 +1703,24 @@ def _add_emisor(rfc, args): return True +def _delete_emisor(rfc): + con = sqlite3.connect(COMPANIES) + cursor = con.cursor() + sql = """ + DELETE FROM names + WHERE rfc = '?'""" + try: + cursor.execute(sql, (rfc,)) + except Exception as e: + log.error(e) + return False + + con.commit() + cursor.close() + con.close() + return True + + def _iniciar_bd(): rfc = input('Introduce el RFC: ').strip().upper() if not rfc: @@ -1750,6 +1768,23 @@ def _agregar_rfc(): return +def _borrar_rfc(): + rfc = input('Introduce el RFC a borrar: ').strip().upper() + if not rfc: + msg = 'El RFC es requerido' + log.error(msg) + return + + confirm = input('¿Estás seguro de borrar el RFC?') + + if _delete_emisor(rfc): + log.info('RFC borrado correctamente...') + return + + log.error('No se pudo borrar el RFC') + return + + def _listar_rfc(): data = util.get_rfcs() for row in data: