Commit f85f99f2 authored by Jérome Perrin's avatar Jérome Perrin

In DeliveryMovement_getCorrespondingTaxLineList, tax movement that are not...

In DeliveryMovement_getCorrespondingTaxLineList, tax movement that are not applied directly to a delivery movement are equally shared in all delivery movements. This might not be perfect, but this way taxs on taxs are also copied in simulation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20520 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2c172f06
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Calculate the tax price for this movement.\n <value> <string>"""Calculate the tax price for this movement.\n
\n \n
We assume that all movemnt equally participate to each tax applied to base\n We assume that all movement equally participate to each tax applied to base\n
amounts they are contributing to.\n amounts they are contributing to.\n
\n \n
"""\n """\n
...@@ -77,13 +77,14 @@ total_price = context.getTotalPrice()\n ...@@ -77,13 +77,14 @@ total_price = context.getTotalPrice()\n
contributed_tax_line_list = []\n contributed_tax_line_list = []\n
adjusted_tax_line_list = []\n adjusted_tax_line_list = []\n
tax_line_list = context.getExplanationValue().contentValues(\n tax_line_list = context.getExplanationValue().contentValues(\n
portal_type=\'Tax Line\')\n portal_type=context.getPortalTaxMovementTypeList())\n
\n \n
# 1 find all tax lines that this line contributed to\n # 1 find all tax lines that this line contributed to\n
for base_amount in context.getBaseContributionList():\n for base_amount in context.getBaseContributionList():\n
for tax_line in tax_line_list:\n for tax_line in tax_line_list:\n
if base_amount in tax_line.getBaseApplicationList():\n if base_amount in tax_line.getBaseApplicationList():\n
contributed_tax_line_list.append(tax_line)\n if tax_line not in contributed_tax_line_list:\n
contributed_tax_line_list.append(tax_line)\n
\n \n
other_movement_list = [m for m in context.getExplanationValue().getMovementList(\n other_movement_list = [m for m in context.getExplanationValue().getMovementList(\n
portal_type=context.getPortalMovementTypeList())]\n portal_type=context.getPortalMovementTypeList())]\n
...@@ -102,6 +103,25 @@ for tax_line in contributed_tax_line_list:\n ...@@ -102,6 +103,25 @@ for tax_line in contributed_tax_line_list:\n
# XXX round ?\n # XXX round ?\n
tax_line.getQuantity() * total_price / base_total_price))\n tax_line.getQuantity() * total_price / base_total_price))\n
\n \n
# 3 add tax movement that does not apply directly to any other movement\n
delivery_total_price = context.getExplanationValue().getTotalPrice(fast=0)\n
returned_tax_line_relative_url_list = [x.getRelativeUrl()\n
for x in adjusted_tax_line_list]\n
contributed_base_amount_dict = dict()\n
for movement in other_movement_list + [context]:\n
for base_amount in movement.getBaseContributionList():\n
contributed_base_amount_dict[base_amount] = 1\n
\n
for tax_line in tax_line_list:\n
if tax_line.getRelativeUrl() in returned_tax_line_relative_url_list:\n
continue\n
for base_amount in tax_line.getBaseApplicationList():\n
if base_amount in contributed_base_amount_dict:\n
break\n
else:\n
adjusted_tax_line_list.append(tax_line.asContext(\n
quantity=tax_line.getQuantity() * total_price / delivery_total_price))\n
\n
return adjusted_tax_line_list\n return adjusted_tax_line_list\n
</string> </value> </string> </value>
</item> </item>
...@@ -169,6 +189,11 @@ return adjusted_tax_line_list\n ...@@ -169,6 +189,11 @@ return adjusted_tax_line_list\n
<string>movement</string> <string>movement</string>
<string>_inplacevar_</string> <string>_inplacevar_</string>
<string>_write_</string> <string>_write_</string>
<string>delivery_total_price</string>
<string>x</string>
<string>returned_tax_line_relative_url_list</string>
<string>dict</string>
<string>contributed_base_amount_dict</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
267 271
\ No newline at end of file \ No newline at end of file
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