Commit 524cbb56 authored by Vincent Pelletier's avatar Vincent Pelletier

By default, round account balance at resource's precision.

Always provide unmodified balance as a separate result.
Also, fix coding style.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45564 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 371454a5
...@@ -59,26 +59,37 @@ ...@@ -59,26 +59,37 @@
payment_value = context.restrictedTraverse(payment)\n payment_value = context.restrictedTraverse(payment)\n
\n \n
if not payment_value.BankAccount_isOpened():\n if not payment_value.BankAccount_isOpened():\n
return {\'error_code\':2} # closed account\n return {\'error_code\': 2} # closed account\n
\n \n
account_balance = payment_value.BankAccount_getAvailablePosition(src__=src__)\n account_balance = payment_value.BankAccount_getAvailablePosition(src__=src__)\n
if src__:\n if src__:\n
return account_balance\n return account_balance\n
# XXX: BankAccount_getAvailablePosition returns position as a string for some reason...\n # XXX: BankAccount_getAvailablePosition returns position as a string for some reason...\n
account_balance = float(account_balance)\n raw_account_balance = account_balance = float(account_balance)\n
if round_balance:\n
account_balance = round(account_balance, resource.getQuantityPrecision())\n
\n \n
if account_balance - quantity < 0 :\n if account_balance - quantity < 0:\n
return {\'error_code\':1, \'balance\':account_balance} # insufficient balance\n # insufficient balance\n
return {\n
\'error_code\': 1,\n
\'balance\': account_balance,\n
\'raw_balance\': raw_account_balance,\n
}\n
\n \n
payment_value.serialize()\n payment_value.serialize()\n
return {\'error_code\':0, \'balance\':account_balance} # ok\n return {\n
\'error_code\': 0,\n
\'balance\': account_balance,\n
\'raw_balance\': raw_account_balance,\n
}\n
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>payment, quantity, src__=0</string> </value> <value> <string>payment, quantity, round_balance=True, src__=0</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
571 572
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment