Commit 72528d3c authored by Xiaowu Zhang's avatar Xiaowu Zhang

SimulationTool: add unit_price parameter to get unit price

parent 65577417
......@@ -1833,6 +1833,7 @@ class SimulationTool(BaseTool):
def getInventoryAssetPrice(self, src__=0,
simulation_period='',
valuation_method=None,
unit_price = False,
**kw):
"""
Same thing as getInventory but returns an asset
......@@ -1870,6 +1871,8 @@ class SimulationTool(BaseTool):
'MonthlyWeightedAverage', 'MovingAverage'):
raise ValueError("Invalid valuation method: %s" % valuation_method)
if unit_price and valuation_method in ('Fifo', 'Filo'):
raise ValueError("Unit price is inavailable for valuation method: %s" % valuation_method)
assert 'node_uid' in kw or 'section_uid' in kw
sql_kw = self._generateSQLKeywordDict(**kw)
......@@ -1887,6 +1890,8 @@ class SimulationTool(BaseTool):
return result
if len(result) > 0:
if unit_price:
return result[-1].unit_price
return result[-1].total_asset_price
security.declareProtected(Permissions.AccessContentsInformation,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment