[Erp5-report] r6383 - /erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_ac...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 31 01:50:15 CEST 2006


Author: kevin
Date: Fri Mar 31 01:50:13 2006
New Revision: 6383

URL: http://svn.erp5.org?rev=6383&view=rev
Log:
  * Use generic script Base_getPreferredPrecision and Base_getRoundValue to get the right amount of money.
  * Refactor the query parameter parsing.

Modified:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml?rev=6383&r1=6382&r2=6383&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml Fri Mar 31 01:50:13 2006
@@ -66,40 +66,89 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>kwd = {}\n
-\n
-# read settings from user preference\n
-preference = context.getPortalObject().portal_preferences\n
-from_date = preference.getPreferredAccountingTransactionFromDate()\n
-if from_date :\n
-  kwd[\'from_date\'] = from_date\n
-at_date = preference.getPreferredAccountingTransactionAtDate()\n
-if at_date :\n
-  kwd[\'at_date\'] = at_date\n
-simulation_state = preference.getPreferredAccountingTransactionSimulationStateList()\n
-if simulation_state :\n
-  kwd[\'transaction_simulation_state\'] = simulation_state\n
-section_category = preference.getPreferredAccountingTransactionSectionCategory()\n
-\n
-# parameters only used in reports\n
-if kw.has_key(\'node_uid\'):\n
-  kwd[\'node_uid\'] = kw[\'node_uid\']\n
-if kw.has_key(\'transaction_portal_type\'):\n
-  kwd[\'transaction_portal_type\'] = kw[\'transaction_portal_type\']\n
-\n
-if kw.get(\'omit_input\') :\n
-  kwd[\'omit_input\'] = 1\n
-if kw.get(\'omit_output\') :\n
-  kwd[\'omit_output\'] = 1\n
-\n
-kwd[\'stat\'] = 1\n
-kwd[\'omit_simulation\'] = 1\n
-\n
-result = context.BankAccount_zGetAccountingTransactionList(**kwd)\n
+            <value> <string>params = {}\n
+pref = context.getPortalObject().portal_preferences\n
+precision = context.Base_getPreferredPrecision()\n
+\n
+###\n
+# Get the \'from_date\' parameter\n
+from_date = kw.get( \'from_date\'\n
+                  , pref.getPreferredAccountingTransactionFromDate()\n
+                  )\n
+if from_date:\n
+  params[\'from_date\'] = from_date\n
+\n
+###\n
+# Get the \'at_date\' parameter\n
+at_date = kw.get( \'at_date\'\n
+                , pref.getPreferredAccountingTransactionAtDate()\n
+                )\n
+if at_date:\n
+  params[\'at_date\'] = at_date\n
+\n
+###\n
+# Get the \'simulation_state\' parameter\n
+# Sometimes \'simulation_state\' is now as \'transaction_simulation_state\'\n
+simulation_state = kw.get( \'transaction_simulation_state\'\n
+                         , None\n
+                         )\n
+if not simulation_state:\n
+  simulation_state = kw.get( \'simulation_state\'\n
+                           , pref.getPreferredAccountingTransactionSimulationStateList()\n
+                           )\n
+if simulation_state:\n
+  params[\'transaction_simulation_state\'] = simulation_state\n
+\n
+###\n
+# Get the \'section_category\' parameter\n
+# Sometimes \'section_category\' is now as \'transaction_section_category\'\n
+section_category = kw.get( \'transaction_section_category\'\n
+                         , None\n
+                         )\n
+if not section_category:\n
+  section_category = kw.get( \'section_category\'\n
+                           , pref.getPreferredAccountingTransactionSectionCategory()\n
+                           )\n
+if section_category:\n
+  params[\'transaction_section_category\'] = section_category\n
+\n
+###\n
+# Parameters only used in reports\n
+if kw.has_key(\'node_uid\')               : params[\'node_uid\']                = kw[\'node_uid\']\n
+if kw.has_key(\'transaction_portal_type\'): params[\'transaction_portal_type\'] = kw[\'transaction_portal_type\']\n
+\n
+###\n
+# Get omit parameters\n
+if kw.get(\'omit_input\') : params[\'omit_input\']  = 1\n
+if kw.get(\'omit_output\'): params[\'omit_output\'] = 1\n
+\n
+params[\'stat\']            = 1\n
+params[\'omit_simulation\'] = 1\n
+\n
+###\n
+# Get payment and mirror related parameters\n
+MARKER = []\n
+no_payment_uid        = kw.get(\'no_payment_uid\',        MARKER)\n
+no_mirror_section_uid = kw.get(\'no_mirror_section_uid\', MARKER)\n
+payment_uid           = kw.get(\'payment_uid\',           MARKER)\n
+mirror_section_uid    = kw.get(\'mirror_section_uid\',    MARKER)\n
+if no_payment_uid        is not MARKER: params[\'no_payment_uid\']        = 1\n
+if no_mirror_section_uid is not MARKER: params[\'no_mirror_section_uid\'] = 1\n
+if payment_uid           is not MARKER: params[\'payment_uid\']           = payment_uid\n
+if mirror_section_uid    is not MARKER: params[\'mirror_section_uid\']    = mirror_section_uid\n
+\n
+if kw.has_key(\'getUid\')      : params[\'getUid\']       = kw[\'getUid\']\n
+if kw.has_key(\'getParentUid\'): params[\'getParentUid\'] = kw[\'getParentUid\']\n
+\n
+###\n
+# Call the query with selected parameters\n
+result = context.BankAccount_zGetAccountingTransactionList(**params)\n
 row = result[0]\n
-return float(\'%.02f\' % (row.quantity or 0.00))\n
-\n
-# vim: syntax=python\n
+\n
+###\n
+# Round the result to avoid float bad precision\n
+# TODO: use currency precision\n
+return context.Base_getRoundValue(row.quantity or 0.0, precision)\n
 </string> </value>
         </item>
         <item>
@@ -147,20 +196,26 @@
                         <value>
                           <tuple>
                             <string>kw</string>
-                            <string>kwd</string>
+                            <string>params</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>preference</string>
+                            <string>pref</string>
+                            <string>precision</string>
                             <string>from_date</string>
                             <string>_write_</string>
                             <string>at_date</string>
+                            <string>None</string>
                             <string>simulation_state</string>
                             <string>section_category</string>
                             <string>_getitem_</string>
+                            <string>MARKER</string>
+                            <string>no_payment_uid</string>
+                            <string>no_mirror_section_uid</string>
+                            <string>payment_uid</string>
+                            <string>mirror_section_uid</string>
                             <string>_apply_</string>
                             <string>result</string>
                             <string>row</string>
-                            <string>float</string>
                           </tuple>
                         </value>
                     </item>




More information about the Erp5-report mailing list