Commit 71684baa authored by Jérome Perrin's avatar Jérome Perrin

Introduce new scripts to calculate total debit / total credit on an accounting...

Introduce new scripts to calculate total debit / total credit on an accounting transaction using getMovementList, not SQL call, and use those scripts to show debit and credit on accounting module when debit/credit is not set on the brain, like it happens in list workflow dialog. Also remove the scripts that were previously used here only.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25374 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cb6d9503
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>cell/credit|cell/AccountingTransactionModule_getSourceCredit</string> </value> <value> <string>cell/credit | cell/AccountingTransaction_getTotalCredit</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>cell/debit|cell/AccountingTransactionModule_getSourceDebit</string> </value> <value> <string>cell/debit | cell/AccountingTransaction_getTotalDebit</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -53,25 +53,16 @@ ...@@ -53,25 +53,16 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>params = context.portal_selections.getSelectionParamsFor(selection_name)\n <value> <string>is_source = context.AccountingTransaction_isSourceView()\n
total_debit = 0\n
for line in context.getMovementList(\n
portal_type=context.getPortalAccountingMovementTypeList()):\n
if is_source:\n
total_debit += line.getDestinationInventoriatedTotalAssetDebit()\n
else:\n
total_debit += line.getSourceInventoriatedTotalAssetDebit()\n
\n \n
params[\'stat\'] = 1\n return total_debit\n
params[\'omit_output\'] = 1\n
params[\'omit_input\'] = 0\n
\n
if params.get(\'operation_date\', {}).get(\'query\'):\n
buildSQLQuery = context.portal_catalog.buildSQLQuery\n
params[\'source_section_where_expression\'] = buildSQLQuery(\n
**{\'delivery.start_date\': params[\'operation_date\']})[\'where_expression\']\n
params[\'destination_section_where_expression\'] = buildSQLQuery(\n
**{\'delivery.stop_date\': params[\'operation_date\']})[\'where_expression\']\n
del params[\'operation_date\']\n
\n
result = context.AccountingTransactionModule_zGetAccountingTransactionList(\n
selection=selection, selection_params = params, **params)\n
row = result[0]\n
return float(\'%.02f\' % (row.total_price or 0.0))\n
# vim: syntax=python\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -82,7 +73,7 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n ...@@ -82,7 +73,7 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>selection=None, selection_name=None, **kw</string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -102,25 +93,20 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n ...@@ -102,25 +93,20 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>selection</string>
<string>selection_name</string>
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>params</string> <string>is_source</string>
<string>_write_</string> <string>total_debit</string>
<string>buildSQLQuery</string> <string>_getiter_</string>
<string>_getitem_</string> <string>line</string>
<string>_apply_</string> <string>_inplacevar_</string>
<string>result</string>
<string>row</string>
<string>float</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -132,15 +118,12 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n ...@@ -132,15 +118,12 @@ return float(\'%.02f\' % (row.total_price or 0.0))\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <none/>
<none/>
<none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_statSourceDebit</string> </value> <value> <string>AccountingTransaction_getTotalCredit</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
...@@ -53,26 +53,16 @@ ...@@ -53,26 +53,16 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>params = context.portal_selections.getSelectionParamsFor(selection_name)\n <value> <string>is_source = context.AccountingTransaction_isSourceView()\n
total_debit = 0\n
for line in context.getMovementList(\n
portal_type=context.getPortalAccountingMovementTypeList()):\n
if is_source:\n
total_debit += line.getSourceInventoriatedTotalAssetDebit()\n
else:\n
total_debit += line.getDestinationInventoriatedTotalAssetDebit()\n
\n \n
params[\'stat\'] = 1\n return total_debit\n
params[\'omit_input\'] = 1\n
params[\'omit_output\'] = 0\n
\n
if params.get(\'operation_date\', {}).get(\'query\'):\n
buildSQLQuery = context.portal_catalog.buildSQLQuery\n
params[\'source_section_where_expression\'] = buildSQLQuery(\n
**{\'delivery.start_date\': params[\'operation_date\']})[\'where_expression\']\n
params[\'destination_section_where_expression\'] = buildSQLQuery(\n
**{\'delivery.stop_date\': params[\'operation_date\']})[\'where_expression\']\n
del params[\'operation_date\']\n
\n
result = context.AccountingTransactionModule_zGetAccountingTransactionList(\n
selection=selection,\n
selection_params=params, **params)\n
row = result[0]\n
return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n
# vim: syntax=python\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -83,7 +73,7 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n ...@@ -83,7 +73,7 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>selection=None, selection_name=None, **kw</string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -103,25 +93,20 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n ...@@ -103,25 +93,20 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>selection</string>
<string>selection_name</string>
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>params</string> <string>is_source</string>
<string>_write_</string> <string>total_debit</string>
<string>buildSQLQuery</string> <string>_getiter_</string>
<string>_getitem_</string> <string>line</string>
<string>_apply_</string> <string>_inplacevar_</string>
<string>result</string>
<string>row</string>
<string>float</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -133,15 +118,12 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n ...@@ -133,15 +118,12 @@ return float(\'%.02f\' % (row.total_price and - row.total_price or 0.0))\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <none/>
<none/>
<none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_statSourceCredit</string> </value> <value> <string>AccountingTransaction_getTotalDebit</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
854 855
\ No newline at end of file \ No newline at end of file
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