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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
edda8b58
Commit
edda8b58
authored
Sep 27, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounting: do not group lines from different ledgers
parent
86b90bb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
23 deletions
+93
-23
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_getGroupingExtraParameterList.py
...ccountingTransactionLine_getGroupingExtraParameterList.py
+8
-5
product/ERP5/tests/testAccounting.py
product/ERP5/tests/testAccounting.py
+85
-18
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_getGroupingExtraParameterList.py
View file @
edda8b58
...
...
@@ -6,11 +6,14 @@ For instance, we can refuse to group together lines for different order by retur
The returned value must be hashable.
"""
# By default we take into account mirror section.
# The rationale is that when using internal accounting transaction between
# By default we take into account ledger and mirror accounting.
# We consider ledger so that, by default we don't group lines from different ledger.
# This may be customized too, depending on how ledgers are used in customized implementations.
# We consider mirror accounting because that when using internal accounting transaction between
# two entities of the group, the grouping has to be valid for both sides
# (source_section & destination_section).
# This behavior was introduced in nexedi/erp5@f3bebea3 for compatibility,
# some old sites where accounting lines have been grouped together regardless of
# the mirror node can decide to ignore the mirror account.
...
...
@@ -19,5 +22,5 @@ The returned value must be hashable.
# This can be achieved easily by customizing this script.
if
source
:
return
context
.
getSource
(
portal_type
=
'Account'
)
return
context
.
getDestination
(
portal_type
=
'Account'
)
return
context
.
get
Ledger
(),
context
.
get
Source
(
portal_type
=
'Account'
)
return
context
.
get
Ledger
(),
context
.
get
Destination
(
portal_type
=
'Account'
)
product/ERP5/tests/testAccounting.py
View file @
edda8b58
...
...
@@ -241,6 +241,25 @@ class AccountingTestCase(ERP5TypeTestCase):
'erp5_configurator_standard_invoicing_template'
,
'erp5_simulation_test'
)
@
UnrestrictedMethod
def
setUpLedger
(
self
):
# Create Ledger Categories
ledger_category
=
self
.
portal
.
portal_categories
.
ledger
ledger_accounting_category
=
ledger_category
.
get
(
'accounting'
,
None
)
if
ledger_accounting_category
is
None
:
ledger_accounting_category
=
ledger_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'accounting'
)
if
ledger_accounting_category
.
get
(
'general'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'general'
)
if
ledger_accounting_category
.
get
(
'detailed'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'detailed'
)
if
ledger_accounting_category
.
get
(
'other'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'other'
)
# Allow some ledgers on the 'Sale Invoice Transaction' portal type
self
.
portal
.
portal_types
[
'Sale Invoice Transaction'
].
edit
(
ledger
=
[
'accounting/general'
,
'accounting/detailed'
])
class
TestAccounts
(
AccountingTestCase
):
"""Tests Accounts.
...
...
@@ -1169,24 +1188,6 @@ class TestClosingPeriod(AccountingTestCase):
self
.
assertEqual
(
None
,
pl_movement
.
getSourceTotalAssetPrice
())
self
.
assertEqual
(
200.
,
pl_movement
.
getDestinationCredit
())
@
UnrestrictedMethod
def
setUpLedger
(
self
):
# Create Ledger Categories
ledger_category
=
self
.
portal
.
portal_categories
.
ledger
ledger_accounting_category
=
ledger_category
.
get
(
'accounting'
,
None
)
if
ledger_accounting_category
is
None
:
ledger_accounting_category
=
ledger_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'accounting'
)
if
ledger_accounting_category
.
get
(
'general'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'general'
)
if
ledger_accounting_category
.
get
(
'detailed'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'detailed'
)
if
ledger_accounting_category
.
get
(
'other'
,
None
)
is
None
:
ledger_accounting_category
.
newContent
(
portal_type
=
'Category'
,
id
=
'other'
)
# Allow some ledgers on the 'Sale Invoice Transaction' portal type
self
.
portal
.
portal_types
[
'Sale Invoice Transaction'
].
edit
(
ledger
=
[
'accounting/general'
,
'accounting/detailed'
])
def
test_createBalanceOnLedgerWithTransactionsWithNoLedger
(
self
):
self
.
setUpLedger
()
organisation_module
=
self
.
organisation_module
...
...
@@ -3662,6 +3663,72 @@ class TestTransactions(AccountingTestCase):
for
line
in
invoice
.
contentValues
():
self
.
assertTrue
(
line
.
getGroupingReference
())
def
test_automatically_setting_grouping_reference_when_same_ledger
(
self
):
self
.
setUpLedger
()
invoice
=
self
.
_makeOne
(
title
=
'First Invoice'
,
ledger_value
=
self
.
portal
.
portal_categories
.
ledger
.
accounting
.
general
,
destination_section_value
=
self
.
organisation_module
.
client_1
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
goods_purchase
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_credit
=
100
,
id
=
'line_for_grouping_reference'
,)))
invoice_line
=
invoice
.
line_for_grouping_reference
payment
=
self
.
_makeOne
(
title
=
'First Invoice Payment'
,
portal_type
=
'Payment Transaction'
,
simulation_state
=
'delivered'
,
causality_value
=
invoice
,
ledger_value
=
self
.
portal
.
portal_categories
.
ledger
.
accounting
.
general
,
source_payment_value
=
self
.
section
.
newContent
(
portal_type
=
'Bank Account'
),
destination_section_value
=
self
.
organisation_module
.
client_1
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
receivable
,
id
=
'line_for_grouping_reference'
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
bank
,
source_credit
=
100
,)))
payment_line
=
payment
.
line_for_grouping_reference
invoice
.
stop
()
self
.
assertTrue
(
invoice_line
.
getGroupingReference
())
self
.
assertTrue
(
payment_line
.
getGroupingReference
())
def
test_not_automatically_setting_grouping_reference_when_different_ledger
(
self
):
self
.
setUpLedger
()
invoice
=
self
.
_makeOne
(
title
=
'First Invoice'
,
ledger_value
=
self
.
portal
.
portal_categories
.
ledger
.
accounting
.
general
,
destination_section_value
=
self
.
organisation_module
.
client_1
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
goods_purchase
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_credit
=
100
,
id
=
'line_for_grouping_reference'
,)))
invoice_line
=
invoice
.
line_for_grouping_reference
payment
=
self
.
_makeOne
(
title
=
'First Invoice Payment'
,
portal_type
=
'Payment Transaction'
,
simulation_state
=
'delivered'
,
causality_value
=
invoice
,
ledger_value
=
self
.
portal
.
portal_categories
.
ledger
.
accounting
.
detailed
,
source_payment_value
=
self
.
section
.
newContent
(
portal_type
=
'Bank Account'
),
destination_section_value
=
self
.
organisation_module
.
client_1
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
receivable
,
id
=
'line_for_grouping_reference'
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
bank
,
source_credit
=
100
,)))
payment_line
=
payment
.
line_for_grouping_reference
invoice
.
stop
()
self
.
assertFalse
(
invoice_line
.
getGroupingReference
())
self
.
assertFalse
(
payment_line
.
getGroupingReference
())
def
test_roundDebitCredit_raises_if_big_difference
(
self
):
invoice
=
self
.
_makeOne
(
portal_type
=
'Sale Invoice Transaction'
,
...
...
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