<?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 encoding="cdata"><![CDATA[

"""Client & vendors accounts.\n
"""\n
\n
from Products.ERP5Form.Report import ReportSection\n
\n
request = context.REQUEST\n
at_date = request[\'at_date\']\n
section_category = request[\'section_category\']\n
simulation_state = request[\'simulation_state\']\n
role_filter_list = request.get(\'entity_role\', None)\n
omit_balanced_accounts = request[\'omit_balanced_accounts\']\n
from_date = request.get(\'from_date\', None)\n
\n
request.other[\'is_accounting_report\'] = True\n
\n
# role_filter_list == None means no filter on the role\n
if role_filter_list == [\'\'] :\n
  role_filter_list = None\n
\n
result = []\n
\n
params =  {\n
    \'at_date\'                     : at_date\n
  , \'section_category\': section_category\n
  , \'simulation_state\': simulation_state\n
  , \'report_depth\'                : 5\n
  #, \'where_expression\'            : " section.portal_type = \'Organisation\' "\n
}\n
\n
params[\'hide_grouping\'] = request[\'omit_grouped_references\']\n
if from_date:\n
  params[\'from_date\'] = from_date\n
else :\n
  params[\'no_from_date\'] = 1\n
\n
portal = context.portal_url.getPortalObject()\n
simulation_tool = portal.portal_simulation\n
\n
entity_columns = [\n
                       (\'date\', \'Date\'),\n
                       (\'Movement_getExplanationTranslatedPortalType\', \'Type\'),\n
                       (\'Movement_getNodeGapId\', \'GAP\'),\n
                       (\'Movement_getExplanationReference\', \'Invoice No\'),\n
                       (\'Movement_getExplanationTitle\', \'Title\'),\n
                       (\'Movement_getSpecificReference\', \'Reference\'),\n
                       (\'getTranslatedSimulationStateTitle\', \'State\'),\n
                       (\'debit\', \'Debit\'),\n
                       (\'credit\', \'Credit\'),\n
                       (\'running_total_price\', \'Balance\'),\n
]\n
\n
# build a list of all accounts which _strictly_ belongs to categories \n
# receivable or payable, to prepare parameter to the getInventory which\n
# will tell wether this third party account is balanced or not.\n
valid_node_uids = []\n
if omit_balanced_accounts :\n
  for account in portal.portal_categories.resolveCategory(\n
                    \'account_type/asset/receivable\'\n
                ).getAccountTypeRelatedValueList(\n
                    strict_membership=1,\n
                    portal_type=\'Account\'):\n
    valid_node_uids.append(account.getUid())\n
  for account in portal.portal_categories.resolveCategory(\n
                    \'account_type/liability/payable\'\n
                ).getAccountTypeRelatedValueList(\n
                    strict_membership=1,\n
                    portal_type=\'Account\'):\n
    valid_node_uids.append(account.getUid())\n
\n
if not params[\'hide_grouping\']  :\n
  entity_columns.append((\'grouping_reference\',\n
                         \'Grouping Reference\'))\n
\n
for party in context.Account_zDistinctSectionList():\n
  o = party.getObject()\n
  if role_filter_list and o.getProperty(\'role\', []) not in role_filter_list:\n
    continue\n
\n
  if o.getPortalType() == \'Person\' or\\\n
      not o.isMemberOf(section_category):\n
        # don\'t show entities belonging to the group we are reporting\n
    if omit_balanced_accounts and (\n
            simulation_tool.getInventoryAssetPrice(\n
                    mirror_section_uid=o.uid,\n
                    node_uid=valid_node_uids, **params) == 0):\n
      pass\n
    else:\n
      title = o.getTitle()\n
      if o.getProperty(\'role\', None):\n
        title += \' (%s)\' % o.getRoleTitle()\n
      result.append(\n
                 ReportSection(title=title,\n
                               level=1,\n
                               path=o.getPhysicalPath(),\n
                               form_id=\'Entity_viewAccountingTransactionList\',\n
                               selection_name = \'other_parties_report_selection\',\n
                               selection_params = params,\n
                               selection_columns = entity_columns,\n
                               selection_sort_order=[(\'stock.date\', \'ascending\'),\n
                                                      (\'stock.uid\', \'ascending\'),],))\n
\n
return result\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>_proxy_roles</string> </key>
            <value>
              <tuple>
                <string>Manager</string>
              </tuple>
            </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>Products.ERP5Form.Report</string>
                            <string>ReportSection</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>request</string>
                            <string>_getitem_</string>
                            <string>at_date</string>
                            <string>section_category</string>
                            <string>simulation_state</string>
                            <string>None</string>
                            <string>role_filter_list</string>
                            <string>omit_balanced_accounts</string>
                            <string>from_date</string>
                            <string>True</string>
                            <string>_write_</string>
                            <string>result</string>
                            <string>params</string>
                            <string>portal</string>
                            <string>simulation_tool</string>
                            <string>entity_columns</string>
                            <string>valid_node_uids</string>
                            <string>_getiter_</string>
                            <string>account</string>
                            <string>party</string>
                            <string>o</string>
                            <string>_apply_</string>
                            <string>title</string>
                            <string>_inplacevar_</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>AccountModule_getOtherPartiesReportSectionList</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
