Commit 5927449b authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Readjust days to delay for trigger next escalation days

    - Invoice is generated 15 days before next period and a RR is created
   - 15 later a stop warning is sent (or when invoice expires)
   - 7 days later all instances are stopped if RR still open
    - 5 days after the user is informed his instances will be removed if payment is not done
    - 10 days after ALL his instances will be removed (for safety, as instances can be scaled faster if needed)

So, we assume:

   User is informed 22 days in advance before his instances stop to work, and if nothing is done 15 after (or 37 days after the first request to pay), we just remove all.
parent f14d5aa9
Pipeline #11733 failed with stage
...@@ -20,7 +20,7 @@ for payment in person.Person_getSubscriptionRequestFirstUnpaidPaymentList(): ...@@ -20,7 +20,7 @@ for payment in person.Person_getSubscriptionRequestFirstUnpaidPaymentList():
# It can't be smaller, we are considernig all open invoices are from unpaid_payment_amount # It can't be smaller, we are considernig all open invoices are from unpaid_payment_amount
if round(float(outstanding_amount), 2) == round(-float(unpaid_payment_amount), 2): if round(float(outstanding_amount), 2) == round(-float(unpaid_payment_amount), 2):
context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statOutstandingAmount()) context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statOutstandingAmount())
return
if (int(outstanding_amount) > 0): if (int(outstanding_amount) > 0):
return return
......
...@@ -19,10 +19,10 @@ else: ...@@ -19,10 +19,10 @@ else:
body = notification_message.convert(format='text')[1] body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
38, delay_period_in_days=15,
'service_module/slapos_crm_acknowledgement', current_service_relative_url='service_module/slapos_crm_acknowledgement',
'service_module/slapos_crm_stop_reminder', next_service_relative_url='service_module/slapos_crm_stop_reminder',
subject, title=subject,
body, text_content=body,
'Stopping reminder.', comment='Stopping reminder.',
) )
...@@ -18,10 +18,10 @@ else: ...@@ -18,10 +18,10 @@ else:
body = notification_message.convert(format='text')[1] body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
2, delay_period_in_days=10,
'service_module/slapos_crm_delete_reminder', current_service_relative_url='service_module/slapos_crm_delete_reminder',
'service_module/slapos_crm_delete_acknowledgement', next_service_relative_url='service_module/slapos_crm_delete_acknowledgement',
subject, title=subject,
body, text_content=body,
'Deleting acknowledgment.', comment='Deleting acknowledgment.',
) )
...@@ -18,10 +18,10 @@ else: ...@@ -18,10 +18,10 @@ else:
body = notification_message.convert(format='text')[1] body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
13, delay_period_in_days=7,
'service_module/slapos_crm_stop_acknowledgement', current_service_relative_url='service_module/slapos_crm_stop_acknowledgement',
'service_module/slapos_crm_delete_reminder', next_service_relative_url='service_module/slapos_crm_delete_reminder',
subject, title=subject,
body, text_content=body,
'Deleting reminder.', comment='Deleting reminder.',
) )
...@@ -18,10 +18,10 @@ else: ...@@ -18,10 +18,10 @@ else:
body = notification_message.convert(format='text')[1] body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep( return context.RegularisationRequest_checkToTriggerNextEscalationStep(
7, delay_period_in_days=7,
'service_module/slapos_crm_stop_reminder', current_service_relative_url='service_module/slapos_crm_stop_reminder',
'service_module/slapos_crm_stop_acknowledgement', next_service_relative_url='service_module/slapos_crm_stop_acknowledgement',
subject, title=subject,
body, text_content=body,
'Stopping acknowledgment.', comment='Stopping acknowledgment.',
) )
...@@ -823,18 +823,18 @@ class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation( ...@@ -823,18 +823,18 @@ class TestSlapOSRegularisationRequest_triggerAcknowledgmentEscalation(
REQUEST={}) REQUEST={})
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_matching_event(self): def test_checkToTriggerNextEscalationStep_matching_event(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.RegularisationRequest_triggerAcknowledgmentEscalation() ticket.RegularisationRequest_triggerAcknowledgmentEscalation()
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(38, (15,
'service_module/slapos_crm_acknowledgement', 'service_module/slapos_crm_acknowledgement',
'service_module/slapos_crm_stop_reminder', 'service_module/slapos_crm_stop_reminder',
'Reminder: invoice payment requested', 'Reminder: invoice payment requested',
...@@ -855,11 +855,11 @@ The slapos team ...@@ -855,11 +855,11 @@ The slapos team
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])') 'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_notification_message(self): def test_checkToTriggerNextEscalationStep_notification_message(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -876,7 +876,7 @@ The slapos team ...@@ -876,7 +876,7 @@ The slapos team
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(38, (15,
'service_module/slapos_crm_acknowledgement', 'service_module/slapos_crm_acknowledgement',
'service_module/slapos_crm_stop_reminder', 'service_module/slapos_crm_stop_reminder',
'Test NM title %s' % new_id, 'Test NM title %s' % new_id,
...@@ -895,11 +895,11 @@ class TestSlapOSRegularisationRequest_triggerStopReminderEscalation( ...@@ -895,11 +895,11 @@ class TestSlapOSRegularisationRequest_triggerStopReminderEscalation(
REQUEST={}) REQUEST={})
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_matching_event(self): def test_checkToTriggerNextEscalationStep_matching_event(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.RegularisationRequest_triggerStopReminderEscalation() ticket.RegularisationRequest_triggerStopReminderEscalation()
...@@ -927,11 +927,11 @@ The slapos team ...@@ -927,11 +927,11 @@ The slapos team
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])') 'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_notification_message(self): def test_checkToTriggerNextEscalationStep_notification_message(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -967,18 +967,18 @@ class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation( ...@@ -967,18 +967,18 @@ class TestSlapOSRegularisationRequest_triggerStopAcknowledgmentEscalation(
REQUEST={}) REQUEST={})
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_matching_event(self): def test_checkToTriggerNextEscalationStep_matching_event(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.RegularisationRequest_triggerStopAcknowledgmentEscalation() ticket.RegularisationRequest_triggerStopAcknowledgmentEscalation()
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(13, (7,
'service_module/slapos_crm_stop_acknowledgement', 'service_module/slapos_crm_stop_acknowledgement',
'service_module/slapos_crm_delete_reminder', 'service_module/slapos_crm_delete_reminder',
'Last reminder: invoice payment requested', 'Last reminder: invoice payment requested',
...@@ -999,11 +999,11 @@ The slapos team ...@@ -999,11 +999,11 @@ The slapos team
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])') 'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_notification_message(self): def test_checkToTriggerNextEscalationStep_notification_message(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1020,7 +1020,7 @@ The slapos team ...@@ -1020,7 +1020,7 @@ The slapos team
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(13, (7,
'service_module/slapos_crm_stop_acknowledgement', 'service_module/slapos_crm_stop_acknowledgement',
'service_module/slapos_crm_delete_reminder', 'service_module/slapos_crm_delete_reminder',
'Test NM title %s' % new_id, 'Test NM title %s' % new_id,
...@@ -1039,18 +1039,18 @@ class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation( ...@@ -1039,18 +1039,18 @@ class TestSlapOSRegularisationRequest_triggerDeleteReminderEscalation(
REQUEST={}) REQUEST={})
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_matching_event(self): def test_checkToTriggerNextEscalationStep_matching_event(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
ticket.RegularisationRequest_triggerDeleteReminderEscalation() ticket.RegularisationRequest_triggerDeleteReminderEscalation()
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(2, (10,
'service_module/slapos_crm_delete_reminder', 'service_module/slapos_crm_delete_reminder',
'service_module/slapos_crm_delete_acknowledgement', 'service_module/slapos_crm_delete_acknowledgement',
'Acknowledgment: instances deleted', 'Acknowledgment: instances deleted',
...@@ -1071,11 +1071,11 @@ The slapos team ...@@ -1071,11 +1071,11 @@ The slapos team
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])') 'context.REQUEST["test_checkToTriggerNextEscalationStep_notification_message"])')
@simulate('RegularisationRequest_checkToTriggerNextEscalationStep', @simulate('RegularisationRequest_checkToTriggerNextEscalationStep',
'day, current, next, title, text_content, comment, REQUEST=None', 'delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'comment="Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s" % (day, current, next, title, text_content, comment))') '%s %s %s %s %s %s" % (delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment))')
def test_checkToTriggerNextEscalationStep_notification_message(self): def test_checkToTriggerNextEscalationStep_notification_message(self):
ticket = self.createRegularisationRequest() ticket = self.createRegularisationRequest()
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -1092,7 +1092,7 @@ The slapos team ...@@ -1092,7 +1092,7 @@ The slapos team
self.assertEqual( self.assertEqual(
'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \ 'Visited by RegularisationRequest_checkToTriggerNextEscalationStep ' \
'%s %s %s %s %s %s' % \ '%s %s %s %s %s %s' % \
(2, (10,
'service_module/slapos_crm_delete_reminder', 'service_module/slapos_crm_delete_reminder',
'service_module/slapos_crm_delete_acknowledgement', 'service_module/slapos_crm_delete_acknowledgement',
'Test NM title %s' % new_id, 'Test NM title %s' % new_id,
......
...@@ -490,7 +490,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): ...@@ -490,7 +490,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
self.tic() self.tic()
# escalate 1 # escalate 1
self.trickCrmEvent('slapos_crm_acknowledgement', 38, public_reference) self.trickCrmEvent('slapos_crm_acknowledgement', 15, public_reference)
self.stepCallSlaposCrmTriggerAcknowledgmentEscalationAlarm() self.stepCallSlaposCrmTriggerAcknowledgmentEscalationAlarm()
self.tic() self.tic()
...@@ -505,12 +505,12 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): ...@@ -505,12 +505,12 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
self.assertSubscriptionStopped(person) self.assertSubscriptionStopped(person)
# escalate 3 # escalate 3
self.trickCrmEvent('slapos_crm_stop_acknowledgement', 13, public_reference) self.trickCrmEvent('slapos_crm_stop_acknowledgement', 7, public_reference)
self.stepCallSlaposCrmTriggerStopAcknowledgmentEscalationAlarm() self.stepCallSlaposCrmTriggerStopAcknowledgmentEscalationAlarm()
self.tic() self.tic()
# escalate 4 # escalate 4
self.trickCrmEvent('slapos_crm_delete_reminder', 2, public_reference) self.trickCrmEvent('slapos_crm_delete_reminder', 10, public_reference)
self.stepCallSlaposCrmTriggerDeleteReminderEscalationAlarm() self.stepCallSlaposCrmTriggerDeleteReminderEscalationAlarm()
self.tic() self.tic()
......
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