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
8901ea21
Commit
8901ea21
authored
Sep 30, 2022
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: create Open Order Cell
parent
ac516e90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
18 deletions
+44
-18
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
...pos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
+44
-18
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
View file @
8901ea21
...
...
@@ -18,17 +18,22 @@ def storeWorkflowComment(document, comment):
portal
.
portal_workflow
.
doActionFor
(
document
,
'edit_action'
,
comment
=
comment
)
def
newOpenOrder
():
def
newOpenOrder
(
start_date
):
new_open_sale_order
=
portal
.
open_sale_order_module
.
newContent
(
portal_type
=
"Open Sale Order"
)
new_open_sale_order
.
edit
(
specialise
=
specialise
,
effective_date
=
DateTime
(),
start_date
=
start_date
,
# Ensure stop date value is higher than start date
# it will be updated by OpenSaleOrder_updatePeriod
stop_date
=
start_date
+
1
,
activate_kw
=
activate_kw
,
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_value
=
person
,
destination_section_value
=
person
,
destination_decision_value
=
person
,
title
=
"%s SlapOS Subscription"
%
person
.
getTitle
(),
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
source
_project_value
=
instance_tree
.
getFollowUpValue
(),
destination
_project_value
=
instance_tree
.
getFollowUpValue
(),
)
new_open_sale_order
.
order
(
activate_kw
=
activate_kw
)
...
...
@@ -65,11 +70,6 @@ if instance_tree.getCausalityState() == 'diverged':
# Let's create the open order
if
is_open_order_creation_needed
:
open_sale_order
=
newOpenOrder
()
open_order_explanation
=
""
# Add lines
open_order_line
=
open_sale_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
hosting_subscription
=
portal
.
hosting_subscription_module
.
newContent
(
portal_type
=
"Hosting Subscription"
,
...
...
@@ -79,6 +79,11 @@ if instance_tree.getCausalityState() == 'diverged':
hosting_subscription
.
validate
()
start_date
=
hosting_subscription
.
HostingSubscription_calculateSubscriptionStartDate
()
open_sale_order
=
newOpenOrder
(
start_date
)
open_order_explanation
=
""
# Add lines
open_order_line
=
open_sale_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
# Search for matching resource
service
=
instance_tree
.
InstanceTree_getSoftwareProduct
()
if
(
service
is
None
)
or
(
service
.
getUse
()
!=
'trade/sale'
):
...
...
@@ -86,9 +91,14 @@ if instance_tree.getCausalityState() == 'diverged':
#assert instance_tree.getPortalType() in service.getRequiredAggregatedPortalTypeList()
resource_vcl
=
list
(
service
.
getVariationCategoryList
(
omit_individual_variation
=
0
))
resource_vcl
.
sort
()
assert
len
(
resource_vcl
)
!=
0
,
service
edit_kw
=
{
'quantity'
:
1
,
'resource_value'
:
service
,
'variation_category_list'
:
resource_vcl
,
'quantity_unit'
:
service
.
getQuantityUnit
(),
'base_contribution_list'
:
service
.
getBaseContributionList
(),
'use'
:
service
.
getUse
()
...
...
@@ -104,17 +114,31 @@ if instance_tree.getCausalityState() == 'diverged':
open_order_line
.
edit
(
activate_kw
=
activate_kw
,
title
=
instance_tree
.
getTitle
(),
start_date
=
start_date
,
# Ensure stop date value is higher than start date
# it will be updated by OpenSaleOrder_updatePeriod
stop_date
=
start_date
+
1
,
# stop_date=calculateOpenOrderLineStopDate(open_sale_order_line,
# instance_tree, start_date_delta=start_date_delta),
aggregate_value_list
=
[
hosting_subscription
,
instance_tree
],
**
edit_kw
)
base_id
=
'path'
# XXX XXX XXX TODO WRONG: it should not get the first random variations
# but match the instance tree parameters instead
cell_key
=
list
(
open_order_line
.
getCellKeyList
(
base_id
=
base_id
))[
0
]
open_order_cell
=
open_order_line
.
newCell
(
base_id
=
base_id
,
portal_type
=
'Open Sale Order Cell'
,
*
cell_key
)
open_order_cell
.
edit
(
mapped_value_property_list
=
[
'price'
,
'quantity'
],
quantity
=
1
,
predicate_category_list
=
cell_key
,
variation_category_list
=
cell_key
,
aggregate_value
=
[
hosting_subscription
,
instance_tree
],
)
open_order
=
open_order_line
.
getParentValue
()
open_order
.
SaleOrder_applySaleTradeCondition
(
batch_mode
=
1
,
force
=
1
)
...
...
@@ -127,6 +151,8 @@ if instance_tree.getCausalityState() == 'diverged':
inherited_trade_condition
=
open_sale_order
.
getSpecialiseValue
()
if
specialise
is
None
:
# XXX Comment on instance tree that no open can be created
# XXX ensure no open order has been created
assert
inherited_trade_condition
is
not
None
while
inherited_trade_condition
is
not
None
:
...
...
@@ -152,7 +178,7 @@ if instance_tree.getCausalityState() == 'diverged':
str
([
x
.
getRelativeUrl
()
for
x
in
predicate_list
]),
str
([(
x
.
getRelativeUrl
(),
x
.
getResource
())
for
x
in
log_predicate_list
]),
))
open_order_
line
.
edit
(
open_order_
cell
.
edit
(
price
=
price
)
...
...
@@ -166,7 +192,7 @@ if instance_tree.getCausalityState() == 'diverged':
open_order
=
open_order_line
.
getParentValue
()
assert
open_order_line
.
getResource
().
startswith
(
'software_product'
)
assert
open_order_line
.
getQuantityUnit
()
==
'
unit/piece'
assert
open_order_line
.
getQuantityUnit
()
==
'
time/month'
,
open_order_line
.
getQuantityUnit
()
assert
open_order_line
.
getBaseContribution
()
==
'base_amount/invoicing/discounted'
assert
open_order_line
.
getBaseContributionList
()[
1
]
==
'base_amount/invoicing/taxable'
assert
open_order_line
.
getUse
()
==
'trade/sale'
...
...
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