<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </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[

locked = context.getSlapState() == \'locked\'\n
customer_uid = context.getUid()\n
balance = context.portal_simulation.getInventoryAssetPrice(\n
  node_category=\'account_type/asset/receivable\',\n
  simulation_state=simulation_state,\n
  section_uid=section_uid,\n
  mirror_section_uid=customer_uid)\n
\n
if maximum_balance > balance:\n
  # customer reached his balance, shall be locked\n
  if not locked and operation == \'lock\':\n
      context.lock(comment="Balance value is %s" % balance)\n
      return\n
\n
# check ongoing payments and check that date if is acceptable, if not lock\n
if context.portal_simulation.getInventoryAssetPrice(\n
  parent_portal_type=\'Payment Transaction\',\n
  node_category=\'account_type/asset/receivable\',\n
  simulation_state=ongoing_simulation_state,\n
  section_uid=section_uid,\n
  mirror_section_uid=customer_uid,\n
  at_date=maximum_due_date,\n
  ) > 0:\n
    # there are ongoing old payments, shall be locked\n
    if not locked and operation == \'lock\':\n
        context.lock(comment="Payment transaction not paid for more than %s days" % maximum_due_date)\n
elif balance >= 0.0:\n
   # there are no ongoing payments and customer owns nothing\n
   if locked and operation == \'unlock\':\n
     context.unlock()\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>maximum_balance, maximum_due_date, simulation_state, section_uid, ongoing_simulation_state, operation</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Person_manageLockByBalance</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
