Fix - al identificarse con datos inexistentes

This commit is contained in:
Mauricio Baeza 2017-11-30 17:34:25 -06:00
parent b3c2e16841
commit a30bb4fcd3
2 changed files with 24 additions and 24 deletions

View File

@ -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,

View File

@ -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