forked from elmau/empresa-libre
Update catalogos SAT
This commit is contained in:
parent
aeb045e76a
commit
fe09860922
|
@ -358,6 +358,10 @@ def loads(data):
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
|
|
||||||
|
|
||||||
|
def json_loads(path):
|
||||||
|
return json.loads(open(path, 'r').read())
|
||||||
|
|
||||||
|
|
||||||
def _validate_db_rfc():
|
def _validate_db_rfc():
|
||||||
con = sqlite3.connect(DB_COMPANIES)
|
con = sqlite3.connect(DB_COMPANIES)
|
||||||
sql = """
|
sql = """
|
||||||
|
|
|
@ -9009,7 +9009,7 @@ def _init_values(rfc):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not Certificado.select().count():
|
if not Certificado.select().count():
|
||||||
Certificado.create(rfc=rfc)
|
Certificado.create(rfc=rfc.upper())
|
||||||
|
|
||||||
log.info('Valores iniciales insertados...')
|
log.info('Valores iniciales insertados...')
|
||||||
return
|
return
|
||||||
|
@ -10104,6 +10104,26 @@ def _delete_client(rfc, no_database, ask=True):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def _update_sat():
|
||||||
|
clients = utils.rfc_get()
|
||||||
|
tables = utils.json_loads(PATHS['SAT'])
|
||||||
|
for rfc, con in clients:
|
||||||
|
log.info(f'Importando datos en: {rfc.upper()}')
|
||||||
|
conectar(utils.loads(con))
|
||||||
|
for table in tables:
|
||||||
|
t = globals()[table['tabla']]
|
||||||
|
with database_proxy.atomic():
|
||||||
|
for r in table['datos']:
|
||||||
|
try:
|
||||||
|
t.get_or_create(**r)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
log.info(f"\tTabla importada: {table['tabla']}")
|
||||||
|
desconectar()
|
||||||
|
log.info('Importación terminada...')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def _process_command_line_arguments():
|
def _process_command_line_arguments():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Empresa Libre')
|
description='Empresa Libre')
|
||||||
|
@ -10115,12 +10135,14 @@ def _process_command_line_arguments():
|
||||||
action='store_true', default=False, required=False)
|
action='store_true', default=False, required=False)
|
||||||
parser.add_argument('-ndb', '--no-database', dest='no_database',
|
parser.add_argument('-ndb', '--no-database', dest='no_database',
|
||||||
action='store_true', default=False, required=False)
|
action='store_true', default=False, required=False)
|
||||||
|
parser.add_argument('-us', '--update-sat', dest='update_sat',
|
||||||
|
action='store_true', default=False, required=False)
|
||||||
|
|
||||||
parser.add_argument('-r', '--rfc', dest='rfc', default='')
|
parser.add_argument('-r', '--rfc', dest='rfc', default='')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main2(args):
|
def main(args):
|
||||||
if args.list_clients:
|
if args.list_clients:
|
||||||
_list_clients()
|
_list_clients()
|
||||||
return
|
return
|
||||||
|
@ -10133,6 +10155,9 @@ def main2(args):
|
||||||
_delete_client(args.rfc, args.no_database)
|
_delete_client(args.rfc, args.no_database)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if args.update_sat:
|
||||||
|
_update_sat()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -10170,7 +10195,7 @@ help_lr = 'Listar RFCs'
|
||||||
@click.option('-d', '--detalle', is_flag=True, default=False)
|
@click.option('-d', '--detalle', is_flag=True, default=False)
|
||||||
@click.option('-id', '--importar-directorio')
|
@click.option('-id', '--importar-directorio')
|
||||||
@click.option('-ed', '--exportar_documentos', is_flag=True, default=False)
|
@click.option('-ed', '--exportar_documentos', is_flag=True, default=False)
|
||||||
def main(iniciar_bd, migrar_bd, nuevo_superusuario, cambiar_contraseña,
|
def main2(iniciar_bd, migrar_bd, nuevo_superusuario, cambiar_contraseña,
|
||||||
borrar_rfc, listar_rfc, importar_valores, archivo, conexion,
|
borrar_rfc, listar_rfc, importar_valores, archivo, conexion,
|
||||||
factura_libre, test, generar_archivo_productos,
|
factura_libre, test, generar_archivo_productos,
|
||||||
importar_productos, backup_dbs, no_bd, alta, rfc, detalle,
|
importar_productos, backup_dbs, no_bd, alta, rfc, detalle,
|
||||||
|
@ -10283,7 +10308,7 @@ def main(iniciar_bd, migrar_bd, nuevo_superusuario, cambiar_contraseña,
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = _process_command_line_arguments()
|
args = _process_command_line_arguments()
|
||||||
main2(args)
|
main(args)
|
||||||
# ~ main()
|
# ~ main2()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,7 @@ IS_MV = MV
|
||||||
DB_COMPANIES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'rfc.db'))
|
DB_COMPANIES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'rfc.db'))
|
||||||
path_bk = os.path.join(path_docs, 'tmp')
|
path_bk = os.path.join(path_docs, 'tmp')
|
||||||
path_local = 'facturas'
|
path_local = 'facturas'
|
||||||
|
path_sat = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'valores_iniciales.json'))
|
||||||
|
|
||||||
EXT = {
|
EXT = {
|
||||||
'CSS': 'css',
|
'CSS': 'css',
|
||||||
|
@ -220,6 +221,7 @@ PATHS = {
|
||||||
'LOGOS': path_user_logos,
|
'LOGOS': path_user_logos,
|
||||||
'BK': path_bk,
|
'BK': path_bk,
|
||||||
'LOCAL': path_local,
|
'LOCAL': path_local,
|
||||||
|
'SAT': path_sat,
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUES_PDF = {
|
VALUES_PDF = {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue