Remove dead and untested code

VAT is now calculated in a completely different way.
parent ac81e74b
No related merge requests found
57 58
\ No newline at end of file \ No newline at end of file
<?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[
"""Calculates the VAT for this invoice, returning a dict with keys:\n
\n
* total: The amount of VAT\n
* ratio: The ratio of the VAT\n
* title: The title of this VAT, actually this is the title of the\n
account used in the invoice transaction rule.\n
\n
This scripts first look in the accounting lines related to this invoice, and\n
uses the sum of all accounts of type collected_vat. If nothing is found, it\n
will look in the simulation tree to find all movements which uses a\n
collected_vat account as source.\n
\n
TODO: It\'s now clear that this script now needs a complete rewrite, because it\n
doesn\'t support different VAT rates for different lines and retrieving the VAT\n
rate associated with an invoice line.\n
\n
This API will probably change.\n
"""\n
if REQUEST is not None:\n
from zExceptions import Unauthorized\n
raise Unauthorized, script.getId()\n
\n
vat_infos = {\n
\'total\' : 0,\n
}\n
\n
invoice = context\n
portal = context.getPortalObject()\n
accounting_movement_list = invoice.getMovementList(\n
portal_type=portal.getPortalAccountingMovementTypeList())\n
\n
# 1) the invoice contains accounting lines.\n
if len(accounting_movement_list):\n
for movement in accounting_movement_list:\n
account = movement.getSourceValue(portal_type=\'Account\')\n
if account is None : continue\n
if account.getAccountTypeId() == \'collected_vat\' :\n
vat_infos.setdefault(\'title\', account.getTitle())\n
vat_infos.update({\'total\': vat_infos[\'total\'] + movement.getQuantity()})\n
vat_infos[\'ratio\'] = vat_infos[\'total\'] /\\\n
(float(invoice.getTotalPrice(\n
portal_type=portal.getPortalInvoiceMovementTypeList(),\n
fast=0)) or 1)\n
\n
# 2) no accounting lines => we must look in the simulation\n
if not vat_infos.has_key(\'title\') :\n
for invoice_movement in invoice.getMovementList(\n
portal_type=portal.getPortalInvoiceMovementTypeList() ) :\n
aggregated_simulation_movements = {}\n
for simulation_movement in ( invoice_movement.getDeliveryRelatedValueList(\n
portal_type = \'Simulation Movement\') +\n
invoice_movement.getOrderRelatedValueList(\n
portal_type = \'Simulation Movement\') ):\n
if aggregated_simulation_movements.has_key(\n
simulation_movement.getPath()):\n
continue\n
aggregated_simulation_movements[simulation_movement.getPath()] = 1\n
\n
for applied_rule in simulation_movement.objectValues():\n
# inside we got accounting movements\n
for movement in applied_rule.objectValues() :\n
account = movement.getSourceValue(portal_type=\'Account\')\n
if account is None : continue\n
if account.getAccountTypeId() == \'collected_vat\':\n
vat_infos.setdefault(\'title\', account.getTitle())\n
vat_infos.update( { \'total\':\n
vat_infos[\'total\'] + movement.getQuantity() } )\n
\n
vat_infos[\'ratio\'] = vat_infos[\'total\'] /\\\n
(float(invoice.getTotalPrice(\n
portal_type=portal.getPortalInvoiceMovementTypeList(),\n
fast=0)) or 1)\n
\n
vat_infos.setdefault(\'title\', "")\n
vat_infos.setdefault(\'ratio\', 0)\n
return vat_infos\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_getVAT</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
375 376
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment