Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.core
Commits
646d5bf5
Commit
646d5bf5
authored
Jan 13, 2025
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: create regularisation request for organisations
Stop and delete b2b services
parent
f8b48a03
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
250 additions
and
86 deletions
+250
-86
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_createRegularisationRequest.py
...tal_skins/slapos_crm/Alarm_createRegularisationRequest.py
+7
-7
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_invalidateSuspendedRegularisationRequest.py
...pos_crm/Alarm_invalidateSuspendedRegularisationRequest.py
+2
-2
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Entity_checkToCreateRegularisationRequest.py
...s/slapos_crm/Entity_checkToCreateRegularisationRequest.py
+0
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Entity_checkToCreateRegularisationRequest.xml
.../slapos_crm/Entity_checkToCreateRegularisationRequest.xml
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_deleteInstanceTreeList.py
...lapos_crm/RegularisationRequest_deleteInstanceTreeList.py
+5
-4
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIfEntityBalanceIsOk.py
...rm/RegularisationRequest_invalidateIfEntityBalanceIsOk.py
+3
-3
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIfEntityBalanceIsOk.xml
...m/RegularisationRequest_invalidateIfEntityBalanceIsOk.xml
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_stopInstanceTreeList.py
.../slapos_crm/RegularisationRequest_stopInstanceTreeList.py
+38
-10
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerAcknowledgmentEscalation.py
.../RegularisationRequest_triggerAcknowledgmentEscalation.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerDeleteReminderEscalation.py
.../RegularisationRequest_triggerDeleteReminderEscalation.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopAcknowledgmentEscalation.py
...ularisationRequest_triggerStopAcknowledgmentEscalation.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopReminderEscalation.py
...rm/RegularisationRequest_triggerStopReminderEscalation.py
+1
-1
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+183
-52
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
...mponents/test.erp5.testSlapOSERP5VirtualMasterScenario.py
+6
-2
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_createRegularisationRequest.py
View file @
646d5bf5
portal
=
context
.
getPortalObject
()
person
_uid_list
=
[]
entity
_uid_list
=
[]
for
(
_
,
brain
)
in
enumerate
(
portal
.
portal_simulation
.
getInventoryList
(
simulation_state
=
(
'stopped'
,
'delivered'
),
group_by_mirror_section
=
True
,
...
...
@@ -10,16 +10,16 @@ for (_, brain) in enumerate(portal.portal_simulation.getInventoryList(
grouping_reference
=
None
)):
section_uid
=
brain
.
getDestinationSectionUid
(
portal_type
=
"Person"
)
section_uid
=
brain
.
getDestinationSectionUid
(
portal_type
=
[
"Person"
,
"Organisation"
]
)
if
section_uid
is
not
None
:
person
_uid_list
.
append
(
section_uid
)
entity
_uid_list
.
append
(
section_uid
)
if
person
_uid_list
:
if
entity
_uid_list
:
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Person"
,
portal_type
=
[
"Person"
,
"Organisation"
]
,
validation_state
=
"validated"
,
uid
=
person
_uid_list
,
method_id
=
'
Person
_checkToCreateRegularisationRequest'
,
uid
=
entity
_uid_list
,
method_id
=
'
Entity
_checkToCreateRegularisationRequest'
,
activate_kw
=
{
'tag'
:
tag
}
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_invalidateSuspendedRegularisationRequest.py
View file @
646d5bf5
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Regularisation Request"
,
portal_type
=
"Regularisation Request"
,
simulation_state
=
[
"suspended"
,
"validated"
],
method_id
=
'RegularisationRequest_invalidateIf
Person
BalanceIsOk'
,
method_id
=
'RegularisationRequest_invalidateIf
Entity
BalanceIsOk'
,
activate_kw
=
{
'tag'
:
tag
}
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/
Person
_checkToCreateRegularisationRequest.py
→
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/
Entity
_checkToCreateRegularisationRequest.py
View file @
646d5bf5
File moved
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/
Person
_checkToCreateRegularisationRequest.xml
→
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/
Entity
_checkToCreateRegularisationRequest.xml
View file @
646d5bf5
...
...
@@ -54,7 +54,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person
_checkToCreateRegularisationRequest
</string>
</value>
<value>
<string>
Entity
_checkToCreateRegularisationRequest
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_deleteInstanceTreeList.py
View file @
646d5bf5
...
...
@@ -4,9 +4,9 @@ if REQUEST is not None:
ticket
=
context
state
=
ticket
.
getSimulationState
()
person
=
ticket
.
getDestinationDecisionValue
(
portal_type
=
"Person"
)
entity
=
ticket
.
getDestinationDecisionValue
(
portal_type
=
[
"Person"
,
"Organisation"
]
)
if
(
state
==
'suspended'
)
and
\
(
person
is
not
None
)
and
\
(
entity
is
not
None
)
and
\
(
ticket
.
getResource
()
==
'service_module/slapos_crm_delete_acknowledgement'
):
portal
=
context
.
getPortalObject
()
...
...
@@ -14,16 +14,17 @@ if (state == 'suspended') and \
ledger_uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
# Gather the list of not paid services
for
outstanding_amount
in
person
.
Entity_getOutstandingAmountList
(
for
outstanding_amount
in
entity
.
Entity_getOutstandingAmountList
(
ledger_uid
=
ledger_uid
,
include_planned
=
True
):
for
outstanding_invoice
in
person
.
Entity_getOutstandingAmountList
(
for
outstanding_invoice
in
entity
.
Entity_getOutstandingAmountList
(
section_uid
=
outstanding_amount
.
getSourceSectionUid
(),
resource_uid
=
outstanding_amount
.
getPriceCurrencyUid
(),
ledger_uid
=
outstanding_amount
.
getLedgerUid
(),
group_by_node
=
False
):
person
=
outstanding_invoice
.
getDestinationValue
(
portal_type
=
"Person"
)
subscribed_item
=
None
for
invoice_line
in
outstanding_invoice
.
getMovementList
(
portal_type
=
[
'Invoice Line'
,
'Invoice Cell'
]
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIf
Person
BalanceIsOk.py
→
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIf
Entity
BalanceIsOk.py
View file @
646d5bf5
...
...
@@ -3,10 +3,10 @@ if REQUEST is not None:
raise
Unauthorized
state
=
context
.
getSimulationState
()
person
=
context
.
getDestinationDecisionValue
(
portal_type
=
"Person"
)
entity
=
context
.
getDestinationDecisionValue
(
portal_type
=
[
"Person"
,
"Organisation"
]
)
if
(
state
not
in
(
'suspended'
,
'validated'
))
or
\
(
person
is
None
):
(
entity
is
None
):
return
if
not
person
.
Entity_hasOutstandingAmount
(
ledger_uid
=
context
.
getPortalObject
().
portal_categories
.
ledger
.
automated
.
getUid
()):
if
not
entity
.
Entity_hasOutstandingAmount
(
ledger_uid
=
context
.
getPortalObject
().
portal_categories
.
ledger
.
automated
.
getUid
()):
context
.
invalidate
(
comment
=
"Automatically disabled as balance is ok"
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIf
Person
BalanceIsOk.xml
→
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_invalidateIf
Entity
BalanceIsOk.xml
View file @
646d5bf5
...
...
@@ -54,7 +54,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
RegularisationRequest_invalidateIf
Person
BalanceIsOk
</string>
</value>
<value>
<string>
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_stopInstanceTreeList.py
View file @
646d5bf5
...
...
@@ -4,19 +4,47 @@ if REQUEST is not None:
ticket
=
context
state
=
ticket
.
getSimulationState
()
person
=
ticket
.
getDestinationDecisionValue
(
portal_type
=
"Person"
)
entity
=
ticket
.
getDestinationDecisionValue
(
portal_type
=
[
"Person"
,
"Organisation"
]
)
if
(
state
==
'suspended'
)
and
\
(
person
is
not
None
)
and
\
(
entity
is
not
None
)
and
\
(
ticket
.
getResource
()
in
[
'service_module/slapos_crm_stop_acknowledgement'
,
'service_module/slapos_crm_delete_reminder'
,
'service_module/slapos_crm_delete_acknowledgement'
]):
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Instance Tree"
,
validation_state
=
[
"validated"
],
destination_section__uid
=
person
.
getUid
(),
method_id
=
'InstanceTree_stopFromRegularisationRequest'
,
method_args
=
(
person
.
getRelativeUrl
(),),
activate_kw
=
{
'tag'
:
tag
}
)
ledger_uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
# Gather the list of not paid services
for
outstanding_amount
in
entity
.
Entity_getOutstandingAmountList
(
ledger_uid
=
ledger_uid
,
include_planned
=
True
):
for
outstanding_invoice
in
entity
.
Entity_getOutstandingAmountList
(
section_uid
=
outstanding_amount
.
getSourceSectionUid
(),
resource_uid
=
outstanding_amount
.
getPriceCurrencyUid
(),
ledger_uid
=
outstanding_amount
.
getLedgerUid
(),
group_by_node
=
False
):
person
=
outstanding_invoice
.
getDestinationValue
(
portal_type
=
"Person"
)
subscribed_item
=
None
for
invoice_line
in
outstanding_invoice
.
getMovementList
(
portal_type
=
[
'Invoice Line'
,
'Invoice Cell'
]
):
hosting_subscription
=
invoice_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
if
hosting_subscription
is
not
None
:
subscribed_item
=
invoice_line
.
getAggregateValue
(
portal_type
=
[
'Project'
,
'Instance Tree'
,
'Compute Node'
])
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unhandled invoice line %s'
%
invoice_line
.
getRelativeUrl
())
if
(
subscribed_item
.
getPortalType
()
==
'Instance Tree'
):
# change the slap state to stopped, to allow propagation of the state
# even on remote node
subscribed_item
.
InstanceTree_stopFromRegularisationRequest
(
person
.
getRelativeUrl
())
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unhandled invoice %s'
%
outstanding_invoice
.
getRelativeUrl
())
return
True
return
False
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerAcknowledgmentEscalation.py
View file @
646d5bf5
...
...
@@ -23,7 +23,7 @@ return context.RegularisationRequest_checkToTriggerNextEscalationStep(
comment
=
'Stopping reminder.'
,
notification_message
=
"slapos-crm.acknowledgment.escalation"
,
substitution_method_parameter_dict
=
{
'user_name'
:
context
.
getDestination
Sect
ionTitle
(),
'user_name'
:
context
.
getDestination
Decis
ionTitle
(),
'days'
:
ndays
}
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerDeleteReminderEscalation.py
View file @
646d5bf5
...
...
@@ -23,7 +23,7 @@ return context.RegularisationRequest_checkToTriggerNextEscalationStep(
comment
=
'Deleting acknowledgment.'
,
notification_message
=
"slapos-crm.delete.reminder.escalation"
,
substitution_method_parameter_dict
=
{
'user_name'
:
context
.
getDestination
Sect
ionTitle
(),
'user_name'
:
context
.
getDestination
Decis
ionTitle
(),
'days'
:
ndays
}
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopAcknowledgmentEscalation.py
View file @
646d5bf5
...
...
@@ -22,7 +22,7 @@ return context.RegularisationRequest_checkToTriggerNextEscalationStep(
comment
=
'Deleting reminder.'
,
notification_message
=
"slapos-crm.stop.acknowledgment.escalation"
,
substitution_method_parameter_dict
=
{
'user_name'
:
context
.
getDestination
Sect
ionTitle
(),
'user_name'
:
context
.
getDestination
Decis
ionTitle
(),
'days'
:
ndays
}
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_triggerStopReminderEscalation.py
View file @
646d5bf5
...
...
@@ -23,7 +23,7 @@ return context.RegularisationRequest_checkToTriggerNextEscalationStep(
comment
=
'Stopping acknowledgment.'
,
notification_message
=
"slapos-crm.stop.reminder.escalation"
,
substitution_method_parameter_dict
=
{
'user_name'
:
context
.
getDestination
Sect
ionTitle
(),
'user_name'
:
context
.
getDestination
Decis
ionTitle
(),
'days'
:
ndays
}
)
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
646d5bf5
...
...
@@ -37,6 +37,7 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
current_invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
,
destination_value
=
person
,
destination_section_value
=
person
,
start_date
=
DateTime
(
'2019/10/20'
),
stop_date
=
DateTime
(
'2019/10/20'
),
...
...
@@ -62,7 +63,7 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
#################################################################
# slapos_crm_create_regularisation_request
#################################################################
def
test_
Person
_checkToCreateRegularisationRequest_alarm_expectedPerson
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_expectedPerson
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -74,10 +75,25 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_Person_checkToCreateRegularisationRequest_alarm_started
(
self
):
def
test_Entity_checkToCreateRegularisationRequest_alarm_expectedOrganisation
(
self
):
new_id
=
self
.
generateNewId
()
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
,
title
=
"Test organisation %s"
%
new_id
)
organisation
.
validate
()
self
.
createFinalInvoice
(
organisation
)
self
.
tic
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
organisation
,
'Entity_checkToCreateRegularisationRequest'
)
def
test_Entity_checkToCreateRegularisationRequest_alarm_started
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -89,10 +105,10 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_
Person
_checkToCreateRegularisationRequest_alarm_lettered
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_lettered
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -104,10 +120,10 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_
Person
_checkToCreateRegularisationRequest_alarm_noLedger
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_noLedger
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -119,10 +135,10 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_
Person
_checkToCreateRegularisationRequest_alarm_noReceivable
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_noReceivable
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -134,10 +150,10 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_
Person
_checkToCreateRegularisationRequest_alarm_notValidatedPerson
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_notValidatedPerson
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -150,10 +166,10 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
def
test_
Person
_checkToCreateRegularisationRequest_alarm_noInvoice
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_alarm_noInvoice
(
self
):
new_id
=
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
...
...
@@ -164,7 +180,7 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_crm_create_regularisation_request
,
person
,
'
Person
_checkToCreateRegularisationRequest'
'
Entity
_checkToCreateRegularisationRequest'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
...
...
@@ -172,7 +188,7 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
'assert reference == "slapos-crm.create.regularisation.request"
\
n
'
\
'return'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person_checkToCreateRegularisationRequest_script_paymentRequested
(
self
):
def
test_
Entity_checkToCreateRegularisationRequest_script_paymentRequestedForPerson
(
self
):
for
preference
in
\
self
.
portal
.
portal_catalog
(
portal_type
=
"System Preference"
):
preference
=
preference
.
getObject
()
...
...
@@ -186,7 +202,7 @@ class TestSlapOSCRMCreateRegularisationRequestAlarm(SlapOSTestCaseMixin):
self
.
tic
()
before_date
=
DateTime
()
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
after_date
=
DateTime
()
self
.
tic
()
...
...
@@ -226,13 +242,75 @@ The slapos team
expected_text_content
.
splitlines
())]))
self
.
assertEqual
(
event
.
getSimulationState
(),
'delivered'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None, language="en"'
,
'assert reference == "slapos-crm.create.regularisation.request"
\
n
'
\
'return'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_Entity_checkToCreateRegularisationRequest_script_paymentRequestedForOrganisation
(
self
):
for
preference
in
\
self
.
portal
.
portal_catalog
(
portal_type
=
"System Preference"
):
preference
=
preference
.
getObject
()
if
preference
.
getPreferenceState
()
==
'global'
:
preference
.
setPreferredSlaposWebSiteUrl
(
'http://foobar.org/'
)
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
,
default_email_coordinate_text
=
'test@example.org'
)
organisation
.
validate
()
self
.
createFinalInvoice
(
organisation
)
self
.
tic
()
before_date
=
DateTime
()
ticket
,
event
=
organisation
.
Entity_checkToCreateRegularisationRequest
()
after_date
=
DateTime
()
self
.
tic
()
self
.
assertEqual
(
ticket
.
getPortalType
(),
'Regularisation Request'
)
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'suspended'
)
self
.
assertEqual
(
ticket
.
getResource
(),
'service_module/slapos_crm_acknowledgement'
)
self
.
assertEqual
(
ticket
.
getTitle
(),
'Account regularisation expected for "%s"'
%
organisation
.
getTitle
())
self
.
assertEqual
(
ticket
.
getDestination
(),
organisation
.
getRelativeUrl
())
self
.
assertEqual
(
ticket
.
getDestinationDecision
(),
organisation
.
getRelativeUrl
())
self
.
assertEqual
(
event
.
getPortalType
(),
'Mail Message'
)
self
.
assertEqual
(
event
.
getFollowUp
(),
ticket
.
getRelativeUrl
())
self
.
assertEqual
(
event
.
getResource
(),
'service_module/slapos_crm_acknowledgement'
)
self
.
assertTrue
(
event
.
getStartDate
()
>=
before_date
)
self
.
assertTrue
(
event
.
getStopDate
()
<=
after_date
)
self
.
assertEqual
(
event
.
getTitle
(),
"Invoice payment requested"
)
self
.
assertEqual
(
event
.
getDestination
(),
organisation
.
getRelativeUrl
())
self
.
assertEqual
(
event
.
getSource
(),
ticket
.
getSource
())
expected_text_content
=
"""Dear %s,
A new invoice has been generated.
You can access it in your invoice section at http://foobar.org/.
Regards,
The slapos team
"""
%
organisation
.
getTitle
()
self
.
assertEqual
(
event
.
getTextContent
(),
expected_text_content
,
'
\
n
'
.
join
([
x
for
x
in
difflib
.
unified_diff
(
event
.
getTextContent
().
splitlines
(),
expected_text_content
.
splitlines
())]))
self
.
assertEqual
(
event
.
getSimulationState
(),
'delivered'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None, language="en"'
,
'assert reference == "slapos-crm.create.regularisation.request"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_addRegularisationRequest_notification_message"])'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_notificationMessage
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_notificationMessage
(
self
):
for
preference
in
\
self
.
portal
.
portal_catalog
(
portal_type
=
"System Preference"
):
preference
=
preference
.
getObject
()
...
...
@@ -253,7 +331,7 @@ The slapos team
notification_message
.
getRelativeUrl
()
before_date
=
DateTime
()
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
after_date
=
DateTime
()
self
.
assertEqual
(
ticket
.
getPortalType
(),
'Regularisation Request'
)
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'suspended'
)
...
...
@@ -287,17 +365,17 @@ The slapos team
# def test_addRegularisationRequest_do_not_duplicate_ticket(self):
# person = self.createPerson()
# ticket = person.
Person
_checkToCreateRegularisationRequest()
# ticket2 = person.
Person
_checkToCreateRegularisationRequest()
# ticket = person.
Entity
_checkToCreateRegularisationRequest()
# ticket2 = person.
Entity
_checkToCreateRegularisationRequest()
# self.assertEqual(ticket.getRelativeUrl(), ticket2.getRelativeUrl())
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_doNotDuplicateTicketIfNotReindexed
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_doNotDuplicateTicketIfNotReindexed
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
transaction
.
commit
()
ticket2
,
event2
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket2
,
event2
=
person
.
Entity
_checkToCreateRegularisationRequest
()
self
.
assertNotEqual
(
ticket
,
None
)
self
.
assertNotEqual
(
event
,
None
)
self
.
assertEqual
(
ticket2
,
None
)
...
...
@@ -307,58 +385,58 @@ The slapos team
@
simulate
(
'RegularisationRequest_checkToSendUniqEvent'
,
'*args, **kwargs'
,
'raise NotImplementedError, "Should not have been called"'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_balanceOk
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_balanceOk
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
self
.
assertEqual
(
ticket
,
None
)
self
.
assertEqual
(
event
,
None
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_existingSuspendedTicket
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_existingSuspendedTicket
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
transaction
.
commit
()
self
.
tic
()
ticket2
,
event2
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket2
,
event2
=
person
.
Entity
_checkToCreateRegularisationRequest
()
self
.
assertNotEqual
(
ticket
,
None
)
self
.
assertNotEqual
(
event
,
None
)
self
.
assertEqual
(
ticket2
.
getRelativeUrl
(),
ticket
.
getRelativeUrl
())
self
.
assertEqual
(
event2
,
None
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_existingValidatedTicket
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_existingValidatedTicket
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
,
event
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket
,
event
=
person
.
Entity
_checkToCreateRegularisationRequest
()
ticket
.
validate
()
transaction
.
commit
()
self
.
tic
()
ticket2
,
event2
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket2
,
event2
=
person
.
Entity
_checkToCreateRegularisationRequest
()
self
.
assertNotEqual
(
ticket
,
None
)
self
.
assertNotEqual
(
event
,
None
)
self
.
assertEqual
(
ticket2
.
getRelativeUrl
(),
ticket
.
getRelativeUrl
())
self
.
assertEqual
(
event2
,
None
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_
Person
_checkToCreateRegularisationRequest_script_existingInvalidatedTicket
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_existingInvalidatedTicket
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
=
person
.
Person
_checkToCreateRegularisationRequest
()[
0
]
ticket
=
person
.
Entity
_checkToCreateRegularisationRequest
()[
0
]
ticket
.
invalidate
()
transaction
.
commit
()
self
.
tic
()
ticket2
,
event2
=
person
.
Person
_checkToCreateRegularisationRequest
()
ticket2
,
event2
=
person
.
Entity
_checkToCreateRegularisationRequest
()
self
.
assertNotEqual
(
ticket2
.
getRelativeUrl
(),
ticket
.
getRelativeUrl
())
self
.
assertNotEqual
(
event2
,
None
)
def
test_
Person
_checkToCreateRegularisationRequest_script_REQUEST_disallowed
(
self
):
def
test_
Entity
_checkToCreateRegularisationRequest_script_REQUEST_disallowed
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
self
.
assertRaises
(
Unauthorized
,
person
.
Person
_checkToCreateRegularisationRequest
,
person
.
Entity
_checkToCreateRegularisationRequest
,
REQUEST
=
{})
...
...
@@ -373,77 +451,77 @@ The slapos team
#################################################################
# slapos_crm_invalidate_suspended_regularisation_request
#################################################################
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_alarm_validatedRegularisationRequest
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_alarm_validatedRegularisationRequest
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
validate
()
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_invalidate_suspended_regularisation_request
self
.
_test_alarm
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Person
BalanceIsOk"
)
self
.
_test_alarm
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Entity
BalanceIsOk"
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_alarm_suspendedRegularisationRequest
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_alarm_suspendedRegularisationRequest
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
validate
()
ticket
.
suspend
()
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_invalidate_suspended_regularisation_request
self
.
_test_alarm
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Person
BalanceIsOk"
)
self
.
_test_alarm
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Entity
BalanceIsOk"
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_alarm_invalidatedRegularisationRequest
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_alarm_invalidatedRegularisationRequest
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
validate
()
ticket
.
invalidate
()
self
.
tic
()
alarm
=
self
.
portal
.
portal_alarms
.
\
slapos_crm_invalidate_suspended_regularisation_request
self
.
_test_alarm_not_visited
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Person
BalanceIsOk"
)
self
.
_test_alarm_not_visited
(
alarm
,
ticket
,
"RegularisationRequest_invalidateIf
Entity
BalanceIsOk"
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_script_REQUESTdisallowed
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_script_REQUESTdisallowed
(
self
):
ticket
=
self
.
createRegularisationRequest
()
self
.
assertRaises
(
Unauthorized
,
ticket
.
RegularisationRequest_invalidateIf
Person
BalanceIsOk
,
ticket
.
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
,
REQUEST
=
{})
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return False'
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_script_matchingCase
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_script_matchingCase
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
destination_decision_value
=
person
)
ticket
.
validate
()
ticket
.
suspend
()
ticket
.
RegularisationRequest_invalidateIf
Person
BalanceIsOk
()
ticket
.
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
()
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'invalidated'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return False'
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_script_validated
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_script_validated
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
destination_decision_value
=
person
)
ticket
.
validate
()
ticket
.
RegularisationRequest_invalidateIf
Person
BalanceIsOk
()
ticket
.
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
()
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'invalidated'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return False'
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_script_noPerson
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_script_noPerson
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
validate
()
ticket
.
suspend
()
ticket
.
RegularisationRequest_invalidateIf
Person
BalanceIsOk
()
ticket
.
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
()
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'suspended'
)
@
simulate
(
'Entity_hasOutstandingAmount'
,
'*args, **kwargs'
,
'return True'
)
def
test_RegularisationRequest_invalidateIf
Person
BalanceIsOk_script_wrongBalance
(
self
):
def
test_RegularisationRequest_invalidateIf
Entity
BalanceIsOk_script_wrongBalance
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
index
=
0
,
user
=
0
)
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
destination_decision_value
=
person
)
ticket
.
validate
()
ticket
.
suspend
()
ticket
.
RegularisationRequest_invalidateIf
Person
BalanceIsOk
()
ticket
.
RegularisationRequest_invalidateIf
Entity
BalanceIsOk
()
self
.
assertEqual
(
ticket
.
getSimulationState
(),
'suspended'
)
...
...
@@ -896,6 +974,32 @@ class TestSlapOSCrmStopInstanceTree(SlapOSTestCaseMixinWithAbort):
)
self
.
tic
()
accounting_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
,
destination_value
=
person
,
destination_section_value
=
person
,
start_date
=
DateTime
(),
price_currency
=
"currency_module/EUR"
,
resource
=
"currency_module/EUR"
,
ledger
=
"automated"
,
)
accounting_transaction
.
newContent
(
portal_type
=
"Invoice Line"
,
aggregate_value_list
=
[
instance_tree
,
self
.
portal
.
hosting_subscription_module
.
newContent
()
]
)
accounting_transaction
.
newContent
(
portal_type
=
"Sale Invoice Transaction Line"
,
quantity
=
1
,
source
=
"account_module/receivable"
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
accounting_transaction
,
'stopped'
)
with
TemporaryAlarmScript
(
self
.
portal
,
'Base_reindexAndSenseAlarm'
,
"'disabled'"
,
attribute
=
'comment'
):
self
.
tic
()
result
=
ticket
.
\
RegularisationRequest_stopInstanceTreeList
(
'footag'
)
self
.
assertTrue
(
result
)
...
...
@@ -929,6 +1033,32 @@ class TestSlapOSCrmStopInstanceTree(SlapOSTestCaseMixinWithAbort):
)
self
.
tic
()
accounting_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
,
destination_value
=
person
,
destination_section_value
=
person
,
start_date
=
DateTime
(),
price_currency
=
"currency_module/EUR"
,
resource
=
"currency_module/EUR"
,
ledger
=
"automated"
,
)
accounting_transaction
.
newContent
(
portal_type
=
"Invoice Line"
,
aggregate_value_list
=
[
instance_tree
,
self
.
portal
.
hosting_subscription_module
.
newContent
()
]
)
accounting_transaction
.
newContent
(
portal_type
=
"Sale Invoice Transaction Line"
,
quantity
=
1
,
source
=
"account_module/receivable"
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
accounting_transaction
,
'stopped'
)
with
TemporaryAlarmScript
(
self
.
portal
,
'Base_reindexAndSenseAlarm'
,
"'disabled'"
,
attribute
=
'comment'
):
self
.
tic
()
result
=
ticket
.
\
RegularisationRequest_stopInstanceTreeList
(
'footag'
)
self
.
assertTrue
(
result
)
...
...
@@ -1118,6 +1248,7 @@ class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
accounting_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
,
destination_value
=
person
,
destination_section_value
=
person
,
start_date
=
DateTime
(),
price_currency
=
"currency_module/EUR"
,
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
View file @
646d5bf5
...
...
@@ -157,7 +157,9 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
# required to generate accounting report
price_currency_value
=
currency
,
# required to calculate the vat
default_address_region
=
'europe/west/france'
default_address_region
=
'europe/west/france'
,
# required email to send events
default_email_url_string
=
'test@example.org'
)
seller_bank_account
=
seller_organisation
.
newContent
(
portal_type
=
"Bank Account"
,
...
...
@@ -553,7 +555,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
portal_type
=
'Organisation'
,
title
=
'TestOrganisation Section %s'
%
self
.
generateNewId
(),
default_address_region
=
'europe/west/france'
,
vat_code
=
self
.
generateNewId
()
vat_code
=
self
.
generateNewId
(),
# required email to send events
default_email_url_string
=
'test@example.org'
)
customer_section_organisation
.
validate
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment