[Erp5-report] r19177 - in /experimental/bt5/erp5_accounting_experimental: SkinTemplateItem/...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Feb 8 14:00:20 CET 2008
Author: bartek
Date: Fri Feb 8 14:00:20 2008
New Revision: 19177
URL: http://svn.erp5.org?rev=19177&view=rev
Log:
A script returning transaction lines as matching pairs of accounts (some accountants want such reporting).
Added:
experimental/bt5/erp5_accounting_experimental/SkinTemplateItem/portal_skins/erp5_accounting_experimental/AccountingTransaction_getTwoSideTransactionLineList.xml
Modified:
experimental/bt5/erp5_accounting_experimental/bt/revision
Added: experimental/bt5/erp5_accounting_experimental/SkinTemplateItem/portal_skins/erp5_accounting_experimental/AccountingTransaction_getTwoSideTransactionLineList.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_accounting_experimental/SkinTemplateItem/portal_skins/erp5_accounting_experimental/AccountingTransaction_getTwoSideTransactionLineList.xml?rev=19177&view=auto
==============================================================================
--- experimental/bt5/erp5_accounting_experimental/SkinTemplateItem/portal_skins/erp5_accounting_experimental/AccountingTransaction_getTwoSideTransactionLineList.xml (added)
+++ experimental/bt5/erp5_accounting_experimental/SkinTemplateItem/portal_skins/erp5_accounting_experimental/AccountingTransaction_getTwoSideTransactionLineList.xml Fri Feb 8 14:00:20 2008
@@ -1,0 +1,244 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+ <tuple/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>Python_magic</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>Script_magic</string> </key>
+ <value> <int>3</int> </value>
+ </item>
+ <item>
+ <key> <string>__ac_local_roles__</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_bind_names</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>_asgns</string> </key>
+ <value>
+ <dictionary>
+ <item>
+ <key> <string>name_container</string> </key>
+ <value> <string>container</string> </value>
+ </item>
+ <item>
+ <key> <string>name_context</string> </key>
+ <value> <string>context</string> </value>
+ </item>
+ <item>
+ <key> <string>name_m_self</string> </key>
+ <value> <string>script</string> </value>
+ </item>
+ <item>
+ <key> <string>name_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>_body</string> </key>
+ <value> <string>"""\n
+ The purpose of this is to reshuffle transaction lines so that they match line\n
+ by line, like some accountants wants to see them in reports.\n
+ E.g. if we have:\n
+ gap debit credit\n
+ 100 70.00\n
+ 130 30.00\n
+ 234 100.00\n
+ we want:\n
+ gap_debit gap_credit amount\n
+ 100 234 70.00\n
+ 130 234 30.00\n
+\n
+ And if we have:\n
+ gap debit credit\n
+ 300 50.00\n
+ 223 10.00\n
+ 201 20.00\n
+ 100 40.00\n
+ we want:\n
+ gap_debit gap_credit amount\n
+ 300 201 20.00\n
+ 300 100 30.00\n
+ 223 100 10.00\n
+"""\n
+\n
+line_list = context.AccountingTransaction_getInvoiceTransactionLineList()\n
+left_lines = []\n
+right_lines = []\n
+\n
+def makeLineDict(line):\n
+ """\n
+ Turn a line into a dict while determining balance and side\n
+ """\n
+ d = {}\n
+ is_purchase = line.getPortalType() == \'Purchase Invoice Transaction Line\'\n
+ account_url = is_purchase and line.getDestination() or line.getSource();\n
+ account = context.restrictedTraverse(account_url);\n
+ d[\'gap_id\'] = hasattr(account, \'getGapId\') and account.getGapId() or \'error or missing\'\n
+ d[\'amount\'] = line.getSourceCredit() + line.getSourceDebit()\n
+ if is_purchase:\n
+ d[\'side\'] = line.getDestinationDebit() and \'left\' or \'right\'\n
+ else:\n
+ d[\'side\'] = line.getSourceDebit() and \'left\' or \'right\'\n
+ return d\n
+\n
+# analyze lines, assign to debit/credit lists\n
+for line in line_list:\n
+ line_dict = makeLineDict(line)\n
+ if line_dict[\'side\'] == \'left\': left_lines.append(line_dict)\n
+ else: right_lines.append(line_dict)\n
+\n
+# check if it is out-of-balance or empty\n
+if sum([l[\'amount\'] for l in left_lines]) != sum([l[\'amount\'] for l in right_lines]):\n
+ return [dict(gap_debit=\'Out of balance\', gap_credit=\'Out of balance\', amount=0)]\n
+if sum([l[\'amount\'] for l in left_lines]) == 0:\n
+ return []\n
+\n
+line_dict_list = []\n
+\n
+# produce result\n
+indices = [0, 0]\n
+for i in range(len(line_list)):\n
+ d = {}\n
+ left = left_lines[indices[0]]\n
+ right = right_lines[indices[1]]\n
+ amount = min(left[\'amount\'], right[\'amount\'])\n
+ if amount == 0:\n
+ continue\n
+ d[\'gap_debit\'] = left[\'gap_id\']\n
+ d[\'gap_credit\'] = right[\'gap_id\']\n
+ d[\'amount\'] = amount\n
+ line_dict_list.append(d)\n
+ left[\'amount\'] = left[\'amount\'] - amount\n
+ right[\'amount\'] = right[\'amount\'] - amount\n
+ if left[\'amount\'] == right[\'amount\'] == 0: break\n
+ indices[right[\'amount\']==0] = indices[right[\'amount\']==0] + 1\n
+\n
+return line_dict_list\n
+\n
+# vi: set filetype=python shiftwidth=2 expandtab:\n
+</string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_filepath</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string></string> </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>0</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>_getattr_</string>
+ <string>context</string>
+ <string>line_list</string>
+ <string>left_lines</string>
+ <string>right_lines</string>
+ <string>makeLineDict</string>
+ <string>_getiter_</string>
+ <string>line</string>
+ <string>line_dict</string>
+ <string>_getitem_</string>
+ <string>sum</string>
+ <string>append</string>
+ <string>$append0</string>
+ <string>l</string>
+ <string>dict</string>
+ <string>line_dict_list</string>
+ <string>indices</string>
+ <string>range</string>
+ <string>len</string>
+ <string>i</string>
+ <string>d</string>
+ <string>left</string>
+ <string>right</string>
+ <string>min</string>
+ <string>amount</string>
+ <string>_write_</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>AccountingTransaction_getTwoSideTransactionLineList</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: experimental/bt5/erp5_accounting_experimental/bt/revision
URL: http://svn.erp5.org/experimental/bt5/erp5_accounting_experimental/bt/revision?rev=19177&r1=19176&r2=19177&view=diff
==============================================================================
--- experimental/bt5/erp5_accounting_experimental/bt/revision (original)
+++ experimental/bt5/erp5_accounting_experimental/bt/revision Fri Feb 8 14:00:20 2008
@@ -1,1 +1,1 @@
-4
+5
More information about the Erp5-report
mailing list