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
Mikolaï Krol
erp5
Commits
414042ad
Commit
414042ad
authored
Aug 31, 2011
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amount generator no longer ignores quantity=0 result like legacy trade model rule.
parent
04e1768e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
46 deletions
+32
-46
bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py
...on_legacy/DocumentTemplateItem/SimulationLegacyPatches.py
+0
-18
bt5/erp5_simulation_legacy/bt/revision
bt5/erp5_simulation_legacy/bt/revision
+1
-1
product/ERP5/mixin/amount_generator.py
product/ERP5/mixin/amount_generator.py
+20
-12
product/ERP5/tests/testComplexTradeModelLineUseCase.py
product/ERP5/tests/testComplexTradeModelLineUseCase.py
+5
-5
product/ERP5/tests/testTradeModelLine.py
product/ERP5/tests/testTradeModelLine.py
+6
-5
product/ERP5Legacy/tests/testLegacyTradeModelLine.py
product/ERP5Legacy/tests/testLegacyTradeModelLine.py
+0
-5
No files found.
bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py
View file @
414042ad
...
...
@@ -32,24 +32,6 @@ def patch():
ERP5Site
.
getPortalBusinessPathTypeList
=
getPortalBusinessPathTypeList
## AmountGeneratorMixin
class
true
:
def
__nonzero__
(
self
):
warnings
.
warn
(
"Default value for 'generate_empty_amounts' parameter"
" is False for new simulation"
,
DeprecationWarning
)
return
True
true
=
true
()
from
Products.ERP5.mixin.amount_generator
import
AmountGeneratorMixin
for
method_id
in
(
'getAggregatedAmountList'
,):
# getGeneratedAmountList
m
=
getattr
(
AmountGeneratorMixin
,
method_id
)
f
=
m
.
im_func
f
=
type
(
f
)(
f
.
func_code
,
f
.
func_globals
,
f
.
func_name
,
f
.
func_defaults
[:
3
]
+
(
true
,),
f
.
func_closure
)
m
=
type
(
m
)(
f
,
None
,
AmountGeneratorMixin
)
setattr
(
AmountGeneratorMixin
,
method_id
,
m
)
## CompositionMixin
composition
.
_LEGACY_SIMULATION
=
True
...
...
bt5/erp5_simulation_legacy/bt/revision
View file @
414042ad
15
\ No newline at end of file
16
\ No newline at end of file
product/ERP5/mixin/amount_generator.py
View file @
414042ad
...
...
@@ -159,8 +159,7 @@ class AmountGeneratorMixin:
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getGeneratedAmountList'
)
def
getGeneratedAmountList
(
self
,
amount_list
=
None
,
rounding
=
False
,
amount_generator_type_list
=
None
,
generate_empty_amounts
=
False
):
amount_generator_type_list
=
None
):
"""
Implementation of a generic transformation algorithm which is
applicable to payroll, tax generation and BOMs. Return the
...
...
@@ -312,8 +311,14 @@ class AmountGeneratorMixin:
if
property_dict
.
get
(
key
,
0
)
in
(
None
,
''
):
del
property_dict
[
key
]
quantity
*=
property_dict
.
pop
(
'quantity'
,
1
)
if
not
(
quantity
or
generate_empty_amounts
):
continue
# Before we ignore 'quantity==0' amount here for better
# performance, but it is not a good idea, especially when the
# first expand causes non-zero quantity and then quantity
# becomes zero.
# if not (quantity or generate_empty_amounts):
# continue
# Backward compatibility
if
getattr
(
self
.
aq_base
,
'create_line'
,
None
)
==
0
:
property_dict
[
'resource'
]
=
None
...
...
@@ -369,8 +374,7 @@ class AmountGeneratorMixin:
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAggregatedAmountList'
)
def
getAggregatedAmountList
(
self
,
amount_list
=
None
,
rounding
=
False
,
amount_generator_type_list
=
None
,
generate_empty_amounts
=
False
):
amount_generator_type_list
=
None
):
"""
Implementation of a generic transformation algorith which is
applicable to payroll, tax generation and BOMs. Return the
...
...
@@ -378,8 +382,7 @@ class AmountGeneratorMixin:
"""
generated_amount_list
=
self
.
getGeneratedAmountList
(
amount_list
=
amount_list
,
rounding
=
rounding
,
amount_generator_type_list
=
amount_generator_type_list
,
generate_empty_amounts
=
generate_empty_amounts
)
amount_generator_type_list
=
amount_generator_type_list
)
# XXX: Do we handle rounding correctly ?
# What to do if only total price is rounded ??
aggregate_dict
=
{}
...
...
@@ -394,10 +397,15 @@ class AmountGeneratorMixin:
else
:
aggregate
[
1
]
+=
amount
.
getQuantity
()
for
amount
,
quantity
in
aggregate_dict
.
itervalues
():
if
quantity
or
generate_empty_amounts
:
amount
.
_setQuantity
(
quantity
)
else
:
result_list
.
remove
(
amount
)
# Before we ignore 'quantity==0' amount here for better
# performance, but it is not a good idea, especially when the
# first expand causes non-zero quantity and then quantity
# becomes zero.
# if quantity or generate_empty_amounts:
# amount._setQuantity(quantity)
# else:
# result_list.remove(amount)
amount
.
_setQuantity
(
quantity
)
if
0
:
print
'getAggregatedAmountList(%r) -> (%s)'
%
(
self
.
getRelativeUrl
(),
...
...
product/ERP5/tests/testComplexTradeModelLineUseCase.py
View file @
414042ad
...
...
@@ -198,7 +198,7 @@ return getBaseAmountQuantity""")
self
.
appendBaseContributionCategory
(
order
[
'2'
],
special_discount
)
transaction
.
commit
()
self
.
getAggregatedAmountDict
(
order
,
partial_check
=
True
,
SPECIAL_DISCOUNT_3CD_LINEAR
=
None
,
SPECIAL_DISCOUNT_3CD_LINEAR
=
dict
(
total_price
=
0
)
,
TOTAL_PRICE_WITHOUT_VAT
=
dict
(
total_price
=
8100
),
TOTAL_PRICE_WITH_VAT
=
dict
(
total_price
=
8505
),
VAT_AMOUNT
=
dict
(
total_price
=
405
))
...
...
@@ -254,7 +254,7 @@ return lambda delivery_amount, base_application, **kw: \\
self
.
appendBaseContributionCategory
(
order
[
'2'
],
special_discount
)
transaction
.
commit
()
self
.
getAggregatedAmountDict
(
order
,
partial_check
=
True
,
SPECIAL_DISCOUNT_3CD_FIXED
=
None
,
SPECIAL_DISCOUNT_3CD_FIXED
=
dict
(
total_price
=
0
)
,
TOTAL_PRICE_WITHOUT_VAT
=
dict
(
total_price
=
11000
),
TOTAL_PRICE_WITH_VAT
=
dict
(
total_price
=
11550
),
VAT_AMOUNT
=
dict
(
total_price
=
550
))
...
...
@@ -314,7 +314,7 @@ return getBaseAmountQuantity""")
self
.
appendBaseContributionCategory
(
order
[
'3'
],
special_discount
)
transaction
.
commit
()
self
.
getAggregatedAmountDict
(
order
,
partial_check
=
True
,
SPECIAL_DISCOUNT_3CD_LINEAR
=
None
,
SPECIAL_DISCOUNT_3CD_LINEAR
=
dict
(
total_price
=
0
)
,
TOTAL_PRICE_WITHOUT_VAT
=
dict
(
total_price
=
11000
),
TOTAL_PRICE_WITH_VAT
=
dict
(
total_price
=
11550
),
VAT_AMOUNT
=
dict
(
total_price
=
550
))
...
...
@@ -374,7 +374,7 @@ return lambda delivery_amount, base_application, **kw: \\
self
.
appendBaseContributionCategory
(
order
[
'1'
],
poster_present_3cd
)
transaction
.
commit
()
self
.
getAggregatedAmountDict
(
order
,
partial_check
=
True
,
SPECIAL_DISCOUNT_3CD_OR_1DVD_FIXED
=
None
,
SPECIAL_DISCOUNT_3CD_OR_1DVD_FIXED
=
dict
(
total_price
=
None
)
,
TOTAL_PRICE_WITHOUT_VAT
=
dict
(
total_price
=
6000
),
TOTAL_PRICE_WITH_VAT
=
dict
(
total_price
=
6300
),
VAT_AMOUNT
=
dict
(
total_price
=
300
))
...
...
@@ -450,7 +450,7 @@ return getBaseAmountQuantity""")
self
.
appendBaseContributionCategory
(
order
[
'4'
],
special_discount
)
transaction
.
commit
()
self
.
getAggregatedAmountDict
(
order
,
partial_check
=
True
,
SPECIAL_DISCOUNT_3CD
=
None
,
SPECIAL_DISCOUNT_3CD
=
dict
(
total_price
=
0
)
,
TOTAL_PRICE_WITHOUT_VAT
=
dict
(
total_price
=
12000
),
TOTAL_PRICE_WITH_VAT
=
dict
(
total_price
=
12600
),
VAT_AMOUNT
=
dict
(
total_price
=
600
))
...
...
product/ERP5/tests/testTradeModelLine.py
View file @
414042ad
...
...
@@ -425,10 +425,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
self
.
assertEqual
(
len
(
simulation_movement_list
),
len
(
result_dict
))
for
use
in
'discount'
,
'tax'
:
total_price
=
expected_result_dict
[
use
].
get
(
line
.
getId
())
if
total_pric
e
:
total_price
=
expected_result_dict
[
use
].
get
(
line
.
getId
())
or
0.0
if
Tru
e
:
sm
=
result_dict
.
pop
(
use
)
self
.
assertEqual
(
str
(
sm
.
getTotalPrice
()),
str
(
total_price
))
self
.
assertEqual
(
str
(
sm
.
getTotalPrice
()
or
0.0
),
str
(
total_price
))
self
.
assertEqual
(
3
,
len
(
sm
.
getCausalityValueList
()))
self
.
assertEqual
(
1
,
len
(
sm
.
getCausalityValueList
(
portal_type
=
self
.
business_link_portal_type
)))
...
...
@@ -853,7 +853,7 @@ return getBaseAmountQuantity""")
(
'tax_share/B'
,):
.
6
,
},
base_application
=
(
0
,))
from
Products.ERP5Type.Document
import
newTempAmount
for
x
in
((
100
,
30
,
10
,
20
,
5
,
12
),
for
x
in
((
100
,
30
,
10
,
0
,
0
,
20
,
5
,
12
),
(
500
,
150
,
20
,
90
,
40
,
120
,
55
,
96
)):
amount
=
newTempAmount
(
self
.
portal
,
'_'
,
quantity
=
x
[
0
],
price
=
1
,
...
...
@@ -880,7 +880,8 @@ return lambda *args, **kw: 1""")
order
=
self
.
createOrder
(
trade_condition
,
(
dict
(),
))
self
.
assertEqual
([],
self
.
getAggregatedAmountList
(
order
))
amount_list
=
order
.
getAggregatedAmountList
()
self
.
assertEqual
([
0
,
0
],
[
x
.
getTotalPrice
()
for
x
in
amount_list
])
for
line
in
trade_condition
.
objectValues
():
line
.
setBaseApplication
(
fixed_quantity
)
amount_list
=
order
.
getAggregatedAmountList
()
...
...
product/ERP5Legacy/tests/testLegacyTradeModelLine.py
View file @
414042ad
...
...
@@ -41,11 +41,6 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
TestComplexTradeModelLineUseCasePurchase
))
return
suite
def
getAggregatedAmountList
(
self
,
amount_generator
,
*
args
,
**
kw
):
kw
.
setdefault
(
'generate_empty_amounts'
,
False
)
return
amount_generator
.
getAggregatedAmountList
(
*
args
,
**
kw
)
TestTradeModelLineMixin
.
getAggregatedAmountList
=
getAggregatedAmountList
###
## TestTradeModelLine
##
...
...
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