diff --git a/l10n_ch_pain_credit_transfer/README.rst b/l10n_ch_pain_credit_transfer/README.rst new file mode 100644 index 000000000..a90a06746 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/README.rst @@ -0,0 +1,103 @@ +================================== +Switzerland - PAIN Credit Transfer +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dcdd9d8807816c0392d729de3b0c60c6717aa2ffad6485b4b032502cb7f7aebb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fl10n--switzerland-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-switzerland/tree/14.0/l10n_ch_pain_credit_transfer + :alt: OCA/l10n-switzerland +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-switzerland-14-0/l10n-switzerland-14-0-l10n_ch_pain_credit_transfer + :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/l10n-switzerland&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds support for *pain.001.001.03.ch.02* which is used for ISO 20022 credit transfers in Switzerland (SEPA or not SEPA). + +It implements the guidelines for `ISO 20022 credit transfers `_ published by SIX Interbank Clearing. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +In the menu *Accounting > Configuration > Management > Payment Methods*, +select the payment method that has the code *sepa_credit_transfer* and +set the *PAIN Version* to *pain.001.001.03.ch.02 (credit transfer in Switzerland)*. + +Usage +===== + +This module doesn't modify the standard usage of the modules +*account_payment_order* and *account_banking_sepa_credit_transfer*. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Alexis de Lattre +* Denis Leemann +* Mykhailo Panarin +* Emanuel Cino + +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-ecino| image:: https://github.com/ecino.png?size=40px + :target: https://github.com/ecino + :alt: ecino + +Current `maintainer `__: + +|maintainer-ecino| + +This module is part of the `OCA/l10n-switzerland `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_ch_pain_credit_transfer/__init__.py b/l10n_ch_pain_credit_transfer/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_ch_pain_credit_transfer/__manifest__.py b/l10n_ch_pain_credit_transfer/__manifest__.py new file mode 100644 index 000000000..c6212b1d5 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/__manifest__.py @@ -0,0 +1,19 @@ +# copyright 2016 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Switzerland - PAIN Credit Transfer", + "summary": "Generate ISO 20022 credit transfert (SEPA and not SEPA)", + "version": "14.0.1.0.0", + "category": "Finance", + "author": "Akretion,Camptocamp,Odoo Community Association (OCA)", + "maintainers": ["ecino"], + "license": "AGPL-3", + "website": "https://github.com/OCA/l10n-switzerland", + "depends": [ + "l10n_ch_pain_base", + "l10n_ch_base_bank", + "account_banking_sepa_credit_transfer", + ], + "installable": True, +} diff --git a/l10n_ch_pain_credit_transfer/data/pain.001.001.03.ch.02.xsd b/l10n_ch_pain_credit_transfer/data/pain.001.001.03.ch.02.xsd new file mode 100644 index 000000000..4bd616fdf --- /dev/null +++ b/l10n_ch_pain_credit_transfer/data/pain.001.001.03.ch.02.xsd @@ -0,0 +1,1212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n_ch_pain_credit_transfer/i18n/de.po b/l10n_ch_pain_credit_transfer/i18n/de.po new file mode 100644 index 000000000..3c8adf26e --- /dev/null +++ b/l10n_ch_pain_credit_transfer/i18n/de.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ch_pain_credit_transfer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-11-23 21:12+0000\n" +"Last-Translator: chrispi-ch \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.2.2\n" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model.fields,field_description:l10n_ch_pain_credit_transfer.field_account_payment_method__pain_version +msgid "PAIN Version" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model,name:l10n_ch_pain_credit_transfer.model_account_payment_method +msgid "Payment Methods" +msgstr "Zahlungsmethoden" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.02" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03 (recommended for credit transfer)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03.ch.02 (credit transfer in Switzerland)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.04" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.05" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.003.03 (credit transfer in Germany)" +msgstr "" diff --git a/l10n_ch_pain_credit_transfer/i18n/fr.po b/l10n_ch_pain_credit_transfer/i18n/fr.po new file mode 100644 index 000000000..7db644ebc --- /dev/null +++ b/l10n_ch_pain_credit_transfer/i18n/fr.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ch_pain_credit_transfer +# +# Translators: +# leemannd , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-07 03:41+0000\n" +"PO-Revision-Date: 2017-03-07 03:41+0000\n" +"Last-Translator: leemannd , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model.fields,field_description:l10n_ch_pain_credit_transfer.field_account_payment_method__pain_version +msgid "PAIN Version" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model,name:l10n_ch_pain_credit_transfer.model_account_payment_method +msgid "Payment Methods" +msgstr "Moyens de Paiement" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.02" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03 (recommended for credit transfer)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03.ch.02 (credit transfer in Switzerland)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.04" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.05" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.003.03 (credit transfer in Germany)" +msgstr "" diff --git a/l10n_ch_pain_credit_transfer/i18n/l10n_ch_pain_credit_transfer.pot b/l10n_ch_pain_credit_transfer/i18n/l10n_ch_pain_credit_transfer.pot new file mode 100644 index 000000000..9897ceb67 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/i18n/l10n_ch_pain_credit_transfer.pot @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_ch_pain_credit_transfer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model.fields,field_description:l10n_ch_pain_credit_transfer.field_account_payment_method__pain_version +msgid "PAIN Version" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: model:ir.model,name:l10n_ch_pain_credit_transfer.model_account_payment_method +msgid "Payment Methods" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.02" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03 (recommended for credit transfer)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.03.ch.02 (credit transfer in Switzerland)" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.04" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.001.05" +msgstr "" + +#. module: l10n_ch_pain_credit_transfer +#: selection:account.payment.method,pain_version:0 +msgid "pain.001.003.03 (credit transfer in Germany)" +msgstr "" + diff --git a/l10n_ch_pain_credit_transfer/models/__init__.py b/l10n_ch_pain_credit_transfer/models/__init__.py new file mode 100644 index 000000000..2f2249e15 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/models/__init__.py @@ -0,0 +1 @@ +from . import account_payment_method diff --git a/l10n_ch_pain_credit_transfer/models/account_payment_method.py b/l10n_ch_pain_credit_transfer/models/account_payment_method.py new file mode 100644 index 000000000..5c7bf8323 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/models/account_payment_method.py @@ -0,0 +1,26 @@ +# copyright 2016 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountPaymentMethod(models.Model): + _inherit = "account.payment.method" + + pain_version = fields.Selection( + selection_add=[ + ( + "pain.001.001.03.ch.02", + "pain.001.001.03.ch.02 (credit transfer in Switzerland)", + ), + ], + ondelete={"pain.001.001.03.ch.02": "set null"}, + ) + + def get_xsd_file_path(self): + self.ensure_one() + painv = self.pain_version + if painv == "pain.001.001.03.ch.02": + path = "l10n_ch_pain_credit_transfer/data/%s.xsd" % painv + return path + return super().get_xsd_file_path() diff --git a/l10n_ch_pain_credit_transfer/readme/CONFIGURE.rst b/l10n_ch_pain_credit_transfer/readme/CONFIGURE.rst new file mode 100644 index 000000000..a4e8413a8 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +In the menu *Accounting > Configuration > Management > Payment Methods*, +select the payment method that has the code *sepa_credit_transfer* and +set the *PAIN Version* to *pain.001.001.03.ch.02 (credit transfer in Switzerland)*. diff --git a/l10n_ch_pain_credit_transfer/readme/CONTRIBUTORS.rst b/l10n_ch_pain_credit_transfer/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9356af4df --- /dev/null +++ b/l10n_ch_pain_credit_transfer/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Alexis de Lattre +* Denis Leemann +* Mykhailo Panarin +* Emanuel Cino diff --git a/l10n_ch_pain_credit_transfer/readme/DESCRIPTION.rst b/l10n_ch_pain_credit_transfer/readme/DESCRIPTION.rst new file mode 100644 index 000000000..954f87fbb --- /dev/null +++ b/l10n_ch_pain_credit_transfer/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module adds support for *pain.001.001.03.ch.02* which is used for ISO 20022 credit transfers in Switzerland (SEPA or not SEPA). + +It implements the guidelines for `ISO 20022 credit transfers `_ published by SIX Interbank Clearing. diff --git a/l10n_ch_pain_credit_transfer/readme/USAGE.rst b/l10n_ch_pain_credit_transfer/readme/USAGE.rst new file mode 100644 index 000000000..c11330b29 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/readme/USAGE.rst @@ -0,0 +1,2 @@ +This module doesn't modify the standard usage of the modules +*account_payment_order* and *account_banking_sepa_credit_transfer*. diff --git a/l10n_ch_pain_credit_transfer/static/description/icon.png b/l10n_ch_pain_credit_transfer/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/l10n_ch_pain_credit_transfer/static/description/icon.png differ diff --git a/l10n_ch_pain_credit_transfer/static/description/index.html b/l10n_ch_pain_credit_transfer/static/description/index.html new file mode 100644 index 000000000..0d71d4d36 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/static/description/index.html @@ -0,0 +1,441 @@ + + + + + + +Switzerland - PAIN Credit Transfer + + + +
+

Switzerland - PAIN Credit Transfer

+ + +

Beta License: AGPL-3 OCA/l10n-switzerland Translate me on Weblate Try me on Runboat

+

This module adds support for pain.001.001.03.ch.02 which is used for ISO 20022 credit transfers in Switzerland (SEPA or not SEPA).

+

It implements the guidelines for ISO 20022 credit transfers published by SIX Interbank Clearing.

+

Table of contents

+ +
+

Configuration

+

In the menu Accounting > Configuration > Management > Payment Methods, +select the payment method that has the code sepa_credit_transfer and +set the PAIN Version to pain.001.001.03.ch.02 (credit transfer in Switzerland).

+
+
+

Usage

+

This module doesn’t modify the standard usage of the modules +account_payment_order and account_banking_sepa_credit_transfer.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

ecino

+

This module is part of the OCA/l10n-switzerland project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_ch_pain_credit_transfer/tests/__init__.py b/l10n_ch_pain_credit_transfer/tests/__init__.py new file mode 100644 index 000000000..0c2b82cc9 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ch_sct diff --git a/l10n_ch_pain_credit_transfer/tests/test_ch_sct.py b/l10n_ch_pain_credit_transfer/tests/test_ch_sct.py new file mode 100644 index 000000000..a1aaa5f63 --- /dev/null +++ b/l10n_ch_pain_credit_transfer/tests/test_ch_sct.py @@ -0,0 +1,339 @@ +# (c) 2016 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 +from datetime import date + +from lxml import etree + +from odoo.tests import tagged +from odoo.tools import float_compare + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + +ch_iban = "CH15 3881 5158 3845 3843 7" + + +@tagged("post_install", "-at_install") +class TestSCTCH(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls, chart_template_ref="l10n_ch.l10nch_chart_template"): + super().setUpClass(chart_template_ref) + Journal = cls.env["account.journal"] + PaymentMode = cls.env["account.payment.mode"] + Account = cls.env["account.account"] + + cls.payment_order_model = cls.env["account.payment.order"] + cls.payment_line_model = cls.env["account.payment.line"] + cls.partner_bank_model = cls.env["res.partner.bank"] + cls.attachment_model = cls.env["ir.attachment"] + cls.account_move_model = cls.env["account.move"] + + cls.partner_agrolait = cls.env.ref("base.res_partner_2") + + cls.account_expense = Account.search( + [ + ( + "user_type_id", + "=", + cls.env.ref("account.data_account_type_expenses").id, + ) + ], + limit=1, + ) + cls.account_payable = Account.search( + [ + ( + "user_type_id", + "=", + cls.env.ref("account.data_account_type_payable").id, + ) + ], + limit=1, + ) + # Create a swiss bank + ch_bank1 = cls.env["res.bank"].create( + { + "name": "Alternative Bank Schweiz AG", + "bic": "ALSWCH21XXX", + "clearing": "38815", + } + ) + # create a ch bank account for my company + cls.cp_partner_bank = cls.partner_bank_model.create( + { + "acc_number": ch_iban, + "partner_id": cls.env.user.company_id.partner_id.id, + } + ) + cls.cp_partner_bank._onchange_acc_number_set_swiss_bank() + # create journal + cls.bank_journal = Journal.create( + { + "name": "Company Bank journal", + "type": "bank", + "code": "BNKFB", + "bank_account_id": cls.cp_partner_bank.id, + "bank_id": ch_bank1.id, + } + ) + # create a payment mode + pay_method_id = cls.env.ref( + "account_banking_sepa_credit_transfer.sepa_credit_transfer" + ).id + cls.payment_mode = PaymentMode.create( + { + "name": "CH credit transfer", + "bank_account_link": "fixed", + "fixed_journal_id": cls.bank_journal.id, + "payment_method_id": pay_method_id, + } + ) + cls.payment_mode.payment_method_id.pain_version = "pain.001.001.03.ch.02" + cls.chf_currency = cls.env.ref("base.CHF") + cls.eur_currency = cls.env.ref("base.EUR") + ch_bank2 = cls.env["res.bank"].create( + { + "name": "Banque Cantonale Vaudoise", + "bic": "BCVLCH2LXXX", + "clearing": "767", + } + ) + # Create a bank account with clearing 767 + cls.agrolait_partner_bank = cls.partner_bank_model.create( + { + "acc_number": "CH9100767000S00023455", + "partner_id": cls.partner_agrolait.id, + "bank_id": ch_bank2.id, + "l10n_ch_postal": "01-1234-1", + } + ) + + def test_sct_ch_payment_type1(self): + invoice1 = self.create_invoice( + self.partner_agrolait.id, + self.agrolait_partner_bank.id, + self.eur_currency, + 42.0, + "132000000000000000000000014", + ) + invoice2 = self.create_invoice( + self.partner_agrolait.id, + self.agrolait_partner_bank.id, + self.eur_currency, + 12.0, + "132000000000000000000000022", + ) + for inv in [invoice1, invoice2]: + action = inv.create_account_payment_line() + self.assertEqual(action["res_model"], "account.payment.order") + self.payment_order = self.payment_order_model.browse(action["res_id"]) + self.assertEqual(self.payment_order.payment_type, "outbound") + self.assertEqual(self.payment_order.payment_mode_id, self.payment_mode) + self.assertEqual(self.payment_order.journal_id, self.bank_journal) + pay_lines = self.payment_line_model.search( + [ + ("partner_id", "=", self.partner_agrolait.id), + ("order_id", "=", self.payment_order.id), + ] + ) + self.assertEqual(len(pay_lines), 2) + agrolait_pay_line1 = pay_lines[0] + accpre = self.env["decimal.precision"].precision_get("Account") + self.assertEqual(agrolait_pay_line1.currency_id, self.eur_currency) + self.assertEqual(agrolait_pay_line1.partner_bank_id, invoice1.partner_bank_id) + self.assertEqual( + float_compare( + agrolait_pay_line1.amount_currency, 42, precision_digits=accpre + ), + 0, + ) + self.assertEqual(agrolait_pay_line1.communication_type, "isr") + self.assertEqual( + agrolait_pay_line1.communication, "132000000000000000000000014" + ) + self.payment_order.draft2open() + self.assertEqual(self.payment_order.state, "open") + self.assertEqual(self.payment_order.sepa, False) + bank_lines = self.payment_line_model.search( + [("partner_id", "=", self.partner_agrolait.id)] + ) + self.assertEqual(len(bank_lines), 2) + for bank_line in bank_lines: + self.assertEqual(bank_line.currency_id, self.eur_currency) + self.assertEqual(bank_line.communication_type, "isr") + self.assertTrue( + bank_line.communication + in ["132000000000000000000000014", "132000000000000000000000022"] + ) + self.assertEqual(bank_line.partner_bank_id, invoice1.partner_bank_id) + + action = self.payment_order.open2generated() + self.assertEqual(self.payment_order.state, "generated") + self.assertEqual(action["res_model"], "ir.attachment") + attachment = self.attachment_model.browse(action["res_id"]) + self.assertEqual(attachment.name[-4:], ".xml") + xml_file = base64.b64decode(attachment.datas) + xml_root = etree.fromstring(xml_file) + # print "xml_file=", etree.tostring(xml_root, pretty_print=True) + namespaces = xml_root.nsmap + namespaces["p"] = xml_root.nsmap[None] + namespaces.pop(None) + pay_method_xpath = xml_root.xpath("//p:PmtInf/p:PmtMtd", namespaces=namespaces) + self.assertEqual( + namespaces["p"], + "http://www.six-interbank-clearing.com/de/" "pain.001.001.03.ch.02.xsd", + ) + self.assertEqual(pay_method_xpath[0].text, "TRF") + sepa_xpath = xml_root.xpath( + "//p:PmtInf/p:PmtTpInf/p:SvcLvl/p:Cd", namespaces=namespaces + ) + self.assertEqual(len(sepa_xpath), 0) + local_instrument_xpath = xml_root.xpath( + "//p:PmtInf/p:PmtTpInf/p:LclInstrm/p:Prtry", namespaces=namespaces + ) + self.assertEqual(local_instrument_xpath[0].text, "CH01") + + debtor_acc_xpath = xml_root.xpath( + "//p:PmtInf/p:DbtrAcct/p:Id/p:IBAN", namespaces=namespaces + ) + self.assertEqual( + debtor_acc_xpath[0].text, + self.payment_order.company_partner_bank_id.sanitized_acc_number, + ) + self.payment_order.generated2uploaded() + self.assertEqual(self.payment_order.state, "uploaded") + for inv in [invoice1, invoice2]: + self.assertEqual(inv.state, "posted") + return + + def test_sct_ch_payment_type3(self): + invoice1 = self.create_invoice( + self.partner_agrolait.id, + self.agrolait_partner_bank.id, + self.eur_currency, + 4042.0, + "Inv1242", + ) + invoice2 = self.create_invoice( + self.partner_agrolait.id, + self.agrolait_partner_bank.id, + self.eur_currency, + 1012.55, + "Inv1248", + ) + for inv in [invoice1, invoice2]: + action = inv.create_account_payment_line() + self.assertEqual(action["res_model"], "account.payment.order") + self.payment_order = self.payment_order_model.browse(action["res_id"]) + self.assertEqual(self.payment_order.payment_type, "outbound") + self.assertEqual(self.payment_order.payment_mode_id, self.payment_mode) + self.assertEqual(self.payment_order.journal_id, self.bank_journal) + pay_lines = self.payment_line_model.search( + [ + ("partner_id", "=", self.partner_agrolait.id), + ("order_id", "=", self.payment_order.id), + ] + ) + self.assertEqual(len(pay_lines), 2) + agrolait_pay_line1 = pay_lines[0] + accpre = self.env["decimal.precision"].precision_get("Account") + self.assertEqual(agrolait_pay_line1.currency_id, self.eur_currency) + self.assertEqual(agrolait_pay_line1.partner_bank_id, invoice1.partner_bank_id) + self.assertEqual( + float_compare( + agrolait_pay_line1.amount_currency, + 4042.0, + precision_digits=accpre, + ), + 0, + ) + self.assertEqual(agrolait_pay_line1.communication_type, "normal") + self.assertEqual(agrolait_pay_line1.communication, "Inv1242") + self.payment_order.draft2open() + self.assertEqual(self.payment_order.state, "open") + self.assertEqual(self.payment_order.sepa, False) + bank_lines = self.env["account.payment"].search( + [("partner_id", "=", self.partner_agrolait.id)] + ) + self.assertEqual(len(bank_lines), 1) + bank_line = bank_lines[0] + self.assertEqual(bank_line.currency_id, self.eur_currency) + self.assertEqual(bank_line.payment_type, "outbound") + self.assertEqual(bank_line.payment_reference, "Inv1242 - Inv1248") + self.assertEqual(bank_line.partner_bank_id, invoice1.partner_bank_id) + + action = self.payment_order.open2generated() + self.assertEqual(self.payment_order.state, "generated") + self.assertEqual(action["res_model"], "ir.attachment") + attachment = self.attachment_model.browse(action["res_id"]) + self.assertEqual(attachment.name[-4:], ".xml") + xml_file = base64.b64decode(attachment.datas) + xml_root = etree.fromstring(xml_file) + # print "xml_file=", etree.tostring(xml_root, pretty_print=True) + namespaces = xml_root.nsmap + namespaces["p"] = xml_root.nsmap[None] + namespaces.pop(None) + pay_method_xpath = xml_root.xpath("//p:PmtInf/p:PmtMtd", namespaces=namespaces) + self.assertEqual( + namespaces["p"], + "http://www.six-interbank-clearing.com/de/" "pain.001.001.03.ch.02.xsd", + ) + self.assertEqual(pay_method_xpath[0].text, "TRF") + sepa_xpath = xml_root.xpath( + "//p:PmtInf/p:PmtTpInf/p:SvcLvl/p:Cd", namespaces=namespaces + ) + self.assertEqual(len(sepa_xpath), 0) + local_instrument_xpath = xml_root.xpath( + "//p:PmtInf/p:PmtTpInf/p:LclInstrm/p:Prtry", namespaces=namespaces + ) + self.assertEqual(len(local_instrument_xpath), 0) + + debtor_acc_xpath = xml_root.xpath( + "//p:PmtInf/p:DbtrAcct/p:Id/p:IBAN", namespaces=namespaces + ) + self.assertEqual( + debtor_acc_xpath[0].text, + self.payment_order.company_partner_bank_id.sanitized_acc_number, + ) + self.payment_order.generated2uploaded() + self.assertEqual(self.payment_order.state, "uploaded") + for inv in [invoice1, invoice2]: + self.assertEqual(inv.state, "posted") + return + + def create_invoice( + self, + partner_id, + partner_bank_id, + currency, + price_unit, + ref, + inv_type="in_invoice", + ): + invoice = self.account_move_model.create( + { + "partner_id": partner_id, + "ref": ref, + "currency_id": currency.id, + "move_type": inv_type, + "name": "/", + "payment_mode_id": self.payment_mode.id, + "partner_bank_id": partner_bank_id, + "invoice_date": date.today(), + "invoice_line_ids": [ + ( + 0, + 0, + { + "price_unit": price_unit, + "quantity": 1, + "name": "Great service", + "account_id": self.account_expense.id, + }, + ) + ], + } + ) + invoice.action_post() + return invoice diff --git a/setup/l10n_ch_pain_credit_transfer/odoo/addons/l10n_ch_pain_credit_transfer b/setup/l10n_ch_pain_credit_transfer/odoo/addons/l10n_ch_pain_credit_transfer new file mode 120000 index 000000000..d1b388fb7 --- /dev/null +++ b/setup/l10n_ch_pain_credit_transfer/odoo/addons/l10n_ch_pain_credit_transfer @@ -0,0 +1 @@ +../../../../l10n_ch_pain_credit_transfer \ No newline at end of file diff --git a/setup/l10n_ch_pain_credit_transfer/setup.py b/setup/l10n_ch_pain_credit_transfer/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_ch_pain_credit_transfer/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)