From a30bb4fcd380a133e4ba31d7a695f31ee0debd62 Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Thu, 30 Nov 2017 17:34:25 -0600 Subject: [PATCH] Fix - al identificarse con datos inexistentes --- source/app/controllers/util.py | 4 +++- source/app/models/main.py | 44 ++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 3512985..baff914 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -1460,11 +1460,12 @@ class ImportFacturaLibre(object): return data def _categorias(self): - sql = "SELECT * FROM categorias" + sql = "SELECT * FROM categorias ORDER BY id_padre" self._cursor.execute(sql) rows = self._cursor.fetchall() fields = ( + ('id', 'id'), ('categoria', 'categoria'), ('id_padre', 'padre'), ) @@ -1561,6 +1562,7 @@ class ImportFacturaLibre(object): tasas = { '16': 0.16, + '11': 0.11, '-10': 0.10, '0': 0.0, '-2/3': 0.666667, diff --git a/source/app/models/main.py b/source/app/models/main.py index 80503f2..d22167f 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -3222,7 +3222,6 @@ class FacturasPagos(BaseModel): auto_round=True) saldo = DecimalField(default=0.0, max_digits=18, decimal_places=6, auto_round=True) - # ~ cancelado = BooleanField(default=False) class Meta: order_by = ('factura',) @@ -3351,16 +3350,16 @@ def authenticate(args): respuesta = {'login': False, 'msg': 'No Autorizado', 'user': ''} values = util.get_con(args['rfc']) if not values: - return respuesta + return respuesta, None conectar(values) try: obj = Usuarios.get(usuario=args['usuario'], es_activo=True) except Usuarios.DoesNotExist: - return respuesta + return respuesta, None if not obj.contraseña.check_password(args['contra']): - return respuesta + return respuesta, None obj.ultimo_ingreso = util.now() obj.save() @@ -3763,25 +3762,24 @@ def _importar_facturas(rows): def _importar_categorias(rows): log.info('\tImportando Categorías...') for row in rows: - if row['padre'] is None: - filters = ( - (Categorias.categoria==row['categoria']) & - (Categorias.padre.is_null(True)) - ) - else: - filters = ( - (Categorias.categoria==row['categoria']) & - (Categorias.padre==row['padre']) - ) - - if Categorias.exists(filters): - continue - - try: - Categorias.create(**row) - except IntegrityError: - msg = '\tCategoria: ({}) {}'.format(row['padre'], row['categoria']) - log.error(msg) + # ~ if row['padre'] is None: + # ~ filters = ( + # ~ (Categorias.categoria==row['categoria']) & + # ~ (Categorias.padre.is_null(True)) + # ~ ) + # ~ else: + # ~ filters = ( + # ~ (Categorias.categoria==row['categoria']) & + # ~ (Categorias.padre==row['padre']) + # ~ ) + with database_proxy.atomic() as txn: + # ~ if Categorias.exists(filters): + # ~ continue + try: + Categorias.create(**row) + except IntegrityError: + msg = '\tCategoria: ({}) {}'.format(row['padre'], row['categoria']) + log.error(msg) log.info('\tCategorías importadas...') return