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
0
Merge Requests
0
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
Xiaowu Zhang
slapos.core
Commits
c1ea6cea
Commit
c1ea6cea
authored
Feb 27, 2019
by
Rafael Monnerat
Committed by
Alain Takoudjou
Mar 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Generate deduction for the reservation fee.
parent
3b56aae6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
4 deletions
+178
-4
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
...iption_request/SubscriptionRequest_boostrapUserAccount.py
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_checkPaymentBalance.py
...iption_request/SubscriptionRequest_checkPaymentBalance.py
+4
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_generateReservationRefoundSalePackingList.py
...ptionRequest_generateReservationRefoundSalePackingList.py
+81
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_generateReservationRefoundSalePackingList.xml
...tionRequest_generateReservationRefoundSalePackingList.xml
+62
-0
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
...al_components/test.erp5.testSlapOSSubscriptionScenario.py
+30
-2
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_boostrapUserAccount.py
View file @
c1ea6cea
...
@@ -24,7 +24,7 @@ role_list = ['member', 'subscriber']
...
@@ -24,7 +24,7 @@ role_list = ['member', 'subscriber']
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
open_assignment_list
=
person
.
searchFolder
(
portal_type
=
"Assignment"
,
validation_state
=
"open"
)
validation_state
=
"open"
)
#Initialisation
#
Initialisation
assignment_duration
=
context
.
portal_preferences
.
getPreferredCredentialAssignmentDuration
()
assignment_duration
=
context
.
portal_preferences
.
getPreferredCredentialAssignmentDuration
()
today
=
DateTime
()
today
=
DateTime
()
delay
=
today
+
assignment_duration
delay
=
today
+
assignment_duration
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_checkPaymentBalance.py
View file @
c1ea6cea
...
@@ -10,7 +10,10 @@ if hosting_subscription is None:
...
@@ -10,7 +10,10 @@ if hosting_subscription is None:
if
hosting_subscription
is
not
None
:
if
hosting_subscription
is
not
None
:
instance
=
hosting_subscription
.
getPredecessorValue
()
instance
=
hosting_subscription
.
getPredecessorValue
()
# This ensure that the user has a valid cloud contract
# This ensure that the user has a valid cloud contract
user_contract
=
instance
.
SoftwareInstance_requestValidationPayment
()
instance
.
SoftwareInstance_requestValidationPayment
()
# create a Deduction for his fee
context
.
SubscriptionRequest_generateReservationRefoundSalePackingList
()
if
context
.
SubscriptionRequest_testPaymentBalance
():
if
context
.
SubscriptionRequest_testPaymentBalance
():
context
.
confirm
()
context
.
confirm
()
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_generateReservationRefoundSalePackingList.py
0 → 100644
View file @
c1ea6cea
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
pass
#raise Unauthorized
portal
=
context
.
getObject
()
if
context
.
REQUEST
.
get
(
"refund_packing_list_%s"
%
context
.
getUid
(),
None
)
is
not
None
:
return
tag
=
"refund_packing_list_%s_inProfess"
%
context
.
getUid
()
if
(
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
):
return
service
=
portal
.
restrictedTraverse
(
"service_module/slapos_reservation_refund"
)
if
len
(
portal
.
portal_catalog
(
default_resource_uid
=
service
.
getUid
(),
portal_type
=
"Sale Packing List Line"
,
simulation_state
=
"delivered"
,
parent_causality_uid
=
context
.
getUid
())):
# Already generated
return
sale_invoice_transaction
=
context
.
getCausalityValue
(
portal_type
=
"Sale Invoice Transaction"
)
if
sale_invoice_transaction
is
None
or
sale_invoice_transaction
.
getSimulationState
()
in
[
"draft"
,
"cancelled"
,
"deleted"
]:
# No invoice generated, nothing to do
return
payment_transaction
=
sale_invoice_transaction
.
getCausalityRelatedValue
(
portal_type
=
"Payment Transaction"
)
if
payment_transaction
is
None
or
payment_transaction
.
getSimulationState
()
!=
"stopped"
:
# Nothing to do bug wait the payment
return
# Time to create the PL
person
=
sale_invoice_transaction
.
getDestinationValue
(
portal_type
=
"Person"
)
delivery_template
=
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceDeliveryTemplate
())
delivery
=
delivery_template
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery
.
edit
(
title
=
"Reservation Deduction"
,
specialise
=
"sale_trade_condition_module/slapos_reservation_refund_trade_condition"
,
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
start_date
=
payment_transaction
.
getCreationDate
(),
causality_uid
=
context
.
getUid
()
)
line
=
delivery
.
newContent
(
portal_type
=
"Sale Packing List Line"
,
title
=
"Reservation Deduction"
,
quantity
=
1
,
destination_value
=
person
,
destination_decision_value
=
person
,
destination_section_value
=
person
,
resource_value
=
service
,
quantity_unit
=
service
.
getQuantityUnit
(),
price
=-
sale_invoice_transaction
.
getTotalPrice
(),
causality_uid
=
context
.
getUid
()
)
delivery
.
confirm
(
comment
=
"Created from %s"
%
context
.
getRelativeUrl
())
delivery
.
start
()
delivery
.
stop
()
delivery
.
deliver
()
delivery
.
startBuilding
()
delivery
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
line
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
REQUEST
.
set
(
"refound_packing_list_%s"
%
context
.
getUid
(),
delivery
)
return
delivery
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_generateReservationRefoundSalePackingList.xml
0 → 100644
View file @
c1ea6cea
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_generateReservationRefoundSalePackingList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
View file @
c1ea6cea
...
@@ -38,8 +38,21 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
...
@@ -38,8 +38,21 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
self
.
createNotificationMessage
(
"subscription_request-confirmation-with-password"
)
self
.
createNotificationMessage
(
"subscription_request-confirmation-with-password"
)
self
.
createNotificationMessage
(
"subscription_request-confirmation-without-password"
,
self
.
createNotificationMessage
(
"subscription_request-confirmation-without-password"
,
text_content
=
'${name} ${login_name}'
)
text_content
=
'${name} ${login_name}'
)
self
.
cleanUpSubscriptionRequest
()
self
.
tic
()
self
.
tic
()
def
cleanUpSubscriptionRequest
(
self
):
for
subscription_request
in
self
.
portal
.
portal_catalog
(
portal_type
=
"Subscription Request"
,
simulation_state
=
[
"draft"
,
"planned"
,
"ordered"
],
title
=
"Test Subscription Request %"
):
if
subscription_request
.
getSimulationState
()
==
"draft"
:
subscription_request
.
cancel
()
if
subscription_request
.
getSimulationState
()
==
"planned"
:
subscription_request
.
order
()
if
subscription_request
.
getSimulationState
()
==
"ordered"
:
subscription_request
.
confirm
()
def
createNotificationMessage
(
self
,
reference
,
def
createNotificationMessage
(
self
,
reference
,
content_type
=
'text/html'
,
text_content
=
'${name} ${login_name} ${login_password}'
):
content_type
=
'text/html'
,
text_content
=
'${name} ${login_name} ${login_password}'
):
...
@@ -171,10 +184,13 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
...
@@ -171,10 +184,13 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
self
.
logout
()
self
.
logout
()
self
.
login
()
self
.
login
()
# 195 is the month payment
# 195*3 is the 3 months to pay upfront to use.
# 25 is the reservation fee deduction.
data_kw
=
{
data_kw
=
{
'errorCode'
:
'0'
,
'errorCode'
:
'0'
,
'transactionStatus'
:
'6'
,
'transactionStatus'
:
'6'
,
'authAmount'
:
58500
*
quantity
,
'authAmount'
:
(
19500
*
3
-
2500
)
*
quantity
,
'authDevise'
:
'978'
,
'authDevise'
:
'978'
,
}
}
payment
.
PaymentTransaction_createPayzenEvent
().
PayzenEvent_processUpdate
(
data_kw
,
True
)
payment
.
PaymentTransaction_createPayzenEvent
().
PayzenEvent_processUpdate
(
data_kw
,
True
)
...
@@ -287,7 +303,8 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
...
@@ -287,7 +303,8 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
self
.
assertNotEqual
(
instance
.
getAggregate
(),
None
)
self
.
assertNotEqual
(
instance
.
getAggregate
(),
None
)
def
checkAggregatedSalePackingList
(
self
,
subscription_request
,
sale_packing_list
):
def
checkAggregatedSalePackingList
(
self
,
subscription_request
,
sale_packing_list
):
sale_packing_list_line
=
sale_packing_list
.
objectValues
()[
0
]
sale_packing_list_line
=
[
i
for
i
in
sale_packing_list
.
objectValues
()
if
i
.
getResource
()
==
"service_module/slapos_instance_subscription"
][
0
]
quantity
=
subscription_request
.
getQuantity
()
quantity
=
subscription_request
.
getQuantity
()
# The values are without tax
# The values are without tax
...
@@ -298,6 +315,17 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
...
@@ -298,6 +315,17 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
self
.
assertEqual
(
sale_packing_list
.
getCausality
(),
self
.
assertEqual
(
sale_packing_list
.
getCausality
(),
subscription_request
.
getRelativeUrl
())
subscription_request
.
getRelativeUrl
())
sale_packing_list_line
=
[
i
for
i
in
sale_packing_list
.
objectValues
()
if
i
.
getResource
()
==
"service_module/slapos_reservation_refund"
][
0
]
quantity
=
subscription_request
.
getQuantity
()
# The values are without tax
self
.
assertEqual
(
sale_packing_list_line
.
getQuantity
(),
1
)
self
.
assertEqual
(
sale_packing_list_line
.
getPrice
(),
-
25
*
quantity
)
self
.
assertEqual
(
sale_packing_list_line
.
getTotalPrice
(),
-
25
*
quantity
)
self
.
assertEqual
(
sale_packing_list
.
getCausality
(),
subscription_request
.
getRelativeUrl
())
@
changeSkin
(
'Hal'
)
@
changeSkin
(
'Hal'
)
def
_requestSubscription
(
self
,
**
kw
):
def
_requestSubscription
(
self
,
**
kw
):
return
self
.
web_site
.
hateoas
.
SubscriptionRequestModule_requestSubscritption
(
**
kw
)
return
self
.
web_site
.
hateoas
.
SubscriptionRequestModule_requestSubscritption
(
**
kw
)
...
...
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