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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
dd813bf0
Commit
dd813bf0
authored
2 months ago
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trade: prevent ZeroDivisionError for 0 quantity when using base_price_per_slice
parent
b3bd73bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
...skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
+13
-10
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testResource.py
...tTemplateItem/portal_components/test.erp5.testResource.py
+1
-0
No files found.
bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/Resource_getPriceCalculationOperandDict.py
View file @
dd813bf0
...
@@ -24,16 +24,19 @@ result = context.getPriceParameterDict(context=movement, **kw)
...
@@ -24,16 +24,19 @@ result = context.getPriceParameterDict(context=movement, **kw)
if
result
[
"slice_base_price"
]:
if
result
[
"slice_base_price"
]:
total_price
=
0.
total_price
=
0.
quantity
=
movement
.
getQuantity
()
quantity
=
movement
.
getQuantity
()
sliced_base_price_list
=
zip
(
result
[
"slice_base_price"
],
result
[
"slice_quantity_range"
])
if
quantity
:
for
slice_price
,
slice_range
in
sliced_base_price_list
:
sliced_base_price_list
=
zip
(
result
[
"slice_base_price"
],
result
[
"slice_quantity_range"
])
slice_min
,
slice_max
=
slice_range
for
slice_price
,
slice_range
in
sliced_base_price_list
:
if
slice_max
is
None
:
slice_min
,
slice_max
=
slice_range
slice_max
=
quantity
+
1
if
slice_max
is
None
:
if
slice_min
==
0
:
slice_max
=
quantity
+
1
slice_min
=
1
if
slice_min
==
0
:
priced_quantity
=
min
(
slice_max
-
1
,
quantity
)
-
(
slice_min
-
1
)
slice_min
=
1
total_price
+=
priced_quantity
*
slice_price
priced_quantity
=
min
(
slice_max
-
1
,
quantity
)
-
(
slice_min
-
1
)
result
[
"base_price"
]
=
total_price
/
quantity
total_price
+=
priced_quantity
*
slice_price
result
[
"base_price"
]
=
total_price
/
quantity
else
:
result
[
"base_price"
]
=
0.
base_price
=
result
[
"base_price"
]
base_price
=
result
[
"base_price"
]
if
base_price
in
(
None
,
""
):
if
base_price
in
(
None
,
""
):
...
...
This diff is collapsed.
Click to expand it.
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testResource.py
View file @
dd813bf0
...
@@ -1338,6 +1338,7 @@ class TestResource(ERP5TypeTestCase):
...
@@ -1338,6 +1338,7 @@ class TestResource(ERP5TypeTestCase):
{
'quantity'
:
21
,
'price'
:
198.
/
21
,
'total_price'
:
198.
},
{
'quantity'
:
21
,
'price'
:
198.
/
21
,
'total_price'
:
198.
},
{
'quantity'
:
22
,
'price'
:
206.
/
22
,
'total_price'
:
206.
},
{
'quantity'
:
22
,
'price'
:
206.
/
22
,
'total_price'
:
206.
},
{
'quantity'
:
25
,
'price'
:
230.
/
25
,
'total_price'
:
230.
},
{
'quantity'
:
25
,
'price'
:
230.
/
25
,
'total_price'
:
230.
},
{
'quantity'
:
0.
,
'price'
:
0.
,
'total_price'
:
0.
},
]:
]:
_test
(
**
case
)
_test
(
**
case
)
...
...
This diff is collapsed.
Click to expand it.
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