diff --git a/.gitignore b/.gitignore index d1ff85d..146d9ac 100644 --- a/.gitignore +++ b/.gitignore @@ -84,10 +84,13 @@ celerybeat-schedule # virtualenv .venv +.pain001/ +.pytest_cache/ bandit-env myenv venv/ ENV/ +pyvenv.cfg # Spyder project settings .spyderproject @@ -114,3 +117,13 @@ ENV/ # Database *.db-shm *.db-wal +pain001/bin/activate +pain001/bin/activate.csh +pain001/bin/activate.fish +pain001/bin/Activate.ps1 +pain001/bin/pip +pain001/bin/pip3 +pain001/bin/pip3.11 +pain001/bin/python +pain001/bin/python3 +pain001/bin/python3.11 diff --git a/Makefile b/Makefile index 627d40e..5b0bd86 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,10 @@ dist: rm -rf ./dist && \ - python3 setup.py sdist bdist_wheel + python setup.py sdist bdist_wheel release: dist bzr diff && \ twine upload dist/* && \ - bzr tag $$(python3 setup.py --version|tail -1) && \ + bzr tag $$(python setup.py --version|tail -1) && \ bzr push \ No newline at end of file diff --git a/README.md b/README.md index 3e1c550..766a5bd 100644 --- a/README.md +++ b/README.md @@ -4,52 +4,34 @@ ## A Powerful Python Library that enables you to create ISO 20022-Compliant Payment Files directly from CSV or SQLite data files -[![PyPI][pypi-badge]][3] [![PyPI Downloads][pypi-downloads-badge]][7] [![License][license-badge]][1] [![Codecov][codecov-badge]][6] +[![PyPI][pypi-badge]][03] [![PyPI Downloads][pypi-downloads-badge]][07] [![License][license-badge]][01] [![Codecov][codecov-badge]][06] ## Overview - -**Pain001** is an open-source Python Library that you can use to create -**ISO 20022-Compliant Payment Files** directly from your **CSV** or **SQLite** -Data Files. +**Pain001** is an open-source Python Library that you can use to create **ISO 20022-Compliant Payment Files** directly from your **CSV** or **SQLite** Data Files. - **Website:** - **Source code:** - **Bug reports:** -The Python library focuses specifically on -**Payment Initiation and Advice Messages**, commonly known as **Pain**. In a -very simplified way, a **pain.001** is a message that initiates the customer -payment. +The Python library focuses specifically on **Payment Initiation and Advice Messages**, commonly known as **Pain**. In a very simplified way, a **pain.001** is a message that initiates the customer payment. As of today the library is designed to be compatible with the: -- **Payments Initiation V03 (pain.001.001.03)** - ISO20022 message format for - initiating payments with version 03, -- **Payments Initiation V04 (pain.001.001.04)** - ISO20022 message format for - initiating payments with version 04, -- **Payments Initiation V05 (pain.001.001.05)** - ISO20022 message format for - initiating payments with version 05 and, -- **Payments Initiation V09 (pain.001.001.09)** - ISO20022 message format for - initiating payments with version 09. - -message types and will support more in the future. - -Payments usually start with a **pain.001 payment initiation message**. The -payer sends it to the payee (or the payee’s bank) via a secure network. This -network could be **SWIFT** or **SEPA (Single Euro Payments Area) network**, or -other payment networks such as **CHAPS**, **BACS**, **Faster Payments**, etc. -The message contains the payer’s and payee’s bank account details, payment -amount, and other information required to process the payment. - -The **Pain001** library can reduce payment processing complexity and costs by -generating ISO 20022-compliant payment files. These files automatically remove -the need to create and validate them manually, making the payment process more -efficient and cost-effective. It will save you time and resources and minimises -the risk of errors, making sure accurate and seamless payment processing. - -Use the **Pain001** library to simplify, accelerate and automate your payment -processing. +- **Payments Initiation V03 (pain.001.001.03)**: This version is used for initiating credit transfers within the SEPA (Single Euro Payments Area). +- **Payments Initiation V04 (pain.001.001.04)**: Introduced support for non-SEPA payments and additional functionalities. +- **Payments Initiation V05 (pain.001.001.05)**: Brought further enhancements and clarifications. +- **Payments Initiation V06 (pain.001.001.06)**: Focused on introducing support for instant payments. +- **Payments Initiation V07 (pain.001.001.07)**: Added support for Request for Large Payment (RLP) and Request to Modify Payment (RTP) functionalities. +- **Payments Initiation V08 (pain.001.001.08)**: Included support for the TARGET Instant Settlement Service (TISS) and introduced a new pain.002 message type for debit transfers. +- **Payments Initiation V09 (pain.001.001.09)**: The latest version, which introduced support for Request for Account Information (RAI) functionality. + +Payments usually start with a **pain.001 payment initiation message**. The payer sends it to the payee (or the payee’s bank) via a secure network. This +network could be **SWIFT** or **SEPA (Single Euro Payments Area) network**, or other payment networks such as **CHAPS**, **BACS**, **Faster Payments**, etc. The message contains the payer’s and payee’s bank account details, payment amount, and other information required to process the payment. + +The **Pain001** library can reduce payment processing complexity and costs by generating ISO 20022-compliant payment files. These files automatically remove the need to create and validate them manually, making the payment process more efficient and cost-effective. It will save you time and resources and minimises the risk of errors, making sure accurate and seamless payment processing. + +Use the **Pain001** library to simplify, accelerate and automate your payment processing. ## Table of Contents @@ -60,6 +42,10 @@ processing. - [Features](#features) - [Requirements](#requirements) - [Installation](#installation) + - [Install `virtualenv`](#install-virtualenv) + - [Create a Virtual Environment](#create-a-virtual-environment) + - [Activate environment](#activate-environment) + - [Getting Started](#getting-started) - [Quick Start](#quick-start) - [Arguments](#arguments) - [Examples](#examples) @@ -113,33 +99,58 @@ processing. ## Requirements -**Pain001** works with macOS, Linux and Windows and requires Python 3.9.0 and -above. +**Pain001** works with macOS, Linux and Windows and requires Python 3.9.0 and above. ## Installation -It takes just a few seconds to get up and running with **Pain001**. You can -install Pain001 from PyPI with pip or your favourite package manager: +We recommend creating a virtual environment to install **Pain001**. This will ensure that the package is installed in an isolated environment and will not affect other projects. To install **Pain001** in a virtual environment, follow these steps: + +### Install `virtualenv` + +```sh +python -m pip install virtualenv +``` + +### Create a Virtual Environment + +```sh +python -m venv venv +``` + +| Code | Explanation | +|---|---| +| `-m` | executes module `venv` | +| `env` | name of the virtual environment | + +### Activate environment -Open your terminal and run the following command: +```sh +source venv/bin/activate +``` + +### Getting Started + +It takes just a few seconds to get up and running with **Pain001**. You can install Pain001 from PyPI with pip or your favourite package manager: + +Open your terminal and run the following command to add the latest version: ```sh -pip install pain001 +python -m pip install pain001 ``` -Add the -U switch to update to the current version, if `pain001` is already -installed. +Add the -U switch to update to the current version, if `pain001` is already installed. + +```sh +python -m pip install -U pain001 +``` ## Quick Start -After installation, you can run **Pain001** directly from the command line. -Simply call the main module pain001 with the paths of your: +After installation, you can run **Pain001** directly from the command line. Simply call the main module pain001 with the paths of your: -- **XML template file** containing the various parameters you want to pass from - your Data file, +- **XML template file** containing the various parameters you want to pass from your Data file, - **XSD schema file** to validate the generated XML file, and -- **Data file (CSV or SQLite)** containing the payment instructions that you - want to submit. +- **Data file (CSV or SQLite)** containing the payment instructions that you want to submit. Here’s how you would do that: @@ -158,15 +169,22 @@ When running **Pain001**, you will need to specify four arguments: - An `xml_message_type`: This is the type of XML message you want to generate. The currently supported types are: + - pain.001.001.03 - pain.001.001.04 - pain.001.001.05 + - pain.001.001.06 + - pain.001.001.07 + - pain.001.001.08 - pain.001.001.09 + - An `xml_template_file_path`: This is the path to the XML template file you are using that contains variables that will be replaced by the values in your Data file. + - An `xsd_schema_file_path`: This is the path to the XSD schema file you are using to validate the generated XML file. + - A `data_file_path`: This is the path to the CSV or SQLite Data file you want to convert to XML format. @@ -205,9 +223,7 @@ GitHub: git clone https://github.com/sebastienrousseau/pain001.git ``` - Then, navigate to the `pain001` directory and run the following command: - - ```sh +```sh python -m pain001 \ -t pain.001.001.03 \ -m templates/pain.001.001.03/template.xml \ @@ -277,7 +293,7 @@ print(f"XML validation result: {is_valid}") ## Documentation -> **Info:** Do check out our [website][0] for comprehensive documentation. +> **Info:** Do check out our [website][00] for comprehensive documentation. ### Supported messages @@ -324,9 +340,9 @@ and monitor payments. | ✅ | [pain.001.001.03][pain.001.001.03] | Customer Credit Transfer Initiation | | ✅ | [pain.001.001.04][pain.001.001.04] | Customer Direct Debit Initiation | | ✅ | [pain.001.001.05][pain.001.001.05] | Customer Direct Debit Reversal | -| ⏳ | pain.001.001.06 | Customer Credit Transfer Reversal | -| ⏳ | pain.001.001.07 | Customer Account Notification | -| ⏳ | pain.001.001.08 | Customer Account Statement | +| ✅ | [pain.001.001.06][pain.001.001.06] | Customer Credit Transfer Reversal | +| ✅ | [pain.001.001.07][pain.001.001.07] | Customer Account Notification | +| ✅ | [pain.001.001.08][pain.001.001.08] | Customer Account Statement | | ✅ | [pain.001.001.09][pain.001.001.09] | Customer Credit Transfer Initiation | | ⏳ | pain.001.001.10 | Customer Account Closure Request | | ⏳ | pain.001.001.11 | Customer Account Change Request | @@ -336,13 +352,13 @@ and monitor payments. The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0). -- [Apache License, Version 2.0][1] -- [MIT license][2] +- [Apache License, Version 2.0][01] +- [MIT license][02] ## Contribution We welcome contributions to **Pain001**. Please see the -[contributing instructions][4] for more information. +[contributing instructions][04] for more information. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the @@ -352,20 +368,23 @@ additional terms or conditions. ## Acknowledgements We would like to extend a big thank you to all the awesome contributors -of [Pain001][5] for their help and support. +of [Pain001][05] for their help and support. -[0]: https://pain001.com -[1]: https://opensource.org/license/apache-2-0/ -[2]: http://opensource.org/licenses/MIT -[3]: https://github.com/sebastienrousseau/pain001 -[4]: https://github.com/sebastienrousseau/pain001/blob/main/CONTRIBUTING.md -[5]: https://github.com/sebastienrousseau/pain001/graphs/contributors -[6]: https://codecov.io/github/sebastienrousseau/pain001?branch=main -[7]: https://pypi.org/project/pain001/ +[00]: https://pain001.com +[01]: https://opensource.org/license/apache-2-0/ +[02]: http://opensource.org/licenses/MIT +[03]: https://github.com/sebastienrousseau/pain001 +[04]: https://github.com/sebastienrousseau/pain001/blob/main/CONTRIBUTING.md +[05]: https://github.com/sebastienrousseau/pain001/graphs/contributors +[06]: https://codecov.io/github/sebastienrousseau/pain001?branch=main +[07]: https://pypi.org/project/pain001/ [pain.001.001.03]: https://pain001.com/pain.001.001.03/index.html [pain.001.001.04]: https://pain001.com/pain.001.001.04/index.html [pain.001.001.05]: https://pain001.com/pain.001.001.05/index.html +[pain.001.001.06]: https://pain001.com/pain.001.001.06/index.html +[pain.001.001.07]: https://pain001.com/pain.001.001.07/index.html +[pain.001.001.08]: https://pain001.com/pain.001.001.08/index.html [pain.001.001.09]: https://pain001.com/pain.001.001.09/index.html [banner]: https://kura.pro/pain001/images/banners/banner-pain001.svg 'Pain001, A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Or SQlite Data Files.' diff --git a/TEMPLATE.md b/TEMPLATE.md index 71a66d5..9de70c4 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -19,16 +19,47 @@ above. ## Installation -It takes just a few seconds to get up and running with **Pain001**. You can -install Pain001 from PyPI with pip or your favourite package manager: +We recommend creating a virtual environment to install **Pain001**. This will ensure that the package is installed in an isolated environment and will not affect other projects. To install **Pain001** in a virtual environment, follow these steps: -Open your terminal and run the following command: +### Install `virtualenv` ```sh -pip install pain001 +python -m pip install virtualenv ``` -Add the -U switch to update to the current version, if `pain001` is already -installed. +### Create a Virtual Environment + +```sh +python -m venv venv +``` + +| Code | Explanation | +|---|---| +| `-m` | executes module `venv` | +| `env` | name of the virtual environment | + +### Activate environment + +```sh +source venv/bin/activate +``` + +### Getting Started + +It takes just a few seconds to get up and running with **Pain001**. You can install Pain001 from PyPI with pip or your favourite package manager: + +Open your terminal and run the following command to add the latest version: + +```sh +python -m pip install pain001 +``` + +Add the -U switch to update to the current version, if `pain001` is already installed. + +```sh +python -m pip install -U pain001 +``` [banner]: https://kura.pro/pain001/images/banners/banner-pain001.svg 'Pain001, A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Or SQlite Data Files.' + +## Changelog diff --git a/pain001/__init__.py b/pain001/__init__.py index 2518882..bf12afc 100644 --- a/pain001/__init__.py +++ b/pain001/__init__.py @@ -14,4 +14,4 @@ # limitations under the License. """The Python pain001 module.""" -__version__ = "0.0.23" +__version__ = "0.0.24" diff --git a/pain001/constants/constants.py b/pain001/constants/constants.py index 5c510ab..807afaf 100644 --- a/pain001/constants/constants.py +++ b/pain001/constants/constants.py @@ -16,13 +16,13 @@ # Defines the valid XML types for the ISO 20022 Payment Initiation # message types that are supported by the pain001 library. valid_xml_types = [ - "pain.001.001.03", # Customer Credit Transfer Initiation - "pain.001.001.04", # Customer Direct Debit Initiation - "pain.001.001.05", # Request for Payment Status - "pain.001.001.06", # Notification of Payment Status - "pain.001.001.07", # Request for Reversal - "pain.001.001.08", # Notification of Reversal - "pain.001.001.09", # Request for Amendment - "pain.001.001.10" # Notification of Amendment - "pain.001.001.11", # Request for Cancellation + "pain.001.001.03", # Customer Credit Transfer Initiation (pain.001.001.03) + "pain.001.001.04", # Customer Direct Debit Initiation (pain.001.001.04) + "pain.001.001.05", # Request for Payment Status (pain.001.001.05) + "pain.001.001.06", # Notification of Payment Status (pain.001.001.06) + "pain.001.001.07", # Request for Reversal (pain.001.001.07) + "pain.001.001.08", # Notification of Reversal (pain.001.001.08) + "pain.001.001.09", # Request for Amendment (pain.001.001.09) + "pain.001.001.10" # Notification of Amendment (pain.001.001.10) + "pain.001.001.11", # Request for Cancellation (pain.001.001.11) ] diff --git a/pain001/core/core.py b/pain001/core/core.py index f1db8be..8837124 100644 --- a/pain001/core/core.py +++ b/pain001/core/core.py @@ -41,7 +41,8 @@ def process_files( Args: xml_message_type (str): The type of XML message to generate. Valid - options are 'pain.001.001.03' and 'pain.001.001.09'. + options are 'pain.001.001.03', 'pain.001.001.04', 'pain.001.001.05', + 'pain.001.001.06' and 'pain.001.001.09'. xml_template_file_path (str): The path of the XML template file. xsd_schema_file_path (str): The path of the XSD schema file. data_file_path (str): The path of the CSV or SQLite file containing the diff --git a/pain001/csv/validate_csv_data.py b/pain001/csv/validate_csv_data.py index 41c0316..75b7315 100644 --- a/pain001/csv/validate_csv_data.py +++ b/pain001/csv/validate_csv_data.py @@ -23,7 +23,7 @@ # - payment_information_id (str) - payment information identifier # - payment_method (str) - payment method # - batch_booking (bool) - batch booking -# - control_sum (int) - control sum +# - ctrl_sum (int) - control sum # - service_level_code (str) - service level code # - requested_execution_date (str) - requested execution date # - debtor_name (str) - debtor name @@ -53,11 +53,11 @@ def validate_csv_data(data): "id": int, "date": str, "nb_of_txs": int, + "ctrl_sum": str, "initiator_name": str, "payment_information_id": str, "payment_method": str, "batch_booking": bool, - "control_sum": int, "service_level_code": str, "requested_execution_date": str, "debtor_name": str, diff --git a/pain001/db/validate_db_data.py b/pain001/db/validate_db_data.py index 1a4e30d..71a6178 100644 --- a/pain001/db/validate_db_data.py +++ b/pain001/db/validate_db_data.py @@ -27,11 +27,11 @@ def validate_db_data(data): "id": int, "date": str, "nb_of_txs": int, + "ctrl_sum": str, "initiator_name": str, "payment_information_id": str, "payment_method": str, "batch_booking": bool, - "control_sum": int, "service_level_code": str, "requested_execution_date": str, "debtor_name": str, diff --git a/pain001/xml/create_xml_v4.py b/pain001/xml/create_xml_v4.py index e006e29..a00d41e 100644 --- a/pain001/xml/create_xml_v4.py +++ b/pain001/xml/create_xml_v4.py @@ -79,7 +79,7 @@ def create_xml_v4(root, data): "debtor_town": data[0]["debtor_town"], "debtor_country": data[0]["debtor_country"], "debtor_account_IBAN": data[0]["debtor_account_IBAN"], - "debtor_agent_BICFI": data[0]["debtor_agent_BICFI"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], "payment_instruction_id": data[0]["payment_instruction_id"], "payment_end_to_end_id": data[0]["payment_end_to_end_id"], "payment_currency": data[0]["payment_currency"], diff --git a/pain001/xml/create_xml_v5.py b/pain001/xml/create_xml_v5.py index 071ebfc..1e690d0 100644 --- a/pain001/xml/create_xml_v5.py +++ b/pain001/xml/create_xml_v5.py @@ -81,7 +81,7 @@ def create_xml_v5(root, data): "debtor_town": data[0]["debtor_town"], "debtor_country": data[0]["debtor_country"], "debtor_account_IBAN": data[0]["debtor_account_IBAN"], - "debtor_agent_BICFI": data[0]["debtor_agent_BICFI"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], "payment_instruction_id": data[0]["payment_instruction_id"], "payment_end_to_end_id": data[0]["payment_end_to_end_id"], "payment_currency": data[0]["payment_currency"], diff --git a/pain001/xml/create_xml_v6.py b/pain001/xml/create_xml_v6.py new file mode 100644 index 0000000..52d0647 --- /dev/null +++ b/pain001/xml/create_xml_v6.py @@ -0,0 +1,109 @@ +# Copyright (C) 2023 Sebastien Rousseau. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This module contains the function `create_xml_v6`, which constructs an XML tree +following the ISO 20022 pain.001.001.06 schema. + +The function takes in a root ElementTree element and a list of dictionaries +containing the required data. It then uses Jinja2 templating to dynamically +generate the XML content based on the given data. The function ultimately +returns the root element of the modified XML tree. +""" + +# Import ElementTree and Jinja2 +import xml.etree.ElementTree as et +from jinja2 import Environment, FileSystemLoader + + +def create_xml_v6(root, data): + """Create XML tree for pain.001.001.06 schema. + + Args: + root (ElementTree.Element): Root element of XML tree. + data (list): List of dicts with data. + + Returns: + ElementTree.Element: Root element of updated XML tree. + """ + + # Create CstmrCdtTrfInitn element + # pylint: disable=E1101 + cstmr_cdt_trf_initn_element = et.Element("CstmrCdtTrfInitn") + root.append(cstmr_cdt_trf_initn_element) + + # Create a Jinja2 environment + env = Environment(loader=FileSystemLoader("."), autoescape=True) + + # Load pain.001.001.06 template + template = env.get_template("templates/pain.001.001.06/template.xml") + + # Prepare data for rendering + xml_data = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town_name"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0]["requested_execution_date"], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "debtor_agent_name": data[0]["debtor_agent_name"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0]["creditor_building_number"], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "creditor_agent_name": data[0]["creditor_agent_name"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"] + } + + # Render template + xml_content = template.render(**xml_data) + + # Parse rendered content + rendered_xml = et.fromstring(xml_content) + + # Append rendered XML children + for child in rendered_xml: + cstmr_cdt_trf_initn_element.append(child) + + return root diff --git a/pain001/xml/create_xml_v7.py b/pain001/xml/create_xml_v7.py new file mode 100644 index 0000000..83ab84d --- /dev/null +++ b/pain001/xml/create_xml_v7.py @@ -0,0 +1,109 @@ +# Copyright (C) 2023 Sebastien Rousseau. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This module contains the function `create_xml_v7`, which constructs an XML tree +following the ISO 20022 pain.001.001.07 schema. + +The function takes in a root ElementTree element and a list of dictionaries +containing the required data. It then uses Jinja2 templating to dynamically +generate the XML content based on the given data. The function ultimately +returns the root element of the modified XML tree. +""" + +# Import ElementTree and Jinja2 +import xml.etree.ElementTree as et +from jinja2 import Environment, FileSystemLoader + + +def create_xml_v7(root, data): + """Create XML tree for pain.001.001.07 schema. + + Args: + root (ElementTree.Element): Root element of XML tree. + data (list): List of dicts with data. + + Returns: + ElementTree.Element: Root element of updated XML tree. + """ + + # Create CstmrCdtTrfInitn element + # pylint: disable=E1101 + cstmr_cdt_trf_initn_element = et.Element("CstmrCdtTrfInitn") + root.append(cstmr_cdt_trf_initn_element) + + # Create a Jinja2 environment + env = Environment(loader=FileSystemLoader("."), autoescape=True) + + # Load pain.001.001.07 template + template = env.get_template("templates/pain.001.001.07/template.xml") + + # Prepare data for rendering + xml_data = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town_name"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0]["requested_execution_date"], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "debtor_agent_name": data[0]["debtor_agent_name"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0]["creditor_building_number"], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "creditor_agent_name": data[0]["creditor_agent_name"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"] + } + + # Render template + xml_content = template.render(**xml_data) + + # Parse rendered content + rendered_xml = et.fromstring(xml_content) + + # Append rendered XML children + for child in rendered_xml: + cstmr_cdt_trf_initn_element.append(child) + + return root diff --git a/pain001/xml/create_xml_v8.py b/pain001/xml/create_xml_v8.py new file mode 100644 index 0000000..2ecf3ab --- /dev/null +++ b/pain001/xml/create_xml_v8.py @@ -0,0 +1,109 @@ +# Copyright (C) 2023 Sebastien Rousseau. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This module contains the function `create_xml_v8`, which constructs an XML tree +following the ISO 20022 pain.001.001.08 schema. + +The function takes in a root ElementTree element and a list of dictionaries +containing the required data. It then uses Jinja2 templating to dynamically +generate the XML content based on the given data. The function ultimately +returns the root element of the modified XML tree. +""" + +# Import ElementTree and Jinja2 +import xml.etree.ElementTree as et +from jinja2 import Environment, FileSystemLoader + + +def create_xml_v8(root, data): + """Create XML tree for pain.001.001.08 schema. + + Args: + root (ElementTree.Element): Root element of XML tree. + data (list): List of dicts with data. + + Returns: + ElementTree.Element: Root element of updated XML tree. + """ + + # Create CstmrCdtTrfInitn element + # pylint: disable=E1101 + cstmr_cdt_trf_initn_element = et.Element("CstmrCdtTrfInitn") + root.append(cstmr_cdt_trf_initn_element) + + # Create a Jinja2 environment + env = Environment(loader=FileSystemLoader("."), autoescape=True) + + # Load pain.001.001.08 template + template = env.get_template("templates/pain.001.001.08/template.xml") + + # Prepare data for rendering + xml_data = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town_name"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0]["requested_execution_date"], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "debtor_agent_name": data[0]["debtor_agent_name"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0]["creditor_building_number"], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "creditor_agent_name": data[0]["creditor_agent_name"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"] + } + + # Render template + xml_content = template.render(**xml_data) + + # Parse rendered content + rendered_xml = et.fromstring(xml_content) + + # Append rendered XML children + for child in rendered_xml: + cstmr_cdt_trf_initn_element.append(child) + + return root diff --git a/pain001/xml/create_xml_v9.py b/pain001/xml/create_xml_v9.py index df385ca..fdaa086 100644 --- a/pain001/xml/create_xml_v9.py +++ b/pain001/xml/create_xml_v9.py @@ -70,7 +70,7 @@ def create_xml_v9(root, data): ], "debtor_name": row["debtor_name"], "debtor_account_IBAN": row["debtor_account_IBAN"], - "debtor_agent_BICFI": row["debtor_agent_BIC"], + "debtor_agent_BIC": row["debtor_agent_BIC"], "charge_bearer": row["charge_bearer"], "transactions": [ { diff --git a/pain001/xml/generate_xml.py b/pain001/xml/generate_xml.py index 322215b..d9cc9cd 100644 --- a/pain001/xml/generate_xml.py +++ b/pain001/xml/generate_xml.py @@ -27,6 +27,9 @@ from pain001.xml.create_xml_v3 import create_xml_v3 from pain001.xml.create_xml_v4 import create_xml_v4 from pain001.xml.create_xml_v5 import create_xml_v5 +from pain001.xml.create_xml_v6 import create_xml_v6 +from pain001.xml.create_xml_v7 import create_xml_v7 +from pain001.xml.create_xml_v8 import create_xml_v8 from pain001.xml.create_xml_v9 import create_xml_v9 from pain001.xml.validate_via_xsd import validate_via_xsd @@ -39,7 +42,8 @@ def generate_xml( Args: data: List of dictionaries containing payment data payment_initiation_message_type: String indicating message type - such as "pain.001.001.03, pain.001.001.04, pain.001.001.05, etc." + such as "pain.001.001.03, pain.001.001.04, pain.001.001.05, + pain.001.001.06, pain.001.001.07, pain.001.001.08, etc." xml_file_path: Path to write generated XML file to xsd_file_path: Path to XML schema file for validation @@ -52,6 +56,9 @@ def generate_xml( "pain.001.001.03": create_xml_v3, "pain.001.001.04": create_xml_v4, "pain.001.001.05": create_xml_v5, + "pain.001.001.06": create_xml_v6, + "pain.001.001.07": create_xml_v7, + "pain.001.001.08": create_xml_v8, "pain.001.001.09": create_xml_v9, } @@ -172,7 +179,7 @@ def generate_xml( "debtor_town": data[0]["debtor_town_name"], "debtor_country": data[0]["debtor_country_code"], "debtor_account_IBAN": data[0]["debtor_account_IBAN"], - "debtor_agent_BICFI": data[0]["debtor_agent_BIC"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], "debtor_agent_account_IBAN": data[0][ "debtor_agent_account_IBAN" ], @@ -272,7 +279,7 @@ def generate_xml( "debtor_town": data[0]["debtor_town"], "debtor_country": data[0]["debtor_country"], "debtor_account_IBAN": data[0]["debtor_account_IBAN"], - "debtor_agent_BICFI": data[0]["debtor_agent_BICFI"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], "payment_instruction_id": data[0][ "payment_instruction_id" ], @@ -299,6 +306,207 @@ def generate_xml( "reference_date": data[0]["reference_date"], } + elif payment_initiation_message_type == "pain.001.001.06": + xml_data_pain001_001_06 = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0][ + "requested_execution_date" + ], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0][ + "creditor_building_number" + ], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"], + "transactions": [ + { + "payment_id": row["payment_id"], + "payment_amount": row["payment_amount"], + "payment_currency": row.get( + "payment_currency", "" + ), + "charge_bearer": row["charge_bearer"], + "creditor_agent_BIC": row["creditor_agent_BIC"], + "creditor_name": row["creditor_name"], + "creditor_account_IBAN": row[ + "creditor_account_IBAN" + ], + "creditor_remittance_information": row[ + "remittance_information" + ], + } + for row in data[1:] + ], + } + + elif payment_initiation_message_type == "pain.001.001.07": + xml_data_pain001_001_07 = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0][ + "requested_execution_date" + ], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0][ + "creditor_building_number" + ], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"], + "transactions": [ + { + "payment_id": row["payment_id"], + "payment_amount": row["payment_amount"], + "payment_currency": row.get( + "payment_currency", "" + ), + "charge_bearer": row["charge_bearer"], + "creditor_agent_BIC": row["creditor_agent_BIC"], + "creditor_name": row["creditor_name"], + "creditor_account_IBAN": row[ + "creditor_account_IBAN" + ], + "creditor_remittance_information": row[ + "remittance_information" + ], + } + for row in data[1:] + ], + } + + elif payment_initiation_message_type == "pain.001.001.08": + xml_data_pain001_001_08 = { + "id": data[0]["id"], + "date": data[0]["date"], + "nb_of_txs": data[0]["nb_of_txs"], + "ctrl_sum": data[0]["ctrl_sum"], + "initiator_name": data[0]["initiator_name"], + "initiator_street_name": data[0]["initiator_street_name"], + "initiator_building_number": data[0][ + "initiator_building_number" + ], + "initiator_postal_code": data[0]["initiator_postal_code"], + "initiator_town": data[0]["initiator_town"], + "initiator_country": data[0]["initiator_country"], + "payment_information_id": data[0]["payment_information_id"], + "payment_method": data[0]["payment_method"], + "batch_booking": data[0]["batch_booking"], + "requested_execution_date": data[0][ + "requested_execution_date" + ], + "debtor_name": data[0]["debtor_name"], + "debtor_street": data[0]["debtor_street"], + "debtor_building_number": data[0]["debtor_building_number"], + "debtor_postal_code": data[0]["debtor_postal_code"], + "debtor_town": data[0]["debtor_town"], + "debtor_country": data[0]["debtor_country"], + "debtor_account_IBAN": data[0]["debtor_account_IBAN"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], + "payment_instruction_id": data[0]["payment_instruction_id"], + "payment_end_to_end_id": data[0]["payment_end_to_end_id"], + "payment_currency": data[0]["payment_currency"], + "payment_amount": data[0]["payment_amount"], + "charge_bearer": data[0]["charge_bearer"], + "creditor_name": data[0]["creditor_name"], + "creditor_street": data[0]["creditor_street"], + "creditor_building_number": data[0][ + "creditor_building_number" + ], + "creditor_postal_code": data[0]["creditor_postal_code"], + "creditor_town": data[0]["creditor_town"], + "creditor_country": data[0]["creditor_country"], + "creditor_account_IBAN": data[0]["creditor_account_IBAN"], + "creditor_agent_BICFI": data[0]["creditor_agent_BICFI"], + "purpose_code": data[0]["purpose_code"], + "reference_number": data[0]["reference_number"], + "reference_date": data[0]["reference_date"], + "transactions": [ + { + "payment_id": row["payment_id"], + "payment_amount": row["payment_amount"], + "payment_currency": row.get( + "payment_currency", "" + ), + "charge_bearer": row["charge_bearer"], + "creditor_agent_BIC": row["creditor_agent_BIC"], + "creditor_name": row["creditor_name"], + "creditor_account_IBAN": row[ + "creditor_account_IBAN" + ], + "creditor_remittance_information": row[ + "remittance_information" + ], + } + for row in data[1:] + ], + } + elif payment_initiation_message_type == "pain.001.001.09": xml_data_pain001_001_09 = { "id": data[0]["id"], @@ -313,7 +521,7 @@ def generate_xml( ], "debtor_name": data[0]["debtor_name"], "debtor_account_IBAN": data[0]["debtor_account_IBAN"], - "debtor_agent_BICFI": data[0]["debtor_agent_BIC"], + "debtor_agent_BIC": data[0]["debtor_agent_BIC"], "charge_bearer": data[0]["charge_bearer"], "transactions": [ { @@ -348,6 +556,18 @@ def generate_xml( elif payment_initiation_message_type == "pain.001.001.05": # xml_data_pain001_001_05 = {} xml_data = xml_data_pain001_001_05 + # Check if the payment initiation message type is "pain.001.001.06" + elif payment_initiation_message_type == "pain.001.001.06": + # xml_data_pain001_001_06 = {} + xml_data = xml_data_pain001_001_06 + # Check if the payment initiation message type is "pain.001.001.07" + elif payment_initiation_message_type == "pain.001.001.07": + # xml_data_pain001_001_07 = {} + xml_data = xml_data_pain001_001_07 + # Check if the payment initiation message type is "pain.001.001.08" + elif payment_initiation_message_type == "pain.001.001.08": + # xml_data_pain001_001_08 = {} + xml_data = xml_data_pain001_001_08 # Check if the payment initiation message type is "pain.001.001.09" elif payment_initiation_message_type == "pain.001.001.09": # xml_data_pain001_001_09 = {} diff --git a/poetry.lock b/poetry.lock index 8d90ff6..b83e464 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. [[package]] name = "click" @@ -173,27 +173,28 @@ files = [ [[package]] name = "pygments" -version = "2.16.1" +version = "2.17.1" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.7" files = [ - {file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"}, - {file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"}, + {file = "pygments-2.17.1-py3-none-any.whl", hash = "sha256:1b37f1b1e1bff2af52ecaf28cc601e2ef7077000b227a0675da25aef85784bc4"}, + {file = "pygments-2.17.1.tar.gz", hash = "sha256:e45a0e74bf9c530f564ca81b8952343be986a29f6afe7f5ad95c5f06b7bdf5e8"}, ] [package.extras] plugins = ["importlib-metadata"] +windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "rich" -version = "13.5.2" +version = "13.7.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.7.0" files = [ - {file = "rich-13.5.2-py3-none-any.whl", hash = "sha256:146a90b3b6b47cac4a73c12866a499e9817426423f57c5a66949c086191a8808"}, - {file = "rich-13.5.2.tar.gz", hash = "sha256:fb9d6c0a0f643c99eed3875b5377a184132ba9be4d61516a55273d3554d75a39"}, + {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, + {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, ] [package.dependencies] @@ -205,13 +206,13 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "xmlschema" -version = "2.4.0" +version = "2.5.0" description = "An XML Schema validator and decoder" optional = false python-versions = ">=3.7" files = [ - {file = "xmlschema-2.4.0-py3-none-any.whl", hash = "sha256:dc87be0caaa61f42649899189aab2fd8e0d567f2cf548433ba7b79278d231a4a"}, - {file = "xmlschema-2.4.0.tar.gz", hash = "sha256:d74cd0c10866ac609e1ef94a5a69b018ad16e39077bc6393408b40c6babee793"}, + {file = "xmlschema-2.5.0-py3-none-any.whl", hash = "sha256:f2b29c45485fac414cc1fdb38d18a220c5987d7d3aa996e6df6ff35ee94d5a63"}, + {file = "xmlschema-2.5.0.tar.gz", hash = "sha256:276a03e0fd3c94c148d528bff4d9482f9b99bf8c7b4056a2e8e703d28149d454"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 443f056..3c57cfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pain001" -version = "0.0.23" +version = "0.0.24" description = "Pain001 is a Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data." authors = ["Sebastien Rousseau "] license = "Apache Software License" diff --git a/requirements.txt b/requirements.txt index 7412be5..34580b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -80,12 +80,12 @@ markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "4.0" \ mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" \ --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \ --hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba -pygments==2.16.1 ; python_version >= "3.9" and python_version < "4.0" \ - --hash=sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692 \ - --hash=sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29 -rich==13.5.2 ; python_version >= "3.9" and python_version < "4.0" \ - --hash=sha256:146a90b3b6b47cac4a73c12866a499e9817426423f57c5a66949c086191a8808 \ - --hash=sha256:fb9d6c0a0f643c99eed3875b5377a184132ba9be4d61516a55273d3554d75a39 -xmlschema==2.4.0 ; python_version >= "3.9" and python_version < "4.0" \ - --hash=sha256:d74cd0c10866ac609e1ef94a5a69b018ad16e39077bc6393408b40c6babee793 \ - --hash=sha256:dc87be0caaa61f42649899189aab2fd8e0d567f2cf548433ba7b79278d231a4a +pygments==2.17.1 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:1b37f1b1e1bff2af52ecaf28cc601e2ef7077000b227a0675da25aef85784bc4 \ + --hash=sha256:e45a0e74bf9c530f564ca81b8952343be986a29f6afe7f5ad95c5f06b7bdf5e8 +rich==13.7.0 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa \ + --hash=sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235 +xmlschema==2.5.0 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:276a03e0fd3c94c148d528bff4d9482f9b99bf8c7b4056a2e8e703d28149d454 \ + --hash=sha256:f2b29c45485fac414cc1fdb38d18a220c5987d7d3aa996e6df6ff35ee94d5a63 diff --git a/setup.cfg b/setup.cfg index 096eebc..0fc57ed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,50 +16,21 @@ [metadata] name = pain001 -version = 0.0.23 -description = Pain001, A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Or SQlite Data Files. -keywords = pain001,iso20022,payment-processing,automate-payments,sepa,financial,banking-payments,csv,sqlite -author = Sebastian Rousseau -author_email = sebastian.rousseau@gmail.com -url = https://github.com/sebastienrousseau/pain001 -license = Apache License 2.0 -license_files = - LICENSE-APACHE - LICENSE-MIT -long_description = file: README.md -long_description_content_type = text/markdown - -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Intended Audience :: Financial and Insurance Industry - License :: OSI Approved :: Apache Software License - Operating System :: MacOS - Operating System :: OS Independent - Operating System :: POSIX - Operating System :: Unix - Programming Language :: Python - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Software Development :: Libraries :: Python Modules - -project_urls = - Documentation = https://pain001.com/ - Funding = https://paypal.me/wwdseb - Source = https://github.com/sebastienrousseau/pain001/releases +version = 0.0.24 [options] -packages = - pain001 -zip_safe = False -include_package_data = True -python_requires = ~=3.9 install_requires = - click - defusedxml - rich - xmlschema + click==8.1.7 + colorama==0.4.6 + defusedxml==0.7.1 + elementpath==4.1.5 + jinja2==3.1.2 + markdown-it-py==3.0.0 + markupsafe==2.1.3 + mdurl==0.1.2 + pygments==2.17.1 + rich==13.7.0 + xmlschema==2.5.0 [aliases] test = pytest @@ -69,4 +40,3 @@ testpaths = tests [wheel] universal = 1 - diff --git a/setup.py b/setup.py index 87bc302..b36bbc9 100644 --- a/setup.py +++ b/setup.py @@ -14,18 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +from pathlib import Path from setuptools import setup, find_packages -with open("README.md", "r") as fh: - long_description = fh.read() +this_directory = Path(__file__).parent +long_description = (this_directory / "README.md").read_text() setup_requirements = [] test_requirements = ["pytest>=7.4.2"] setup( name="pain001", - version="0.0.23", + version="0.0.24", description=""" Pain001, A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Or SQLite Data Files. @@ -34,7 +35,7 @@ long_description_content_type="text/markdown", author="Sebastien Rousseau", author_email="sebastian.rousseau@gmail.com", - url="https://github.com/sebastienrousseau/pain001", + url="https://pain001.com", license="Apache Software License", classifiers=[ "Development Status :: 4 - Beta", @@ -45,9 +46,10 @@ "Operating System :: OS Independent", "Operating System :: POSIX", "Operating System :: Unix", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.12", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", ], @@ -55,22 +57,22 @@ pain001,iso20022,payment-processing,automate-payments,sepa,financial, banking-payments,csv,sqlite """, - packages=find_packages(), + packages=find_packages(exclude=["docs", "tests*"]), install_requires=[ - "click>=8.1.7", - "colorama>=0.4.6", - "defusedxml>=0.7.1", - "elementpath>=4.1.5", - "jinja2>=3.1.2", - "markdown-it-py>=3.0.0", - "markupsafe>=2.1.3", - "mdurl>=0.1.2", - "pygments>=2.16.1", - "python>=3.9", - "rich>=13.5.2", - "xmlschema>=2.4.0", + "click==8.1.7", + "colorama==0.4.6", + "defusedxml==0.7.1", + "elementpath==4.1.5", + "jinja2==3.1.2", + "markdown-it-py==3.0.0", + "markupsafe==2.1.3", + "mdurl==0.1.2", + "pygments==2.17.1", + "rich==13.7.0", + "xmlschema==2.5.0", ], - setup_requires=setup_requirements, - tests_require=test_requirements, + python_requires=">=3.9,<3.13", + setup_requires=["pytest-runner"], + tests_require=["pytest"], test_suite="tests", ) diff --git a/templates/pain.001.001.03/template.csv b/templates/pain.001.001.03/template.csv index 6d66407..db2f064 100644 --- a/templates/pain.001.001.03/template.csv +++ b/templates/pain.001.001.03/template.csv @@ -1,4 +1,4 @@ -id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,payment_currency,control_sum,creditor_agent_BIC,creditor_name,creditor_street_name,creditor_building_number,creditor_postal_code,creditor_town_name,creditor_country_code,creditor_account_IBAN,purpose_code,reference_number,reference_date,service_level_code,forwarding_agent_BIC,remittance_information,charge_account_IBAN +id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,payment_currency,ctrl_sum,creditor_agent_BIC,creditor_name,creditor_street_name,creditor_building_number,creditor_postal_code,creditor_town_name,creditor_country_code,creditor_account_IBAN,purpose_code,reference_number,reference_date,service_level_code,forwarding_agent_BIC,remittance_information,charge_account_IBAN 1,2023-03-10T15:30:47.000Z,2,John Doe,John's Street,1,12345,John's Town,DE,Payment-Info-12345,TRF,true,2023-03-12,Acme Corp,Acme Street,2,67890,Acme Town,DE,DE75512108001245126162,BANKDEFFXXX,SLEV,PaymentID6789,150,EUR,EUR,15000,SPUEDE2UXXX,Global Tech,Global Street,3,11223,Global Town,DE,DE68210501700024690959,OTHR,Invoice-98765,2023-03-09,SEPA,SPUEDE2UXXX,Invoice-12345,CHARGE-IBAN-12345 2,2023-03-11T10:20:18.000Z,3,Jane Smith,Jane's Street,10,67890,Jane's Town,DE,Payment-Info-67890,TRF,true,2023-03-14,Brown Industries,Brown Street,20,45678,Brown Town,DE,DE44500105175407324931,BANKDEFFXXX,SHAR,PaymentID4321,300,EUR,EUR,30000,SPUEDE2UXXX,Green Energy,Green Street,30,78901,Green Town,DE,DE89370400440532013008,OTHR,Invoice-12345,2023-03-13,SEPA,SPUEDE2UXXX,Invoice-67890,CHARGE-IBAN-67890 3,2023-03-11T11:45:23.000Z,1,Michael Johnson,Michael's Street,15,89101,Michael's Town,DE,Payment-Info-24680,TRF,true,2023-03-13,Alpha Electronics,Alpha Street,25,32165,Alpha Town,DE,DE47500105175711000100,BANKDEFFXXX,SLEV,PaymentID1357,250,EUR,EUR,25000,SPUEDE2UXXX,Beta Chemicals,Beta Street,35,65432,Beta Town,DE,DE44500105175407123457,OTHR,Invoice-24680,2023-03-11,SEPA,SPUEDE2UXXX,Invoice-24680,CHARGE-IBAN-24680 diff --git a/templates/pain.001.001.03/template.db b/templates/pain.001.001.03/template.db index 6323f2f..8773c60 100644 Binary files a/templates/pain.001.001.03/template.db and b/templates/pain.001.001.03/template.db differ diff --git a/templates/pain.001.001.04/template.csv b/templates/pain.001.001.04/template.csv index 6a4d030..9d8890d 100644 --- a/templates/pain.001.001.04/template.csv +++ b/templates/pain.001.001.04/template.csv @@ -1,2 +1,2 @@ -id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_agent_BIC,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_account_IBAN,purpose_code,reference_number,reference_date,control_sum,service_level_code,forwarding_agent_BIC,payment_id,currency,remittance_information,debtor_agent_BICFI,debtor_agent_account_IBAN,charge_account_IBAN,charge_agent_BICFI,instruction_for_debtor_agent,instruction_id -1,2023-03-10T15:30:47.000Z,2,John Doe,"John's Street",1,12345,"John's Town",DE,PaymentID6789,TRF,true,2023-03-12,Acme Corp,"Acme Street",2,67890,"Acme Town",DE,DE75512108001245126162,BANKDEFFXXX,1234567890,1234567890,EUR,300,SHAR,SPUEDE2UXXX,Green Energy,"Green Street",30,78901,"Green Town",DE89370400440532013008,OTHR,Invoice-12345,2023-03-31,97,INST,GENODEF1M04,1234567890,EUR,Invoice-12345,BANKDEFFXXX,DE75512108001245126199,DE75512108001245126162,DEUTDEFFXXX,Invoice-12345,PaymentID6789 \ No newline at end of file +id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_agent_BIC,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_account_IBAN,purpose_code,reference_number,reference_date,ctrl_sum,service_level_code,forwarding_agent_BIC,payment_id,currency,remittance_information,debtor_agent_account_IBAN,charge_account_IBAN,charge_agent_BICFI,instruction_for_debtor_agent,instruction_id +1,2023-03-10T15:30:47.000Z,2,John Doe,"John's Street",1,12345,"John's Town",DE,PaymentID6789,TRF,true,2023-03-12,Acme Corp,"Acme Street",2,67890,"Acme Town",DE,DE75512108001245126162,BANKDEFFXXX,1234567890,1234567890,EUR,300,SHAR,SPUEDE2UXXX,Green Energy,"Green Street",30,78901,"Green Town",DE89370400440532013008,OTHR,Invoice-12345,2023-03-31,97,INST,GENODEF1M04,1234567890,EUR,Invoice-12345,DE75512108001245126199,DE75512108001245126162,DEUTDEFFXXX,Invoice-12345,PaymentID6789 \ No newline at end of file diff --git a/templates/pain.001.001.04/template.db b/templates/pain.001.001.04/template.db index 00262fb..a97778f 100644 Binary files a/templates/pain.001.001.04/template.db and b/templates/pain.001.001.04/template.db differ diff --git a/templates/pain.001.001.04/template.xml b/templates/pain.001.001.04/template.xml index def0f32..c29659e 100644 --- a/templates/pain.001.001.04/template.xml +++ b/templates/pain.001.001.04/template.xml @@ -41,7 +41,7 @@ - {{debtor_agent_BICFI}} + {{debtor_agent_BIC}} diff --git a/templates/pain.001.001.05/pain.001.001.05.xml b/templates/pain.001.001.05/pain.001.001.05.xml index e77a12a..4da6091 100644 --- a/templates/pain.001.001.05/pain.001.001.05.xml +++ b/templates/pain.001.001.05/pain.001.001.05.xml @@ -7,7 +7,7 @@ 1 2023-01-01T12:00:00Z 3 - 500.75 + 2 John Doe @@ -43,7 +43,7 @@ - BANKGB2L + DEUTDEFF diff --git a/templates/pain.001.001.05/template.csv b/templates/pain.001.001.05/template.csv index 742e2a7..97d741f 100644 --- a/templates/pain.001.001.05/template.csv +++ b/templates/pain.001.001.05/template.csv @@ -1,2 +1,2 @@ -id,date,nb_of_txs,ctrl_sum,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country,ultimate_debtor_name,service_level_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street,debtor_building_number,debtor_postal_code,debtor_town,debtor_country,debtor_account_IBAN,debtor_agent_BICFI,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_country,creditor_account_IBAN,creditor_agent_BICFI,purpose_code,reference_number,reference_date,control_sum,debtor_agent_BIC,forwarding_agent_BIC,payment_id,currency,creditor_agent_BIC,remittance_information +id,date,nb_of_txs,ctrl_sum,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country,ultimate_debtor_name,service_level_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street,debtor_building_number,debtor_postal_code,debtor_town,debtor_country,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_country,creditor_account_IBAN,creditor_agent_BICFI,purpose_code,reference_number,reference_date,ctrl_sum,debtor_agent_BIC,forwarding_agent_BIC,payment_id,currency,creditor_agent_BIC,remittance_information 1,2023-01-01T12:00:00Z,3,500.75,John Doe,Main St,123,12345,London,GB,Acme Inc,SEPA,Payment001,TRF,true,2023-01-04,John Doe,Main St,123,12345,London,GB,GB123456789,BANKGB2L,123456,90876,EUR,100,SLEV,ABC Corp,Church St,5,54321,Paris,FR,FR123456789,BANKEU2L,INV,123,2023-01-02,2,DEUTDEFF,DEUTDEFF,123456,EUR,BANKEU2L,INV \ No newline at end of file diff --git a/templates/pain.001.001.05/template.xml b/templates/pain.001.001.05/template.xml index 7c29a7f..b5a1bad 100644 --- a/templates/pain.001.001.05/template.xml +++ b/templates/pain.001.001.05/template.xml @@ -43,7 +43,7 @@ - {{debtor_agent_BICFI}} + {{debtor_agent_BIC}} diff --git a/templates/pain.001.001.06/pain.001.001.06.xml b/templates/pain.001.001.06/pain.001.001.06.xml new file mode 100644 index 0000000..f2a3fff --- /dev/null +++ b/templates/pain.001.001.06/pain.001.001.06.xml @@ -0,0 +1,93 @@ + + + + + 1 + 2023-01-01T12:00:00Z + 3 + 500.75 + + John Doe + + Main St + 123 + 12345 + London + GB + + + + + Payment001 + TRF + true + 2023-01-04 + + John Doe + + Main St + 123 + 12345 + London + GB + + + + + + GB123456789 + + + + + + BANKGB2L + + + + + 123456 + 90876 + + + 100 + + SLEV + + + BANKEU2L + + + + ABC Corp + + Church St + 5 + 54321 + Paris + + + + + + FR123456789 + + + + + INV + + + + + 123 + 2023-02-01 + + + + + + + \ No newline at end of file diff --git a/templates/pain.001.001.06/pain.001.001.06.xsd b/templates/pain.001.001.06/pain.001.001.06.xsd new file mode 100644 index 0000000..3bf40cd --- /dev/null +++ b/templates/pain.001.001.06/pain.001.001.06.xsd @@ -0,0 +1,987 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/pain.001.001.06/template.csv b/templates/pain.001.001.06/template.csv new file mode 100644 index 0000000..1e860d7 --- /dev/null +++ b/templates/pain.001.001.06/template.csv @@ -0,0 +1,2 @@ +id,date,nb_of_txs,ctrl_sum,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town,initiator_country,service_level_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street,debtor_building_number,debtor_postal_code,debtor_town,debtor_country,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_country,creditor_account_IBAN,creditor_agent_BICFI,purpose_code,reference_number,reference_date,forwarding_agent_BIC,payment_id,currency,creditor_agent_BIC,remittance_information +1,2023-01-01T12:00:00Z,3,500.75,John Doe,Main St,123,12345,London,GB,SEPA,Payment001,TRF,true,2023-01-04,John Doe,Main St,123,12345,London,GB,GB123456789,BANKGB2L,123456,90876,EUR,100,SLEV,ABC Corp,Church St,5,54321,Paris,FR,FR123456789,BANKEU2L,INV,123,2023-02-01,DEUTDEFF,123456,EUR,BANKEU2L,INV \ No newline at end of file diff --git a/templates/pain.001.001.06/template.db b/templates/pain.001.001.06/template.db new file mode 100644 index 0000000..3ceeccc Binary files /dev/null and b/templates/pain.001.001.06/template.db differ diff --git a/templates/pain.001.001.06/template.xml b/templates/pain.001.001.06/template.xml new file mode 100644 index 0000000..d013a47 --- /dev/null +++ b/templates/pain.001.001.06/template.xml @@ -0,0 +1,93 @@ + + + + + {{id}} + {{date}} + {{nb_of_txs}} + {{ctrl_sum}} + + {{initiator_name}} + + {{initiator_street_name}} + {{initiator_building_number}} + {{initiator_postal_code}} + {{initiator_town}} + {{initiator_country}} + + + + + {{payment_information_id}} + {{payment_method}} + {{batch_booking}} + {{requested_execution_date}} + + {{debtor_name}} + + {{debtor_street}} + {{debtor_building_number}} + {{debtor_postal_code}} + {{debtor_town}} + {{debtor_country}} + + + + + + {{debtor_account_IBAN}} + + + + + + {{debtor_agent_BIC}} + + + + + {{payment_instruction_id}} + {{payment_end_to_end_id}} + + + {{payment_amount}} + + {{charge_bearer}} + + + {{creditor_agent_BICFI}} + + + + {{creditor_name}} + + {{creditor_street}} + {{creditor_building_number}} + {{creditor_postal_code}} + {{creditor_town}} + + + + + + {{creditor_account_IBAN}} + + + + + {{purpose_code}} + + + + + {{reference_number}} + {{reference_date}} + + + + + + + \ No newline at end of file diff --git a/templates/pain.001.001.07/pain.001.001.07.xml b/templates/pain.001.001.07/pain.001.001.07.xml new file mode 100644 index 0000000..e645b01 --- /dev/null +++ b/templates/pain.001.001.07/pain.001.001.07.xml @@ -0,0 +1,93 @@ + + + + + 1 + 2023-01-01T12:00:00Z + 3 + 500.75 + + John Doe + + Main St + 123 + 12345 + London + GB + + + + + Payment001 + TRF + true + 2023-01-04 + + John Doe + + Main St + 123 + 12345 + London + GB + + + + + + GB123456789 + + + + + + BANKGB2L + + + + + 123456 + 90876 + + + 100 + + SLEV + + + BANKEU2L + + + + ABC Corp + + Church St + 5 + 54321 + Paris + + + + + + FR123456789 + + + + + INV + + + + + 123 + 2023-02-01 + + + + + + + \ No newline at end of file diff --git a/templates/pain.001.001.07/pain.001.001.07.xsd b/templates/pain.001.001.07/pain.001.001.07.xsd new file mode 100644 index 0000000..8ee0f20 --- /dev/null +++ b/templates/pain.001.001.07/pain.001.001.07.xsd @@ -0,0 +1,1030 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/pain.001.001.07/template.csv b/templates/pain.001.001.07/template.csv new file mode 100644 index 0000000..1e860d7 --- /dev/null +++ b/templates/pain.001.001.07/template.csv @@ -0,0 +1,2 @@ +id,date,nb_of_txs,ctrl_sum,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town,initiator_country,service_level_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street,debtor_building_number,debtor_postal_code,debtor_town,debtor_country,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_country,creditor_account_IBAN,creditor_agent_BICFI,purpose_code,reference_number,reference_date,forwarding_agent_BIC,payment_id,currency,creditor_agent_BIC,remittance_information +1,2023-01-01T12:00:00Z,3,500.75,John Doe,Main St,123,12345,London,GB,SEPA,Payment001,TRF,true,2023-01-04,John Doe,Main St,123,12345,London,GB,GB123456789,BANKGB2L,123456,90876,EUR,100,SLEV,ABC Corp,Church St,5,54321,Paris,FR,FR123456789,BANKEU2L,INV,123,2023-02-01,DEUTDEFF,123456,EUR,BANKEU2L,INV \ No newline at end of file diff --git a/templates/pain.001.001.07/template.db b/templates/pain.001.001.07/template.db new file mode 100644 index 0000000..3ceeccc Binary files /dev/null and b/templates/pain.001.001.07/template.db differ diff --git a/templates/pain.001.001.07/template.xml b/templates/pain.001.001.07/template.xml new file mode 100644 index 0000000..7c6344f --- /dev/null +++ b/templates/pain.001.001.07/template.xml @@ -0,0 +1,93 @@ + + + + + {{id}} + {{date}} + {{nb_of_txs}} + {{ctrl_sum}} + + {{initiator_name}} + + {{initiator_street_name}} + {{initiator_building_number}} + {{initiator_postal_code}} + {{initiator_town}} + {{initiator_country}} + + + + + {{payment_information_id}} + {{payment_method}} + {{batch_booking}} + {{requested_execution_date}} + + {{debtor_name}} + + {{debtor_street}} + {{debtor_building_number}} + {{debtor_postal_code}} + {{debtor_town}} + {{debtor_country}} + + + + + + {{debtor_account_IBAN}} + + + + + + {{debtor_agent_BIC}} + + + + + {{payment_instruction_id}} + {{payment_end_to_end_id}} + + + {{payment_amount}} + + {{charge_bearer}} + + + {{creditor_agent_BICFI}} + + + + {{creditor_name}} + + {{creditor_street}} + {{creditor_building_number}} + {{creditor_postal_code}} + {{creditor_town}} + + + + + + {{creditor_account_IBAN}} + + + + + {{purpose_code}} + + + + + {{reference_number}} + {{reference_date}} + + + + + + + \ No newline at end of file diff --git a/templates/pain.001.001.08/pain.001.001.08.xml b/templates/pain.001.001.08/pain.001.001.08.xml new file mode 100644 index 0000000..9dc2563 --- /dev/null +++ b/templates/pain.001.001.08/pain.001.001.08.xml @@ -0,0 +1,95 @@ + + + + + 1 + 2023-01-01T12:00:00Z + 3 + 500.75 + + John Doe + + Main St + 123 + 12345 + London + GB + + + + + Payment001 + TRF + true + +
2023-01-04
+
+ + John Doe + + Main St + 123 + 12345 + London + GB + + + + + + GB123456789 + + + + + + BANKGB2L + + + + + 123456 + 90876 + + + 100 + + SLEV + + + BANKEU2L + + + + ABC Corp + + Church St + 5 + 54321 + Paris + + + + + + FR123456789 + + + + + INV + + + + + 123 + 2023-02-01 + + + + +
+
+
\ No newline at end of file diff --git a/templates/pain.001.001.08/pain.001.001.08.xsd b/templates/pain.001.001.08/pain.001.001.08.xsd new file mode 100644 index 0000000..d690b5c --- /dev/null +++ b/templates/pain.001.001.08/pain.001.001.08.xsd @@ -0,0 +1,1036 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/pain.001.001.08/template.csv b/templates/pain.001.001.08/template.csv new file mode 100644 index 0000000..1e860d7 --- /dev/null +++ b/templates/pain.001.001.08/template.csv @@ -0,0 +1,2 @@ +id,date,nb_of_txs,ctrl_sum,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town,initiator_country,service_level_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street,debtor_building_number,debtor_postal_code,debtor_town,debtor_country,debtor_account_IBAN,debtor_agent_BIC,payment_instruction_id,payment_end_to_end_id,payment_currency,payment_amount,charge_bearer,creditor_name,creditor_street,creditor_building_number,creditor_postal_code,creditor_town,creditor_country,creditor_account_IBAN,creditor_agent_BICFI,purpose_code,reference_number,reference_date,forwarding_agent_BIC,payment_id,currency,creditor_agent_BIC,remittance_information +1,2023-01-01T12:00:00Z,3,500.75,John Doe,Main St,123,12345,London,GB,SEPA,Payment001,TRF,true,2023-01-04,John Doe,Main St,123,12345,London,GB,GB123456789,BANKGB2L,123456,90876,EUR,100,SLEV,ABC Corp,Church St,5,54321,Paris,FR,FR123456789,BANKEU2L,INV,123,2023-02-01,DEUTDEFF,123456,EUR,BANKEU2L,INV \ No newline at end of file diff --git a/templates/pain.001.001.08/template.db b/templates/pain.001.001.08/template.db new file mode 100644 index 0000000..3ceeccc Binary files /dev/null and b/templates/pain.001.001.08/template.db differ diff --git a/templates/pain.001.001.08/template.xml b/templates/pain.001.001.08/template.xml new file mode 100644 index 0000000..6e3f32e --- /dev/null +++ b/templates/pain.001.001.08/template.xml @@ -0,0 +1,95 @@ + + + + + {{id}} + {{date}} + {{nb_of_txs}} + {{ctrl_sum}} + + {{initiator_name}} + + {{initiator_street_name}} + {{initiator_building_number}} + {{initiator_postal_code}} + {{initiator_town}} + {{initiator_country}} + + + + + {{payment_information_id}} + {{payment_method}} + {{batch_booking}} + +
{{requested_execution_date}}
+
+ + {{debtor_name}} + + {{debtor_street}} + {{debtor_building_number}} + {{debtor_postal_code}} + {{debtor_town}} + {{debtor_country}} + + + + + + {{debtor_account_IBAN}} + + + + + + {{debtor_agent_BIC}} + + + + + {{payment_instruction_id}} + {{payment_end_to_end_id}} + + + {{payment_amount}} + + {{charge_bearer}} + + + {{creditor_agent_BICFI}} + + + + {{creditor_name}} + + {{creditor_street}} + {{creditor_building_number}} + {{creditor_postal_code}} + {{creditor_town}} + + + + + + {{creditor_account_IBAN}} + + + + + {{purpose_code}} + + + + + {{reference_number}} + {{reference_date}} + + + + +
+
+
\ No newline at end of file diff --git a/templates/pain.001.001.09/template.csv b/templates/pain.001.001.09/template.csv index 33c6ea6..23aca0b 100644 --- a/templates/pain.001.001.09/template.csv +++ b/templates/pain.001.001.09/template.csv @@ -1,4 +1,4 @@ -id,date,nb_of_txs,initiator_name,payment_information_id,payment_method,batch_booking,control_sum,service_level_code,requested_execution_date,debtor_name,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,creditor_agent_BIC,creditor_name,creditor_account_IBAN,remittance_information,forwarding_agent_BIC,payment_currency +id,date,nb_of_txs,initiator_name,payment_information_id,payment_method,batch_booking,ctrl_sum,service_level_code,requested_execution_date,debtor_name,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,creditor_agent_BIC,creditor_name,creditor_account_IBAN,remittance_information,forwarding_agent_BIC,payment_currency 1,2023-03-10T15:30:47.000Z,2,John Doe,Payment-Info-12345,TRF,TRUE,2,SEPA,2023-03-12,Acme Corp,DE75512108001245126162,DEUTDEFFXXX,DEBT,PaymentID6789,150.00,EUR,DEUTDEFFXXX,Global Tech,DE68210501700024690959,Payment for Invoice-98765,FA98765,EUR 2,2023-03-11T10:20:18.000Z,3,Jane Smith,Payment-Info-67890,TRF,TRUE,3,SEPA,2023-03-14,Brown Industries,DE44500105175407324931,DEUTDEFFXXX,DEBT,PaymentID4321,300.00,EUR,DEUTDEFFXXX,Green Energy,DE89370400440532013008,Payment for Invoice-12345,FA24680,EUR 3,2023-03-11T11:45:23.000Z,1,Michael Johnson,Payment-Info-24680,TRF,TRUE,1,SEPA,2023-03-13,Alpha Electronics,DE47500105175711000100,DEUTDEFFXXX,DEBT,PaymentID1357,250.00,EUR,DEUTDEFFXXX,Beta Chemicals,DE44500105175407123457,Payment for Invoice-24680,FA13579,EUR diff --git a/templates/pain.001.001.09/template.xml b/templates/pain.001.001.09/template.xml index 9d765bf..1a2c85c 100644 --- a/templates/pain.001.001.09/template.xml +++ b/templates/pain.001.001.09/template.xml @@ -26,7 +26,7 @@ - {{debtor_agent_BICFI}} + {{debtor_agent_BIC}} {{charge_bearer}} diff --git a/tests/data/template.csv b/tests/data/template.csv index eca3029..f6eae4f 100644 --- a/tests/data/template.csv +++ b/tests/data/template.csv @@ -1,4 +1,4 @@ -id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,payment_currency,control_sum,creditor_agent_BIC,creditor_name,creditor_street_name,creditor_building_number,creditor_postal_code,creditor_town_name,creditor_country_code,creditor_account_IBAN,purpose_code,reference_number,reference_date,service_level_code,forwarding_agent_BIC,remittance_information,charge_account_IBAN +id,date,nb_of_txs,initiator_name,initiator_street_name,initiator_building_number,initiator_postal_code,initiator_town_name,initiator_country_code,payment_information_id,payment_method,batch_booking,requested_execution_date,debtor_name,debtor_street_name,debtor_building_number,debtor_postal_code,debtor_town_name,debtor_country_code,debtor_account_IBAN,debtor_agent_BIC,charge_bearer,payment_id,payment_amount,currency,payment_currency,ctrl_sum,creditor_agent_BIC,creditor_name,creditor_street_name,creditor_building_number,creditor_postal_code,creditor_town_name,creditor_country_code,creditor_account_IBAN,purpose_code,reference_number,reference_date,service_level_code,forwarding_agent_BIC,remittance_information,charge_account_IBAN 1,2023-03-10T15:30:47.000Z,2,John Doe,John's Street,1,12345,John's Town,DE,Payment-Info-12345,TRF,true,2023-03-12,Acme Corp,Acme Street,2,67890,Acme Town,DE,DE75512108001245126162,BANKDEFFXXX,SLEV,PaymentID6789,150,EUR,EUR,15000,SPUEDE2UXXX,Global Tech,Global Street,3,11223,Global Town,DE,DE68210501700024690959,OTHR,Invoice-98765,2023-03-09,SEPA,SPUEDE2UXXX,Invoice-12345,CHARGE-IBAN-12345 2,2023-03-11T10:20:18.000Z,3,Jane Smith,Jane's Street,10,67890,Jane's Town,DE,Payment-Info-67890,TRF,true,2023-03-14,Brown Industries,Brown Street,20,45678,Brown Town,DE,DE44500105175407324931,BANKDEFFXXX,SHAR,PaymentID4321,300,EUR,EUR,30000,SPUEDE2UXXX,Green Energy,Green Street,30,78901,Green Town,DE,DE89370400440532013008,OTHR,Invoice-12345,2023-03-13,SEPA,SPUEDE2UXXX,Invoice-67890,CHARGE-IBAN-67890 3,2023-03-11T11:45:23.000Z,1,Michael Johnson,Michael's Street,15,89101,Michael's Town,DE,Payment-Info-24680,TRF,true,2023-03-13,Alpha Electronics,Alpha Street,25,32165,Alpha Town,DE,DE47500105175711000100,BANKDEFFXXX,SLEV,PaymentID1357,250,EUR,EUR,25000,SPUEDE2UXXX,Beta Chemicals,Beta Street,35,65432,Beta Town,DE,DE44500105175407123457,OTHR,Invoice-24680,2023-03-11,SEPA,SPUEDE2UXXX,Invoice-24680,CHARGE-IBAN-24680 diff --git a/tests/data/template.db b/tests/data/template.db index 31f1798..f0a5beb 100644 Binary files a/tests/data/template.db and b/tests/data/template.db differ diff --git a/tests/test_validate_csv_data.py b/tests/test_validate_csv_data.py index 43dabe9..4ff94b3 100644 --- a/tests/test_validate_csv_data.py +++ b/tests/test_validate_csv_data.py @@ -16,7 +16,7 @@ def test_valid_data(self): "payment_information_id": "12345", "payment_method": "TRF", "batch_booking": "false", - "control_sum": "100", + "ctrl_sum": "100", "service_level_code": "SEPA", "requested_execution_date": "2022-01-01", "debtor_name": "John Doe", @@ -40,7 +40,7 @@ def test_valid_data(self): "payment_information_id": "67890", "payment_method": "TRF", "batch_booking": "false", - "control_sum": "200", + "ctrl_sum": "200", "service_level_code": "SEPA", "requested_execution_date": "2022-01-02", "debtor_name": "Jane Doe", @@ -70,7 +70,7 @@ def test_missing_required_columns(self): "payment_information_id": "12345", "payment_method": "TRF", "batch_booking": "false", - "control_sum": "100", + "ctrl_sum": "100", "service_level_code": "SEPA", "requested_execution_date": "2022-01-01", "debtor_name": "John Doe", @@ -94,7 +94,7 @@ def test_missing_required_columns(self): "payment_information_id": "67890", "payment_method": "TRF", "batch_booking": "false", - "control_sum": "200", + "ctrl_sum": "200", "service_level_code": "SEPA", "requested_execution_date": "2022-01-02", "debtor_name": "Jane Doe",