[Erp5-report] r37225 jerome - in /erp5/trunk/products/ERP5: Document/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Jul 21 18:11:59 CEST 2010
Author: jerome
Date: Wed Jul 21 18:11:53 2010
New Revision: 37225
URL: http://svn.erp5.org?rev=37225&view=rev
Log:
introduce BudgetLine.getAvailableBudgetDict
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=37225&r1=37224&r2=37225&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BudgetLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BudgetLine.py [utf8] Wed Jul 21 18:11:53 2010
@@ -83,6 +83,25 @@ class BudgetLine(Predicate, XMLMatrix, V
self.getPortalTransitInventoryStateList())
return self._getBudgetDict(**kw)
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'getAvailableBudgetDict')
+ def getAvailableBudgetDict(self, **kw):
+ """Returns all the engagements in a dict where the keys are the cells, and
+ the value is the engaged budget.
+ """
+ budget_dict = dict([(k, v * -1) for (k,v) in
+ self.getEngagedBudgetDict(**kw).items()])
+
+ cell_key_list = self.getCellKeyList()
+ for cell_key in cell_key_list:
+ cell_key = tuple(cell_key)
+ cell = self.getCell(*cell_key)
+ if cell is not None:
+ engaged = budget_dict.get(cell_key, 0)
+ budget_dict[cell_key] = cell.getCurrentBalance() + engaged
+
+ return budget_dict
+
def _getBudgetDict(self, **kw):
"""Use getCurrentInventoryList to compute all budget cell consumptions at
once, and returns them in a dict.
Modified: erp5/trunk/products/ERP5/tests/testBudget.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBudget.py?rev=37225&r1=37224&r2=37225&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBudget.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBudget.py [utf8] Wed Jul 21 18:11:53 2010
@@ -363,7 +363,17 @@ class TestBudget(ERP5TypeTestCase):
{('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())
+ # we can view the forms without error
+ budget_line.BudgetLine_viewEngagedBudget()
+ budget_line.BudgetLine_viewConsumedBudget()
+ budget_line.BudgetLine_viewAvailableBudget()
+
def test_all_other_and_strict_consumption(self):
# tests consumptions, by using "all other" virtual node on a node budget
# variation, and strict membership on category budget variation
@@ -476,6 +486,11 @@ class TestBudget(ERP5TypeTestCase):
{('source/%s' % budget_line.getRelativeUrl(), 'account_type/asset'): -100.0,
('source/account_module/goods_purchase', 'account_type/expense'): 100.0},
budget_line.getEngagedBudgetDict())
+
+ self.assertEquals(
+ {('source/%s' % budget_line.getRelativeUrl(), 'account_type/asset'): 102.0,
+ ('source/account_module/goods_purchase', 'account_type/expense'): -99.0},
+ budget_line.getAvailableBudgetDict())
def test_consumption_movement_category(self):
@@ -612,6 +627,15 @@ class TestBudget(ERP5TypeTestCase):
},
budget_line.getEngagedBudgetDict())
+ self.assertEquals(
+ {('source/account_module/fixed_assets', 'product_line/1/1.2'): 100.0,
+ ('source/account_module/goods_purchase', 'product_line/1/1.1'): -98.0,
+ # summary line is automatically added (TODO)
+## ('source/account_module/goods_purchase', 'product_line/1'): 98.0
+ ('source/account_module/goods_purchase', 'product_line/1'): 2.0
+ },
+ budget_line.getAvailableBudgetDict())
+
# Other TODOs:
More information about the Erp5-report
mailing list