Commit 0450841e authored by Vincent Pelletier's avatar Vincent Pelletier

It is not required to pass resource parameter to getAvailableInventory when called on a resource.

Also, remove unuder variable.
Also, de-duplicate code from BankAccount_checkAvailableBalance.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40264 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7bdc6008
......@@ -9,10 +9,22 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -53,44 +65,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# check that the amount of `resource` in account `payment` is greater than or equal to `quantity`\n
\n
# returns a dictionnary like : {\'error_code\', \'balance\'}\n
\n
#workflow_id = \'bank_account_workflow\'\n
manual_validation_account_category_list = (\'test\',)\n
\n
# First check that the payment account is in an acceptable state\n
#payment_state = context.portal_workflow.getInfoFor(ob=payment, name=\'simulation_state\', wf_id=workflow_id)\n
payment_value = context.restrictedTraverse(payment)\n
\n
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
# context.log("account balance",account_balance)\n
# context.log("resource payement", str((resource,payment)))\n
if src__ :\n
return account_balance \n
\n
if account_balance - quantity < 0 :\n
# if payment.getBankAccountType() in manual_validation_account_category_list :\n
# return {\'error_code\':3, \'balance\':account_balance} # manual_validation\n
\n
return {\'error_code\':1, \'balance\':account_balance} # insufficient balance\n
\n
return {\'error_code\':0, \'balance\':account_balance} # ok\n
]]></string> </value>
<value> <string>return context.BankAccount_checkBalance(payment, quantity, src__=src__)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -98,6 +74,12 @@ return {\'error_code\':0, \'balance\':account_balance} # ok\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>payment, quantity, src__=0</string> </value>
......@@ -105,9 +87,7 @@ return {\'error_code\':0, \'balance\':account_balance} # ok\n
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -137,14 +117,8 @@ return {\'error_code\':0, \'balance\':account_balance} # ok\n
<string>payment</string>
<string>quantity</string>
<string>src__</string>
<string>manual_validation_account_category_list</string>
<string>_getattr_</string>
<string>context</string>
<string>payment_value</string>
<string>resource</string>
<string>None</string>
<string>AttributeError</string>
<string>account_balance</string>
</tuple>
</value>
</item>
......
......@@ -9,10 +9,22 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -58,8 +70,6 @@
# check that the amount of `resource` in account `payment` is greater than or equal to `quantity`\n
# returns a dictionnary like : {\'error_code\', \'balance\'}\n
\n
manual_validation_account_category_list = (\'test\',)\n
\n
# First check that the payment account is in an acceptable state\n
payment_value = context.restrictedTraverse(payment)\n
\n
......@@ -72,8 +82,7 @@ if resource is None :\n
raise AttributeError, \'No currency defined on %s\' % payment\n
\n
# Next, check the balance of the account\n
# We must specify the resource !\n
account_balance = resource.getAvailableInventory(payment=payment, resource=resource.getRelativeUrl(),src__=src__)\n
account_balance = resource.getAvailableInventory(payment=payment, src__=src__)\n
if src__ :\n
return account_balance \n
\n
......@@ -91,6 +100,12 @@ return {\'error_code\':0, \'balance\':account_balance} # ok\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>payment, quantity, src__=0</string> </value>
......@@ -130,7 +145,6 @@ return {\'error_code\':0, \'balance\':account_balance} # ok\n
<string>payment</string>
<string>quantity</string>
<string>src__</string>
<string>manual_validation_account_category_list</string>
<string>_getattr_</string>
<string>context</string>
<string>payment_value</string>
......
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