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