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
10b2144b
Commit
10b2144b
authored
Oct 03, 2022
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: get price from sale supply
parent
23271cbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
49 deletions
+12
-49
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
...pos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
+2
-33
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Movement_getPriceCalculationOperandDict.py
...pos_accounting/Movement_getPriceCalculationOperandDict.py
+8
-6
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SupplyLine_asPredicate.py
.../portal_skins/slapos_accounting/SupplyLine_asPredicate.py
+2
-10
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/InstanceTree_requestUpdateOpenSaleOrder.py
View file @
10b2144b
...
@@ -158,41 +158,10 @@ if instance_tree.getCausalityState() == 'diverged':
...
@@ -158,41 +158,10 @@ if instance_tree.getCausalityState() == 'diverged':
if
specialise
is
not
None
:
if
specialise
is
not
None
:
assert
open_order
.
getSpecialise
()
==
specialise
assert
open_order
.
getSpecialise
()
==
specialise
predicate_list
=
[]
log_predicate_list
=
[]
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
:
predicate_list
.
extend
([
x
for
x
in
inherited_trade_condition
.
contentValues
(
portal_type
=
'Sale Supply Line'
)
if
x
.
getResource
()
==
service
.
getRelativeUrl
()
])
log_predicate_list
.
extend
([
x
for
x
in
inherited_trade_condition
.
contentValues
(
portal_type
=
'Sale Supply Line'
)
])
inherited_trade_condition
=
inherited_trade_condition
.
getSpecialiseValue
(
portal_type
=
inherited_trade_condition
.
getPortalType
())
price
=
service
.
getPrice
(
context
=
open_order_line
,
predicate_list
=
predicate_list
,
default
=
None
,
)
if
price
is
None
:
raise
NotImplementedError
(
'Price not found on %s (%s) for %s %s - %s'
%
(
open_sale_order
.
getSpecialiseTitle
(),
open_sale_order
.
getSpecialise
(),
service
.
getRelativeUrl
(),
str
([
x
.
getRelativeUrl
()
for
x
in
predicate_list
]),
str
([(
x
.
getRelativeUrl
(),
x
.
getResource
())
for
x
in
log_predicate_list
]),
))
open_order_cell
.
edit
(
open_order_cell
.
edit
(
price
=
price
price
=
open_order_cell
.
getPrice
()
)
)
# XXX XXX XXX assert open_order_cell.getPrice() is not None
storeWorkflowComment
(
open_order_line
,
"Created for %s"
%
instance_tree
.
getRelativeUrl
())
storeWorkflowComment
(
open_order_line
,
"Created for %s"
%
instance_tree
.
getRelativeUrl
())
# instance_tree.converge(comment="Last open order: %s" % open_sale_order_line.getRelativeUrl())
# instance_tree.converge(comment="Last open order: %s" % open_sale_order_line.getRelativeUrl())
...
...
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Movement_getPriceCalculationOperandDict.py
View file @
10b2144b
...
@@ -12,7 +12,7 @@ def sort_key_method(e):
...
@@ -12,7 +12,7 @@ def sort_key_method(e):
parent
=
parent
.
getParentValue
()
parent
=
parent
.
getParentValue
()
return
0
-
1
*
int
(
parent
.
hasSourceFunction
())
-
2
*
int
(
parent
.
hasGroup
())
return
0
-
1
*
int
(
parent
.
hasSourceFunction
())
-
2
*
int
(
parent
.
hasGroup
())
def
filter_method
(
source_function
,
group
):
def
filter_method
(
currency
,
destination_project
,
group
):
def
filter_by_source_function_and_group
(
l
):
def
filter_by_source_function_and_group
(
l
):
ret
=
[]
ret
=
[]
for
i
in
l
:
for
i
in
l
:
...
@@ -20,8 +20,8 @@ def filter_method(source_function, group):
...
@@ -20,8 +20,8 @@ def filter_method(source_function, group):
if
parent
.
getPortalType
().
endswith
(
'Line'
):
if
parent
.
getPortalType
().
endswith
(
'Line'
):
parent
=
parent
.
getParentValue
()
parent
=
parent
.
getParentValue
()
# Price should be set in Sale Supply only.
# Price should be set in Sale Supply only.
#
if parent.getPortalType() != 'Sale Supply' and parent.getParentValue().getPortalType() != 'Sale Supply':
if
parent
.
getPortalType
()
!=
'Sale Supply'
and
parent
.
getParentValue
().
getPortalType
()
!=
'Sale Supply'
:
#
continue
continue
date
=
context
.
getStartDate
()
date
=
context
.
getStartDate
()
# Check if effective
# Check if effective
if
parent
.
hasStartDateRangeMin
()
and
date
<
parent
.
getStartDateRangeMin
():
if
parent
.
hasStartDateRangeMin
()
and
date
<
parent
.
getStartDateRangeMin
():
...
@@ -29,8 +29,10 @@ def filter_method(source_function, group):
...
@@ -29,8 +29,10 @@ def filter_method(source_function, group):
# Check if not expired
# Check if not expired
if
parent
.
hasStartDateRangeMax
()
and
date
>
parent
.
getStartDateRangeMax
():
if
parent
.
hasStartDateRangeMax
()
and
date
>
parent
.
getStartDateRangeMax
():
continue
continue
# Sale Supply having a different source_function should not be applied.
# Sale Supply having a different destination_project should not be applied.
if
parent
.
getSourceFunction
()
not
in
(
None
,
source_function
):
if
parent
.
getDestinationProject
()
!=
destination_project
:
continue
if
parent
.
getPriceCurrency
()
!=
currency
:
continue
continue
# XXX Sale Supply having a different group should not be applied.
# XXX Sale Supply having a different group should not be applied.
#if parent.getGroup() not in (None, group):
#if parent.getGroup() not in (None, group):
...
@@ -43,7 +45,7 @@ if source is None:
...
@@ -43,7 +45,7 @@ if source is None:
group
=
None
group
=
None
else
:
else
:
group
=
source
.
getGroup
()
group
=
source
.
getGroup
()
kw
[
'filter_method'
]
=
filter_method
(
context
.
get
SourceFunction
(),
group
)
kw
[
'filter_method'
]
=
filter_method
(
context
.
get
PriceCurrency
(),
context
.
getDestinationProject
(),
group
)
"""
"""
def filter_couscous(predicate_list):
def filter_couscous(predicate_list):
...
...
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SupplyLine_asPredicate.py
View file @
10b2144b
parent
=
context
.
getParentValue
()
parent
=
context
.
getParentValue
()
if
(
parent
.
getPortalType
()
!=
'Sale
Trade Condition
'
)
or
(
parent
.
getValidationState
()
!=
'validated'
):
if
(
parent
.
getPortalType
()
!=
'Sale
Supply
'
)
or
(
parent
.
getValidationState
()
!=
'validated'
):
# If this supply line is not in a validated
trade condition
, it does not apply.
# If this supply line is not in a validated
Sale Supply
, it does not apply.
return
None
return
None
...
@@ -21,14 +21,6 @@ if context.getSourceProject():
...
@@ -21,14 +21,6 @@ if context.getSourceProject():
if
context
.
getDestinationProject
():
if
context
.
getDestinationProject
():
base_category_tuple
+=
(
'destination_project'
,)
base_category_tuple
+=
(
'destination_project'
,)
# Supply Lines from trade conditions are set as specialise to this trade condition,
# so that we can apply a predicate on movements later. Supply Lines from trade condition
# only apply on movements using these trade conditions.
category_list
=
context
.
getCategoryList
()
+
[
'specialise/%s'
%
context
.
getParentValue
().
getRelativeUrl
()]
context
=
context
.
asContext
(
categories
=
category_list
)
base_category_tuple
+=
(
'specialise'
,
)
#backwards compatibility
#backwards compatibility
mapped_value_property_list
=
context
.
getMappedValuePropertyList
()
mapped_value_property_list
=
context
.
getMappedValuePropertyList
()
for
mapped_property
in
(
'priced_quantity'
,
'quantity_unit'
):
for
mapped_property
in
(
'priced_quantity'
,
'quantity_unit'
):
...
...
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