-
-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by StefanRijnhart
- Loading branch information
Showing
58 changed files
with
3,092 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
============================================= | ||
Reconcile entries from pseudo bank statements | ||
============================================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github | ||
:target: https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_clearing_account | ||
:alt: OCA/bank-statement-import | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_clearing_account | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/174/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This is a technical modules that you can use to improve the processing of | ||
statement files from payment providers. These statements usually consist | ||
of lines that to be reconciled by customer debts, offset by lines that are | ||
to be reconciled by the imbursements from the payment provider, corrected | ||
for customer credits and the costs of the payment provider. Typically, the | ||
balance of such a statement is zero. Effectively, the counterpart of each | ||
statement line is made on a clearing account and you should keep track of | ||
the balance of the clearing account to see if the payment provider still owes | ||
you money. You can keep track of the account by reconciling each entry on it. | ||
|
||
That is where this module comes in. When importing such a statement, this | ||
module reconciles all the counterparts on the clearing account with one | ||
another. Reconciliation is executed when validating the statement. When | ||
reopening the statement, the reconcilation is undone. | ||
|
||
Known issues | ||
============ | ||
This module does not come with its own tests because it depends on a | ||
statement filter being installed. Instead, it is tested in | ||
`account_bank_statement_import_adyen` | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
In order to enable the reconcilation of the counterparts of zero-balance | ||
statement files from payment providers, you need to make sure that the journal | ||
that is used for these statements have the same default debit account as their | ||
default credit account, and this account is configured for reconciliation. | ||
|
||
Usage | ||
===== | ||
|
||
After installing this module, any statement where the sum of all debit and | ||
credit lines match, and where the default journal account is reconcilable, will | ||
reconcile all posted moved when the statement is confirmed. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_clearing_account%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Opener B.V. | ||
* Vanmoof BV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Stefan Rijnhart <[email protected]> (https://opener.amsterdam) | ||
* Martin Pishpecki <[email protected]> (https://www.vanmoof.com) | ||
* Ronald Portier <[email protected]> (https://therp.nl) | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_clearing_account>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2017 Opener BV (<https://opener.amsterdam>) | ||
# Copyright 2020 Vanmoof BV (<https://www.vanmoof.com>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Reconcile entries from pseudo bank statements", | ||
"version": "13.0.1.0.0", | ||
"author": "Opener B.V., Vanmoof BV, Odoo Community Association (OCA)", | ||
"category": "Banking addons", | ||
"website": "https://github.com/oca/bank-statement-import", | ||
"license": "AGPL-3", | ||
"depends": ["account"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_bank_statement |
86 changes: 86 additions & 0 deletions
86
account_bank_statement_clearing_account/models/account_bank_statement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright 2017 Opener BV (<https://opener.amsterdam>) | ||
# Copyright 2020 Vanmoof BV (<https://www.vanmoof.com>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class BankStatement(models.Model): | ||
_inherit = "account.bank.statement" | ||
|
||
def get_reconcile_clearing_account_lines(self): | ||
""" If this statement qualifies for clearing account reconciliation, | ||
return the relevant lines to (un)reconcile. This is the case if the | ||
default journal account is reconcilable, each statement line has a | ||
counterpart line on this account for the full amount and the sum of | ||
the counterpart lines is zero. | ||
""" | ||
self.ensure_one() | ||
if ( | ||
self.journal_id.default_debit_account_id | ||
!= self.journal_id.default_credit_account_id | ||
or not self.journal_id.default_debit_account_id.reconcile | ||
): | ||
return False | ||
account = self.journal_id.default_debit_account_id | ||
currency = self.journal_id.currency_id or self.company_id.currency_id | ||
|
||
def get_bank_line(st_line): | ||
for line in st_line.journal_entry_ids: | ||
field = "debit" if st_line.amount > 0 else "credit" | ||
if line.account_id == account and not currency.compare_amounts( | ||
line[field], abs(st_line.amount) | ||
): | ||
return line | ||
return False | ||
|
||
move_lines = self.env["account.move.line"] | ||
for st_line in self.line_ids: | ||
bank_line = get_bank_line(st_line) | ||
if not bank_line: | ||
return False | ||
move_lines += bank_line | ||
balance = sum(line.debit - line.credit for line in move_lines) | ||
if not currency.is_zero(balance): | ||
return False | ||
return move_lines | ||
|
||
def reconcile_clearing_account(self): | ||
""" If applicable, reconcile the clearing account lines in case | ||
all lines are still unreconciled. """ | ||
self.ensure_one() | ||
lines = self.get_reconcile_clearing_account_lines() | ||
if not lines or any( | ||
li.matched_debit_ids or li.matched_credit_ids for li in lines | ||
): | ||
return False | ||
lines.reconcile() | ||
return True | ||
|
||
def unreconcile_clearing_account(self): | ||
""" If applicable, unreconcile the clearing account lines | ||
if still fully reconciled with each other. """ | ||
self.ensure_one() | ||
lines = self.get_reconcile_clearing_account_lines() | ||
if not lines: | ||
return False | ||
reconciliation = lines[0].full_reconcile_id | ||
if reconciliation and lines == reconciliation.reconciled_line_ids: | ||
lines.remove_move_reconcile() | ||
return True | ||
return False | ||
|
||
def button_reopen(self): | ||
""" When setting the statement back to draft, unreconcile the | ||
reconciliation on the clearing account """ | ||
res = super(BankStatement, self).button_reopen() | ||
for statement in self: | ||
statement.unreconcile_clearing_account() | ||
return res | ||
|
||
def button_confirm_bank(self): | ||
""" When confirming the statement, trigger the reconciliation of | ||
the lines on the clearing account (if applicable) """ | ||
res = super(BankStatement, self).button_confirm_bank() | ||
for statement in self: | ||
statement.reconcile_clearing_account() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
In order to enable the reconcilation of the counterparts of zero-balance | ||
statement files from payment providers, you need to make sure that the journal | ||
that is used for these statements have the same default debit account as their | ||
default credit account, and this account is configured for reconciliation. |
3 changes: 3 additions & 0 deletions
3
account_bank_statement_clearing_account/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Stefan Rijnhart <[email protected]> (https://opener.amsterdam) | ||
* Martin Pishpecki <[email protected]> (https://www.vanmoof.com) | ||
* Ronald Portier <[email protected]> (https://therp.nl) |
20 changes: 20 additions & 0 deletions
20
account_bank_statement_clearing_account/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
This is a technical modules that you can use to improve the processing of | ||
statement files from payment providers. These statements usually consist | ||
of lines that to be reconciled by customer debts, offset by lines that are | ||
to be reconciled by the imbursements from the payment provider, corrected | ||
for customer credits and the costs of the payment provider. Typically, the | ||
balance of such a statement is zero. Effectively, the counterpart of each | ||
statement line is made on a clearing account and you should keep track of | ||
the balance of the clearing account to see if the payment provider still owes | ||
you money. You can keep track of the account by reconciling each entry on it. | ||
|
||
That is where this module comes in. When importing such a statement, this | ||
module reconciles all the counterparts on the clearing account with one | ||
another. Reconciliation is executed when validating the statement. When | ||
reopening the statement, the reconcilation is undone. | ||
|
||
Known issues | ||
============ | ||
This module does not come with its own tests because it depends on a | ||
statement filter being installed. Instead, it is tested in | ||
`account_bank_statement_import_adyen` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
After installing this module, any statement where the sum of all debit and | ||
credit lines match, and where the default journal account is reconcilable, will | ||
reconcile all posted moved when the statement is confirmed. |
Oops, something went wrong.