Commit 01151a0c authored by Jérome Perrin's avatar Jérome Perrin

getEngagedBudgetDict was not working, because it was using

getCurrentInventoryList


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43319 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0794f93e
......@@ -81,6 +81,7 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
self.getPortalReservedInventoryStateList() +
self.getPortalCurrentInventoryStateList() +
self.getPortalTransitInventoryStateList())
kw['simulation_period'] = ''
return self._getBudgetDict(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -102,7 +103,7 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
return budget_dict
def _getBudgetDict(self, **kw):
def _getBudgetDict(self, simulation_period='Current', **kw):
"""Use getCurrentInventoryList to compute all budget cell consumptions at
once, and returns them in a dict.
"""
......@@ -118,8 +119,13 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
sign = self.BudgetLine_getConsumptionSign()
cell_key_cache = dict()
budget_dict = dict()
for brain in self.getPortalObject().portal_simulation\
.getCurrentInventoryList(**query_dict):
portal = self.getPortalObject()
getInventoryList = portal.portal_simulation.getInventoryList
if simulation_period == 'Current':
getInventoryList = portal.portal_simulation.getCurrentInventoryList
for brain in getInventoryList(**query_dict):
cell_key = budget_model._getCellKeyFromInventoryListBrain(brain, self,
cell_key_cache=cell_key_cache)
# XXX total_quantity or total_price ??
......
......@@ -406,8 +406,29 @@ class TestBudget(ERP5TypeTestCase):
portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.fixed_assets,
source_credit=100)
atransaction.stop()
atransaction.confirm()
# a confirmed transaction engages budget
transaction.commit()
self.tic()
self.assertEquals(
{('source/account_module/fixed_assets', 'account_type/asset'): 0.0,
('source/account_module/goods_purchase', 'account_type/expense'): 0.0},
budget_line.getConsumedBudgetDict())
self.assertEquals(
{('source/account_module/fixed_assets', 'account_type/asset'): -100.0,
('source/account_module/goods_purchase', 'account_type/expense'): 100.0},
budget_line.getEngagedBudgetDict())
self.assertEquals(
{('source/account_module/fixed_assets', 'account_type/asset'): 102.0,
('source/account_module/goods_purchase', 'account_type/expense'): -99.0},
budget_line.getAvailableBudgetDict())
atransaction.stop()
# a stopped transaction consumes budget
transaction.commit()
self.tic()
......
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