Mtm
This commit is contained in:
@@ -375,6 +375,18 @@ class ValuationBase(ModelSQL):
|
||||
def _supports_strategy_mtm(values):
|
||||
return values and values.get('type') in {'pur. priced', 'sale priced'}
|
||||
|
||||
@classmethod
|
||||
def _signed_strategy_mtm(cls, values, strategy, line):
|
||||
mtm = strategy.get_mtm(line, values['quantity'])
|
||||
if mtm is None:
|
||||
return mtm
|
||||
amount = values.get('amount')
|
||||
if amount:
|
||||
return abs(mtm) if amount > 0 else -abs(mtm)
|
||||
if values.get('type') in {'pur. priced', 'pur. efp'}:
|
||||
return -abs(mtm)
|
||||
return abs(mtm)
|
||||
|
||||
@staticmethod
|
||||
def _get_basis_component_total(record):
|
||||
getter = getattr(record, '_get_basis_component_price', None)
|
||||
@@ -526,7 +538,7 @@ class ValuationBase(ModelSQL):
|
||||
if line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, line)
|
||||
values['mtm'] = strat.get_mtm(line, values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -544,7 +556,7 @@ class ValuationBase(ModelSQL):
|
||||
if line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, line)
|
||||
values['mtm'] = strat.get_mtm(line,values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -567,7 +579,7 @@ class ValuationBase(ModelSQL):
|
||||
if line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, line)
|
||||
values['mtm'] = strat.get_mtm(line,values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -602,7 +614,7 @@ class ValuationBase(ModelSQL):
|
||||
if sl_line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, sl_line)
|
||||
values['mtm'] = strat.get_mtm(sl_line,values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, sl_line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -624,7 +636,7 @@ class ValuationBase(ModelSQL):
|
||||
if sl_line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in sl_line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, sl_line)
|
||||
values['mtm'] = strat.get_mtm(sl_line,values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, sl_line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -750,7 +762,7 @@ class ValuationBase(ModelSQL):
|
||||
if sale_line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in sale_line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, sale_line)
|
||||
values['mtm'] = strat.get_mtm(sale_line, values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, sale_line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -767,7 +779,7 @@ class ValuationBase(ModelSQL):
|
||||
if sale_line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in sale_line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, sale_line)
|
||||
values['mtm'] = strat.get_mtm(sale_line, values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, sale_line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
@@ -790,7 +802,7 @@ class ValuationBase(ModelSQL):
|
||||
if sale_line.mtm and cls._supports_strategy_mtm(values):
|
||||
for strat in sale_line.mtm:
|
||||
values['mtm_price'] = cls._get_strategy_mtm_price(strat, sale_line)
|
||||
values['mtm'] = strat.get_mtm(sale_line, values['quantity'])
|
||||
values['mtm'] = cls._signed_strategy_mtm(values, strat, sale_line)
|
||||
values['strategy'] = strat
|
||||
|
||||
if values:
|
||||
|
||||
Reference in New Issue
Block a user