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
Carlos Ramos Carreño
erp5
Commits
b7f87dac
Commit
b7f87dac
authored
Apr 26, 2022
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_accounting_ui_test: update tests
parent
88f60f5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
24 deletions
+131
-24
bt5/erp5_accounting_ui_test/TestTemplateItem/portal_components/test.erp5.testConversionInSimulation.py
...portal_components/test.erp5.testConversionInSimulation.py
+131
-24
No files found.
bt5/erp5_accounting_ui_test/TestTemplateItem/portal_components/test.erp5.testConversionInSimulation.py
View file @
b7f87dac
...
@@ -313,7 +313,7 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -313,7 +313,7 @@ class TestConversionInSimulation(AccountingTestCase):
delivery_movement
.
getPriceCurrencyValue
())
delivery_movement
.
getPriceCurrencyValue
())
self
.
assertEquals
\
self
.
assertEquals
\
(
invoice_transaction_movement_1
.
getDestinationTotalAssetPrice
(),
(
invoice_transaction_movement_1
.
getDestinationTotalAssetPrice
(),
round
(
655.957
*
delivery_movement
.
getTotalPrice
()
))
655.957
*
invoice_transaction_movement_1
.
getTotalPrice
(
))
self
.
assertEquals
\
self
.
assertEquals
\
(
invoice_transaction_movement_1
.
getSourceTotalAssetPrice
(),
(
invoice_transaction_movement_1
.
getSourceTotalAssetPrice
(),
None
)
None
)
...
@@ -325,7 +325,7 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -325,7 +325,7 @@ class TestConversionInSimulation(AccountingTestCase):
delivery_movement
.
getPriceCurrencyValue
())
delivery_movement
.
getPriceCurrencyValue
())
self
.
assertEquals
\
self
.
assertEquals
\
(
invoice_transaction_movement_2
.
getDestinationTotalAssetPrice
(),
(
invoice_transaction_movement_2
.
getDestinationTotalAssetPrice
(),
round
(
655.957
*
delivery_movement
.
getTotalPrice
()
))
655.957
*
invoice_transaction_movement_2
.
getTotalPrice
(
))
def
test_01_simulation_movement_source_asset_price
(
self
,
quiet
=
0
,
def
test_01_simulation_movement_source_asset_price
(
self
,
quiet
=
0
,
run
=
run_all_test
):
run
=
run_all_test
):
...
@@ -405,7 +405,7 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -405,7 +405,7 @@ class TestConversionInSimulation(AccountingTestCase):
delivery_movement
.
getPriceCurrencyValue
())
delivery_movement
.
getPriceCurrencyValue
())
self
.
assertEquals
\
self
.
assertEquals
\
(
invoice_transaction_movement
.
getSourceTotalAssetPrice
(),
(
invoice_transaction_movement
.
getSourceTotalAssetPrice
(),
round
(
655.957
*
delivery_movement
.
getTotalPrice
()
))
-
655.957
*
invoice_transaction_movement
.
getTotalPrice
(
))
self
.
assertEquals
\
self
.
assertEquals
\
(
invoice_transaction_movement
.
getDestinationTotalAssetPrice
(),
(
invoice_transaction_movement
.
getDestinationTotalAssetPrice
(),
None
)
None
)
...
@@ -478,11 +478,6 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -478,11 +478,6 @@ class TestConversionInSimulation(AccountingTestCase):
related_packing_list
.
stop
()
related_packing_list
.
stop
()
self
.
tic
()
self
.
tic
()
self
.
buildInvoices
()
self
.
buildInvoices
()
related_applied_rule
=
order
.
getCausalityRelatedValue
(
portal_type
=
'Applied Rule'
)
order_movement
=
related_applied_rule
.
contentValues
()[
0
]
delivery_applied_rule
=
order_movement
.
contentValues
()[
0
]
delivery_movement
=
delivery_applied_rule
.
contentValues
()[
0
]
related_invoice
=
related_packing_list
.
getCausalityRelatedValue
(
related_invoice
=
related_packing_list
.
getCausalityRelatedValue
(
portal_type
=
'Sale Invoice Transaction'
)
portal_type
=
'Sale Invoice Transaction'
)
self
.
assertNotEquals
(
related_invoice
,
None
)
self
.
assertNotEquals
(
related_invoice
,
None
)
...
@@ -491,9 +486,113 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -491,9 +486,113 @@ class TestConversionInSimulation(AccountingTestCase):
line_list
=
related_invoice
.
contentValues
(
line_list
=
related_invoice
.
contentValues
(
portal_type
=
self
.
portal
.
getPortalAccountingMovementTypeList
())
portal_type
=
self
.
portal
.
getPortalAccountingMovementTypeList
())
self
.
assertNotEquals
(
line_list
,
None
)
self
.
assertNotEquals
(
line_list
,
None
)
result_list
=
[]
for
line
in
line_list
:
for
line
in
line_list
:
self
.
assertEqual
(
line
.
getDestinationTotalAssetPrice
(),
result_list
.
append
((
line
.
getSource
(),
line
.
getDestinationTotalAssetPrice
()))
round
(
655.957
*
delivery_movement
.
getTotalPrice
()))
self
.
assertEqual
(
line
.
getSourceTotalAssetPrice
(),
None
)
self
.
assertEquals
(
sorted
(
result_list
),
sorted
([
(
'account_module/customer'
,
round
(
-
2
*
(
1
+
0.196
)
*
655.957
)),
(
'account_module/receivable_vat'
,
round
(
2
*
0.196
*
655.957
)),
(
'account_module/sale'
,
round
(
2
*
655.957
))
])
)
self
.
assertEqual
(
len
(
related_invoice
.
checkConsistency
()),
0
)
def
test_01_source_total_asset_price_on_accounting_lines
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""
tests that the delivery builder of the invoice transaction lines
copies the source asset price on the accounting_lines of the invoice
"""
if
not
run
:
return
if
not
quiet
:
printAndLog
(
'test_01_source_total_asset_price_on_accounting_lines'
)
resource
=
self
.
portal
.
product_module
.
newContent
(
portal_type
=
'Product'
,
title
=
'Resource'
,
product_line
=
'apparel'
)
currency
=
self
.
portal
.
currency_module
.
newContent
(
portal_type
=
'Currency'
,
title
=
'euro'
)
currency
.
setBaseUnitQuantity
(
0.01
)
new_currency
=
\
self
.
portal
.
currency_module
.
newContent
(
portal_type
=
'Currency'
)
new_currency
.
setReference
(
'XOF'
)
new_currency
.
setTitle
(
'Francs CFA'
)
new_currency
.
setBaseUnitQuantity
(
1.00
)
self
.
tic
()
#execute transaction
x_curr_ex_line
=
currency
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
price_currency
=
new_currency
.
getRelativeUrl
())
x_curr_ex_line
.
setTitle
(
'Euro to Francs CFA'
)
x_curr_ex_line
.
setBasePrice
(
655.957
)
x_curr_ex_line
.
setStartDate
(
DateTime
(
2008
,
10
,
21
))
x_curr_ex_line
.
setStopDate
(
DateTime
(
2008
,
10
,
22
))
x_curr_ex_line
.
validate
()
self
.
createBusinessProcess
(
currency
)
self
.
tic
()
#execute transaction
client
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
,
title
=
'Client'
,
default_address_region
=
self
.
default_region
)
vendor
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
,
title
=
'Vendor'
,
price_currency
=
new_currency
.
getRelativeUrl
(),
default_address_region
=
self
.
default_region
)
order
=
self
.
portal
.
sale_order_module
.
newContent
(
portal_type
=
'Sale Order'
,
source_value
=
vendor
,
source_section_value
=
vendor
,
destination_value
=
client
,
destination_section_value
=
client
,
start_date
=
DateTime
(
2008
,
10
,
21
),
price_currency_value
=
currency
,
specialise_value
=
self
.
business_process
,
title
=
'Order'
)
order
.
newContent
(
portal_type
=
'Sale Order Line'
,
resource_value
=
resource
,
quantity
=
1
,
price
=
2
)
order
.
confirm
()
self
.
tic
()
self
.
buildPackingLists
()
related_packing_list
=
order
.
getCausalityRelatedValue
(
portal_type
=
'Sale Packing List'
)
self
.
assertNotEquals
(
related_packing_list
,
None
)
related_packing_list
.
start
()
related_packing_list
.
stop
()
self
.
tic
()
self
.
buildInvoices
()
related_invoice
=
related_packing_list
.
getCausalityRelatedValue
(
portal_type
=
'Sale Invoice Transaction'
)
self
.
assertNotEquals
(
related_invoice
,
None
)
related_invoice
.
start
()
self
.
tic
()
line_list
=
related_invoice
.
contentValues
(
portal_type
=
self
.
portal
.
getPortalAccountingMovementTypeList
())
self
.
assertNotEquals
(
line_list
,
None
)
result_list
=
[]
for
line
in
line_list
:
result_list
.
append
((
line
.
getSource
(),
line
.
getSourceTotalAssetPrice
()))
self
.
assertEqual
(
line
.
getDestinationTotalAssetPrice
(),
None
)
self
.
assertEquals
(
sorted
(
result_list
),
sorted
([
(
'account_module/customer'
,
round
(
2
*
(
1
+
0.196
)
*
655.957
)),
(
'account_module/receivable_vat'
,
round
(
-
2
*
0.196
*
655.957
)),
(
'account_module/sale'
,
round
(
-
2
*
655.957
))
])
)
self
.
assertEqual
(
len
(
related_invoice
.
checkConsistency
()),
0
)
def
test_01_diverged_sale_packing_list_destination_total_asset_price
(
def
test_01_diverged_sale_packing_list_destination_total_asset_price
(
self
,
quiet
=
0
,
run
=
run_all_test
):
self
,
quiet
=
0
,
run
=
run_all_test
):
...
@@ -565,8 +664,6 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -565,8 +664,6 @@ class TestConversionInSimulation(AccountingTestCase):
related_packing_list_line_list
=
related_packing_list
.
getMovementList
()
related_packing_list_line_list
=
related_packing_list
.
getMovementList
()
related_packing_list_line
=
related_packing_list_line_list
[
0
]
related_packing_list_line
=
related_packing_list_line_list
[
0
]
self
.
assertEqual
(
related_packing_list_line
.
getQuantity
(),
5.0
)
self
.
assertEqual
(
related_packing_list_line
.
getQuantity
(),
5.0
)
old_destination_asset_price
=
\
round
(
655.957
*
related_packing_list_line
.
getTotalPrice
())
related_packing_list_line
.
edit
(
quantity
=
3.0
)
related_packing_list_line
.
edit
(
quantity
=
3.0
)
self
.
tic
()
self
.
tic
()
...
@@ -587,11 +684,17 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -587,11 +684,17 @@ class TestConversionInSimulation(AccountingTestCase):
invoice_applied_rule
=
delivery_movement
.
contentValues
()[
0
]
invoice_applied_rule
=
delivery_movement
.
contentValues
()[
0
]
invoice_movement
=
invoice_applied_rule
.
contentValues
()[
0
]
invoice_movement
=
invoice_applied_rule
.
contentValues
()[
0
]
invoice_transaction_applied_rule
=
invoice_movement
.
contentValues
()[
0
]
invoice_transaction_applied_rule
=
invoice_movement
.
contentValues
()[
0
]
invoice_transaction_movement
=
\
result_list
=
[]
invoice_transaction_applied_rule
.
contentValues
()[
0
]
for
invoice_transaction_movement
in
invoice_transaction_applied_rule
.
contentValues
():
self
.
assertEqual
(
result_list
.
append
((
invoice_transaction_movement
.
getSource
(),
invoice_transaction_movement
.
getDestinationTotalAssetPrice
()))
invoice_transaction_movement
.
getDestinationTotalAssetPrice
(),
self
.
assertEquals
(
old_destination_asset_price
*
(
3.0
/
5.0
))
sorted
(
result_list
),
sorted
([
(
'account_module/customer'
,
-
2
*
3
*
(
1
+
0.196
)
*
655.957
),
(
'account_module/receivable_vat'
,
2
*
3
*
0.196
*
655.957
),
(
'account_module/sale'
,
2
*
3
*
655.957
)
])
)
def
test_01_diverged_purchase_packing_list_source_total_asset_price
(
def
test_01_diverged_purchase_packing_list_source_total_asset_price
(
...
@@ -664,8 +767,6 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -664,8 +767,6 @@ class TestConversionInSimulation(AccountingTestCase):
related_packing_list_line_list
=
related_packing_list
.
getMovementList
()
related_packing_list_line_list
=
related_packing_list
.
getMovementList
()
related_packing_list_line
=
related_packing_list_line_list
[
0
]
related_packing_list_line
=
related_packing_list_line_list
[
0
]
self
.
assertEqual
(
related_packing_list_line
.
getQuantity
(),
5.0
)
self
.
assertEqual
(
related_packing_list_line
.
getQuantity
(),
5.0
)
old_source_asset_price
=
\
round
(
655.957
*
related_packing_list_line
.
getTotalPrice
())
related_packing_list_line
.
edit
(
quantity
=
3.0
)
related_packing_list_line
.
edit
(
quantity
=
3.0
)
self
.
tic
()
self
.
tic
()
...
@@ -687,11 +788,17 @@ class TestConversionInSimulation(AccountingTestCase):
...
@@ -687,11 +788,17 @@ class TestConversionInSimulation(AccountingTestCase):
invoice_applied_rule
=
delivery_movement
.
contentValues
()[
0
]
invoice_applied_rule
=
delivery_movement
.
contentValues
()[
0
]
invoice_movement
=
invoice_applied_rule
.
contentValues
()[
0
]
invoice_movement
=
invoice_applied_rule
.
contentValues
()[
0
]
invoice_transaction_applied_rule
=
invoice_movement
.
contentValues
()[
0
]
invoice_transaction_applied_rule
=
invoice_movement
.
contentValues
()[
0
]
invoice_transaction_movement
=
\
result_list
=
[]
invoice_transaction_applied_rule
.
contentValues
()[
0
]
for
invoice_transaction_movement
in
invoice_transaction_applied_rule
.
contentValues
():
self
.
assertEqual
(
invoice_transaction_movement
.
\
result_list
.
append
((
invoice_transaction_movement
.
getSource
(),
invoice_transaction_movement
.
getSourceTotalAssetPrice
()))
getSourceTotalAssetPrice
(),
self
.
assertEquals
(
old_source_asset_price
*
(
3.0
/
5.0
))
sorted
(
result_list
),
sorted
([
(
'account_module/customer'
,
2
*
3
*
(
1
+
0.196
)
*
655.957
),
(
'account_module/receivable_vat'
,
-
2
*
3
*
0.196
*
655.957
),
(
'account_module/sale'
,
-
2
*
3
*
655.957
)
])
)
def
test_01_delivery_mode_on_sale_packing_list_and_invoice
(
def
test_01_delivery_mode_on_sale_packing_list_and_invoice
(
self
,
quiet
=
0
,
run
=
run_all_test
):
self
,
quiet
=
0
,
run
=
run_all_test
):
...
...
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