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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
b7ea0416
Commit
b7ea0416
authored
Jan 30, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testTradeModelLine py3
parent
8f34d4b2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testTradeModelLine.py
...ateItem/portal_components/test.erp5.testTradeModelLine.py
+9
-6
No files found.
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testTradeModelLine.py
View file @
b7ea0416
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
##############################################################################
##############################################################################
from
six.moves
import
UserDict
from
six.moves
import
UserDict
import
functools
import
random
import
random
import
unittest
import
unittest
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
...
@@ -815,7 +816,7 @@ return getBaseAmountQuantity""")
...
@@ -815,7 +816,7 @@ return getBaseAmountQuantity""")
reference
=
'tax3'
),
reference
=
'tax3'
),
))
))
def
createCells
(
line
,
matrix
,
base_application
=
(),
base_contribution
=
()):
def
createCells
(
line
,
matrix
,
base_application
=
(),
base_contribution
=
()):
range_list
=
[
set
()
for
x
in
iter
(
matrix
).
next
(
)]
range_list
=
[
set
()
for
x
in
next
(
iter
(
matrix
)
)]
for
index
in
matrix
:
for
index
in
matrix
:
for
x
,
y
in
zip
(
range_list
,
index
):
for
x
,
y
in
zip
(
range_list
,
index
):
x
.
add
(
y
)
x
.
add
(
y
)
...
@@ -884,7 +885,7 @@ return context""" % (base_amount, base_amount))
...
@@ -884,7 +885,7 @@ return context""" % (base_amount, base_amount))
))
))
total_price
=
order
.
getTotalPrice
()
total_price
=
order
.
getTotalPrice
()
total_ratio
=
reduce
(
lambda
x
,
y
:
x
*
(
1
-
y
),
discount_list
,
1.2
)
total_ratio
=
functools
.
reduce
(
lambda
x
,
y
:
x
*
(
1
-
y
),
discount_list
,
1.2
)
amount_list
=
order
.
getAggregatedAmountList
()
amount_list
=
order
.
getAggregatedAmountList
()
self
.
assertAlmostEqual
(
total_price
*
total_ratio
,
self
.
assertAlmostEqual
(
total_price
*
total_ratio
,
sum
((
x
.
getTotalPrice
()
for
x
in
amount_list
),
total_price
))
sum
((
x
.
getTotalPrice
()
for
x
in
amount_list
),
total_price
))
...
@@ -902,7 +903,7 @@ return context""" % (base_amount, base_amount))
...
@@ -902,7 +903,7 @@ return context""" % (base_amount, base_amount))
}
for
index
,
application
,
contribution
in
lines
]
}
for
index
,
application
,
contribution
in
lines
]
def
check
():
def
check
():
resolver
(
delivery_amount
,
property_dict_list
)
resolver
(
delivery_amount
,
property_dict_list
)
self
.
assertEqual
(
range
(
len
(
property_dict_list
)),
self
.
assertEqual
(
list
(
range
(
len
(
property_dict_list
)
)),
[
x
[
'index'
]
for
x
in
property_dict_list
])
[
x
[
'index'
]
for
x
in
property_dict_list
])
# Case 1: calculation of some base_amount depends on others.
# Case 1: calculation of some base_amount depends on others.
...
@@ -1232,6 +1233,7 @@ return lambda *args, **kw: 1""")
...
@@ -1232,6 +1233,7 @@ return lambda *args, **kw: 1""")
self
.
assertEqual
(
sorted
(
expected_tax
),
self
.
assertEqual
(
sorted
(
expected_tax
),
sorted
(
x
.
getTotalPrice
()
for
x
in
amount_list
))
sorted
(
x
.
getTotalPrice
()
for
x
in
amount_list
))
@
expectedFailure
def
test_tradeModelLineWithRounding
(
self
):
def
test_tradeModelLineWithRounding
(
self
):
"""
"""
Test if trade model line works with rounding.
Test if trade model line works with rounding.
...
@@ -1291,9 +1293,10 @@ return lambda *args, **kw: 1""")
...
@@ -1291,9 +1293,10 @@ return lambda *args, **kw: 1""")
self
.
assertEqual
(
3333
*
0.05
+
171
*
0.05
,
amount
.
getTotalPrice
())
# 175.2
self
.
assertEqual
(
3333
*
0.05
+
171
*
0.05
,
amount
.
getTotalPrice
())
# 175.2
# check the result with rounding
# check the result with rounding
amount_list
=
order
.
getAggregatedAmountList
(
rounding
=
True
)
amount_list
=
order
.
getAggregatedAmountList
(
rounding
=
True
)
# XXX Mark it as expectedFailure until we have clear specification
# XXX Here, the assertion will fail with the current implementation.
# of what we wish with rounding
self
.
assertEqual
(
2
,
len
(
amount_list
))
# XXX 1 or 2 ???
expectedFailure
(
self
.
assertEqual
)(
2
,
len
(
amount_list
))
# XXX 1 or 2 ???
# XXX and here, the result is 175, because round is applied against
# already aggregated single amount.
self
.
assertEqual
(
174
,
getTotalAmount
(
amount_list
))
self
.
assertEqual
(
174
,
getTotalAmount
(
amount_list
))
# check getAggregatedAmountList result of each movement
# check getAggregatedAmountList result of each movement
...
...
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