Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Tryton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
Tryton
Commits
9df4acde
Commit
9df4acde
authored
3 years ago
by
Cédric Krier
Browse files
Options
Downloads
Patches
Plain Diff
Reconcile payment clearing line with all statement lines
issue11173 review385851002
parent
b79478a7
Loading
Loading
1 merge request
!114
Return an empty list when the treeview has no selection
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG
+1
-0
1 addition, 0 deletions
CHANGELOG
__init__.py
+3
-0
3 additions, 0 deletions
__init__.py
payment.py
+53
-0
53 additions, 0 deletions
payment.py
statement.py
+38
-14
38 additions, 14 deletions
statement.py
with
95 additions
and
14 deletions
CHANGELOG
+
1
−
0
View file @
9df4acde
* Reconcile payment clearing line with all statement lines
* Use reference field for statement line relation
* Add support for Python 3.10
* Remove support for Python 3.6
...
...
This diff is collapsed.
Click to expand it.
__init__.py
+
3
−
0
View file @
9df4acde
...
...
@@ -9,8 +9,9 @@
Pool
.
register
(
payment
.
Journal
,
payment
.
Payment
,
payment
.
Group
,
payment
.
SucceedStart
,
account
.
Move
,
ir
.
Cron
,
module
=
'
account_payment_clearing
'
,
type_
=
'
model
'
)
Pool
.
register
(
...
...
@@ -12,8 +13,10 @@
payment
.
SucceedStart
,
account
.
Move
,
ir
.
Cron
,
module
=
'
account_payment_clearing
'
,
type_
=
'
model
'
)
Pool
.
register
(
statement
.
Payment
,
statement
.
PaymentGroup
,
statement
.
Statement
,
statement
.
StatementLine
,
module
=
'
account_payment_clearing
'
,
type_
=
'
model
'
,
...
...
This diff is collapsed.
Click to expand it.
payment.py
+
53
−
0
View file @
9df4acde
...
...
@@ -192,6 +192,7 @@
if
not
sum
(
l
.
debit
-
l
.
credit
for
l
in
lines
):
to_reconcile
.
append
(
lines
)
Line
.
reconcile
(
*
to_reconcile
)
cls
.
reconcile_clearing
(
payments
)
@property
def
clearing_account
(
self
):
...
...
@@ -278,6 +279,34 @@
super
(
Payment
,
cls
).
fail
(
payments
)
@classmethod
def
reconcile_clearing
(
cls
,
payments
):
pool
=
Pool
()
MoveLine
=
pool
.
get
(
'
account.move.line
'
)
Group
=
pool
.
get
(
'
account.payment.group
'
)
to_reconcile
=
[]
for
payment
in
payments
:
if
not
payment
.
clearing_move
:
continue
clearing_account
=
payment
.
journal
.
clearing_account
if
not
clearing_account
or
not
clearing_account
.
reconcile
:
continue
lines
=
[
l
for
l
in
payment
.
clearing_lines
if
not
l
.
reconciliation
]
if
lines
and
not
sum
((
l
.
debit
-
l
.
credit
)
for
l
in
lines
):
to_reconcile
.
append
(
lines
)
if
to_reconcile
:
MoveLine
.
reconcile
(
*
to_reconcile
)
Group
.
reconcile_clearing
(
Group
.
browse
(
list
({
p
.
group
for
p
in
payments
if
p
.
group
})))
@property
def
clearing_lines
(
self
):
clearing_account
=
self
.
journal
.
clearing_account
if
self
.
clearing_move
:
for
line
in
self
.
clearing_move
.
lines
:
if
line
.
account
==
clearing_account
:
yield
line
@classmethod
def
copy
(
cls
,
payments
,
default
=
None
):
if
default
is
None
:
default
=
{}
...
...
@@ -287,6 +316,30 @@
return
super
(
Payment
,
cls
).
copy
(
payments
,
default
=
default
)
class
Group
(
metaclass
=
PoolMeta
):
__name__
=
'
account.payment.group
'
@classmethod
def
reconcile_clearing
(
cls
,
groups
):
pool
=
Pool
()
MoveLine
=
pool
.
get
(
'
account.move.line
'
)
to_reconcile
=
[]
for
group
in
groups
:
clearing_account
=
group
.
journal
.
clearing_account
if
not
clearing_account
or
not
clearing_account
.
reconcile
:
continue
lines
=
[
l
for
l
in
group
.
clearing_lines
if
not
l
.
reconciliation
]
if
lines
and
not
sum
((
l
.
debit
-
l
.
credit
)
for
l
in
lines
):
to_reconcile
.
append
(
lines
)
if
to_reconcile
:
MoveLine
.
reconcile
(
*
to_reconcile
)
@property
def
clearing_lines
(
self
):
for
payment
in
self
.
payments
:
yield
from
payment
.
clearing_lines
class
Succeed
(
Wizard
):
"
Succeed Payment
"
__name__
=
'
account.payment.succeed
'
...
...
This diff is collapsed.
Click to expand it.
statement.py
+
38
−
14
View file @
9df4acde
...
...
@@ -8,9 +8,45 @@
from
trytond.transaction
import
Transaction
class
Payment
(
metaclass
=
PoolMeta
):
__name__
=
'
account.payment
'
statement_lines
=
fields
.
One2Many
(
'
account.statement.line
'
,
'
related_to
'
,
"
Statement Lines
"
,
readonly
=
True
)
@property
def
clearing_lines
(
self
):
clearing_account
=
self
.
journal
.
clearing_account
yield
from
super
().
clearing_lines
for
statement_line
in
self
.
statement_lines
:
if
statement_line
.
move
:
for
line
in
statement_line
.
move
.
lines
:
if
line
.
account
==
clearing_account
:
yield
line
class
PaymentGroup
(
metaclass
=
PoolMeta
):
__name__
=
'
account.payment.group
'
statement_lines
=
fields
.
One2Many
(
'
account.statement.line
'
,
'
related_to
'
,
"
Statement Lines
"
,
readonly
=
True
)
@property
def
clearing_lines
(
self
):
clearing_account
=
self
.
journal
.
clearing_account
yield
from
super
().
clearing_lines
for
statement_line
in
self
.
statement_lines
:
if
statement_line
.
move
:
for
line
in
statement_line
.
move
.
lines
:
if
line
.
account
==
clearing_account
:
yield
line
class
Statement
(
metaclass
=
PoolMeta
):
__name__
=
'
account.statement
'
@classmethod
def
create_move
(
cls
,
statements
):
pool
=
Pool
()
...
...
@@ -11,10 +47,9 @@
class
Statement
(
metaclass
=
PoolMeta
):
__name__
=
'
account.statement
'
@classmethod
def
create_move
(
cls
,
statements
):
pool
=
Pool
()
MoveLine
=
pool
.
get
(
'
account.move.line
'
)
Payment
=
pool
.
get
(
'
account.payment
'
)
moves
=
super
(
Statement
,
cls
).
create_move
(
statements
)
...
...
@@ -46,19 +81,8 @@
with
Transaction
().
set_context
(
clearing_date
=
date
):
Payment
.
fail
(
Payment
.
browse
(
payments
))
for
move
,
statement
,
lines
in
moves
:
assert
len
({
l
.
payment
for
l
in
lines
})
==
1
line
=
lines
[
0
]
if
line
.
payment
and
line
.
payment
.
clearing_move
:
clearing_account
=
line
.
payment
.
journal
.
clearing_account
if
clearing_account
.
reconcile
:
to_reconcile
=
[]
for
line
in
move
.
lines
+
line
.
payment
.
clearing_move
.
lines
:
if
(
line
.
account
==
clearing_account
and
not
line
.
reconciliation
):
to_reconcile
.
append
(
line
)
if
not
sum
((
l
.
debit
-
l
.
credit
)
for
l
in
to_reconcile
):
MoveLine
.
reconcile
(
to_reconcile
)
Payment
.
__queue__
.
reconcile_clearing
(
list
(
set
.
union
(
*
to_success
.
values
(),
*
to_fail
.
values
())))
return
moves
def
_group_key
(
self
,
line
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment