Commit b56ba3de authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Respect stop_date and archive lineless OpenOrders

Archive Open Orders which contains no lines, there is no reason to keep a user active if he has no Hosting subscription

Don't set new stop dates smaller them the ones currently set. If the value is set for 3 months, we wait until that period come. This affects HS related to Subscription Requests, that required 3 months payment up front.
parent 7b610666
...@@ -94,7 +94,7 @@ if open_sale_order is not None: ...@@ -94,7 +94,7 @@ if open_sale_order is not None:
# First check if the hosting subscription has been correctly simulated (this script may run only once per year...) # First check if the hosting subscription has been correctly simulated (this script may run only once per year...)
stop_date = calculateOpenOrderLineStopDate(open_order_line, hosting_subscription, start_date_delta=0) stop_date = calculateOpenOrderLineStopDate(open_order_line, hosting_subscription, start_date_delta=0)
if current_stop_date != stop_date: if current_stop_date < stop_date:
# Bingo, new subscription to generate # Bingo, new subscription to generate
open_order_line.edit( open_order_line.edit(
stop_date=stop_date, stop_date=stop_date,
...@@ -198,3 +198,8 @@ if (delete_line_list): ...@@ -198,3 +198,8 @@ if (delete_line_list):
open_order_explanation += "Removed %s." % str(delete_line_list) open_order_explanation += "Removed %s." % str(delete_line_list)
storeWorkflowComment(new_open_sale_order, open_order_explanation) storeWorkflowComment(new_open_sale_order, open_order_explanation)
if open_sale_order is not None:
if not len(open_sale_order.contentValues(
portal_type='Open Sale Order Line')):
open_sale_order.archive()
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