[Erp5-report] r6712 - /erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_ac...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Apr 14 23:18:45 CEST 2006
Author: kevin
Date: Fri Apr 14 23:18:43 2006
New Revision: 6712
URL: http://svn.erp5.org?rev=6712&view=rev
Log:
Don't just truncate value.
Round it really.
Modified:
erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getRoundValue.xml
Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getRoundValue.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getRoundValue.xml?rev=6712&r1=6711&r2=6712&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getRoundValue.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getRoundValue.xml Fri Apr 14 23:18:43 2006
@@ -69,7 +69,22 @@
<value> <string encoding="cdata"><![CDATA[
try:\n
- return float( (\'%.\' + str(precision) + \'f\') % float(value))\n
+ # Round the value\n
+ # Fortunately, the round() python method follow french fiscal rules.\n
+ # Exemples:\n
+ # 116.5049 should be rounded to 116.50\n
+ # 116.505 should be rounded to 116.51\n
+ # 116.5051 should be rounded to 116.51\n
+ # Please check in your country if the round() method comply with local accounting and fiscal laws.\n
+ rounded_value = round(value, precision)\n
+\n
+ # Truncate the rounded value\n
+ trunc_value = (\'%.\' + str(precision) + \'f\') % rounded_value\n
+\n
+ if as_string:\n
+ return trunc_value\n
+ return float(trunc_value)\n
+\n
except:\n
context.log("bad convertion >>>", repr(context) + " | " + repr(value) + " | " + repr(precision))\n
return 0.0\n
@@ -95,7 +110,7 @@
</item>
<item>
<key> <string>_params</string> </key>
- <value> <string>value, precision</string> </value>
+ <value> <string>value, precision, as_string=False</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
@@ -115,7 +130,7 @@
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
- <value> <int>2</int> </value>
+ <value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
@@ -123,8 +138,12 @@
<tuple>
<string>value</string>
<string>precision</string>
+ <string>as_string</string>
+ <string>round</string>
+ <string>rounded_value</string>
+ <string>str</string>
+ <string>trunc_value</string>
<string>float</string>
- <string>str</string>
<string>_getattr_</string>
<string>context</string>
<string>repr</string>
@@ -139,7 +158,9 @@
<item>
<key> <string>func_defaults</string> </key>
<value>
- <none/>
+ <tuple>
+ <int>0</int>
+ </tuple>
</value>
</item>
<item>
More information about the Erp5-report
mailing list