-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD]account_statement_import_online_plaid
- Loading branch information
1 parent
890eeab
commit 71cd063
Showing
19 changed files
with
12,365 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,126 @@ | ||
================================= | ||
Online Bank Statements: plaid.com | ||
================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:a7b84e04274ce7746346dbb4b33c1d2d98df5306dfde3a173ce2982576104eae | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/16.0/account_statement_import_online_plaid | ||
: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-16-0/bank-statement-import-16-0-account_statement_import_online_plaid | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module provides online bank statements from Plaid.com. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To configure online bank statements provider: | ||
|
||
#. Go to *Invoicing > Configuration > Bank Accounts* | ||
#. Open bank account to configure and edit it | ||
#. Set *Bank Feeds* to *Online* | ||
#. Select *Plaid.com* as online bank statements provider in | ||
*Online Bank Statements (OCA)* section | ||
#. Save the bank account | ||
#. Click on provider and configure provider-specific settings. | ||
|
||
or, alternatively: | ||
|
||
#. Go to *Invoicing > Overview* | ||
#. Open settings of the corresponding journal account | ||
#. Switch to *Bank Account* tab | ||
#. Set *Bank Feeds* to *Online* | ||
#. Select *Plaid.com* as online bank statements provider in | ||
*Online Bank Statements (OCA)* section | ||
#. Save the bank account | ||
#. Click on provider and configure provider-specific settings. | ||
|
||
To obtain *Login* and *Key*: | ||
|
||
#. Open `Plaid.com <https://plaid.com/>`_. | ||
|
||
Check also ``account_bank_statement_import_online`` configuration instructions | ||
for more information. | ||
|
||
Usage | ||
===== | ||
|
||
To pull historical bank statements: | ||
|
||
#. Go to *Invoicing > Configuration > Bank Accounts* | ||
#. Select specific bank accounts | ||
#. Configure username, password and host for plaid | ||
#. Launch *Actions > Sync with plaid.com* | ||
|
||
#. After launch *Actions > Online Bank Statements Pull Wizard* | ||
#. Configure date interval and click *Pull* | ||
|
||
If historical data is not needed, then just simply wait for the scheduled | ||
activity "Pull Online Bank Statements" to be executed for getting new | ||
transactions. | ||
|
||
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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_online_plaid%0Aversion:%2016.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 | ||
~~~~~~~ | ||
|
||
* Binhex | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Binhex <https://binhex.cloud>`_: | ||
|
||
* Adasat Torres de León <a.torres@binhex.cloud> | ||
|
||
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/16.0/account_statement_import_online_plaid>`_ 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,3 @@ | ||
# License AGPL-3.0 or later (https://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,23 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Online Bank Statements: plaid.com", | ||
"version": "16.0.1.0.0", | ||
"category": "Account", | ||
"website": "https://github.com/OCA/bank-statement-import", | ||
"author": "Binhex, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["account_statement_import_online"], | ||
"data": [ | ||
"views/online_bank_statement_provider.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"/account_statement_import_online_plaid/static/src/**/*.js", | ||
], | ||
}, | ||
"external_dependencies": { | ||
"python": ["plaid-python"], | ||
}, | ||
} |
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,102 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_statement_import_online_plaid | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0-20240104\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-05-22 12:02+0000\n" | ||
"PO-Revision-Date: 2024-05-22 13:04+0100\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Generator: Poedit 3.4.3\n" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model.fields.selection,name:account_statement_import_online_plaid.selection__online_bank_statement_provider__plaid_host__development | ||
msgid "Development" | ||
msgstr "Desarrollo" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#. odoo-python | ||
#: code:addons/account_statement_import_online_plaid/models/plaid_interface.py:0 | ||
#, python-format | ||
msgid "Error getting access token: %s" | ||
msgstr "Error al obtener el token de acceso: %s" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#. odoo-python | ||
#: code:addons/account_statement_import_online_plaid/models/plaid_interface.py:0 | ||
#, python-format | ||
msgid "Error getting client api: %s" | ||
msgstr "Error obteniendo api de cliente: %s" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#. odoo-python | ||
#: code:addons/account_statement_import_online_plaid/models/plaid_interface.py:0 | ||
#, python-format | ||
msgid "Error getting link token: %s" | ||
msgstr "Error al obtener el token de enlace: %s" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#. odoo-python | ||
#: code:addons/account_statement_import_online_plaid/models/plaid_interface.py:0 | ||
#, python-format | ||
msgid "Error getting transactions: %s" | ||
msgstr "Error al obtener transacciones: %s" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online_plaid.online_bank_statement_provider_form | ||
msgid "Login" | ||
msgstr "Iniciar sesión" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model,name:account_statement_import_online_plaid.model_online_bank_statement_provider | ||
msgid "Online Bank Statement Provider" | ||
msgstr "Proveedor de extractos bancarios en línea" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model.fields,field_description:account_statement_import_online_plaid.field_online_bank_statement_provider__plaid_access_token | ||
msgid "Plaid Access Token" | ||
msgstr "Ficha de acceso Plaid" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model.fields,field_description:account_statement_import_online_plaid.field_online_bank_statement_provider__plaid_host | ||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online_plaid.online_bank_statement_provider_form | ||
msgid "Plaid Host" | ||
msgstr "Anfitrión" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model,name:account_statement_import_online_plaid.model_plaid_interface | ||
msgid "Plaid Interface" | ||
msgstr "Interfaz plaid" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online_plaid.online_bank_statement_provider_form | ||
msgid "Plaid config" | ||
msgstr "Configuración plaid" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model.fields.selection,name:account_statement_import_online_plaid.selection__online_bank_statement_provider__plaid_host__production | ||
msgid "Production" | ||
msgstr "Producción" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model:ir.model.fields.selection,name:account_statement_import_online_plaid.selection__online_bank_statement_provider__plaid_host__sandbox | ||
msgid "Sandbox" | ||
msgstr "Salvadera" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online_plaid.online_bank_statement_provider_form | ||
msgid "Secret Key" | ||
msgstr "LLave secreta" | ||
|
||
#. module: account_statement_import_online_plaid | ||
#: model_terms:ir.ui.view,arch_db:account_statement_import_online_plaid.online_bank_statement_provider_form | ||
msgid "Sync with Plaid.com" | ||
msgstr "Sincronizar con plaid.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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from . import online_bank_statement_provider_plaid | ||
from . import plaid_interface |
90 changes: 90 additions & 0 deletions
90
account_statement_import_online_plaid/models/online_bank_statement_provider_plaid.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,90 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
|
||
|
||
class OnlineBankStatementProvider(models.Model): | ||
_inherit = "online.bank.statement.provider" | ||
plaid_access_token = fields.Char() | ||
plaid_host = fields.Selection( | ||
[ | ||
("development", "Development"), | ||
("sandbox", "Sandbox"), | ||
("production", "Production"), | ||
], | ||
default="sandbox", | ||
) | ||
|
||
def _obtain_statement_data(self, date_since, date_until): | ||
self.ensure_one() | ||
if self.service != "plaid": | ||
return super()._obtain_statement_data(date_since, date_until) | ||
return self._plaid_retrieve_data(date_since, date_until), {} | ||
|
||
@api.model | ||
def _get_available_services(self): | ||
return super()._get_available_services() + [ | ||
("plaid", "Plaid.com"), | ||
] | ||
|
||
def action_sync_with_plaid(self): | ||
self.ensure_one() | ||
plaid_interface = self.env["plaid.interface"] | ||
args = [self.username, self.password, self.plaid_host] | ||
client = plaid_interface._client(*args) | ||
lang = self.env["res.lang"].search([("code", "=", self.env.user.lang)]).iso_code | ||
company_name = self.env.user.company_id.name | ||
country_code = self.env.user.company_id.country_id.code | ||
link_token = plaid_interface._link( | ||
client=client, | ||
language=lang, | ||
country_code=country_code, | ||
company_name=company_name, | ||
products=["transactions"], | ||
) | ||
return { | ||
"type": "ir.actions.client", | ||
"tag": "plaid_login", | ||
"params": { | ||
"call_model": "online.bank.statement.provider", | ||
"call_method": "plaid_create_access_token", | ||
"token": link_token, | ||
"object_id": self.id, | ||
}, | ||
"target": "new", | ||
} | ||
|
||
def _plaid_retrieve_data(self, date_since, date_until): | ||
plaid_interface = self.env["plaid.interface"] | ||
args = [self.username, self.password, self.plaid_host] | ||
client = plaid_interface._client(*args) | ||
transactions = plaid_interface._get_transactions( | ||
client, self.plaid_access_token, date_since, date_until | ||
) | ||
return self._prepare_vals_for_statement(transactions) | ||
|
||
@api.model | ||
def plaid_create_access_token(self, public_token, active_id): | ||
provider = self.browse(active_id) | ||
plaid_interface = self.env["plaid.interface"] | ||
client = plaid_interface._client( | ||
provider.username, provider.password, provider.plaid_host | ||
) | ||
args = [client, public_token] | ||
provider.plaid_access_token = plaid_interface._login(*args) | ||
if provider.plaid_access_token: | ||
return True | ||
return False | ||
|
||
def _prepare_vals_for_statement(self, transactions): | ||
return [ | ||
{ | ||
"date": transaction["date"], | ||
"ref": transaction["name"], | ||
"payment_ref": transaction["name"], | ||
"unique_import_id": transaction["transaction_id"], | ||
"amount": transaction["amount"], | ||
"raw_data": transaction, | ||
} | ||
for transaction in transactions | ||
] |
Oops, something went wrong.