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,20 +88,34 @@ context.REQUEST.other[\'src__\'] = 1\n
context.REQUEST.other[\'no_limit\'] = 1\n
context.REQUEST.other[\'search_result_keys\'] = [\'catalog.uid\']\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
# selection\'s query, using the src__=1 trick from above\n
for brain in simtool.getMovementHistoryList(\n
where_expression="catalog.parent_uid IN (%s)" %\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
movement = brain.getObject()\n
transaction = movement.getParentValue()\n
origin = transaction.getProperty(\'origin_id\')\n
sheet = transaction.getProperty(\'aggregate_title\')\n
payment_mode_codification = getPaymentModeCodification(\n
transaction.getPaymentMode())\n
\n
obj = Object(\n
parent_portal_type=transaction.getTranslatedPortalType(),\n
parent_int_index="%05d" % transaction.getIntIndex(0),\n
payment_mode_codification=payment_mode_codification,\n
parent_aggregate_title=sheet,\n
parent_origin_id=origin,\n
\n
......@@ -110,9 +124,11 @@ for brain in simtool.getMovementHistoryList(\n
node_relative_url=brain.node_relative_url,\n
getObject=brain.getObject,\n
asContext=movement.asContext,\n
# asContext=lambda *args, **kw: movement, # optim ?\n
# Movement_getExplanationUrl=movement.Movement_getExplanationUrl,\n
\n
date=brain.date,\n
causality_title="\\n".join(transaction.getCausalityTitleList() or []) ,\n
debit=max(brain.total_price, 0),\n
credit=max(-brain.total_price, 0), )\n
line_list.append(obj)\n
......@@ -125,8 +141,8 @@ for brain in simtool.getMovementHistoryList(\n
account[origin] = total + (brain.total_price or 0)\n
# per origin and sheet\n
origin_cache = per_origin_and_sheet_cache.setdefault(origin, {})\n
total = origin_cache.setdefault((brain.node_relative_url, sheet), 0)\n
origin_cache[(brain.node_relative_url, sheet)] = total + (brain.total_price or 0)\n
total = origin_cache.setdefault((sheet, brain.node_relative_url), 0)\n
origin_cache[(sheet, brain.node_relative_url)] = total + (brain.total_price or 0)\n
\n
return line_list\n
</string> </value>
......@@ -186,12 +202,16 @@ return line_list\n
<string>per_origin_and_sheet_cache</string>
<string>simtool</string>
<string>_write_</string>
<string>None</string>
<string>payment_mode_cache</string>
<string>getPaymentModeCodification</string>
<string>_getiter_</string>
<string>brain</string>
<string>movement</string>
<string>transaction</string>
<string>origin</string>
<string>sheet</string>
<string>payment_mode_codification</string>
<string>max</string>
<string>obj</string>
<string>account</string>
......
......@@ -81,7 +81,9 @@ origin_list.sort()\n
\n
for origin in origin_list:\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_getFormattedTitle()\n
debit = max(total_price, 0)\n
......@@ -156,8 +158,9 @@ return line_list\n
<string>_getiter_</string>
<string>origin</string>
<string>values</string>
<string>account_url</string>
<string>items</string>
<string>sheet</string>
<string>account_url</string>
<string>total_price</string>
<string>account_title</string>
<string>max</string>
......
......@@ -361,6 +361,14 @@
<string>Movement_getMirrorSectionTitle</string>
<string>Third Party</string>
</tuple>
<tuple>
<string>causality_title</string>
<string>Causalities</string>
</tuple>
<tuple>
<string>payment_mode_codification</string>
<string>Payment Mode Codif.</string>
</tuple>
<tuple>
<string>debit</string>
<string>Debit</string>
......
58
\ No newline at end of file
61
\ 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