Commit 7c3f0dba authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: No need this script, use Entity_getOutstandingDepositAmountList for now

parent f1dc41ed
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
ledger_uid = portal.portal_categories.ledger.automated.getUid()
if not currency_uid:
raise ValueError("You must provide an currency to calculate the amount")
outstanding_amount_list = context.Entity_getOutstandingDepositAmountList(
resource_uid=currency_uid, ledger_uid=ledger_uid)
if not outstanding_amount_list:
# Nothing found
return 0
if len(outstanding_amount_list) > 1:
raise ValueError('More them one value for the %s currency was found' % currency_uid)
return outstanding_amount_list[0].total_price
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>currency_uid, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Entity_getOutstandingDepositAmount</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -589,7 +589,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -589,7 +589,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
aggregate__uid=service.getUid(), aggregate__uid=service.getUid(),
simulation_state=simulation_state simulation_state=simulation_state
) )
self.assertNotEqual(subscription_request, None) self.assertNotEqual(subscription_request, None,
"Not found subscription request for %s" % service.getRelativeUrl())
return subscription_request return subscription_request
def checkInstanceAllocation(self, person_user_id, person_reference, def checkInstanceAllocation(self, person_user_id, person_reference,
...@@ -672,8 +673,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -672,8 +673,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.tic() self.tic()
amount = person.Entity_getOutstandingDepositAmount( amount = sum([i.total_price for i in person.Entity_getOutstandingDepositAmountList(
currency.getUid()) currency.getUid(), ledger_uid=subscription_request.getLedgerUid())])
self.assertEqual(amount, deposit_amount) self.assertEqual(amount, deposit_amount)
# Action to submit project subscription # Action to submit project subscription
...@@ -694,7 +695,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -694,7 +695,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.checkServiceSubscriptionRequest(instance_tree, 'invalidated') self.checkServiceSubscriptionRequest(instance_tree, 'invalidated')
amount = person.Entity_getOutstandingDepositAmount(currency.getUid()) amount = sum([i.total_price for i in person.Entity_getOutstandingDepositAmountList(
currency.getUid(), ledger_uid=subscription_request.getLedgerUid())])
self.assertEqual(0, amount) self.assertEqual(0, amount)
self.login(person_user_id) self.login(person_user_id)
......
...@@ -717,7 +717,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -717,7 +717,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
assert len(inventory_list) == 1, len(inventory_list) assert len(inventory_list) == 1, len(inventory_list)
assert inventory_list[0].quantity == 1, inventory_list[0].quantity assert inventory_list[0].quantity == 1, inventory_list[0].quantity
resource_vcl = [ resource_vcl = [
#'software_release/%s' % release_variation.getRelativeUrl(), # 'software_release/%s' % release_variation.getRelativeUrl(),
'software_type/%s' % type_variation.getRelativeUrl() 'software_type/%s' % type_variation.getRelativeUrl()
] ]
resource_vcl.sort() resource_vcl.sort()
...@@ -817,7 +817,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -817,7 +817,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
sale_supply.validate() sale_supply.validate()
self.tic() self.tic()
# some preparation # some preparation
self.logout() self.logout()
...@@ -855,13 +854,14 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -855,13 +854,14 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# format the compute_nodes # format the compute_nodes
self.formatComputeNode(public_server) self.formatComputeNode(public_server)
self.logout() self.logout()
self.login(project_owner_person.getUserId()) self.login(project_owner_person.getUserId())
# Pay deposit to validate virtual master.
# Pay deposit to validate virtual master + one computer
deposit_amount = 42.0 + 99.0 deposit_amount = 42.0 + 99.0
amount = project_owner_person.Entity_getOutstandingDepositAmount( ledger = self.portal.portal_categories.ledger.automated
currency.getUid()) amount = sum([i.total_price for i in project_owner_person.Entity_getOutstandingDepositAmountList(
currency.getUid(), ledger_uid=ledger.getUid())])
self.assertEqual(amount, deposit_amount) self.assertEqual(amount, deposit_amount)
def wrapWithShadow(_person, *arg): def wrapWithShadow(_person, *arg):
...@@ -879,9 +879,12 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -879,9 +879,12 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
assert payment_transaction.receivable.getGroupingReference(None) is not None assert payment_transaction.receivable.getGroupingReference(None) is not None
self.login(project_owner_person.getUserId()) self.login(project_owner_person.getUserId())
amount = project_owner_person.Entity_getOutstandingDepositAmount(currency.getUid()) amount = sum([i.total_price for i in project_owner_person.Entity_getOutstandingDepositAmountList(
currency.getUid(), ledger_uid=ledger.getUid())])
self.assertEqual(0, amount) self.assertEqual(0, amount)
self.logout()
# join as the another visitor and request software instance on public # join as the another visitor and request software instance on public
# compute_node # compute_node
self.logout() self.logout()
......
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