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
Titouan Soulard
slapos.core
Commits
d756f2fa
Commit
d756f2fa
authored
Jun 09, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: block subscription process if there is no deposit
parent
f916f09e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_validateIfSubmitted.py
...iption_request/SubscriptionRequest_validateIfSubmitted.py
+40
-0
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_validateIfSubmitted.py
View file @
d756f2fa
...
...
@@ -8,6 +8,46 @@ if item is None:
# Use list setter, to ensure it crashes if item is still None
# subscription_request.setAggregateValueList([item])
# Accept the subscription only if user paid the security payment
if
(
subscription_request
.
getSourceValue
()
is
None
)
or
\
(
subscription_request
.
getSource
()
!=
subscription_request
.
getDestination
()):
# Check that user has enough guarantee deposit to request a new service
portal
=
context
.
getPortalObject
()
assert_price_kw
=
{
'resource_uid'
:
subscription_request
.
getPriceCurrencyUid
(),
'portal_type'
:
portal
.
getPortalAccountingMovementTypeList
(),
}
deposit_amount
=
portal
.
portal_simulation
.
getInventoryAssetPrice
(
section_uid
=
subscription_request
.
getSourceSectionUid
(),
mirror_section_uid
=
subscription_request
.
getDestinationSectionUid
(),
mirror_node_uid
=
portal
.
restrictedTraverse
(
'account_module/deposit'
).
getUid
(),
#node_category_strict_membership=['account_type/income'],
simulation_state
=
(
'stopped'
,
'delivered'
),
#src__=1,
**
assert_price_kw
)
#return deposit_amount
payable_amount
=
portal
.
portal_simulation
.
getInventoryAssetPrice
(
mirror_section_uid
=
subscription_request
.
getSourceSectionUid
(),
section_uid
=
subscription_request
.
getDestinationSectionUid
(),
node_category_strict_membership
=
[
'account_type/asset/receivable'
,
'account_type/liability/payable'
],
grouping_reference
=
None
,
**
assert_price_kw
)
total_price
=
subscription_request
.
getTotalPrice
()
# XXX what is the guarantee deposit account_type?
if
deposit_amount
<
payable_amount
+
total_price
:
# if not enough, user will have to pay a deposit for the subscription
# XXX probably create an event asking for a deposit
#pass
return
'NO deposit_amount %s
\
n
payable_amount %s
\
n
total_price %s'
%
(
deposit_amount
,
payable_amount
,
total_price
)
#return 'YES deposit_amount %s\npayable_amount %s\ntotal_price %s' % (deposit_amount, payable_amount, total_price)
subscription_request
.
SubscriptionRequest_createOpenSaleOrder
()
subscription_request
.
validate
()
subscription_request
.
invalidate
()
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