[Erp5-report] r41551 vincent - in /erp5/trunk/bt5/erp5_banking_core: SkinTemplateItem/porta...
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Dec 20 17:10:42 CET 2010
Author: vincent
Date: Mon Dec 20 17:10:42 2010
New Revision: 41551
URL: http://svn.erp5.org?rev=41551&view=rev
Log:
Use BankAccount_getAvailablePosition to factorise code.
Also, serialise bank account when checking if an operation can happen,
so it doesn't have to be done in each caller script.
This should not be a performance problem to serialise multiple time the
same account per transaction, and BankAccount_checkBalance should
only be called when there is an intent to withdraw cash from the account.
Modified:
erp5/trunk/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/BankAccount_checkBalance.xml
erp5/trunk/bt5/erp5_banking_core/bt/revision
Modified: erp5/trunk/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/BankAccount_checkBalance.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/BankAccount_checkBalance.xml?rev=41551&r1=41550&r2=41551&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/BankAccount_checkBalance.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/BankAccount_checkBalance.xml [utf8] Mon Dec 20 17:10:42 2010
@@ -76,19 +76,16 @@ payment_value = context.restrictedTraver
if not payment_value.BankAccount_isOpened():\n
return {\'error_code\':2} # closed account\n
\n
-resource = payment_value.getPriceCurrencyValue()\n
-\n
-if resource is None :\n
- raise AttributeError, \'No currency defined on %s\' % payment\n
-\n
-# Next, check the balance of the account\n
-account_balance = resource.getAvailableInventory(payment=payment, src__=src__)\n
-if src__ :\n
- return account_balance \n
+account_balance = payment_value.BankAccount_getAvailablePosition(src__=src__)\n
+if src__:\n
+ return account_balance\n
+# XXX: BankAccount_getAvailablePosition returns position as a string for some reason...\n
+account_balance = float(account_balance)\n
\n
if account_balance - quantity < 0 :\n
return {\'error_code\':1, \'balance\':account_balance} # insufficient balance\n
\n
+payment_value.serialize()\n
return {\'error_code\':0, \'balance\':account_balance} # ok\n
@@ -148,10 +145,8 @@ return {\'error_code\':0, \'balance\':ac
<string>_getattr_</string>
<string>context</string>
<string>payment_value</string>
- <string>resource</string>
- <string>None</string>
- <string>AttributeError</string>
<string>account_balance</string>
+ <string>float</string>
</tuple>
</value>
</item>
Modified: erp5/trunk/bt5/erp5_banking_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_banking_core/bt/revision?rev=41551&r1=41550&r2=41551&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_banking_core/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_banking_core/bt/revision [utf8] Mon Dec 20 17:10:42 2010
@@ -1 +1 @@
-546
\ No newline at end of file
+547
\ No newline at end of file
More information about the Erp5-report
mailing list