[ADD] account_reconcile_payment_order

This commit is contained in:
Holger Brunn
2015-08-04 17:50:21 +02:00
committed by CarlosRoca13
parent b3c36f985c
commit 22428eeec0
6 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
Reconcile payment orders
========================
Payment orders that show up as as one big transaction can be difficult for the accounting to handle if a transfer acount is used. In this case, we need to reconcile this transaction with possibly hunderds of move lines, which can be a bit tiresome. This module tries to recognize transactions deriving from payment orders and propose the unreconciled move lines from this payment order.
Usage
=====
It should just work. What the module does is to search for a payment order in state 'sent' that has the same amount as the statement line, and the same bank account than the statement.
For further information, please visit:
* https://www.odoo.com/forum/help-1
Known issues / Roadmap
======================
* it would be good to check references too, but at least the bank in use here changes some characters, so this doesn't seem to be a general solution.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-reconcile/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
`here <https://github.com/OCA/bank-statement-reconcile/issues/new?body=module:%20account_reconcile_payment_order%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Holger Brunn <hbrunn@therp.nl>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit http://odoo-community.org.

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import models

View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Reconcile payment orders",
"version": "1.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Accounting & Finance",
"summary": "Automatically reconcile all lines from sent payment orders",
"depends": [
'account_banking_payment_transfer',
],
"auto_install": False,
"installable": True,
"application": False,
}

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import account_bank_statement_line

View File

@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2015 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from decimal import Decimal
from openerp import models, api
from openerp.tools.float_utils import float_repr
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
@api.model
def get_possible_payment_orders_for_statement_line(self, this):
"""find orders that might be candidates for matching a statement
line"""
digits = self.env['decimal.precision'].precision_get('Account')
self.env.cr.execute(
'''with order_sums as (
select order_id, sum(amount_currency) as amount
from payment_line
join payment_order o on o.id=order_id
where o.state = 'sent'
group by order_id)
select order_id from order_sums where amount = %s''',
(Decimal(float_repr(abs(this.amount), digits)),))
order_ids = [i for i, in self.env.cr.fetchall()]
# verify that this ids are accessible to the user and from the
# right bank account if applicable
domain = [
('id', 'in', order_ids),
]
if this.bank_account_id.acc_number:
domain.append(
('mode.bank_id.acc_number', '=',
this.bank_account_id.acc_number))
return self.env['payment.order'].search(domain)
@api.model
def get_reconcile_lines_from_order(self, this, orders, excluded_ids=None):
"""return lines to reconcile our statement line with"""
order = orders[0]
return self.env['account.move.line']\
.prepare_move_lines_for_reconciliation_widget(
list(set(order._get_transfer_move_lines())))
@api.model
def get_reconciliation_proposition(self, this, excluded_ids=None):
"""See if we find a set payment order that matches our line. If yes,
return all unreconciled lines from there"""
orders = self.get_possible_payment_orders_for_statement_line(this)
if orders:
reconcile_lines = self.get_reconcile_lines_from_order(
this, orders, excluded_ids=None)
if reconcile_lines:
return reconcile_lines
return super(AccountBankStatementLine, self)\
.get_reconciliation_proposition(this, excluded_ids=excluded_ids)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB