forked from elmau/empresa-libre
Fix - unidades al importar
This commit is contained in:
commit
1d35ce7324
|
@ -4507,7 +4507,7 @@ class TicketsDetalle(BaseModel):
|
||||||
price_with_tax = cls._with_tax(cls, p)
|
price_with_tax = cls._with_tax(cls, p)
|
||||||
importe = round(price_with_tax * float(p.cantidad), DECIMALES)
|
importe = round(price_with_tax * float(p.cantidad), DECIMALES)
|
||||||
l = '{:>6,.2f} {:<4} {:<14} {:>9,.2f} {:>10,.2f}\n'.format(
|
l = '{:>6,.2f} {:<4} {:<14} {:>9,.2f} {:>10,.2f}\n'.format(
|
||||||
p.cantidad, p.producto.unidad.name, p.descripcion,
|
p.cantidad, p.producto.unidad.name[:5], p.descripcion[:14],
|
||||||
price_with_tax, importe
|
price_with_tax, importe
|
||||||
)
|
)
|
||||||
lines.append(l)
|
lines.append(l)
|
||||||
|
@ -5112,7 +5112,7 @@ def _get_id_unidad(unidad):
|
||||||
obj = SATUnidades.get(SATUnidades.name.contains(unidad))
|
obj = SATUnidades.get(SATUnidades.name.contains(unidad))
|
||||||
except SATUnidades.DoesNotExist:
|
except SATUnidades.DoesNotExist:
|
||||||
msg = '\tNo se encontró la unidad: {}'.format(unidad)
|
msg = '\tNo se encontró la unidad: {}'.format(unidad)
|
||||||
log.error(msg)
|
# ~ log.error(msg)
|
||||||
return unidad
|
return unidad
|
||||||
|
|
||||||
return str(obj.id)
|
return str(obj.id)
|
||||||
|
@ -5177,12 +5177,22 @@ def _generar_archivo_productos(archivo):
|
||||||
)
|
)
|
||||||
|
|
||||||
data = ['|'.join(fields)]
|
data = ['|'.join(fields)]
|
||||||
|
not_units = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
impuestos = row.pop('impuestos', ())
|
impuestos = row.pop('impuestos', ())
|
||||||
line = [str(row[r]) for r in fields]
|
line = [str(row[r]) for r in fields]
|
||||||
if line[10] == 'None':
|
if line[10] == 'None':
|
||||||
line[10] = '0.0'
|
line[10] = '0.0'
|
||||||
line[2] = _get_id_unidad(line[2])
|
line[2] = _get_id_unidad(line[2])
|
||||||
|
try:
|
||||||
|
int(line[2])
|
||||||
|
except ValueError:
|
||||||
|
if not line[2] in not_units:
|
||||||
|
not_units.append(line[2])
|
||||||
|
msg = 'No se encontró la unidad: {}'.format(line[2])
|
||||||
|
log.error(msg)
|
||||||
|
continue
|
||||||
|
|
||||||
line = '|'.join(line) + _get_impuestos(impuestos)
|
line = '|'.join(line) + _get_impuestos(impuestos)
|
||||||
data.append(line)
|
data.append(line)
|
||||||
|
|
||||||
|
@ -5484,7 +5494,7 @@ help_lr = 'Listar RFCs'
|
||||||
@click.option('-br', '--borrar-rfc', help=help_br, is_flag=True, default=False)
|
@click.option('-br', '--borrar-rfc', help=help_br, is_flag=True, default=False)
|
||||||
@click.option('-lr', '--listar-rfc', help=help_lr, is_flag=True, default=False)
|
@click.option('-lr', '--listar-rfc', help=help_lr, is_flag=True, default=False)
|
||||||
@click.option('-i', '--importar-valores', is_flag=True, default=False)
|
@click.option('-i', '--importar-valores', is_flag=True, default=False)
|
||||||
@click.option('-a', '--archivo')
|
@click.option('-f', '--archivo')
|
||||||
@click.option('-c', '--conexion')
|
@click.option('-c', '--conexion')
|
||||||
@click.option('-fl', '--factura-libre', is_flag=True, default=False)
|
@click.option('-fl', '--factura-libre', is_flag=True, default=False)
|
||||||
@click.option('-flg', '--factura-libre-gambas', is_flag=True, default=False)
|
@click.option('-flg', '--factura-libre-gambas', is_flag=True, default=False)
|
||||||
|
|
Loading…
Reference in New Issue