This commit is contained in:
2026-01-27 10:28:36 +01:00
parent bf7de1e5d1
commit 842a2b1da6

View File

@@ -100,7 +100,7 @@ class ValuationBase(ModelSQL):
values['state'] = f"part. fixed {round(pc.fixed_qt / Decimal(base) * 100, 0)}%"
if pc.price and pc.ratio:
amount = round(pc.price * qty * Decimal(sign) * pc.ratio / 100, 4)
amount = round(pc.price * qty * Decimal(sign) * pc.ratio / 100, 2)
base_amount = amount
currency = sale_line.sale.currency.id if sale_line else line.purchase.currency.id
rate = Decimal(1)
@@ -109,14 +109,14 @@ class ValuationBase(ModelSQL):
base_amount = Currency.compute(currency,amount, line.purchase.company.currency)
rate = round(amount / base_amount,6)
last_price = pc.get_last_price()
mtm = round(Decimal(last_price) * qty * Decimal(sign), 4) if last_price else Decimal(0)
mtm = round(Decimal(last_price) * qty * Decimal(sign), 2) if last_price else Decimal(0)
values.update({
'quantity': round(qty, 5),
'amount': amount,
'base_amount': base_amount,
'rate': rate,
'mtm': round(amount - (mtm * pc.ratio / 100), 4),
'mtm': round(amount - (mtm * pc.ratio / 100), 2),
'unit': sale_line.unit.id if sale_line else line.unit.id,
'currency': currency,
})
@@ -135,7 +135,7 @@ class ValuationBase(ModelSQL):
)
qty = lot.get_current_quantity_converted()
amount = round(price * qty * Decimal(sign), 4)
amount = round(price * qty * Decimal(sign), 2)
base_amount = amount
currency = sale_line.sale.currency.id if sale_line else line.purchase.currency.id
company_currency = sale_line.sale.company.currency if sale_line else line.purchase.company.currency
@@ -318,8 +318,8 @@ class ValuationBase(ModelSQL):
'product': d.product.id,
'state': 'fixed',
'quantity': round(d.quantity, 5),
'amount': round(price * d.quantity * Decimal(-1), 4),
'mtm': round((price * d.quantity * Decimal(-1)) - (mtm * d.quantity * Decimal(-1)), 4),
'amount': round(price * d.quantity * Decimal(-1), 2),
'mtm': round((price * d.quantity * Decimal(-1)) - (mtm * d.quantity * Decimal(-1)), 2),
'unit': line.unit.id,
'currency': line.purchase.currency.id,
})