[Erp5-report] r20520 - in /erp5/trunk/bt5/erp5_trade: SkinTemplateItem/portal_skins/erp5_tr...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 15 13:56:04 CEST 2008


Author: jerome
Date: Tue Apr 15 13:56:04 2008
New Revision: 20520

URL: http://svn.erp5.org?rev=20520&view=rev
Log:
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.

Modified:
    erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml
    erp5/trunk/bt5/erp5_trade/bt/revision

Modified: erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml?rev=20520&r1=20519&r2=20520&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml (original)
+++ erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryMovement_getCorrespondingTaxLineList.xml Tue Apr 15 13:56:04 2008
@@ -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 @@
 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
@@ -101,6 +102,25 @@
   adjusted_tax_line_list.append(tax_line.asContext(quantity=\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>
@@ -169,6 +189,11 @@
                             <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>

Modified: erp5/trunk/bt5/erp5_trade/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_trade/bt/revision?rev=20520&r1=20519&r2=20520&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_trade/bt/revision (original)
+++ erp5/trunk/bt5/erp5_trade/bt/revision Tue Apr 15 13:56:04 2008
@@ -1,1 +1,1 @@
-267
+271




More information about the Erp5-report mailing list