-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
361 additions
and
0 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,88 @@ | ||
=========================== | ||
Bank Account Reconciliation | ||
=========================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| 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 | ||
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-reconcile/tree/12.0/account_banking_reconciliation | ||
:alt: OCA/account-reconcile | ||
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/account-reconcile-12-0/account-reconcile-12-0-account_banking_reconciliation | ||
:alt: Translate me on Weblate | ||
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/98/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| | ||
|
||
This module is designed to help users track when invoices and payments are reconciled | ||
|
||
Usage | ||
===== | ||
|
||
To use this module: | ||
|
||
* Create an invoice | ||
* Create a payment for that invoice | ||
* Reconcile both entries | ||
* Observe "Reconciliation Date" has been set on both records | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-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 <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_banking_reconciliation%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Open Source Integrators | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Steven Campbell <scampbell@opensourceintegrators.com> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
* Open Source Integrators <https://www.opensourceintegrators.com> | ||
|
||
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. | ||
|
||
.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px | ||
:target: https://github.com/max3903 | ||
:alt: max3903 | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-max3903| | ||
|
||
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/12.0/account_banking_reconciliation>`_ 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,4 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
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,18 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Reconciliation Date", | ||
"summary": "Track Reconciliation Date of Payments and Invoices", | ||
"version": "12.0.1.0.0", | ||
"depends": ["account"], | ||
"author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
"website": "http://www.github.com/OCA/account-reconcile", | ||
"category": "Finance", | ||
'license': 'AGPL-3', | ||
"data": [ | ||
'views/account_invoice.xml', | ||
'views/account_payment.xml' | ||
], | ||
'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,6 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import account_full_reconcile | ||
from . import account_invoice | ||
from . import account_payment |
26 changes: 26 additions & 0 deletions
26
account_reconcile_reconciliation_date/models/account_full_reconcile.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,26 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from datetime import date | ||
from odoo import api, fields, models | ||
|
||
|
||
class AccountFullReconcile(models.Model): | ||
_inherit = "account.full.reconcile" | ||
_description = "Full Reconcile" | ||
|
||
reconciliation_date = fields.Date(string="Reconciliation Date", | ||
default=date.today()) | ||
|
||
@api.model | ||
def create(self, vals): | ||
res = super().create(vals) | ||
for reconcile_id in res: | ||
for line_id in reconcile_id.reconciled_line_ids: | ||
if line_id.payment_id: | ||
line_id.payment_id.reconciliation_date = reconcile_id.\ | ||
reconciliation_date | ||
if line_id.invoice_id: | ||
line_id.invoice_id.reconciliation_date = reconcile_id.\ | ||
reconciliation_date | ||
return res |
10 changes: 10 additions & 0 deletions
10
account_reconcile_reconciliation_date/models/account_invoice.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,10 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
reconciliation_date = fields.Date(string="Reconciliation Date") |
10 changes: 10 additions & 0 deletions
10
account_reconcile_reconciliation_date/models/account_payment.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,10 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountPayment(models.Model): | ||
_inherit = "account.payment" | ||
|
||
reconciliation_date = fields.Date(string="Reconciliation Date") |
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 @@ | ||
* Steven Campbell <scampbell@opensourceintegrators.com> |
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 @@ | ||
This module is designed to help users track when invoices and payments are reconciled |
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 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_account_reconcile_reconciliation_date |
165 changes: 165 additions & 0 deletions
165
account_reconcile_reconciliation_date/tests/test_account_reconcile_reconciliation_date.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,165 @@ | ||
# Copyright (C) 2019, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase | ||
import time | ||
|
||
|
||
class TestAccountReconcileReconciliationDate(AccountingTestCase): | ||
def setUp(self): | ||
super(TestAccountReconcileReconciliationDate, self).setUp() | ||
self.register_payments_model = self.env['account.register.payments'].\ | ||
with_context(active_model='account.invoice') | ||
self.payment_model = self.env['account.payment'] | ||
self.invoice_model = self.env['account.invoice'] | ||
self.invoice_line_model = self.env['account.invoice.line'] | ||
self.acc_bank_stmt_model = self.env['account.bank.statement'] | ||
self.acc_bank_stmt_line_model = self.\ | ||
env['account.bank.statement.line'] | ||
|
||
self.partner_agrolait = self.env.ref("base.res_partner_2") | ||
self.partner_china_exp = self.env.ref("base.res_partner_3") | ||
self.currency_chf_id = self.env.ref("base.CHF").id | ||
self.currency_usd_id = self.env.ref("base.USD").id | ||
self.currency_eur_id = self.env.ref("base.EUR").id | ||
|
||
company = self.env.ref('base.main_company') | ||
self.cr.\ | ||
execute("UPDATE res_company SET currency_id = %s WHERE id = %s", | ||
[self.currency_eur_id, company.id]) | ||
self.product = self.env.ref("product.product_product_4") | ||
self.payment_method_manual_in = self.env.\ | ||
ref("account.account_payment_method_manual_in") | ||
self.payment_method_manual_out = self.env.\ | ||
ref("account.account_payment_method_manual_out") | ||
|
||
self.account_receivable = self.env['account.account'].\ | ||
search([('user_type_id', '=', self. | ||
env.ref('account.data_account_type_receivable').id)], | ||
limit=1) | ||
self.account_payable = self.env['account.account'].\ | ||
search([('user_type_id', '=', self.env. | ||
ref('account.data_account_type_payable').id)], limit=1) | ||
self.account_revenue = self.env['account.account'].\ | ||
search([('user_type_id', '=', self.env. | ||
ref('account.data_account_type_revenue').id)], limit=1) | ||
|
||
self.bank_journal_euro = self.env['account.journal'].\ | ||
create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'}) | ||
self.account_eur = self.bank_journal_euro.default_debit_account_id | ||
|
||
self.bank_journal_usd = self.env['account.journal'].\ | ||
create({'name': 'Bank US', | ||
'type': 'bank', | ||
'code': 'BNK68', | ||
'currency_id': self.currency_usd_id}) | ||
self.account_usd = self.bank_journal_usd.default_debit_account_id | ||
|
||
self.transfer_account = self.env['res.users'].\ | ||
browse(self.env.uid).company_id.transfer_account_id | ||
self.diff_income_account = self.env['res.users'].\ | ||
browse(self.env.uid).company_id.\ | ||
income_currency_exchange_account_id | ||
self.diff_expense_account = self.env['res.users'].\ | ||
browse(self.env.uid).company_id.\ | ||
expense_currency_exchange_account_id | ||
|
||
def create_invoice(self, amount=100, | ||
type='out_invoice', currency_id=None, | ||
partner=None, account_id=None): | ||
""" Returns an open invoice """ | ||
invoice = self.invoice_model.create({ | ||
'partner_id': partner or self.partner_agrolait.id, | ||
'currency_id': currency_id or self.currency_eur_id, | ||
'name': type, | ||
'account_id': account_id or self.account_receivable.id, | ||
'type': type, | ||
'date_invoice': time.strftime('%Y') + '-06-26', | ||
}) | ||
self.invoice_line_model.create({ | ||
'product_id': self.product.id, | ||
'quantity': 1, | ||
'price_unit': amount, | ||
'invoice_id': invoice.id, | ||
'name': 'something', | ||
'account_id': self.account_revenue.id, | ||
}) | ||
invoice.action_invoice_open() | ||
return invoice | ||
|
||
def reconcile(self, liquidity_aml, | ||
amount=0.0, amount_currency=0.0, currency_id=None): | ||
""" Reconcile a journal entry corresponding \ | ||
to a payment with its bank statement line """ | ||
bank_stmt = self.acc_bank_stmt_model.create({ | ||
'journal_id': liquidity_aml.journal_id.id, | ||
'date': time.strftime('%Y') + '-07-15', | ||
}) | ||
bank_stmt_line = self.acc_bank_stmt_line_model.create({ | ||
'name': 'payment', | ||
'statement_id': bank_stmt.id, | ||
'partner_id': self.partner_agrolait.id, | ||
'amount': amount, | ||
'amount_currency': amount_currency, | ||
'currency_id': currency_id, | ||
'date': time.strftime('%Y') + '-07-15' | ||
}) | ||
|
||
bank_stmt_line.process_reconciliation(payment_aml_rec=liquidity_aml) | ||
return bank_stmt | ||
|
||
def test_full_payment_process(self): | ||
""" Create a payment for two invoices, \ | ||
post it and reconcile it with a bank statement """ | ||
inv_1 = self.create_invoice(amount=100, | ||
currency_id=self.currency_eur_id, | ||
partner=self.partner_agrolait.id) | ||
inv_2 = self.create_invoice(amount=200, | ||
currency_id=self.currency_eur_id, | ||
partner=self.partner_agrolait.id) | ||
|
||
ctx = {'active_model': 'account.invoice', | ||
'active_ids': [inv_1.id, inv_2.id]} | ||
register_payments = self.register_payments_model.\ | ||
with_context(ctx).\ | ||
create({ | ||
'payment_date': time.strftime('%Y') + '-07-15', | ||
'journal_id': self.bank_journal_euro.id, | ||
'payment_method_id': self.payment_method_manual_in.id, | ||
}) | ||
register_payments.create_payments() | ||
payment = self.payment_model.search([], order="id desc", limit=1) | ||
|
||
self.assertAlmostEquals(payment.amount, 300) | ||
self.assertEqual(payment.state, 'posted') | ||
self.assertEqual(payment.state, 'posted') | ||
self.assertEqual(inv_1.state, 'paid') | ||
self.assertEqual(inv_2.state, 'paid') | ||
|
||
self.assertRecordValues(payment.move_line_ids, [ | ||
{'account_id': self.account_eur.id, | ||
'debit': 300.0, | ||
'credit': 0.0, | ||
'amount_currency': 0, | ||
'currency_id': False}, | ||
{'account_id': inv_1.account_id.id, | ||
'debit': 0.0, | ||
'credit': 300.0, | ||
'amount_currency': 0, | ||
'currency_id': False}, | ||
]) | ||
self.assertTrue(payment.move_line_ids. | ||
filtered(lambda l: l.account_id == inv_1.account_id) | ||
[0].full_reconcile_id) | ||
|
||
liquidity_aml = payment.move_line_ids.\ | ||
filtered(lambda r: r.account_id == self.account_eur) | ||
bank_statement = self.reconcile(liquidity_aml, 200, 0, False) | ||
|
||
self.assertEqual(liquidity_aml.statement_id, bank_statement) | ||
self.assertEqual(liquidity_aml.statement_line_id, | ||
bank_statement.line_ids[0]) | ||
|
||
self.assertEqual(payment.state, 'reconciled') | ||
self.assertEqual(payment.reconciliation_date, | ||
inv_1.reconciliation_date) |
14 changes: 14 additions & 0 deletions
14
account_reconcile_reconciliation_date/views/account_invoice.xml
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,14 @@ | ||
<odoo> | ||
|
||
<record id="account_invoice_reconciliation_date" model="ir.ui.view"> | ||
<field name="name">account.invoice.reconciliation.date</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="date_due" position="after"> | ||
<field name="reconciliation_date" invisible="[('reconciliation_date', '=', False)]"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
14 changes: 14 additions & 0 deletions
14
account_reconcile_reconciliation_date/views/account_payment.xml
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,14 @@ | ||
<odoo> | ||
|
||
<record id="account_payment_reconciliation_date" model="ir.ui.view"> | ||
<field name="name">account.payment.reconciliation.date</field> | ||
<field name="model">account.payment</field> | ||
<field name="inherit_id" ref="account.view_account_payment_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="payment_date" position="after"> | ||
<field name="reconciliation_date" invisible="[('reconciliation_date', '=', False)]"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |