This commit is contained in:
2026-02-08 21:51:04 +01:00
parent 04179fde77
commit df5ef074ad
3 changed files with 33 additions and 38 deletions

View File

@@ -91,7 +91,7 @@ class MtmStrategy(ModelSQL, ModelView):
def default_active(cls):
return True
def compute_mtm(self):
def get_mtm(self,qty):
pool = Pool()
Currency = pool.get('currency.currency')
total = Decimal(0)
@@ -104,7 +104,7 @@ class MtmStrategy(ModelSQL, ModelView):
if comp.price_source_type == 'curve' and comp.price_curve:
value = Decimal(
comp.price_curve.get_price(
comp.price_index.get_price(
dt,
self.purchase_line.unit,
self.currency,
@@ -118,7 +118,7 @@ class MtmStrategy(ModelSQL, ModelView):
if comp.ratio:
value *= Decimal(comp.ratio)
total += value
total += value * qty
return total

View File

@@ -528,11 +528,6 @@ class Line(metaclass=PoolMeta):
if self.lots:
return [l for l in self.lots if l.lot_type=='virtual'][0]
# @fields.depends('quantity','quantity_theorical')
# def on_change_quantity(self):
# if not self.quantity_theorical:
# self.quantity_theorical = self.quantity
def get_basis_price(self):
price = Decimal(0)
for pc in self.price_components:

View File

@@ -179,7 +179,7 @@ class ValuationBase(ModelSQL):
values = cls._build_basis_pnl(line=line, lot=lot, sale_line=None, pc=pc, sign=-1)
if line.mtm:
for strat in line.mtm:
values['mtm'] = line.get_mtm(values['qty'])
values['mtm'] = strat.get_mtm(values['qty'])
values['strategy'] = strat
if values:
@@ -200,7 +200,7 @@ class ValuationBase(ModelSQL):
)
if line.mtm:
for strat in line.mtm:
values['mtm'] = line.get_mtm(values['qty'])
values['mtm'] = strat.get_mtm(values['qty'])
values['strategy'] = strat
if values:
@@ -227,7 +227,7 @@ class ValuationBase(ModelSQL):
values = cls._build_basis_pnl(line=line, lot=sl, sale_line=sl_line, pc=pc, sign=+1)
if sl_line.mtm:
for strat in line.mtm:
values['mtm'] = sl_line.get_mtm(values['qty'])
values['mtm'] = strat.get_mtm(values['qty'])
values['strategy'] = strat
if values:
@@ -248,7 +248,7 @@ class ValuationBase(ModelSQL):
)
if sl_line.mtm:
for strat in sl_line.mtm:
values['mtm'] = sl_line.get_mtm(values['qty'])
values['mtm'] = strat.get_mtm(values['qty'])
values['strategy'] = strat
if values: