Commit 46861d74 authored by Jérome Perrin's avatar Jérome Perrin

update M9-style transaction print.

display causality title, payment mode codification or title 
sort transactions by int index



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11726 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 67726983
...@@ -88,33 +88,49 @@ context.REQUEST.other[\'src__\'] = 1\n ...@@ -88,33 +88,49 @@ context.REQUEST.other[\'src__\'] = 1\n
context.REQUEST.other[\'no_limit\'] = 1\n context.REQUEST.other[\'no_limit\'] = 1\n
context.REQUEST.other[\'search_result_keys\'] = [\'catalog.uid\']\n context.REQUEST.other[\'search_result_keys\'] = [\'catalog.uid\']\n
\n \n
payment_mode_cache = {None:\'\', \'\':\'\'}\n
def getPaymentModeCodification(payment_mode):\n
if payment_mode in payment_mode_cache:\n
return payment_mode_cache[payment_mode]\n
category = context.portal_categories.payment_mode.restrictedTraverse(payment_mode)\n
category_title = category.getCodification() or category.getTitle()\n
payment_mode_cache[payment_mode] = category_title\n
return category_title\n
\n
# call getMovementHistory by building a subquery with accounting module\n # call getMovementHistory by building a subquery with accounting module\n
# selection\'s query, using the src__=1 trick from above\n # selection\'s query, using the src__=1 trick from above\n
for brain in simtool.getMovementHistoryList(\n for brain in simtool.getMovementHistoryList(\n
where_expression="catalog.parent_uid IN (%s)" %\n where_expression="catalog.parent_uid IN (%s)" %\n
stool.callSelectionFor(selection_name),\n stool.callSelectionFor(selection_name),\n
section_category=selection.getParams().get(\'section_category\')):\n section_category=selection.getParams().get(\'section_category\'),\n
sort_on=\'parent_int_index\'):\n
\n \n
movement = brain.getObject()\n movement = brain.getObject()\n
transaction = movement.getParentValue()\n transaction = movement.getParentValue()\n
origin = transaction.getProperty(\'origin_id\')\n origin = transaction.getProperty(\'origin_id\')\n
sheet = transaction.getProperty(\'aggregate_title\')\n sheet = transaction.getProperty(\'aggregate_title\')\n
payment_mode_codification = getPaymentModeCodification(\n
transaction.getPaymentMode())\n
\n
obj = Object(\n obj = Object(\n
parent_portal_type=transaction.getTranslatedPortalType(),\n parent_portal_type=transaction.getTranslatedPortalType(),\n
parent_int_index="%05d" % transaction.getIntIndex(0),\n parent_int_index="%05d" % transaction.getIntIndex(0),\n
parent_aggregate_title=sheet,\n payment_mode_codification=payment_mode_codification,\n
parent_origin_id=origin,\n parent_aggregate_title=sheet,\n
\n parent_origin_id=origin,\n
mirror_section_uid=brain.mirror_section_uid,\n \n
section_uid=brain.section_uid,\n mirror_section_uid=brain.mirror_section_uid,\n
node_relative_url=brain.node_relative_url,\n section_uid=brain.section_uid,\n
getObject=brain.getObject,\n node_relative_url=brain.node_relative_url,\n
asContext=movement.asContext,\n getObject=brain.getObject,\n
# Movement_getExplanationUrl=movement.Movement_getExplanationUrl,\n asContext=movement.asContext,\n
# asContext=lambda *args, **kw: movement, # optim ?\n
# Movement_getExplanationUrl=movement.Movement_getExplanationUrl,\n
\n \n
date=brain.date,\n date=brain.date,\n
debit=max(brain.total_price, 0),\n causality_title="\\n".join(transaction.getCausalityTitleList() or []) ,\n
credit=max(-brain.total_price, 0), )\n debit=max(brain.total_price, 0),\n
credit=max(-brain.total_price, 0), )\n
line_list.append(obj)\n line_list.append(obj)\n
\n \n
if brain.node_relative_url:\n if brain.node_relative_url:\n
...@@ -125,8 +141,8 @@ for brain in simtool.getMovementHistoryList(\n ...@@ -125,8 +141,8 @@ for brain in simtool.getMovementHistoryList(\n
account[origin] = total + (brain.total_price or 0)\n account[origin] = total + (brain.total_price or 0)\n
# per origin and sheet\n # per origin and sheet\n
origin_cache = per_origin_and_sheet_cache.setdefault(origin, {})\n origin_cache = per_origin_and_sheet_cache.setdefault(origin, {})\n
total = origin_cache.setdefault((brain.node_relative_url, sheet), 0)\n total = origin_cache.setdefault((sheet, brain.node_relative_url), 0)\n
origin_cache[(brain.node_relative_url, sheet)] = total + (brain.total_price or 0)\n origin_cache[(sheet, brain.node_relative_url)] = total + (brain.total_price or 0)\n
\n \n
return line_list\n return line_list\n
</string> </value> </string> </value>
...@@ -186,12 +202,16 @@ return line_list\n ...@@ -186,12 +202,16 @@ return line_list\n
<string>per_origin_and_sheet_cache</string> <string>per_origin_and_sheet_cache</string>
<string>simtool</string> <string>simtool</string>
<string>_write_</string> <string>_write_</string>
<string>None</string>
<string>payment_mode_cache</string>
<string>getPaymentModeCodification</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>brain</string> <string>brain</string>
<string>movement</string> <string>movement</string>
<string>transaction</string> <string>transaction</string>
<string>origin</string> <string>origin</string>
<string>sheet</string> <string>sheet</string>
<string>payment_mode_codification</string>
<string>max</string> <string>max</string>
<string>obj</string> <string>obj</string>
<string>account</string> <string>account</string>
......
...@@ -81,7 +81,9 @@ origin_list.sort()\n ...@@ -81,7 +81,9 @@ origin_list.sort()\n
\n \n
for origin in origin_list:\n for origin in origin_list:\n
values = origin_cache[origin]\n values = origin_cache[origin]\n
for (account_url, sheet), total_price in values.items():\n items = values.items()\n
items.sort()\n
for (sheet, account_url), total_price in items:\n
account_title = portal.restrictedTraverse(account_url\n account_title = portal.restrictedTraverse(account_url\n
).Account_getFormattedTitle()\n ).Account_getFormattedTitle()\n
debit = max(total_price, 0)\n debit = max(total_price, 0)\n
...@@ -156,8 +158,9 @@ return line_list\n ...@@ -156,8 +158,9 @@ return line_list\n
<string>_getiter_</string> <string>_getiter_</string>
<string>origin</string> <string>origin</string>
<string>values</string> <string>values</string>
<string>account_url</string> <string>items</string>
<string>sheet</string> <string>sheet</string>
<string>account_url</string>
<string>total_price</string> <string>total_price</string>
<string>account_title</string> <string>account_title</string>
<string>max</string> <string>max</string>
......
...@@ -361,6 +361,14 @@ ...@@ -361,6 +361,14 @@
<string>Movement_getMirrorSectionTitle</string> <string>Movement_getMirrorSectionTitle</string>
<string>Third Party</string> <string>Third Party</string>
</tuple> </tuple>
<tuple>
<string>causality_title</string>
<string>Causalities</string>
</tuple>
<tuple>
<string>payment_mode_codification</string>
<string>Payment Mode Codif.</string>
</tuple>
<tuple> <tuple>
<string>debit</string> <string>debit</string>
<string>Debit</string> <string>Debit</string>
......
58 61
\ 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