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
Levin Zimmermann
erp5
Commits
ae15e7e1
Commit
ae15e7e1
authored
Dec 21, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounting: show the context when showing invalid bank accounts
parent
74a00c76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
28 deletions
+87
-28
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getBankAccountItemList.py
...s/erp5_accounting/AccountModule_getBankAccountItemList.py
+30
-28
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
...emplateItem/portal_components/test.erp5.testAccounting.py
+57
-0
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getBankAccountItemList.py
View file @
ae15e7e1
...
@@ -17,6 +17,7 @@ applicable for section_category and section_category_strict_membership.
...
@@ -17,6 +17,7 @@ applicable for section_category and section_category_strict_membership.
If `base_category` is passed, the currently linked bank account with the specified
If `base_category` is passed, the currently linked bank account with the specified
base_category is anyway included.
base_category is anyway included.
"""
"""
from
Products.ERP5Type.Message
import
translateString
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
...
@@ -58,44 +59,45 @@ else:
...
@@ -58,44 +59,45 @@ else:
item_list
=
[(
''
,
''
)]
item_list
=
[(
''
,
''
)]
# If we have bank accounts from more than one
organisation
, include
# If we have bank accounts from more than one
entity
, include
# the
organisation as hierarchy to show which organisation
the bank
# the
entity as hierarchy to show which entity
the bank
# account belongs to.
# account belongs to.
include_
organisation
_hierarchy
=
len
(
set
(
include_
entity
_hierarchy
=
len
(
set
(
[
'/'
.
join
(
b
.
path
.
split
(
'/'
)[:
-
1
])
for
b
in
bank_account_list
]))
>
1
[
'/'
.
join
(
b
.
path
.
split
(
'/'
)[:
-
1
])
for
b
in
bank_account_list
]))
>
1
bank_account_list
=
[
brain
.
getObject
()
for
brain
in
sorted
(
bank_account_list
=
[
brain
.
getObject
()
for
brain
in
sorted
(
bank_account_list
,
key
=
lambda
b
:
b
.
path
bank_account_list
,
key
=
lambda
b
:
b
.
path
)]
)]
if
base_category
is
not
None
:
current_value
=
context
.
getProperty
(
base_category
+
'_value'
)
if
current_value
not
in
bank_account_list
:
bank_account_list
.
append
(
current_value
)
previous_organisation
=
None
def
getItemList
(
bank_account
):
reference
=
bank_account
.
getReference
()
title
=
bank_account
.
getTitle
()
or
bank_account
.
getSourceFreeText
()
or
bank_account
.
getSourceTitle
()
label
=
title
if
reference
!=
title
:
label
=
'{} - {}'
.
format
(
reference
,
title
)
return
(
label
,
bank_account
.
getRelativeUrl
())
previous_entity
=
None
# sort bank accounts in a way that bank accounts from the same
# sort bank accounts in a way that bank accounts from the same
#
organisation
are consecutive
#
entity
are consecutive
for
bank
in
bank_account_list
:
for
bank
in
bank_account_list
:
if
include_
organisation
_hierarchy
:
if
include_
entity
_hierarchy
:
organisation
=
bank
.
getParentValue
()
entity
=
bank
.
getParentValue
()
if
organisation
!=
previous_organisation
:
if
entity
!=
previous_entity
:
previous_
organisation
=
organisation
previous_
entity
=
entity
# include non-selectable element to show hierarchy
# include non-selectable element to show hierarchy
item_list
.
append
((
organisation
.
getTranslatedTitle
(),
None
))
item_list
.
append
((
entity
.
getTranslatedTitle
(),
None
))
item_list
.
append
(
getItemList
(
bank
))
if
bank
.
getReference
()
and
bank
.
getTitle
()
\
and
bank
.
getReference
()
!=
bank
.
getTitle
():
if
base_category
is
not
None
:
item_list
.
append
((
'%s - %s'
%
(
bank
.
getReference
(),
current_value
=
context
.
getProperty
(
base_category
+
'_value'
)
bank
.
getTitle
()
or
if
current_value
and
current_value
not
in
bank_account_list
:
bank
.
getSourceFreeText
()
or
item_list
.
append
((
bank
.
getSourceTitle
()),
translateString
(
bank
.
getRelativeUrl
()))
'Invalid bank account from ${entity_title}'
,
else
:
mapping
=
{
'entity_title'
:
current_value
.
getParentTitle
()}),
None
))
item_list
.
append
((
bank
.
getReference
()
or
item_list
.
append
(
getItemList
(
current_value
))
bank
.
getTitle
()
or
bank
.
getSourceFreeText
()
or
bank
.
getSourceTitle
(),
bank
.
getRelativeUrl
()
))
return
item_list
return
item_list
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
View file @
ae15e7e1
...
@@ -4835,6 +4835,63 @@ class TestTransactions(AccountingTestCase):
...
@@ -4835,6 +4835,63 @@ class TestTransactions(AccountingTestCase):
(
'from section'
,
bank_account
.
getRelativeUrl
()),
(
'from section'
,
bank_account
.
getRelativeUrl
()),
destination_transaction
.
AccountingTransaction_getDestinationPaymentItemList
())
destination_transaction
.
AccountingTransaction_getDestinationPaymentItemList
())
def
test_AccountingTransaction_getSourcePaymentItemList_bank_accounts_from_other_entities
(
self
):
client_1_bank_account
=
self
.
portal
.
organisation_module
.
client_1
.
newContent
(
portal_type
=
'Bank Account'
,
title
=
'client_1 bank account'
)
client_1_bank_account
.
validate
()
source_transaction
=
self
.
_makeOne
(
portal_type
=
'Payment Transaction'
,
destination_section_value
=
self
.
section
,
# section is client 2 but account is for client 1
source_section_value
=
self
.
organisation_module
.
client_2
,
source_payment_value
=
client_1_bank_account
,
lines
=
(
dict
(
destination_value
=
self
.
account_module
.
goods_purchase
,
destination_debit
=
500
),
dict
(
destination_value
=
self
.
account_module
.
receivable
,
destination_credit
=
500
)))
self
.
assertEqual
(
[
(
str
(
label
),
value
)
for
(
label
,
value
)
in
source_transaction
.
AccountingTransaction_getSourcePaymentItemList
()
],
[
(
''
,
''
),
(
'Invalid bank account from Client 1'
,
None
),
(
'client_1 bank account'
,
client_1_bank_account
.
getRelativeUrl
()),
],
)
destination_transaction
=
self
.
_makeOne
(
portal_type
=
'Payment Transaction'
,
source_section_value
=
self
.
section
,
# section is client 2 but account is for client 1
destination_section_value
=
self
.
organisation_module
.
client_2
,
destination_payment_value
=
client_1_bank_account
,
lines
=
(
dict
(
destination_value
=
self
.
account_module
.
goods_purchase
,
destination_debit
=
500
),
dict
(
destination_value
=
self
.
account_module
.
receivable
,
destination_credit
=
500
)))
self
.
assertEqual
(
[
(
str
(
label
),
value
)
for
(
label
,
value
)
in
destination_transaction
.
AccountingTransaction_getDestinationPaymentItemList
()
],
[
(
''
,
''
),
(
'Invalid bank account from Client 1'
,
None
),
(
'client_1 bank account'
,
client_1_bank_account
.
getRelativeUrl
()),
],
)
class
TestAccountingWithSequences
(
ERP5TypeTestCase
):
class
TestAccountingWithSequences
(
ERP5TypeTestCase
):
"""The first test for Accounting
"""The first test for Accounting
...
...
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