<?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>from DateTime import DateTime\n
\n
container_portal_type_list = ["Monetary Reception",]\n
base_price_dict = {}\n
\n
if listbox is None:\n
\n
  node = context.getSource()\n
  if node is None:\n
    request = context.REQUEST\n
    redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
                                  , \'view\'\n
                                  , \'portal_status_message=Please+select+a+source.\'\n
                                  )\n
    return request.RESPONSE.redirect( redirect_url )\n
  \n
  reference_date = DateTime()\n
  container_list = []\n
  listbox = []\n
  for o in context.portal_simulation.getCurrentTrackingList(at_date= reference_date, node = node):\n
    cash_container = o.getObject()\n
    \n
    if cash_container.getObject().getParentValue().getPortalType()  in container_portal_type_list:\n
      # get one line in order to know some properties of the cash container\n
      container_dict = {}\n
      container_lines = cash_container.searchFolder(portal_type=\'Container Line\')\n
      if len(container_lines) == 0:\n
        context.log("CashMovementNewNotEmitted_generateCashContainerInputDialog", "No container line finf for cash container %s" %(cash_container.getRelativeUrl(),))\n
        continue\n
      container_line = container_lines[0].getObject()\n
      container_dict[\'reference\'] = cash_container.getReference()\n
      container_dict[\'cash_number_range_start\'] = cash_container.getCashNumberRangeStart()\n
      container_dict[\'cash_number_range_stop\'] = cash_container.getCashNumberRangeStop()\n
\n
      resource = container_line.getResource()\n
      base_price = base_price_dict.get(resource, None)\n
      if base_price is None:\n
        base_price = container_line.getResourceValue().getBasePrice()\n
        base_price_dict[resource] = base_price\n
      container_dict[\'base_price\'] = base_price\n
      resource_translated_title = resource_translated_title_dict.get(resource, None)\n
      if resource_translated_title is None:\n
        resource_translated_title = container_line.getResourceTranslatedTitle()\n
        resource_translated_title_dict[resource] = resource_translated_title\n
      container_dict[\'resource_translated_title\'] = resource_translated_title\n
      quantity = container_line.getQuantity()\n
      container_dict[\'quantity\'] = quantity\n
      total_price = total_price_dict.get((quantity,resource), None)\n
      if total_price is None:\n
        total_price = container_line.getTotalPrice(fast=0)\n
        total_price_dict[(quantity,resource)] = total_price      \n
      container_dict[\'total_price\'] = total_price\n
      container_dict[\'selection\'] = 0\n
      container_dict[\'date\'] = o.date\n
      container_dict[\'uid\'] = \'new_%s\' %(cash_container.getUid(),)   #cash_container.getReference().replace(\'/\', \'_\'),)\n
\n
      listbox.append(container_dict)\n
\n
  def sortListbox(a, b):\n
    result = cmp(a["date"], b["date"])\n
    if result == 0:\n
      result = cmp(a["base_price"], b["base_price"])\n
      if result == 0:\n
        result = cmp(a["reference"], b["reference"])\n
      \n
    return result\n
\n
  listbox.sort(sortListbox)\n
\n
  context.Base_updateDialogForm(listbox=listbox\n
                                )\n
\n
  return context.asContext(context=None\n
                           , portal_type=context.getPortalType()\n
                           ).CashMovementNewNotEmmited_fastInputForm(**kw)\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>_owner</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>listbox=None, cash_detail_dict=None, **kw</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>2</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>listbox</string>
                            <string>cash_detail_dict</string>
                            <string>kw</string>
                            <string>DateTime</string>
                            <string>container_portal_type_list</string>
                            <string>base_price_dict</string>
                            <string>None</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>node</string>
                            <string>request</string>
                            <string>redirect_url</string>
                            <string>reference_date</string>
                            <string>container_list</string>
                            <string>_getiter_</string>
                            <string>o</string>
                            <string>cash_container</string>
                            <string>container_dict</string>
                            <string>container_lines</string>
                            <string>len</string>
                            <string>_getitem_</string>
                            <string>container_line</string>
                            <string>_write_</string>
                            <string>resource</string>
                            <string>base_price</string>
                            <string>resource_translated_title_dict</string>
                            <string>resource_translated_title</string>
                            <string>quantity</string>
                            <string>total_price_dict</string>
                            <string>total_price</string>
                            <string>sortListbox</string>
                            <string>_apply_</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <none/>
                <none/>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>CashMovementNewNotEmitted_viewCashContainerInputDialog</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
