From 105716bea1b9d2120dc36e84022966ec63fa7f45 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 21 May 2023 18:57:07 +0100 Subject: [PATCH 1/5] feat(pain001): v0.0.18 --- TEMPLATE.md | 2 +- pain001/__init__.py | 2 +- pain001/__main__.py | 103 ++++++++++++++++++++--------------- pain001/context/context.py | 40 +++++++------- pain001/core.py | 11 +--- pain001/xml/xml_generator.py | 22 ++++---- pyproject.toml | 2 +- setup.cfg | 2 +- setup.py | 61 +++++++++++++++++++-- tests/test_context.py | 53 ++++++++++++++++++ tests/test_generate_xml.py | 68 +++++++++++++++++++++++ tests/test_xml_generator.py | 82 ++++++++++++++++++++++++++++ 12 files changed, 353 insertions(+), 95 deletions(-) create mode 100644 tests/test_context.py create mode 100644 tests/test_generate_xml.py create mode 100644 tests/test_xml_generator.py diff --git a/TEMPLATE.md b/TEMPLATE.md index 51643bb..f4982d2 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -10,7 +10,7 @@ -# Pain001 (v0.0.17) +# Pain001 (v0.0.18) ![Pain001 banner][banner] diff --git a/pain001/__init__.py b/pain001/__init__.py index aec0570..4aec091 100644 --- a/pain001/__init__.py +++ b/pain001/__init__.py @@ -15,4 +15,4 @@ """The Python pain001 module.""" __all__ = ["pain001"] -__version__ = "0.0.17" +__version__ = "0.0.18" diff --git a/pain001/__main__.py b/pain001/__main__.py index efdba7e..174c188 100644 --- a/pain001/__main__.py +++ b/pain001/__main__.py @@ -33,52 +33,67 @@ cli_string = """ -Pain001 is a Python Library for Automating ISO 20022-Compliant Payment Files -Using CSV Data. - -It offers a streamlined solution for reducing complexity and costs associated -with payment processing. By providing a simple and efficient method to create -ISO 20022-compliant payment files, it eliminates the manual effort of file -creation and validation. This not only saves valuable time and resources but -also minimizes the risk of errors, ensuring accurate and seamless payment +**Pain001** is a Python Library for Automating ISO 20022-Compliant Payment +Files Using CSV Data. + +**Pain001** offers a streamlined solution for reducing complexity and costs +associated with payment processing. By providing a simple and efficient method +to create ISO 20022-compliant payment files, it eliminates the manual effort of +file creation and validation. This not only saves valuable time and resources +but also minimizes the risk of errors, ensuring accurate and seamless payment processing. -Usage: - python3 -m pain001 \ - \ - \ - \ - - -Arguments: - xml_message_type: The type of XML message. Valid values are: - - pain.001.001.03 - - pain.001.001.09 - xml_file_path: The path to the XML template file. - xsd_file_path: The path to the XSD template file. - csv_file_path: The path to the CSV data file. - -Example: - python3 -m pain001 "pain.001.001.09" \ - ./templates/pain.001.001.09/template.xml \ - ./templates/pain.001.001.09/pain.001.001.09.xsd \ - ./templates/pain.001.001.09/template.csv - - This command will generate a pain.001.001.09 XML file using the template - files in the ./templates/pain.001.001.09/ directory and the CSV data in - ./templates/pain.001.001.09/template.csv. - - The generated XML file will be saved in the directory. - For example, if the is pain.001.001.09, the generated - XML file will be saved in the directory pain.001.001.09 and the file name - will be pain.001.001.09.xml. - - Note: The generated XML file will be validated against the XSD template - file before being saved. If the validation fails, the program will exit - with an error message. - - For more information, please visit - https://github.com/sebastienrousseau/pain001 +If you are seeking to simplify and automate your payment processing, consider +leveraging the capabilities of **Pain001**. + +## Installation + +To install **Pain001**, run this command in your terminal: + +```sh +pip install pain001 +``` + +## Usage + +To use **Pain001**, run this command in your terminal: + +```sh +python3 -m pain001 \ + \ + \ + \ + +``` + +## Arguments: + +- `xml_message_type`: The type of XML message. The current valid values are: + - pain.001.001.03 and + - pain.001.001.09 +- `xml_file_path`: The path to the XML template file. +- `xsd_file_path`: The path to the XSD template file. +- `csv_file_path`: The path to the CSV data file. + +## Example: + +To generate a pain.001.001.03 XML file from the CSV data file you can run the +following command in your terminal: + +```sh +python3 -m pain001 \ + pain.001.001.03 \ + /path/to/your/pain.001.001.03.xml \ + /path/to/your/pain.001.001.03.xsd \ + /path/to/your/pain.001.001.03.csv +``` + +Note: The generated XML file will be validated against the XSD template +file before being saved. If the validation fails, the program will exit +with an error message. + +For more information, please visit the project's GitHub page at: +. """ diff --git a/pain001/context/context.py b/pain001/context/context.py index 872b07f..ef6a761 100644 --- a/pain001/context/context.py +++ b/pain001/context/context.py @@ -29,7 +29,7 @@ class Context: """ instance = None - name = '' + name = "" log_level = logging.INFO logger = None @@ -75,26 +75,26 @@ def set_log_level(self, log_level): Raises: Exception: If the log level is invalid. """ - if log_level is None or log_level.strip() == "": - self.log_level = logging.INFO - return - - if log_level.strip().upper() == "DEBUG": - self.log_level = logging.DEBUG - elif log_level.strip().upper() == "INFO": - self.log_level = logging.INFO - elif log_level.strip().upper() == "WARNING": - self.log_level = logging.WARNING - elif log_level.strip().upper() == "ERROR": - self.log_level = logging.ERROR - elif log_level.strip().upper() == "CRITICAL": - self.log_level = logging.CRITICAL - elif log_level.strip().upper() == "FATAL": - self.log_level = logging.FATAL - elif log_level.strip().upper() == "UNKNOWN": - self.log_level = logging.UNKNOWN + if isinstance( + log_level, int + ): # Check if log_level is an integer + self.log_level = log_level else: - raise Exception("Invalid log level") + log_level = ( + log_level.strip().upper() + ) # Strip and convert to uppercase + if log_level == "DEBUG": + self.log_level = logging.DEBUG + elif log_level == "INFO": + self.log_level = logging.INFO + elif log_level == "WARNING": + self.log_level = logging.WARNING + elif log_level == "ERROR": + self.log_level = logging.ERROR + elif log_level == "CRITICAL": + self.log_level = logging.CRITICAL + else: + raise Exception("Invalid log level") def init_logger(self): """Initializes the logger. diff --git a/pain001/core.py b/pain001/core.py index 1804250..a4c4eb2 100644 --- a/pain001/core.py +++ b/pain001/core.py @@ -27,10 +27,7 @@ def process_files( - xml_message_type, - xml_file_path, - xsd_file_path, - csv_file_path + xml_message_type, xml_file_path, xsd_file_path, csv_file_path ): """ This function, when called, generates an ISO 20022 payment message @@ -113,11 +110,7 @@ def process_files( # Generate the updated XML file path xml_generator( - data, - mapping, - xml_message_type, - xml_file_path, - xsd_file_path + data, mapping, xml_message_type, xml_file_path, xsd_file_path ) diff --git a/pain001/xml/xml_generator.py b/pain001/xml/xml_generator.py index 3ee65b6..c86e0ef 100644 --- a/pain001/xml/xml_generator.py +++ b/pain001/xml/xml_generator.py @@ -17,7 +17,9 @@ # Import the functions from the other modules from .create_root_element import create_root_element -from .generate_updated_xml_file_path import generate_updated_xml_file_path +from .generate_updated_xml_file_path import ( + generate_updated_xml_file_path, +) from .generate_xml import create_xml_v3, create_xml_v9 from .validate_via_xsd import validate_via_xsd from .write_xml_to_file import write_xml_to_file @@ -28,11 +30,11 @@ def xml_generator( - data, - mapping, - payment_initiation_message_type, - xml_file_path, - xsd_file_path + data, + mapping, + payment_initiation_message_type, + xml_file_path, + xsd_file_path, ): # Create the root element and set its attributes root = create_root_element(payment_initiation_message_type) @@ -63,18 +65,14 @@ def xml_generator( # Generate updated XML file path updated_xml_file_path = generate_updated_xml_file_path( - xml_file_path, - payment_initiation_message_type + xml_file_path, payment_initiation_message_type ) # Write the updated XML tree to a file write_xml_to_file(updated_xml_file_path, root) # Validate the updated XML file against the XSD schema - is_valid = validate_via_xsd( - updated_xml_file_path, - xsd_file_path - ) + is_valid = validate_via_xsd(updated_xml_file_path, xsd_file_path) if not is_valid: print("❌ Error: Invalid XML data.") sys.exit(1) diff --git a/pyproject.toml b/pyproject.toml index 84a1984..6db9901 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pain001" -version = "0.0.17" +version = "0.0.18" description = "pain001 is a Python library that makes it easy to automate the creation of ISO20022-compliant payment files directly from a CSV file." authors = ["Sebastien Rousseau "] license = "Apache Software License" diff --git a/setup.cfg b/setup.cfg index 46038f6..7a7ab99 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pain001 -version = 0.0.17 +version = 0.0.18 author = Sebastian Rousseau author_email = sebastian.rousseau@gmail.com description = pain001 is a Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data. diff --git a/setup.py b/setup.py index 6c18fc4..2a6d1ba 100644 --- a/setup.py +++ b/setup.py @@ -22,15 +22,64 @@ **Pain001** is a Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data. -It offers a streamlined solution for reducing complexity and costs associated -with payment processing. By providing a simple and efficient method to create -ISO 20022-compliant payment files, it eliminates the manual effort of file -creation and validation. This not only saves valuable time and resources but -also minimizes the risk of errors, ensuring accurate and seamless payment +**Pain001** offers a streamlined solution for reducing complexity and costs +associated with payment processing. By providing a simple and efficient method +to create ISO 20022-compliant payment files, it eliminates the manual effort of +file creation and validation. This not only saves valuable time and resources +but also minimizes the risk of errors, ensuring accurate and seamless payment processing. If you are seeking to simplify and automate your payment processing, consider leveraging the capabilities of **Pain001**. + +## Installation + +To install **Pain001**, run this command in your terminal: + +```sh +pip install pain001 +``` + +## Usage + +To use **Pain001**, run this command in your terminal: + +```sh +python3 -m pain001 \ + \ + \ + \ + +``` + +## Arguments: + +- `xml_message_type`: The type of XML message. The current valid values are: + - pain.001.001.03 and + - pain.001.001.09 +- `xml_file_path`: The path to the XML template file. +- `xsd_file_path`: The path to the XSD template file. +- `csv_file_path`: The path to the CSV data file. + +## Example: + +To generate a pain.001.001.03 XML file from the CSV data file you can run the +following command in your terminal: + +```sh +python3 -m pain001 \ + pain.001.001.03 \ + /path/to/your/pain.001.001.03.xml \ + /path/to/your/pain.001.001.03.xsd \ + /path/to/your/pain.001.001.03.csv +``` + +Note: The generated XML file will be validated against the XSD template +file before being saved. If the validation fails, the program will exit +with an error message. + +For more information, please visit the project's GitHub page at: +. """.strip() SHORT_DESCRIPTION = """ @@ -41,7 +90,7 @@ TEST_DEPENDENCIES = ["xmlschema>=2.3.0", "pytest>=7.3.1"] -VERSION = "0.0.17" +VERSION = "0.0.18" URL = "https://github.com/sebastienrousseau/pain001" diff --git a/tests/test_context.py b/tests/test_context.py new file mode 100644 index 0000000..9aa1bec --- /dev/null +++ b/tests/test_context.py @@ -0,0 +1,53 @@ +import logging +import unittest + +from pain001.context.context import Context + + +class TestContext(unittest.TestCase): + def setUp(self): + self.context = Context.get_instance() + self.context.set_name("test_context") + + def tearDown(self): + self.context.logger = None + Context.instance = None + + def test_get_instance(self): + # Test that the first call to get_instance() creates a new instance + # of the class. + first_instance = Context.get_instance() + self.assertIsNotNone(first_instance) + + # Test that subsequent calls to get_instance() return the same + # instance. + second_instance = Context.get_instance() + self.assertEqual(first_instance, second_instance) + + def test_set_name(self): + # Test that set_name() sets the name of the logger. + context = self.context + context.set_name("my_context") + self.assertEqual(context.name, "my_context") + + def test_set_log_level(self): + # Test that set_log_level() sets the log level of the logger. + context = self.context + context.set_log_level(logging.DEBUG) + self.assertEqual(context.log_level, logging.DEBUG) + + # Test that set_log_level() raises an exception if the log level is + # invalid. + with self.assertRaises(Exception): + context.set_log_level("INVALID") + + def test_get_logger(self): + # Test that get_logger() returns the logger. + context = self.context + logger = context.get_logger() + self.assertIsNotNone(logger) + self.assertEqual(logger, context.logger) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_generate_xml.py b/tests/test_generate_xml.py new file mode 100644 index 0000000..559d4a6 --- /dev/null +++ b/tests/test_generate_xml.py @@ -0,0 +1,68 @@ +import unittest + +import xml.etree.ElementTree as ET + +from pain001.xml.generate_xml import ( + create_common_elements, + create_xml_v3, + create_xml_v9, +) + + +class TestXMLCreation(unittest.TestCase): + def setUp(self): + self.root = ET.Element("Root") + self.row = { + "initiator_name": "Initiator", + "batch_booking": "true", + "nb_of_txs": "2", + "control_sum": "3000", + "service_level_code": "Code", + "requested_execution_date": "2023-05-21", + "debtor_name": "Debtor", + "debtor_account_IBAN": "DE123456789", + "debtor_agent_BIC": "DEUTDEFF", + "charge_bearer": "Bearer", + "payment_id": "PID123", + "payment_amount": "1500", + "payment_method": "pain.001.001.09", + "currency": "EUR", + "creditor_agent_BIC": "NOLADE21KIE", + "creditor_name": "Creditor", + "remittance_information": "Invoice 123", + } + self.mapping = { + "MsgId": "payment_id", + "CreDtTm": "requested_execution_date", + "NbOfTxs": "nb_of_txs", + "PmtInfId": "payment_id", + "PmtMtd": "payment_method", + } + + def test_create_common_elements(self): + create_common_elements(self.root, self.row, self.mapping) + self.assertEqual(len(self.root), 2) + self.assertEqual(self.root[0].tag, "PmtInfId") + self.assertEqual(self.root[0].text, "PID123") + self.assertEqual(self.root[1].tag, "PmtMtd") + self.assertEqual(self.root[1].text, "pain.001.001.09") + + def test_create_xml_v3(self): + create_xml_v3(self.root, [self.row], self.mapping) + cstmr_cdt_trf_initn_element = self.root[0] + self.assertEqual( + cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn" + ) + # You can continue to assert more conditions based on your expectations + + def test_create_xml_v9(self): + create_xml_v9(self.root, [self.row], self.mapping) + cstmr_cdt_trf_initn_element = self.root[0] + self.assertEqual( + cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn" + ) + # You can continue to assert more conditions based on your expectations + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_xml_generator.py b/tests/test_xml_generator.py new file mode 100644 index 0000000..f3bdde7 --- /dev/null +++ b/tests/test_xml_generator.py @@ -0,0 +1,82 @@ +import unittest + +# import sys + +from pain001.xml.xml_generator import xml_generator + + +class TestXmlGenerator(unittest.TestCase): + def test_xml_generator_with_invalid_input(self): + # Arrange + data = { + "amount": "100.00", + "currency": "USD", + "beneficiary_bic": "ABCDE123", + "beneficiary_iban": "DE8937060198000001234567", + "creditor_bic": "DEFGH456", + "creditor_iban": "DE893706019800000234567", + "initiator_name": "John Doe", + } + mapping = { + "amount": "Amount", + "currency": "Currency", + "beneficiary_bic": "BeneficiaryBIC", + "beneficiary_iban": "BeneficiaryIBAN", + "creditor_bic": "CreditorBIC", + "creditor_iban": "CreditorIBAN", + } + payment_initiation_message_type = "invalid_message_type" + xml_file_path = "test.xml" + xsd_file_path = "schema.xsd" + + # Act + with self.assertRaises(SystemExit): + xml_generator( + data, + mapping, + payment_initiation_message_type, + xml_file_path, + xsd_file_path, + ) + + # Assert + self.assertEqual(sys.exitcode, 1) + + def test_xml_generator_with_invalid_input(self): + # Arrange + data = { + "amount": "100.00", + "currency": "USD", + "beneficiary_bic": "ABCDE123", + "beneficiary_iban": "DE8937060198000001234567", + "creditor_bic": "DEFGH456", + "creditor_iban": "DE893706019800000234567", + } + mapping = { + "amount": "Amount", + "currency": "Currency", + "beneficiary_bic": "BeneficiaryBIC", + "beneficiary_iban": "BeneficiaryIBAN", + "creditor_bic": "CreditorBIC", + "creditor_iban": "CreditorIBAN", + } + payment_initiation_message_type = "invalid_message_type" + xml_file_path = "test.xml" + xsd_file_path = "schema.xsd" + + # Act + with self.assertRaises(SystemExit): + xml_generator( + data, + mapping, + payment_initiation_message_type, + xml_file_path, + xsd_file_path, + ) + + # Assert + # self.assertEqual(sys.exitcode, 1) + + +if __name__ == "__main__": + unittest.main() From 12605672ecede19d1ea38a33c1f07cd8c62a1055 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 21 May 2023 19:01:57 +0100 Subject: [PATCH 2/5] fix(pain001): F821 undefined name 'sys' --- tests/test_xml_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_xml_generator.py b/tests/test_xml_generator.py index f3bdde7..150cbd4 100644 --- a/tests/test_xml_generator.py +++ b/tests/test_xml_generator.py @@ -1,6 +1,6 @@ import unittest -# import sys +import sys from pain001.xml.xml_generator import xml_generator From 8a898e2bf82bc8fcd5a676fac9fa00ce64bdedbd Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 21 May 2023 19:04:09 +0100 Subject: [PATCH 3/5] fix(pain001): F811 redefinition of unused 'test_xml_generator_with_invalid_input' --- tests/test_xml_generator.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/tests/test_xml_generator.py b/tests/test_xml_generator.py index 150cbd4..f256b6a 100644 --- a/tests/test_xml_generator.py +++ b/tests/test_xml_generator.py @@ -6,42 +6,6 @@ class TestXmlGenerator(unittest.TestCase): - def test_xml_generator_with_invalid_input(self): - # Arrange - data = { - "amount": "100.00", - "currency": "USD", - "beneficiary_bic": "ABCDE123", - "beneficiary_iban": "DE8937060198000001234567", - "creditor_bic": "DEFGH456", - "creditor_iban": "DE893706019800000234567", - "initiator_name": "John Doe", - } - mapping = { - "amount": "Amount", - "currency": "Currency", - "beneficiary_bic": "BeneficiaryBIC", - "beneficiary_iban": "BeneficiaryIBAN", - "creditor_bic": "CreditorBIC", - "creditor_iban": "CreditorIBAN", - } - payment_initiation_message_type = "invalid_message_type" - xml_file_path = "test.xml" - xsd_file_path = "schema.xsd" - - # Act - with self.assertRaises(SystemExit): - xml_generator( - data, - mapping, - payment_initiation_message_type, - xml_file_path, - xsd_file_path, - ) - - # Assert - self.assertEqual(sys.exitcode, 1) - def test_xml_generator_with_invalid_input(self): # Arrange data = { From 6dce158d9d29a9a823cd9aa36a240bc97d3ed2a2 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 21 May 2023 19:06:11 +0100 Subject: [PATCH 4/5] fix(pain001): F401 'sys' imported but unused --- tests/test_xml_generator.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_xml_generator.py b/tests/test_xml_generator.py index f256b6a..48f3dc1 100644 --- a/tests/test_xml_generator.py +++ b/tests/test_xml_generator.py @@ -1,7 +1,5 @@ import unittest -import sys - from pain001.xml.xml_generator import xml_generator From c2e40d869e523b780a573f2c2887b6edfb7f4b8f Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 21 May 2023 21:30:49 +0100 Subject: [PATCH 5/5] doc(pain001): minor updates --- README.md | 323 ++++++++++++++++++++++++++----------------------- TEMPLATE.md | 57 ++++++++- pyproject.toml | 6 +- setup.py | 118 +++++++++++++++--- 4 files changed, 330 insertions(+), 174 deletions(-) diff --git a/README.md b/README.md index 4c8b0ca..9843c09 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Pain001 logo -# Python Pain001 +# Pain001 - A Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data ![Pain001 banner][banner] [![PyPI][pypi-badge]][3] [![License][license-badge]][1] [![Codecov][codecov-badge]][6] -## Overview 📖 +**Pain001** is a Python Library for Automating ISO 20022-Compliant Payment +Files Using CSV Data. -The `Pain001` Python package is a CLI tool that makes it easy to -automate the creation of ISO20022-compliant payment files directly from -a CSV file. +**Pain001** offers a streamlined solution for reducing complexity and costs +associated with payment processing. By providing a simple and efficient method +to create ISO 20022-compliant payment files, it eliminates the manual effort of +file creation and validation. This not only saves valuable time and resources +but also minimizes the risk of errors, ensuring accurate and seamless payment +processing. -With `Pain001`, you can easily create payment transactions files in just -a few simple steps. +If you are seeking to simplify and automate your payment processing, consider +leveraging the capabilities of **Pain001**. -The library supports both **Single Euro Payments Area (SEPA)** and -**non-SEPA credit transfers**, making it versatile for use in different -countries and regions. +## Features ✨ + +- **Easy to use:** The library is easy to use and requires minimal coding + knowledge, making it suitable for both developers and non-developers. +- **Open-source**: The library is open-source and free to use, making it + accessible to everyone. +- **Secure**: The library is secure and does not store any sensitive data, + ensuring that all information remains confidential. +- **Customizable**: The library allows developers to customize the output, + making it adaptable to specific business requirements and preferences. +- **Scalable solution**: The **Pain001** library can handle varying volumes of + payment files, making it suitable for businesses of different sizes and + transaction volumes. +- **Time-saving**: The automated file creation process reduces the time spent + on manual data entry and file generation, increasing overall productivity. +- **Seamless integration**: As a Python package, the **Pain001** library is + compatible with various Python-based applications and easily integrates into + any existing projects or workflows. +- **Cross-border compatibility**: The library supports both Single Euro + Payments Area (SEPA) and non-SEPA credit transfers, making it versatile for + use in different countries and regions. +- **Improve accuracy** by providing precise data, the library reduces errors in + payment file creation and processing. +- **Enhance efficiency** by automating the creation of Payment Initiation + message files +- **Accelerate payment file creation** by automating the process and reducing + the time required to create payment files. +- **Guarantee the highest quality and compliance** by validating all payment + files to meet the ISO 20022 standards. +- **Provide flexibility and choice to migrate to any supported ISO 20022 + messaging standard definitions** by simplifying the message creation process + and providing a standardized format for payment files. + +## Installation + +It takes just a few seconds to get up and running with **Pain001**. Open your +terminal and run the following command: + +```sh +pip install pain001 +``` + +## Usage + +After installation, you can run **Pain001** directly from the command line. +Simply call the main function with the path of your XML template file, XSD +schema file and the path of your CSV file containing the payment data. + +Once you have installed **Pain001**, you can generate and validate XML files +using the following command: + +```sh +python3 -m pain001 \ + \ + \ + \ + +``` + +## Arguments + +When running **Pain001**, you will need to specify four arguments: + +- `xml_message_type`: This is the type of XML message you want to generate. + Currently, the valid options are: + - pain.001.001.03 + - pain.001.001.09 +- `xml_file_path`: This is the path to the XML template file you are using. +- `xsd_file_path`: This is the path to the XSD template file you are using. +- `csv_file_path`: This is the path to the CSV data file you want to convert + to XML. + +## Examples + +Here are a few example on how to use **Pain001** to generate a +pain.001.001.03 XML file from a CSV data file: + +### Via the Command Line + +```sh +python3 -m pain001 \ + pain.001.001.03 \ + /path/to/your/pain.001.001.03.xml \ + /path/to/your/pain.001.001.03.xsd \ + /path/to/your/pain.001.001.03.csv +``` + +**Note:** The XML file that **Pain001** generates will be automatically +validated against the XSD template file before the new XML file is saved. If +the validation fails, **Pain001** will stop running and display an error +message in your terminal. + +### Embedded in an Application + +To embed **Pain001** in a new or existing application, import the main function +and use it in your code. + +Here's an example: + +```python +from pain001 import main + +if __name__ == '__main__': + xml_message_type = 'pain.001.001.03' + xml_file_path = 'template.xml' + xsd_file_path = 'schema.xsd' + csv_file_path = 'data.csv' + main(xml_message_type, xml_file_path, xsd_file_path, csv_file_path) +``` + +### Validation + +To validate the generated XML file against a given xsd schema, use the +following method: + +```python +from pain001.core import validate_xml_against_xsd + +xml_message_type = 'pain.001.001.03' +xml_file = 'generated.xml' +xsd_file = 'schema.xsd' + +is_valid = validate_xml_against_xsd( + xml_message_type, + xml_file, + xsd_file +) +print(f"XML validation result: {is_valid}") +``` -## ISO 20022 Payment Initiation Message Types 📨 +## Documentation 📖 + +> ℹī¸ **Info:** Do check out our [website][0] for more information. + +### Payment Messages The following **ISO 20022 Payment Initiation message types** are currently supported: -* **pain.001.001.03** - Customer Credit Transfer Initiation +- **pain.001.001.03** - Customer Credit Transfer Initiation This message is used to transmit credit transfer instructions from the -originator (the party initiating the payment) to the originator's bank. -The message supports both bulk and single payment instructions, allowing -for the transmission of multiple payments in a batch or individual -payments separately. The pain.001.001.03 message format is part of the -ISO 20022 standard and is commonly used for SEPA Credit Transfers within -the Single Euro Payments Area. It includes relevant information such as -the originator's and beneficiary's details, payment amounts, payment -references, and other transaction-related information required for -processing the credit transfers. - -* **pain.001.001.09** - Customer Credit Transfer Initiation - -This message format is part of the ISO 20022 standard and is commonly -used for SEPA Credit Transfers within the Single Euro Payments Area. It -enables the transmission of credit transfer instructions from the -originator to the originator's bank. The message includes essential -information such as the originator's and beneficiary's details, payment -amounts, payment references, and other transaction-related information -required for processing the credit transfers. - -More message types will be added in the future. Please refer to the -[supported messages section][supported-messages] section for more -details. - -## Features ✨ - -* **Simplify file creation:** The library generates payment files in - the desired format quickly and efficiently. -* **Ensure the highest quality and compliance:** The library - guarantees that all created payment files follow the ISO 20022 - standards. -* **Enhance efficiency:** The Pain001 library automates the creation of - Payment Initiation message files, freeing developers to focus on other - aspects of their projects and simplifying the payment process for - users. -* **Improve accuracy:** By providing precise data, the library reduces - errors in payment file creation and processing. -* **Seamless integration:** As a Python package, the Pain001 library is - compatible with various Python-based applications and easily - integrates into any existing projects or workflows. -* **Cross-border compatibility:** The library supports both Single Euro - Payments Area (SEPA) and non-SEPA credit transfers, making it - versatile for use in different countries and regions. -* **Time-saving:** The automated file creation process reduces the time - spent on manual data entry and file generation, increasing overall - productivity. -* **Scalable solution:** The Pain001 library can handle varying volumes - of payment files, making it suitable for businesses of different sizes - and transaction volumes. -* **Customisable:** The library allows developers to customise the - output, making it adaptable to specific business requirements and - preferences. +originator (the party initiating the payment) to the originator's bank. The +message supports both bulk and single payment instructions, allowing for the +transmission of multiple payments in a batch or individual payments separately. +The pain.001.001.03 message format is part of the ISO 20022 standard and is +commonly used for SEPA Credit Transfers within the Single Euro Payments Area. +It includes relevant information such as the originator's and beneficiary's +details, payment amounts, payment references, and other transaction-related +information required for processing the credit transfers. + +- **pain.001.001.09** - Customer Credit Transfer Initiation + +This message format is part of the ISO 20022 standard and is commonly used for +SEPA Credit Transfers within the Single Euro Payments Area. It enables the +transmission of credit transfer instructions from the originator to the +originator's bank. The message includes essential information such as the +originator's and beneficiary's details, payment amounts, payment references, +and other transaction-related information required for processing the credit +transfers. + +More message types will be added in the future. Please refer to the section +below for more details. ### Supported messages This section gives access to the documentation related to the ISO 20022 -message definitions supported by `Pain001`. +message definitions supported by **Pain001**. #### Bank-to-Customer Cash Management @@ -143,98 +246,17 @@ and monitor payments. | âŗ | [pain.001.001.10][pain.001.001.10] | Customer Account Closure Request | | âŗ | [pain.001.001.11][pain.001.001.11] | Customer Account Change Request | -## Getting Started 🚀 - -It takes just a few seconds to get up and running with `Pain001`. - -### Installation - -To install Pain001, run `pip install pain001` - -### Documentation - -> ℹī¸ **Info:** Do check out our [website][0] for more information. - -## Usage 📖 - -`Pain001` can be used in two ways: - -### Command Line Interface (CLI) - -After installation, you can run `pain001` directly from the command -line. Simply call the main function with the path of your XML template -file, XSD schema file and the path of your CSV file containing the -payment data. - -#### Example pain.001.001.03 - -```bash -python3 -m \pain001 "pain.001.001.03" \ - ./templates/pain.001.001.03/template.xml \ - ./templates/pain.001.001.03/pain.001.001.03.xsd \ - ./templates/pain.001.001.03/template.csv - -``` - -#### Example pain.001.001.09 - -```bash -python3 -m \pain001 "pain.001.001.09" \ - ./templates/pain.001.001.09/template.xml \ - ./templates/pain.001.001.09/pain.001.001.09.xsd \ - ./templates/pain.001.001.09/template.csv - -``` - -### Embedded in an Application - -To embed Pain001 in a new or existing application, import the main -function and use it in your code. - -Here's an example: - -```python -from pain001 import main - -if __name__ == '__main__': - xml_message_type = 'pain.001.001.03' - xml_file_path = 'template.xml' - xsd_file_path = 'schema.xsd' - csv_file_path = 'data.csv' - main(xml_file_path, xsd_file_path, csv_file_path) -``` - -### Validation - -To validate the generated XML file against a given xsd schema, use the -following method: - -```python -from pain001.core import validate_xml_against_xsd - -xml_message_type = 'pain.001.001.03' -xml_file = 'generated.xml' -xsd_file = 'schema.xsd' - -is_valid = validate_xml_against_xsd( - xml_message_type, - xml_file, - xsd_file -) -print(f"XML validation result: {is_valid}") -``` - ## License 📝 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][1] +- [MIT license][2] ## Contribution 🤝 -We welcome contributions to `Pain001`. Please see the +We welcome contributions to **Pain001**. Please see the [contributing instructions][4] for more information. Unless you explicitly state otherwise, any contribution intentionally @@ -281,4 +303,3 @@ of [Pain001][5] for their help and support. [codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/pain001?style=for-the-badge&token=AaUxKfRiou 'Codecov badge' [license-badge]: https://img.shields.io/pypi/l/pain001?style=for-the-badge 'License badge' [pypi-badge]: https://img.shields.io/pypi/pyversions/pain001.svg?style=for-the-badge 'PyPI badge' -[supported-messages]: #supported-messages 'Supported messages' diff --git a/TEMPLATE.md b/TEMPLATE.md index f4982d2..28d3b06 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -16,11 +16,60 @@ [![PyPI][pypi]][2] [![License][license]][1] [![Codecov][codecov]][3] -## Overview 📖 +**Pain001** is a Python Library for Automating ISO 20022-Compliant Payment +Files Using CSV Data. -The `Pain001` Python package is a CLI tool that makes it easy to -automate the creation of ISO20022-compliant payment files directly from -a CSV file. +**Pain001** offers a streamlined solution for reducing complexity and costs +associated with payment processing. By providing a simple and efficient method +to create ISO 20022-compliant payment files, it eliminates the manual effort of +file creation and validation. This not only saves valuable time and resources +but also minimizes the risk of errors, ensuring accurate and seamless payment +processing. + +If you are seeking to simplify and automate your payment processing, consider +leveraging the capabilities of **Pain001**. + +## Features ✨ + +- **Easy to use:** The library is easy to use and requires minimal coding + knowledge, making it suitable for both developers and non-developers. +- **Open-source**: The library is open-source and free to use, making it + accessible to everyone. +- **Secure**: The library is secure and does not store any sensitive data, + ensuring that all information remains confidential. +- **Customizable**: The library allows developers to customize the output, + making it adaptable to specific business requirements and preferences. +- **Scalable solution**: The **Pain001** library can handle varying volumes of + payment files, making it suitable for businesses of different sizes and + transaction volumes. +- **Time-saving**: The automated file creation process reduces the time spent + on manual data entry and file generation, increasing overall productivity. +- **Seamless integration**: As a Python package, the **Pain001** library is + compatible with various Python-based applications and easily integrates into + any existing projects or workflows. +- **Cross-border compatibility**: The library supports both Single Euro + Payments Area (SEPA) and non-SEPA credit transfers, making it versatile for + use in different countries and regions. +- **Improve accuracy** by providing precise data, the library reduces errors in + payment file creation and processing. +- **Enhance efficiency** by automating the creation of Payment Initiation + message files +- **Accelerate payment file creation** by automating the process and reducing + the time required to create payment files. +- **Guarantee the highest quality and compliance** by validating all payment + files to meet the ISO 20022 standards. +- **Provide flexibility and choice to migrate to any supported ISO 20022 + messaging standard definitions** by simplifying the message creation process + and providing a standardized format for payment files. + +## Installation + +It takes just a few seconds to get up and running with **Pain001**. Open your +terminal and run the following command: + +```sh +pip install pain001 +``` [1]: https://opensource.org/license/apache-2-0/ [2]: https://github.com/sebastienrousseau/pain001 diff --git a/pyproject.toml b/pyproject.toml index 6db9901..e238f17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [tool.poetry] name = "pain001" version = "0.0.18" -description = "pain001 is a Python library that makes it easy to automate the creation of ISO20022-compliant payment files directly from a CSV file." -authors = ["Sebastien Rousseau "] +description = "Pain001 is a Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data." +authors = ["Sebastien Rousseau "] license = "Apache Software License" readme = "README.md" repository = "https://github.com/sebastienrousseau/pain001" @@ -10,7 +10,7 @@ homepage = "https://pain001.com" [tool.poetry.dependencies] python = "^3.9" -xmlschema = "^1.8.0" +xmlschema = "^2.3.0" [build-system] requires = ["poetry-core"] diff --git a/setup.py b/setup.py index 2a6d1ba..823607d 100644 --- a/setup.py +++ b/setup.py @@ -32,9 +32,43 @@ If you are seeking to simplify and automate your payment processing, consider leveraging the capabilities of **Pain001**. +## Features ✨ + +- **Easy to use:** The library is easy to use and requires minimal coding +knowledge, making it suitable for both developers and non-developers. +- **Open-source**: The library is open-source and free to use, making it +accessible to everyone. +- **Secure**: The library is secure and does not store any sensitive data, +ensuring that all information remains confidential. +- **Customizable**: The library allows developers to customize the output, +making it adaptable to specific business requirements and preferences. +- **Scalable solution**: The **Pain001** library can handle varying volumes of +payment files, making it suitable for businesses of different sizes and +transaction volumes. +- **Time-saving**: The automated file creation process reduces the time spent +on manual data entry and file generation, increasing overall productivity. +- **Seamless integration**: As a Python package, the **Pain001** library is +compatible with various Python-based applications and easily integrates into +any existing projects or workflows. +- **Cross-border compatibility**: The library supports both Single Euro +Payments Area (SEPA) and non-SEPA credit transfers, making it versatile for +use in different countries and regions. +- **Improve accuracy** by providing precise data, the library reduces errors in +payment file creation and processing. +- **Enhance efficiency** by automating the creation of Payment Initiation +message files +- **Accelerate payment file creation** by automating the process and reducing +the time required to create payment files. +- **Guarantee the highest quality and compliance** by validating all payment +files to meet the ISO 20022 standards. +- **Provide flexibility and choice to migrate to any supported ISO 20022 +messaging standard definitions** by simplifying the message creation process +and providing a standardized format for payment files. + ## Installation -To install **Pain001**, run this command in your terminal: +It takes just a few seconds to get up and running with **Pain001**. Open your +terminal and run the following command: ```sh pip install pain001 @@ -42,7 +76,12 @@ ## Usage -To use **Pain001**, run this command in your terminal: +After installation, you can run **Pain001** directly from the command line. +Simply call the main function with the path of your XML template file, XSD +schema file and the path of your CSV file containing the payment data. + +Once you have installed **Pain001**, you can generate and validate XML files +using the following command: ```sh python3 -m pain001 \ @@ -52,19 +91,25 @@ ``` -## Arguments: +## Arguments + +When running **Pain001**, you will need to specify four arguments: -- `xml_message_type`: The type of XML message. The current valid values are: - - pain.001.001.03 and +- `xml_message_type`: This is the type of XML message you want to generate. +Currently, the valid options are: + - pain.001.001.03 - pain.001.001.09 -- `xml_file_path`: The path to the XML template file. -- `xsd_file_path`: The path to the XSD template file. -- `csv_file_path`: The path to the CSV data file. +- `xml_file_path`: This is the path to the XML template file you are using. +- `xsd_file_path`: This is the path to the XSD template file you are using. +- `csv_file_path`: This is the path to the CSV data file you want to convert to +XML. -## Example: +## Examples -To generate a pain.001.001.03 XML file from the CSV data file you can run the -following command in your terminal: +Here are a few example on how to use **Pain001** to generate a +pain.001.001.03 XML file from a CSV data file: + +### Via the Command Line ```sh python3 -m pain001 \ @@ -74,12 +119,53 @@ /path/to/your/pain.001.001.03.csv ``` -Note: The generated XML file will be validated against the XSD template -file before being saved. If the validation fails, the program will exit -with an error message. +**Note:** The XML file that **Pain001** generates will be automatically +validated against the XSD template file before the new XML file is saved. If +the validation fails, **Pain001** will stop running and display an error +message in your terminal. + +### Embedded in an Application + +To embed **Pain001** in a new or existing application, import the main function +and use it in your code. + +Here's an example: + +```python +from pain001 import main + +if __name__ == '__main__': + xml_message_type = 'pain.001.001.03' + xml_file_path = 'template.xml' + xsd_file_path = 'schema.xsd' + csv_file_path = 'data.csv' + main(xml_message_type, xml_file_path, xsd_file_path, csv_file_path) +``` + +### Validation + +To validate the generated XML file against a given xsd schema, use the +following method: + +```python +from pain001.core import validate_xml_against_xsd + +xml_message_type = 'pain.001.001.03' +xml_file = 'generated.xml' +xsd_file = 'schema.xsd' + +is_valid = validate_xml_against_xsd( + xml_message_type, + xml_file, + xsd_file +) +print(f"XML validation result: {is_valid}") +``` + +## Documentation 📖 -For more information, please visit the project's GitHub page at: -. +> ℹī¸ **Info:** Do check out our for more information on +the Pain001 documentation. """.strip() SHORT_DESCRIPTION = """