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
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
Paul Graydon
erp5
Commits
fe662482
Commit
fe662482
authored
Jan 30, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testTradeModelLine py3
parent
80aec86a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testTradeModelLine.py
...ateItem/portal_components/test.erp5.testTradeModelLine.py
+8
-5
No files found.
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testTradeModelLine.py
View file @
fe662482
...
@@ -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.
...
@@ -1291,9 +1292,11 @@ return lambda *args, **kw: 1""")
...
@@ -1291,9 +1292,11 @@ 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 next assertion is commented out until we have clear specification
# of what we wish with rounding
# of what we wish with rounding
expectedFailure
(
self
.
assertEqual
)(
2
,
len
(
amount_list
))
# XXX 1 or 2 ???
# self.assertEqual(2, len(amount_list)) # XXX 1 or 2 ???
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