29.03.26
This commit is contained in:
@@ -113,11 +113,11 @@ class MtmStrategy(ModelSQL, ModelView):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
elif comp.price_source_type == 'matrix' and comp.price_matrix:
|
elif comp.price_source_type == 'matrix' and comp.price_matrix:
|
||||||
value = self._get_matrix_price(comp, line, dt)
|
value = self._get_matrix_price(comp, line, dt)
|
||||||
|
|
||||||
if comp.ratio:
|
if comp.ratio:
|
||||||
value *= Decimal(comp.ratio)
|
value *= Decimal(comp.ratio) / Decimal(100)
|
||||||
|
|
||||||
total += value * qty
|
total += value * qty
|
||||||
|
|
||||||
|
|||||||
@@ -48,5 +48,27 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
Valuation.get_totals(), (Decimal('42.50'), Decimal(0)))
|
Valuation.get_totals(), (Decimal('42.50'), Decimal(0)))
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_get_mtm_applies_component_ratio_as_percentage(self):
|
||||||
|
'get_mtm treats component ratio as a percentage'
|
||||||
|
Strategy = Pool().get('mtm.strategy')
|
||||||
|
strategy = Strategy()
|
||||||
|
strategy.scenario = Mock(
|
||||||
|
valuation_date='2026-03-29',
|
||||||
|
use_last_price=True,
|
||||||
|
)
|
||||||
|
strategy.currency = Mock()
|
||||||
|
strategy.components = [Mock(
|
||||||
|
price_source_type='curve',
|
||||||
|
price_index=Mock(get_price=Mock(return_value=Decimal('100'))),
|
||||||
|
price_matrix=None,
|
||||||
|
ratio=Decimal('25'),
|
||||||
|
)]
|
||||||
|
line = Mock(unit=Mock())
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
strategy.get_mtm(line, Decimal('10')),
|
||||||
|
Decimal('250.00'))
|
||||||
|
|
||||||
|
|
||||||
del ModuleTestCase
|
del ModuleTestCase
|
||||||
|
|||||||
Reference in New Issue
Block a user