<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <tuple>
          <string>Products.PythonScripts.PythonScript</string>
          <string>PythonScript</string>
        </tuple>
        <none/>
      </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>""" Create a reversal transaction from current tansaction. """\n
\n
N_ = context.Base_translateString\n
accounting_module = context.getPortalObject().accounting_module\n
is_source = context.AccountingTransaction_isSourceView()\n
\n
if is_source:\n
  specific_reference = context.getSourceReference()\n
else:\n
  specific_reference = context.getDestinationReference()\n
\n
causality_value_list = context.getCausalityValueList()\n
causality_value_list.append(context)\n
\n
reversal = accounting_module.newContent (\n
    portal_type=context.getPortalType(),\n
    source_section=context.getSourceSection(),\n
    destination_section=context.getDestinationSection(),\n
    source_payment=context.getSourcePayment(),\n
    destination_payment=context.getDestinationPayment(),\n
    title = N_("Reversal Transaction for ${title}",\n
              mapping={\'title\': unicode(context.getTitleOrId(), \'utf8\')}),\n
    description = N_(\n
      "Reversal Transaction for ${title} (${specific_reference})",\n
      mapping={\'title\': unicode(context.getTitleOrId(), \'utf8\'),\n
               \'specific_reference\': specific_reference}),\n
    resource=context.getResource(),\n
    reference=context.getReference(),\n
    causality_value_list=causality_value_list,\n
    created_by_builder=1 # XXX to prevent init script to create lines\n
  )\n
\n
# copy dates\n
if context.getStartDate():\n
  reversal.setStartDate(context.getStartDate())\n
\n
if context.getStopDate() != context.getStartDate():\n
  # stop date is currently acquire from start date.\n
  # we try not to set a stop date on the reversal if it wasn\'t set on the\n
  # original\n
  reversal.setStopDate(context.getStopDate())\n
\n
if context.getProperty(\'payment_mode\'):\n
  reversal.setProperty(\'payment_mode\', context.getProperty(\'payment_mode\'))\n
\n
line_list = context.AccountingTransaction_getInvoiceTransactionLineList(\n
                portal_type=context.getPortalAccountingMovementTypeList())\n
line_list.reverse()\n
\n
# guess portal_type to create lines\n
if line_list:\n
  line_portal_type = line_list[0].getPortalType()\n
\n
for line in line_list:\n
  new_line = reversal.newContent( portal_type=line_portal_type )\n
  new_line.edit(\n
    source=line.getSource(portal_type=\'Account\'),\n
    destination=line.getDestination(portal_type=\'Account\'),\n
    quantity= - line.getQuantity(), )\n
\n
  if line.getSourceTotalAssetPrice():\n
    new_line.setSourceTotalAssetPrice( - line.getSourceTotalAssetPrice() )\n
  if line.getDestinationTotalAssetPrice():\n
    new_line.setDestinationTotalAssetPrice(\n
                                  - line.getDestinationTotalAssetPrice() )\n
  \n
  # copy some values if they are defined explicitly on line\n
  for prop in [ \'source_section\', \'destination_section\',\n
                \'source_payment\', \'destination_payment\', \'resource\' ]:\n
    if line.getProperty(prop) != context.getProperty(prop):\n
      new_line.setProperty(prop, line.getProperty(prop))\n
\n
return context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" %\n
              (reversal.getPath(),\n
               N_("Reversal Transaction for ${specific_reference} created.",\n
             mapping={\'specific_reference\': specific_reference})))\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>N_</string>
                            <string>accounting_module</string>
                            <string>is_source</string>
                            <string>specific_reference</string>
                            <string>causality_value_list</string>
                            <string>unicode</string>
                            <string>reversal</string>
                            <string>line_list</string>
                            <string>_getitem_</string>
                            <string>line_portal_type</string>
                            <string>_getiter_</string>
                            <string>line</string>
                            <string>new_line</string>
                            <string>prop</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_createReversalTransaction</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
