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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
a718073e
Commit
a718073e
authored
Oct 24, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into zope4py2
parents
8098941a
3e5ca320
Pipeline
#24342
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
+60
-3
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.py
...rp5_accounting/AccountingTransaction_guessGroupedLines.py
+5
-3
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
...emplateItem/portal_components/test.erp5.testAccounting.py
+55
-0
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.py
View file @
a718073e
...
...
@@ -75,12 +75,14 @@ changed_line_list = []
for
(
node
,
section
,
mirror_section
,
_
),
line_info_list
in
lines_per_node
.
items
():
if
node
is
None
:
continue
total_price
=
sum
([
l
[
'total_price'
]
for
l
in
line_info_list
])
# get the currency rounding for this section
# get the currency rounding for this section, with a fallback that something that would
# allow grouping in case precision is not defined.
currency_precision
=
5
if
section
:
default_currency
=
portal
.
restrictedTraverse
(
section
).
getPriceCurrencyValue
()
if
default_currency
is
not
None
:
total_price
=
round
(
total_price
,
default_currency
.
getQuantityPrecision
())
currency_precision
=
default_currency
.
getQuantityPrecision
()
total_price
=
round
(
sum
([
l
[
'total_price'
]
for
l
in
line_info_list
]),
currency_precision
)
if
total_price
==
0
or
allow_grouping_with_different_quantity
:
# we should include mirror node in the id_group, but this would reset
# id generators and generate grouping references that were already used.
...
...
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py
View file @
a718073e
...
...
@@ -3786,6 +3786,61 @@ class TestTransactions(AccountingTestCase):
self
.
tic
()
self
.
assertFalse
(
payment
.
line_with_grouping_reference
.
getGroupingReference
())
def
test_grouping_reference_rounding
(
self
):
"""Reproduction of a bug that grouping was not possible because of rounding error
>>> 0.1 + 0.2 - 0.3 == 0
False
"""
invoice
=
self
.
_makeOne
(
title
=
'Invoice'
,
destination_section_value
=
self
.
organisation_module
.
client_1
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
goods_purchase
,
source_debit
=
0.3
),
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_credit
=
0.1
,
id
=
'line_1'
),
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_credit
=
0.2
,
id
=
'line_2'
)))
payment
=
self
.
_makeOne
(
title
=
'Invoice Payment'
,
portal_type
=
'Payment Transaction'
,
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_3'
,
source_debit
=
0.3
),
dict
(
source_value
=
self
.
account_module
.
bank
,
source_credit
=
0.3
,)))
self
.
tic
()
grouped
=
invoice
.
AccountingTransaction_guessGroupedLines
(
accounting_transaction_line_uid_list
=
(
invoice
.
line_1
.
getUid
(),
invoice
.
line_2
.
getUid
(),
payment
.
line_3
.
getUid
(),
))
self
.
assertEqual
(
sorted
(
grouped
),
sorted
([
invoice
.
line_1
.
getRelativeUrl
(),
invoice
.
line_2
.
getRelativeUrl
(),
payment
.
line_3
.
getRelativeUrl
(),
]))
self
.
tic
()
def
test_grouping_reference_rounding_without_accounting_currency_on_section
(
self
):
accounting_currency
=
self
.
section
.
getPriceCurrency
()
self
.
assertTrue
(
accounting_currency
)
self
.
section
.
setPriceCurrency
(
None
)
try
:
self
.
test_grouping_reference_rounding
()
finally
:
self
.
abort
()
self
.
section
.
setPriceCurrency
(
accounting_currency
)
self
.
tic
()
def
test_automatically_setting_grouping_reference
(
self
):
invoice
=
self
.
_makeOne
(
title
=
'First Invoice'
,
...
...
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