diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml index 2397006997b41a74dcaed5cb6b0a6f1a16620a79..bba2846da5b9c062ef2f65dfc2c8601b166a9c8e 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/BankAccount_statSourceBalance.xml @@ -66,40 +66,89 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>kwd = {}\n + <value> <string>params = {}\n +pref = context.getPortalObject().portal_preferences\n +precision = context.Base_getPreferredPrecision()\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 +# 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 -# 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 +# 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 -if kw.get(\'omit_input\') :\n - kwd[\'omit_input\'] = 1\n -if kw.get(\'omit_output\') :\n - kwd[\'omit_output\'] = 1\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 -kwd[\'stat\'] = 1\n -kwd[\'omit_simulation\'] = 1\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 -result = context.BankAccount_zGetAccountingTransactionList(**kwd)\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 +# 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 @@ return float(\'%.02f\' % (row.quantity or 0.00))\n <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>