From eac9628718ac961198ddd158a89a502267cffb49 Mon Sep 17 00:00:00 2001 From: "Samuel Macias Oropeza (smo)" Date: Tue, 3 Oct 2023 10:56:44 -0600 Subject: [PATCH] [ADD] l10n_mx_res_partner_csf_regime --- l10n_mx_res_partner_csf_regime/README.rst | 35 +++++++++++++++ l10n_mx_res_partner_csf_regime/__init__.py | 1 + .../__manifest__.py | 23 ++++++++++ .../wizard/__init__.py | 1 + .../wizard/import_csf.py | 43 +++++++++++++++++++ requirements.txt | 2 + .../addons/l10n_mx_res_partner_csf_regime | 1 + setup/l10n_mx_res_partner_csf_regime/setup.py | 6 +++ 8 files changed, 112 insertions(+) create mode 100644 l10n_mx_res_partner_csf_regime/README.rst create mode 100644 l10n_mx_res_partner_csf_regime/__init__.py create mode 100644 l10n_mx_res_partner_csf_regime/__manifest__.py create mode 100644 l10n_mx_res_partner_csf_regime/wizard/__init__.py create mode 100644 l10n_mx_res_partner_csf_regime/wizard/import_csf.py create mode 120000 setup/l10n_mx_res_partner_csf_regime/odoo/addons/l10n_mx_res_partner_csf_regime create mode 100644 setup/l10n_mx_res_partner_csf_regime/setup.py diff --git a/l10n_mx_res_partner_csf_regime/README.rst b/l10n_mx_res_partner_csf_regime/README.rst new file mode 100644 index 000000000..38929e877 --- /dev/null +++ b/l10n_mx_res_partner_csf_regime/README.rst @@ -0,0 +1,35 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. + + +Automatic changelog generation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`HISTORY.rst` can be auto generated using `towncrier `_. + +Just put towncrier compatible changelog fragments into `readme/newsfragments` +and the changelog file will be automatically generated and updated when a new fragment is added. + +Please refer to `towncrier` documentation to know more. + +NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. +If you need to run it manually, refer to `OCA/maintainer-tools README `_. diff --git a/l10n_mx_res_partner_csf_regime/__init__.py b/l10n_mx_res_partner_csf_regime/__init__.py new file mode 100644 index 000000000..40272379f --- /dev/null +++ b/l10n_mx_res_partner_csf_regime/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/l10n_mx_res_partner_csf_regime/__manifest__.py b/l10n_mx_res_partner_csf_regime/__manifest__.py new file mode 100644 index 000000000..3c67a7ccd --- /dev/null +++ b/l10n_mx_res_partner_csf_regime/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2017 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Mexican Localization Fiscal Regime Scan From CSF", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "summary": "Mexican Localization Fiscal Regime Scan From CSF", + "author": "Open Source Integrators", + "maintainer": "Open Source Integrators", + "website": "https://github.com/ursais/osi-addons", + "depends": [ + # Odoo + Enterprise + "contacts", + "l10n_mx_edi_40", + # OCA + "l10n_mx_res_partner_csf", + ], + "external_dependencies": { + "python": ["pdfminer", "pdfminer.six==20220319"], + }, + "application": False, + "maintainers": ["ursais"], +} diff --git a/l10n_mx_res_partner_csf_regime/wizard/__init__.py b/l10n_mx_res_partner_csf_regime/wizard/__init__.py new file mode 100644 index 000000000..1a0fdb07a --- /dev/null +++ b/l10n_mx_res_partner_csf_regime/wizard/__init__.py @@ -0,0 +1 @@ +from . import import_csf diff --git a/l10n_mx_res_partner_csf_regime/wizard/import_csf.py b/l10n_mx_res_partner_csf_regime/wizard/import_csf.py new file mode 100644 index 000000000..96f1121c7 --- /dev/null +++ b/l10n_mx_res_partner_csf_regime/wizard/import_csf.py @@ -0,0 +1,43 @@ +import logging + +from odoo import models + +_logger = logging.getLogger(__name__) + +try: + pass +except ImportError as err: + _logger.debug(err) + +FISCAL_REGIMES_MAPPING = { + "Régimen General de Ley Personas Morales": "601", + "Régimen de Sueldos y Salarios e Ingresos Asimilados a Salarios": "605", + "Régimen de los demás ingresos": "608", + "Régimen de Ingresos por Dividendos (socios y accionistas)": "611", + "Régimen de las Personas Físicas con Actividades Empresariales y Profesionales": "612", + "Régimen de los ingresos por intereses": "614", + "Régimen de Incorporación Fiscal": "621", + "Régimen de las Actividades Empresariales " + "con ingresos a través de Plataformas Tecnológicas": "625", + "Régimen Simplificado de Confianza": "626", +} + + +class ImportCSF(models.TransientModel): + _inherit = "import.csf" + + def prepare_res_partner_values(self, text): + vals = super().prepare_res_partner_values(text) + split_data = text.split("\n") + fiscal_regime = "" + for index, line in enumerate(split_data): + if "Regímenes" in line: + fiscal_regime += split_data[index + 2].strip() + if fiscal_regime == "Régimen": + fiscal_regime = split_data[index + 3].strip() + fiscal_regime = FISCAL_REGIMES_MAPPING[fiscal_regime] + return vals.update( + { + "l10n_mx_edi_fiscal_regime": fiscal_regime, + } + ) diff --git a/requirements.txt b/requirements.txt index 9cd162922..d2a14183d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ # generated from manifests external_dependencies +pdfminer +pdfminer.six==20220319 diff --git a/setup/l10n_mx_res_partner_csf_regime/odoo/addons/l10n_mx_res_partner_csf_regime b/setup/l10n_mx_res_partner_csf_regime/odoo/addons/l10n_mx_res_partner_csf_regime new file mode 120000 index 000000000..68393d5a9 --- /dev/null +++ b/setup/l10n_mx_res_partner_csf_regime/odoo/addons/l10n_mx_res_partner_csf_regime @@ -0,0 +1 @@ +../../../../l10n_mx_res_partner_csf_regime \ No newline at end of file diff --git a/setup/l10n_mx_res_partner_csf_regime/setup.py b/setup/l10n_mx_res_partner_csf_regime/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_mx_res_partner_csf_regime/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)