Commit 2b227530 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: test InstanceTree_requestUpdateOpenSaleOrder

parent 24eb38eb
......@@ -136,24 +136,24 @@ if instance_tree.getCausalityState() == 'diverged':
if person is not None:
# Search an existing related open order
open_order_line = portal.portal_catalog.getResultValue(
portal_type='Open Sale Order Line',
default_aggregate_uid=instance_tree.getUid())
open_order_cell = portal.portal_catalog.getResultValue(
portal_type='Open Sale Order Cell',
aggregate__uid=instance_tree.getUid())
is_open_order_creation_needed = False
# Simply check that it has never been simulated
if instance_tree.getSlapState() == 'destroy_requested':
# Line should be deleted
if (open_order_line is not None) and (open_order_line.getValidationState() == "invalidated"):
instance_tree.converge(comment="Last open order: %s" % open_order_line.getRelativeUrl())
elif open_order_line is None:
if (open_order_cell is not None) and (open_order_cell.getParentValue().getValidationState() == "invalidated"):
instance_tree.converge(comment="Last open order: %s" % open_order_cell.getRelativeUrl())
elif open_order_cell is None:
# User has no Open Sale Order (likely).
# No need to charge, as it was never allocated
is_open_order_creation_needed = False
instance_tree.converge(comment="No open order needed as it was never allocated")
elif open_order_line is None:
elif open_order_cell is None:
# Let's add
is_open_order_creation_needed = True
......@@ -205,8 +205,8 @@ if instance_tree.getCausalityState() == 'diverged':
price=order_cell.getPrice()
)
if open_order_line is not None:
if open_order_cell is not None:
open_order_line = open_order_cell.getParentValue()
assert open_order_line.getResource().startswith('software_product')
assert open_order_line.getQuantityUnit() == 'time/month', open_order_line.getQuantityUnit()
assert open_order_line.getBaseContribution() == 'base_amount/invoicing/discounted'
......@@ -215,7 +215,7 @@ if instance_tree.getCausalityState() == 'diverged':
#assert open_order_line.getPrice() == 1, open_order_line.getPrice()
assert open_order_cell.getQuantity() == 1
open_sale_order.OpenSaleOrder_updatePeriod()
open_order_line.getParentValue().OpenSaleOrder_updatePeriod()
# Person_storeOpenSaleOrderJournal should fix all divergent Instance Tree in one run
assert instance_tree.getCausalityState() == 'solved'
......
......@@ -95,7 +95,7 @@ if open_sale_order.getValidationState() == 'validated':
assert instance_tree.getCausalityState() == 'diverged'
instance_tree.converge(comment="Last open order: %s" % open_order_line.getRelativeUrl())
open_sale_order.archive()
open_sale_order.invalidate()
storeWorkflowComment(open_sale_order, "Instance Tree destroyed: %s" % instance_tree.getRelativeUrl())
elif (instance_tree.getCausalityState() == 'diverged'):
instance_tree.converge(comment="Nothing to do on open order.")
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