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
Hugo Ricateau
erp5
Commits
498355b7
Commit
498355b7
authored
Nov 30, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounting: test for internal invoice transactions
parent
a754a5bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
0 deletions
+121
-0
product/ERP5/tests/testAccounting.py
product/ERP5/tests/testAccounting.py
+121
-0
No files found.
product/ERP5/tests/testAccounting.py
View file @
498355b7
...
@@ -5387,6 +5387,126 @@ class TestAccountingTransactionTemplate(AccountingTestCase):
...
@@ -5387,6 +5387,126 @@ class TestAccountingTransactionTemplate(AccountingTestCase):
self
.
assertTrue
(
'Template%20created.'
in
ret
,
ret
)
self
.
assertTrue
(
'Template%20created.'
in
ret
,
ret
)
self
.
assertEqual
(
2
,
len
(
self
.
accounting_module
.
contentValues
()))
self
.
assertEqual
(
2
,
len
(
self
.
accounting_module
.
contentValues
()))
class
TestInternalInvoiceTransaction
(
AccountingTestCase
):
def
afterSetUp
(
self
):
AccountingTestCase
.
afterSetUp
(
self
)
# Allow internal invoice in accounting module
module_allowed_type_list
=
self
.
portal
.
portal_types
[
'Accounting Transaction Module'
].
getTypeAllowedContentTypeList
()
self
.
portal
.
portal_types
[
'Accounting Transaction Module'
].
setTypeAllowedContentTypeList
(
module_allowed_type_list
+
[
'Internal Invoice Transaction'
,])
# configure mirror accounts
self
.
portal
.
account_module
.
receivable
.
setDestinationValue
(
self
.
portal
.
account_module
.
payable
)
def
test_internal_invoice_transaction
(
self
):
# source accountant create internal invoice and set values for source side
internal_invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Internal Invoice Transaction'
,
title
=
'test invoice'
,
source_section_value
=
self
.
section
,
destination_section_value
=
self
.
main_section
,
start_date
=
DateTime
(
2015
,
1
,
1
),
)
line_1
,
line_2
=
internal_invoice
.
getMovementList
()
line_1
.
edit
(
source_value
=
self
.
portal
.
account_module
.
receivable
,
source_debit
=
100
)
line_2
.
edit
(
source_value
=
self
.
portal
.
account_module
.
goods_sales
,
source_credit
=
100
)
self
.
commit
()
internal_invoice
.
view
()
# no error on view..
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'start_action'
)
self
.
assertEqual
(
'started'
,
internal_invoice
.
getSimulationState
())
# mirror accounts are initialised
self
.
assertEqual
(
self
.
portal
.
account_module
.
payable
,
line_1
.
getDestinationValue
())
self
.
assertEqual
(
None
,
line_2
.
getDestinationValue
())
# destination accountant set values for source side
internal_invoice
.
edit
(
stop_date
=
DateTime
(
2015
,
1
,
2
),
)
# the amounts can be split over multiple accounts
internal_invoice
.
newContent
(
portal_type
=
'Internal Invoice Transaction Line'
,
destination_value
=
self
.
portal
.
account_module
.
refundable_vat
,
destination_debit
=
30
)
internal_invoice
.
newContent
(
portal_type
=
'Internal Invoice Transaction Line'
,
destination_value
=
self
.
portal
.
account_module
.
goods_purchase
,
destination_debit
=
70
)
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'stop_action'
)
self
.
assertEqual
(
'stopped'
,
internal_invoice
.
getSimulationState
())
# the lines are different on source and destination views
source_line_list
=
internal_invoice
.
InternalInvoiceTransaction_viewSource
.
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
self
.
portal
.
REQUEST
)
self
.
assertEqual
(
2
,
len
([
l
for
l
in
source_line_list
if
l
.
isDataLine
()]))
stat_line
,
=
[
l
for
l
in
source_line_list
if
l
.
isStatLine
()]
self
.
assertEqual
(
100
,
stat_line
.
getColumnProperty
(
'source_debit'
))
self
.
assertEqual
(
100
,
stat_line
.
getColumnProperty
(
'source_credit'
))
destination_line_list
=
internal_invoice
.
InternalInvoiceTransaction_viewDestination
.
listbox
.
get_value
(
'default'
,
render_format
=
'list'
,
REQUEST
=
self
.
portal
.
REQUEST
)
self
.
assertEqual
(
3
,
len
([
l
for
l
in
destination_line_list
if
l
.
isDataLine
()]))
stat_line
,
=
[
l
for
l
in
destination_line_list
if
l
.
isStatLine
()]
self
.
assertEqual
(
100
,
stat_line
.
getColumnProperty
(
'destination_debit'
))
self
.
assertEqual
(
100
,
stat_line
.
getColumnProperty
(
'destination_credit'
))
def
test_internal_invoice_transaction_balanced_constraint
(
self
):
internal_invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Internal Invoice Transaction'
,
title
=
'test invoice'
,
source_section_value
=
self
.
section
,
destination_section_value
=
self
.
main_section
,
start_date
=
DateTime
(
2015
,
1
,
1
),
)
line_1
,
line_2
=
internal_invoice
.
getMovementList
()
line_1
.
edit
(
source_value
=
self
.
portal
.
account_module
.
receivable
,
source_debit
=
100
)
line_2
.
edit
(
source_value
=
self
.
portal
.
account_module
.
goods_sales
,
source_credit
=
101
)
with
self
.
assertRaisesRegexp
(
ValidationFailed
,
'.*Transaction is not balanced.*'
):
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'start_action'
)
line_2
.
setSourceCredit
(
100
)
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'start_action'
)
self
.
assertEqual
(
'started'
,
internal_invoice
.
getSimulationState
())
self
.
assertEqual
(
self
.
portal
.
account_module
.
payable
,
line_1
.
getDestinationValue
())
line_3
=
internal_invoice
.
newContent
(
portal_type
=
'Internal Invoice Transaction Line'
,
destination_value
=
self
.
portal
.
account_module
.
refundable_vat
,
destination_debit
=
101
)
with
self
.
assertRaisesRegexp
(
ValidationFailed
,
'.*Transaction is not balanced.*'
):
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'stop_action'
)
line_3
.
setDestinationDebit
(
100
)
self
.
portal
.
portal_workflow
.
doActionFor
(
internal_invoice
,
'stop_action'
)
self
.
assertEqual
(
'stopped'
,
internal_invoice
.
getSimulationState
())
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
@@ -5397,4 +5517,5 @@ def test_suite():
...
@@ -5397,4 +5517,5 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
TestTransactionValidation
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestTransactionValidation
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestAccountingExport
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestAccountingExport
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestAccountingTransactionTemplate
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestAccountingTransactionTemplate
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestInternalInvoiceTransaction
))
return
suite
return
suite
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