[Erp5-report] r34491 jerome - in /erp5/trunk/bt5/erp5_accounting: SkinTemplateItem/portal_s...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 13 11:59:54 CEST 2010


Author: jerome
Date: Tue Apr 13 11:59:51 2010
New Revision: 34491

URL: http://svn.erp5.org?rev=34491&view=rev
Log:
when creating a related payement, use the quantities from the movements, not the asset price. In case of foreign currency, we want to pay the amount in foreign currency, not the converted amount

Modified:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml?rev=34491&r1=34490&r2=34491&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_createRelatedPaymentTransaction.xml [utf8] Tue Apr 13 11:59:51 2010
@@ -79,7 +79,8 @@
 # Calculate the payable/receivable quantity, using\n
 # Invoice_getRemainingTotalPayablePrice script.\n
 total_payable_price_details = \\\n
-          context.Invoice_getRemainingTotalPayablePrice(detailed=True)\n
+          context.Invoice_getRemainingTotalPayablePrice(detailed=True,\n
+                                                        quantity=True)\n
 \n
 # if there\'s nothing more to pay, don\'t create an empty transaction\n
 if sum(total_payable_price_details.values()) == 0:\n

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml?rev=34491&r1=34490&r2=34491&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Invoice_getRemainingTotalPayablePrice.xml [utf8] Tue Apr 13 11:59:51 2010
@@ -76,6 +76,10 @@
 \n
 The `mirror_section_relative_url` parameter must be passed explicitly if the\n
 context invoice has multiple sections.\n
+\n
+If `quantity` parameter is true, this script will return the quantities in the\n
+original transaction currency. If currencies on this invoice and the related\n
+payments are not consistent, a ValueError is raised.\n
 """\n
 portal = context.getPortalObject()\n
 total_payable_price_per_node_section = dict()\n
@@ -115,6 +119,7 @@
   return movement_item_list\n
 \n
 \n
+invoice_currency = context.getResource()\n
 # calculate the total price of this invoice (according to accounting\n
 # transaction lines)\n
 for is_source, line in getIsSourceMovementItemList(context):\n
@@ -123,12 +128,18 @@
     node_value = line.getSourceValue(portal_type=\'Account\')\n
     line_section = line.getSourceSection()\n
     mirror_section = line.getDestinationSection()\n
-    amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n
+    if quantity:\n
+      amount = -line.getQuantity()\n
+    else:\n
+      amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n
   else:\n
     node_value = line.getDestinationValue(portal_type=\'Account\')\n
     line_section = line.getDestinationSection()\n
     mirror_section = line.getSourceSection()\n
-    amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n
+    if quantity:\n
+      amount = line.getQuantity()\n
+    else:\n
+      amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n
 \n
   if at_date is None and line.getGroupingReference():\n
     continue\n
@@ -185,18 +196,30 @@
     \n
     if at_date is None and line.getGroupingReference():\n
       continue\n
+\n
+    if quantity:\n
+      if line.getResource() != invoice_currency:\n
+        raise ValueError("Unable to calculate"\n
+        ", related transaction %s uses different currency" %\n
+          line.getRelativeUrl())\n
     \n
     if related_transaction_is_source:\n
       node_value = line.getSourceValue(portal_type=\'Account\')\n
       line_section = line.getSourceSection()\n
       mirror_section = line.getDestinationSection()\n
-      amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n
+      if quantity:\n
+        amount = -line.getQuantity()\n
+      else:\n
+        amount = line.getSourceInventoriatedTotalAssetPrice() or 0\n
       date = line.getStartDate().earliestTime()\n
     else:\n
       node_value = line.getDestinationValue(portal_type=\'Account\')\n
       line_section = line.getDestinationSection()\n
       mirror_section = line.getSourceSection()\n
-      amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n
+      if quantity:\n
+        amount = -line.getQuantity()\n
+      else:\n
+        amount = line.getDestinationInventoriatedTotalAssetPrice() or 0\n
       date = line.getStopDate().earliestTime()\n
     \n
     if node_value is not None:\n
@@ -233,7 +256,7 @@
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>detailed=0, at_date=None, account_id=None, simulation_state=None, mirror_section_relative_url=None</string> </value>
+            <value> <string>detailed=0, at_date=None, account_id=None, simulation_state=None, mirror_section_relative_url=None, quantity=False</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -253,7 +276,7 @@
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>5</int> </value>
+                        <value> <int>6</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -264,6 +287,7 @@
                             <string>account_id</string>
                             <string>simulation_state</string>
                             <string>mirror_section_relative_url</string>
+                            <string>quantity</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>portal</string>
@@ -281,6 +305,7 @@
                             <string>str</string>
                             <string>accounting_transaction_type_list</string>
                             <string>getIsSourceMovementItemList</string>
+                            <string>invoice_currency</string>
                             <string>is_source</string>
                             <string>line</string>
                             <string>node_value</string>
@@ -321,6 +346,7 @@
                 <none/>
                 <none/>
                 <none/>
+                <int>0</int>
               </tuple>
             </value>
         </item>

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=34491&r1=34490&r2=34491&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] Tue Apr 13 11:59:51 2010
@@ -1,1 +1,1 @@
-1163
+1164




More information about the Erp5-report mailing list