[Erp5-report] r43319 jerome - in /erp5/trunk/products/ERP5: Document/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Feb 14 16:39:26 CET 2011
Author: jerome
Date: Mon Feb 14 16:39:26 2011
New Revision: 43319
URL: http://svn.erp5.org?rev=43319&view=rev
Log:
getEngagedBudgetDict was not working, because it was using
getCurrentInventoryList
Modified:
erp5/trunk/products/ERP5/Document/BudgetLine.py
erp5/trunk/products/ERP5/tests/testBudget.py
Modified: erp5/trunk/products/ERP5/Document/BudgetLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BudgetLine.py?rev=43319&r1=43318&r2=43319&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BudgetLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BudgetLine.py [utf8] Mon Feb 14 16:39:26 2011
@@ -81,6 +81,7 @@ class BudgetLine(Predicate, XMLMatrix, V
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, V
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, V
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 ??
Modified: erp5/trunk/products/ERP5/tests/testBudget.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBudget.py?rev=43319&r1=43318&r2=43319&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBudget.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBudget.py [utf8] Mon Feb 14 16:39:26 2011
@@ -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()
More information about the Erp5-report
mailing list