Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
140
Merge Requests
140
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
83b13388
Commit
83b13388
authored
Jun 20, 2019
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_pdm: add super basic support for price calculation with sliced_base_price
parent
4ff3d91d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
...skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
+14
-0
product/ERP5/Document/Resource.py
product/ERP5/Document/Resource.py
+1
-0
No files found.
bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
View file @
83b13388
result
=
context
.
getPriceParameterDict
(
context
=
movement
,
**
kw
)
result
=
context
.
getPriceParameterDict
(
context
=
movement
,
**
kw
)
# XXX: Add "stepped_price" in calculation
# sliced_base_price = {'price': 10.0, 'sliced_range': (1, None)}
# Calculate
# Calculate
# ((base_price + SUM(additional_price) +
# ((base_price + SUM(additional_price) +
# variable_value * SUM(variable_additional_price)) *
# variable_value * SUM(variable_additional_price)) *
...
@@ -16,6 +19,17 @@ result = context.getPriceParameterDict(context=movement, **kw)
...
@@ -16,6 +19,17 @@ result = context.getPriceParameterDict(context=movement, **kw)
# It can be seen as a way to define a pricing model that not only
# It can be seen as a way to define a pricing model that not only
# depends on discrete variations, but also on a continuous property
# depends on discrete variations, but also on a continuous property
# of the object
# of the object
if
result
[
"sliced_base_price"
]:
total_price
=
0.
quantity
=
movement
.
getQuantity
()
sliced_base_price_list
=
result
[
"sliced_base_price"
]
for
sliced_base_price
in
sliced_base_price_list
:
slice_min
,
slice_max
=
sliced_base_price
[
'sliced_range'
]
if
slice_max
is
None
:
slice_max
=
quantity
+
1
priced_quantity
=
min
(
slice_max
-
1
,
quantity
)
-
(
slice_min
-
1
)
total_price
+=
priced_quantity
*
sliced_base_price
[
'price'
]
result
[
"base_price"
]
=
total_price
/
quantity
base_price
=
result
[
"base_price"
]
base_price
=
result
[
"base_price"
]
if
base_price
in
(
None
,
""
):
if
base_price
in
(
None
,
""
):
...
...
product/ERP5/Document/Resource.py
View file @
83b13388
...
@@ -712,6 +712,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
...
@@ -712,6 +712,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
'non_discountable_additional_price'
:
[],
'non_discountable_additional_price'
:
[],
'priced_quantity'
:
None
,
'priced_quantity'
:
None
,
'base_unit_price'
:
None
,
'base_unit_price'
:
None
,
'sliced_base_price'
:
[],
}
}
if
mapped_value
is
None
:
if
mapped_value
is
None
:
return
price_parameter_dict
return
price_parameter_dict
...
...
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