Fix - Issue #139
This commit is contained in:
parent
9fcd8c0503
commit
f4863db8ea
|
@ -2200,10 +2200,20 @@ class Productos(BaseModel):
|
|||
|
||||
@classmethod
|
||||
def next_key(cls):
|
||||
value = (Productos
|
||||
.select(fn.Max(cast(Productos.clave, 'int')).alias('fm'))
|
||||
.order_by(SQL('fm'))
|
||||
.scalar())
|
||||
try:
|
||||
with database_proxy.transaction():
|
||||
value = (Productos
|
||||
.select(fn.Max(cast(Productos.clave, 'int')).alias('fm'))
|
||||
.order_by(SQL('fm'))
|
||||
.scalar())
|
||||
except Exception as e:
|
||||
values = (Productos
|
||||
.select(Productos.clave)
|
||||
.order_by(Productos.clave)
|
||||
.tuples()
|
||||
)
|
||||
value = max([int(v[0]) for v in values if v[0].isdigit()])
|
||||
|
||||
value = value or 0
|
||||
value += 1
|
||||
return {'value': value}
|
||||
|
@ -3806,7 +3816,7 @@ class PreFacturas(BaseModel):
|
|||
totals_tax = {}
|
||||
total_trasladados = None
|
||||
total_retenciones = None
|
||||
total_iva = 0
|
||||
# ~ total_iva = 0
|
||||
|
||||
for product in products:
|
||||
id_product = product.pop('id')
|
||||
|
@ -3848,8 +3858,8 @@ class PreFacturas(BaseModel):
|
|||
continue
|
||||
import_tax = round(float(tax.tasa) * tax.importe, DECIMALES)
|
||||
total_trasladados = (total_trasladados or 0) + import_tax
|
||||
if tax.name == 'IVA':
|
||||
total_iva += import_tax
|
||||
# ~ if tax.name == 'IVA':
|
||||
# ~ total_iva += import_tax
|
||||
|
||||
invoice_tax = {
|
||||
'factura': invoice.id,
|
||||
|
@ -3862,10 +3872,10 @@ class PreFacturas(BaseModel):
|
|||
for tax in totals_tax.values():
|
||||
if tax.tipo == 'E' or tax.tipo == 'T':
|
||||
continue
|
||||
if tax.tasa == round(Decimal(2/3), 6):
|
||||
import_tax = round(float(tax.tasa) * total_iva, DECIMALES)
|
||||
else:
|
||||
import_tax = round(float(tax.tasa) * tax.importe, DECIMALES)
|
||||
# ~ if tax.tasa == round(Decimal(2/3), 6):
|
||||
# ~ import_tax = round(float(tax.tasa) * total_iva, DECIMALES)
|
||||
# ~ else:
|
||||
import_tax = round(float(tax.tasa) * tax.importe, DECIMALES)
|
||||
total_retenciones = (total_retenciones or 0) + import_tax
|
||||
|
||||
invoice_tax = {
|
||||
|
|
Loading…
Reference in New Issue