forked from elmau/empresa-libre
Fix - al identificarse con datos inexistentes
This commit is contained in:
parent
b3c2e16841
commit
a30bb4fcd3
|
@ -1460,11 +1460,12 @@ class ImportFacturaLibre(object):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _categorias(self):
|
def _categorias(self):
|
||||||
sql = "SELECT * FROM categorias"
|
sql = "SELECT * FROM categorias ORDER BY id_padre"
|
||||||
self._cursor.execute(sql)
|
self._cursor.execute(sql)
|
||||||
rows = self._cursor.fetchall()
|
rows = self._cursor.fetchall()
|
||||||
|
|
||||||
fields = (
|
fields = (
|
||||||
|
('id', 'id'),
|
||||||
('categoria', 'categoria'),
|
('categoria', 'categoria'),
|
||||||
('id_padre', 'padre'),
|
('id_padre', 'padre'),
|
||||||
)
|
)
|
||||||
|
@ -1561,6 +1562,7 @@ class ImportFacturaLibre(object):
|
||||||
|
|
||||||
tasas = {
|
tasas = {
|
||||||
'16': 0.16,
|
'16': 0.16,
|
||||||
|
'11': 0.11,
|
||||||
'-10': 0.10,
|
'-10': 0.10,
|
||||||
'0': 0.0,
|
'0': 0.0,
|
||||||
'-2/3': 0.666667,
|
'-2/3': 0.666667,
|
||||||
|
|
|
@ -3222,7 +3222,6 @@ class FacturasPagos(BaseModel):
|
||||||
auto_round=True)
|
auto_round=True)
|
||||||
saldo = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
saldo = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||||
auto_round=True)
|
auto_round=True)
|
||||||
# ~ cancelado = BooleanField(default=False)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
order_by = ('factura',)
|
order_by = ('factura',)
|
||||||
|
@ -3351,16 +3350,16 @@ def authenticate(args):
|
||||||
respuesta = {'login': False, 'msg': 'No Autorizado', 'user': ''}
|
respuesta = {'login': False, 'msg': 'No Autorizado', 'user': ''}
|
||||||
values = util.get_con(args['rfc'])
|
values = util.get_con(args['rfc'])
|
||||||
if not values:
|
if not values:
|
||||||
return respuesta
|
return respuesta, None
|
||||||
|
|
||||||
conectar(values)
|
conectar(values)
|
||||||
try:
|
try:
|
||||||
obj = Usuarios.get(usuario=args['usuario'], es_activo=True)
|
obj = Usuarios.get(usuario=args['usuario'], es_activo=True)
|
||||||
except Usuarios.DoesNotExist:
|
except Usuarios.DoesNotExist:
|
||||||
return respuesta
|
return respuesta, None
|
||||||
|
|
||||||
if not obj.contraseña.check_password(args['contra']):
|
if not obj.contraseña.check_password(args['contra']):
|
||||||
return respuesta
|
return respuesta, None
|
||||||
|
|
||||||
obj.ultimo_ingreso = util.now()
|
obj.ultimo_ingreso = util.now()
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -3763,25 +3762,24 @@ def _importar_facturas(rows):
|
||||||
def _importar_categorias(rows):
|
def _importar_categorias(rows):
|
||||||
log.info('\tImportando Categorías...')
|
log.info('\tImportando Categorías...')
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if row['padre'] is None:
|
# ~ if row['padre'] is None:
|
||||||
filters = (
|
# ~ filters = (
|
||||||
(Categorias.categoria==row['categoria']) &
|
# ~ (Categorias.categoria==row['categoria']) &
|
||||||
(Categorias.padre.is_null(True))
|
# ~ (Categorias.padre.is_null(True))
|
||||||
)
|
# ~ )
|
||||||
else:
|
# ~ else:
|
||||||
filters = (
|
# ~ filters = (
|
||||||
(Categorias.categoria==row['categoria']) &
|
# ~ (Categorias.categoria==row['categoria']) &
|
||||||
(Categorias.padre==row['padre'])
|
# ~ (Categorias.padre==row['padre'])
|
||||||
)
|
# ~ )
|
||||||
|
with database_proxy.atomic() as txn:
|
||||||
if Categorias.exists(filters):
|
# ~ if Categorias.exists(filters):
|
||||||
continue
|
# ~ continue
|
||||||
|
try:
|
||||||
try:
|
Categorias.create(**row)
|
||||||
Categorias.create(**row)
|
except IntegrityError:
|
||||||
except IntegrityError:
|
msg = '\tCategoria: ({}) {}'.format(row['padre'], row['categoria'])
|
||||||
msg = '\tCategoria: ({}) {}'.format(row['padre'], row['categoria'])
|
log.error(msg)
|
||||||
log.error(msg)
|
|
||||||
|
|
||||||
log.info('\tCategorías importadas...')
|
log.info('\tCategorías importadas...')
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue