Skip to content

Commit

Permalink
[IMP] account_move_base_import: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardoalso committed Feb 11, 2025
1 parent 3df0589 commit 97c6317
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 152 deletions.
92 changes: 45 additions & 47 deletions account_move_base_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,57 @@ Journal Entry base import
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github
:target: https://github.com/OCA/account-reconcile/tree/16.0/account_move_base_import
:target: https://github.com/OCA/account-reconcile/tree/18.0/account_move_base_import
:alt: OCA/account-reconcile
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_move_base_import
:target: https://translation.odoo-community.org/projects/account-reconcile-18-0/account-reconcile-18-0-account_move_base_import
: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/account-reconcile&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module is a grouping of 7.0/8.0 modules, used to import accounting files
and completing them automatically:
This module is a grouping of 7.0/8.0 modules, used to import accounting
files and completing them automatically:

* account_statement_base_completion
* account_statement_base_import
* account_statement_commission
* account_statement_ext
- account_statement_base_completion
- account_statement_base_import
- account_statement_commission
- account_statement_ext

The main change is that, in order to import financial data, this information
is now imported directly as a Journal Entry.
The main change is that, in order to import financial data, this
information is now imported directly as a Journal Entry.

Most of the information present in the "statement profile" is now located in
the account journal (with 2 boolean parameters which allows to use
this journal for importation and/or auto-completion).
Most of the information present in the "statement profile" is now
located in the account journal (with 2 boolean parameters which allows
to use this journal for importation and/or auto-completion).

Financial data can be imported using a standard .csv or .xls file (you'll find
it in the 'data' folder). It respects the journal to pass the entries.
Financial data can be imported using a standard .csv or .xls file
(you'll find it in the 'data' folder). It respects the journal to pass
the entries.

This module can handle a commission taken by the payment office and has the
following format:
* __date__: date of the payment
* __amount__: amount paid in the currency of the journal used in the
importation
* __label__: the comunication given by the payment office, used as
communication in the generated entries.
This module can handle a commission taken by the payment office and has
the following format: \* \__date\_\_: date of the payment \*
\__amount\_\_: amount paid in the currency of the journal used in the
importation \* \__label\_\_: the comunication given by the payment
office, used as communication in the generated entries.

Another column which can be used is __commission_amount__, representing
the amount for the commission taken by line.
Another column which can be used is \__commission_amount\_\_,
representing the amount for the commission taken by line.

Afterwards, the goal is to populate the journal items with information that
the bank or office gave you. For this, completion rules can be specified by
journal.
Afterwards, the goal is to populate the journal items with information
that the bank or office gave you. For this, completion rules can be
specified by journal.

Some basic rules are provided in this module:

1) Match from statement line label (based on partner field 'Bank Statement
Label')
2) Match from statement line label (based on partner name)
3) Match from statement line label (based on Invoice reference)
1) Match from statement line label (based on partner field 'Bank
Statement Label') 2) Match from statement line label (based on partner
name) 3) Match from statement line label (based on Invoice reference)

Feel free to extend either the importation method, the completion method, or
both.
Feel free to extend either the importation method, the completion
method, or both.

**Table of contents**

Expand All @@ -79,40 +77,40 @@ both.
Known issues / Roadmap
======================

* As for now, the module does not handle multicurrency imports.
- As for now, the module does not handle multicurrency imports.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_move_base_import%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_move_base_import%0Aversion:%2018.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
~~~~~~~
-------

* Akretion
* Camptocamp

Contributors
~~~~~~~~~~~~
------------

* Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
* Nicolas Bessi <nicolas.bessi@camptocamp.com>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Sébastien Beau <sebastien.beau@akretion.com>
* Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>
- Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
- Nicolas Bessi <nicolas.bessi@camptocamp.com>
- Laurent Mignon <laurent.mignon@acsone.eu>
- Sébastien Beau <sebastien.beau@akretion.com>
- Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
- Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
- Akim Juillerat <akim.juillerat@camptocamp.com>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -124,6 +122,6 @@ 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/account-reconcile <https://github.com/OCA/account-reconcile/tree/16.0/account_move_base_import>`_ project on GitHub.
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/18.0/account_move_base_import>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
9 changes: 3 additions & 6 deletions account_move_base_import/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _get_attachment_data(self, moves, file_stream, ftype):
attachment_data = {
"name": "statement file",
"datas": file_stream,
"store_fname": "{}.{}".format(fields.Date.today(), ftype),
"store_fname": f"{fields.Date.today()}.{ftype}",
"res_model": "account.move",
"res_id": moves[0].id,
}
Expand Down Expand Up @@ -373,7 +373,7 @@ def _move_import(self, parser, file_stream, result_row_list=None, ftype="csv"):
attachment_data = {
"name": "statement file",
"datas": file_stream,
"store_fname": "{}.{}".format(fields.Date.today(), ftype),
"store_fname": f"{fields.Date.today()}.{ftype}",
"res_model": "account.move",
"res_id": move.id,
}
Expand All @@ -388,10 +388,7 @@ def _move_import(self, parser, file_stream, result_row_list=None, ftype="csv"):
raise
except Exception:
error_type, error_value, trbk = sys.exc_info()
st = "Error: {}\nDescription: {}\nTraceback:".format(
error_type.__name__,
error_value,
)
st = f"Error: {error_type.__name__}\nDescription: {error_value}\nTraceback:"
st += "".join(traceback.format_tb(trbk, 30))
raise ValidationError(
_("Statement import error " "The statement cannot be created: %s") % st
Expand Down
10 changes: 2 additions & 8 deletions account_move_base_import/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,7 @@ def button_auto_completion(self):
except Exception as exc:
msg_lines.append(repr(exc))
error_type, error_value, trbk = sys.exc_info()
st = "Error: {}\nDescription: {}\nTraceback:".format(
error_type.__name__,
error_value,
)
st = f"Error: {error_type.__name__}\nDescription: {error_value}\nTraceback:"
st += "".join(traceback.format_tb(trbk, 30))
_logger.error(st)
if res:
Expand All @@ -397,10 +394,7 @@ def button_auto_completion(self):
except Exception as exc:
msg_lines.append(repr(exc))
error_type, error_value, trbk = sys.exc_info()
st = "Error: {}\nDescription: {}\nTraceback:".format(
error_type.__name__,
error_value,
)
st = f"Error: {error_type.__name__}\nDescription: {error_value}\nTraceback:"
st += "".join(traceback.format_tb(trbk, 30))
_logger.error(st)
msg = "\n".join(msg_lines)
Expand Down
10 changes: 6 additions & 4 deletions account_move_base_import/parser/file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

try:
import xlrd
except (ImportError, IOError) as err:
except (OSError, ImportError) as err:
_logger.debug(err)
xlrd = False

Expand All @@ -40,7 +40,7 @@ def __init__(
header=None,
dialect=None,
move_ref=None,
**kwargs
**kwargs,
):
"""
:param char: parse_name: The name of the parser
Expand Down Expand Up @@ -123,7 +123,7 @@ def _parse_csv(self):
csv_file = tempfile.NamedTemporaryFile()
csv_file.write(self.filebuffer)
csv_file.flush()
with open(csv_file.name, "r") as fobj:
with open(csv_file.name) as fobj:
reader = UnicodeDictReader(
fobj, fieldnames=self.fieldnames, dialect=self.dialect
)
Expand All @@ -141,7 +141,9 @@ def _parse_xls(self):
header = sheet.row_values(0)
res = []
for rownum in range(1, sheet.nrows):
res.append(dict(list(zip(header, sheet.row_values(rownum)))))
res.append(
dict(list(zip(header, sheet.row_values(rownum), strict=False)))
)
return res

def _from_csv(self, result_set, conversion_rules):
Expand Down
3 changes: 1 addition & 2 deletions account_move_base_import/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def UnicodeDictReader(utf8_data, **kwargs):
yield {str(key or ""): str(value or "") for key, value in row.items()}


class AccountMoveImportParser(object):

class AccountMoveImportParser:
"""
Generic abstract class for defining parser for different files and
format to import in a bank statement. Inherit from it to create your
Expand Down
3 changes: 3 additions & 0 deletions account_move_base_import/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions account_move_base_import/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Joël Grand-Guillaume \<joel.grandguillaume@camptocamp.com\>
- Nicolas Bessi \<nicolas.bessi@camptocamp.com\>
- Laurent Mignon \<laurent.mignon@acsone.eu\>
- Sébastien Beau \<sebastien.beau@akretion.com\>
- Matthieu Dietrich \<matthieu.dietrich@camptocamp.com\>
- Alexandre Fayolle \<alexandre.fayolle@camptocamp.com\>
- Akim Juillerat \<akim.juillerat@camptocamp.com\>
7 changes: 0 additions & 7 deletions account_move_base_import/readme/CONTRIBUTORS.rst

This file was deleted.

40 changes: 40 additions & 0 deletions account_move_base_import/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
This module is a grouping of 7.0/8.0 modules, used to import accounting
files and completing them automatically:

- account_statement_base_completion
- account_statement_base_import
- account_statement_commission
- account_statement_ext

The main change is that, in order to import financial data, this
information is now imported directly as a Journal Entry.

Most of the information present in the "statement profile" is now
located in the account journal (with 2 boolean parameters which allows
to use this journal for importation and/or auto-completion).

Financial data can be imported using a standard .csv or .xls file
(you'll find it in the 'data' folder). It respects the journal to pass
the entries.

This module can handle a commission taken by the payment office and has
the following format: \* \_\_date\_\_: date of the payment \*
\_\_amount\_\_: amount paid in the currency of the journal used in the
importation \* \_\_label\_\_: the comunication given by the payment
office, used as communication in the generated entries.

Another column which can be used is \_\_commission_amount\_\_,
representing the amount for the commission taken by line.

Afterwards, the goal is to populate the journal items with information
that the bank or office gave you. For this, completion rules can be
specified by journal.

Some basic rules are provided in this module:

1\) Match from statement line label (based on partner field 'Bank
Statement Label') 2) Match from statement line label (based on partner
name) 3) Match from statement line label (based on Invoice reference)

Feel free to extend either the importation method, the completion
method, or both.
42 changes: 0 additions & 42 deletions account_move_base_import/readme/DESCRIPTION.rst

This file was deleted.

1 change: 1 addition & 0 deletions account_move_base_import/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- As for now, the module does not handle multicurrency imports.
1 change: 0 additions & 1 deletion account_move_base_import/readme/ROADMAP.rst

This file was deleted.

Loading

0 comments on commit 97c6317

Please sign in to comment.