Commit 13f13a9b authored by Kevin Deldycke's avatar Kevin Deldycke

Support optionnal from_date parameter

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6786 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c05f7ea
......@@ -160,6 +160,10 @@ def getDefaultColumnValues(node_uid=0, **kw):\n
\n
if node_uid != 0:\n
get_inventory_kw[\'node_uid\'] = node_uid\n
\n
opening_balance = 0.0\n
debit_movement = 0.0\n
credit_movement = 0.0\n
\n
# Use custom SQL query to get Bank Account Balance (because standard getInventory doesn\'t work)\n
# TODO: use getInventory\n
......@@ -183,39 +187,43 @@ def getDefaultColumnValues(node_uid=0, **kw):\n
# Round the result to avoid float bad precision\n
return r_(amount)\n
\n
values[\'opening_balance\'] = getBalance( to_date = from_date\n
, **get_inventory_kw\n
)\n
values[\'debit_movement\'] = getBalance( from_date = from_date\n
, at_date = at_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
values[\'credit_movement\'] = - getBalance( from_date = from_date\n
, at_date = at_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
if from_date not in (None, \'\'):\n
opening_balance = getBalance( to_date = from_date\n
, **get_inventory_kw\n
)\n
debit_movement = getBalance( from_date = from_date\n
, at_date = at_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
credit_movement = - getBalance( from_date = from_date\n
, at_date = at_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
else:\n
# Use standard methods\n
values[\'opening_balance\'] = getInventory( to_date = from_date\n
, **get_inventory_kw\n
)\n
values[\'debit_movement\'] = getInventory( from_date = from_date\n
, at_date = at_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
values[\'credit_movement\'] = - getInventory( from_date = from_date\n
, at_date = at_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
if from_date not in (None, \'\'):\n
opening_balance = getInventory( to_date = from_date\n
, **get_inventory_kw\n
)\n
debit_movement = getInventory( from_date = from_date\n
, at_date = at_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
credit_movement = - getInventory( from_date = from_date\n
, at_date = at_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
\n
values[\'opening_balance\'] = opening_balance\n
values[\'debit_movement\'] = debit_movement\n
values[\'credit_movement\'] = credit_movement\n
\n
# Calculate the closing balance\n
values[\'closing_balance\'] = values[\'opening_balance\'] + \\\n
values[\'debit_movement\'] - \\\n
values[\'credit_movement\']\n
values[\'closing_balance\'] = opening_balance + debit_movement - credit_movement\n
return values\n
\n
\n
......
......@@ -88,18 +88,23 @@ getInventory = portal.portal_simulation.getInventoryAssetPrice\n
\n
# FIXME: Here we do not want to sum all movement < 0, but sum the balances\n
# of all nodes whose which have a < 0 balance...\n
opening_debit_balance = getInventory( at_date = from_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
opening_debit_balance = 0.0\n
opening_credit_balance = 0.0\n
closing_debit_balance = 0.0\n
closing_credit_balance = 0.0\n
if from_date not in (None, \'\'):\n
opening_debit_balance = getInventory( at_date = from_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
opening_credit_balance = - getInventory( at_date = from_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
closing_debit_balance = getInventory( at_date = at_date\n
, omit_output = True\n
, **get_inventory_kw\n
)\n
opening_credit_balance = - getInventory( at_date = from_date\n
, omit_input = True\n
, **get_inventory_kw\n
)\n
closing_credit_balance = - getInventory( at_date = at_date\n
, omit_input = True\n
, **get_inventory_kw\n
......@@ -108,10 +113,10 @@ closing_credit_balance = - getInventory( at_date = at_date\n
list_item = newTempBase(portal, \'xxx\')\n
list_item.setUid(\'new_000\')\n
list_item.edit(** {\n
\'total_opening_debit_balance\' : opening_debit_balance or 0\n
, \'total_closing_debit_balance\' : closing_debit_balance or 0\n
, \'total_opening_credit_balance\': opening_credit_balance or 0\n
, \'total_closing_credit_balance\': closing_credit_balance or 0\n
\'total_opening_debit_balance\' : opening_debit_balance\n
, \'total_closing_debit_balance\' : closing_debit_balance\n
, \'total_opening_credit_balance\': opening_credit_balance\n
, \'total_closing_credit_balance\': closing_credit_balance\n
})\n
\n
return [list_item]\n
......@@ -178,11 +183,11 @@ return [list_item]\n
<string>context</string>
<string>portal</string>
<string>getInventory</string>
<string>_apply_</string>
<string>opening_debit_balance</string>
<string>closing_debit_balance</string>
<string>opening_credit_balance</string>
<string>closing_debit_balance</string>
<string>closing_credit_balance</string>
<string>_apply_</string>
<string>list_item</string>
</tuple>
</value>
......
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