diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml index a7ce71bf3b18c990b0571b9433c74feedcfe6432..33d510d16c5943d42198fbf40e6933545b9b2666 100644 --- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml @@ -67,7 +67,7 @@ <key> <string>_body</string> </key> <value> <string>"""Calculate the tax price for this movement.\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 \n """\n @@ -77,13 +77,14 @@ total_price = context.getTotalPrice()\n contributed_tax_line_list = []\n adjusted_tax_line_list = []\n tax_line_list = context.getExplanationValue().contentValues(\n - portal_type=\'Tax Line\')\n + portal_type=context.getPortalTaxMovementTypeList())\n \n # 1 find all tax lines that this line contributed to\n for base_amount in context.getBaseContributionList():\n for tax_line in tax_line_list:\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 other_movement_list = [m for m in context.getExplanationValue().getMovementList(\n portal_type=context.getPortalMovementTypeList())]\n @@ -102,6 +103,25 @@ for tax_line in contributed_tax_line_list:\n # XXX round ?\n tax_line.getQuantity() * total_price / base_total_price))\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 </string> </value> </item> @@ -169,6 +189,11 @@ return adjusted_tax_line_list\n <string>movement</string> <string>_inplacevar_</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> </value> </item> diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision index d36f9fbea43831f3239f96376ee00c977dc2d7de..2a095c4d568d0359f8380b36c8b4cd2178e3e854 100644 --- a/bt5/erp5_trade/bt/revision +++ b/bt5/erp5_trade/bt/revision @@ -1 +1 @@ -267 \ No newline at end of file +271 \ No newline at end of file