From d95623e5c04498c997b77f00a41f3a5a84902d5f Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 19 Jun 2023 19:17:04 +0100 Subject: [PATCH 1/5] feat(pain001): v0.0.21 --- README.md | 3 +- docs/404.html | 6 - docs/404/index.html | 8 - docs/404/manifest.json | 19 - docs/404/robots.txt | 2 - docs/404/rss.xml | 1 - docs/404/sitemap.xml | 30 - docs/CNAME | 2 - docs/browserconfig.xml | 12 - docs/humans.txt | 1 - docs/index.html | 8 - docs/manifest.json | 19 - docs/pain.001.001.03/index.html | 10 - docs/pain.001.001.03/manifest.json | 19 - docs/pain.001.001.03/robots.txt | 2 - docs/pain.001.001.03/rss.xml | 1 - docs/pain.001.001.03/sitemap.xml | 30 - docs/pain.001.001.09/index.html | 9 - docs/pain.001.001.09/manifest.json | 19 - docs/pain.001.001.09/robots.txt | 2 - docs/pain.001.001.09/rss.xml | 1 - docs/pain.001.001.09/sitemap.xml | 30 - docs/payments/index.html | 8 - docs/payments/manifest.json | 19 - docs/payments/robots.txt | 2 - docs/payments/rss.xml | 1 - docs/payments/sitemap.xml | 30 - docs/robots.txt | 2 - docs/rss.xml | 1 - docs/sitemap.xml | 30 - pain001/__init__.py | 2 +- pain001/core/core.py | 3 + pain001/xml/generate_xml.py | 133 +++ pain001/xml/write_xml_to_file.py | 4 +- pain001/xml/xml_generator.py | 9 +- pyproject.toml | 2 +- setup.cfg | 2 +- setup.py | 2 +- templates/pain.001.001.04/pain.001.001.04.xml | 263 +++++ templates/pain.001.001.04/pain.001.001.04.xsd | 968 ++++++++++++++++++ templates/pain.001.001.04/template.csv | 6 + templates/pain.001.001.04/template.db | Bin 0 -> 8192 bytes templates/pain.001.001.04/template.xml | 96 ++ 43 files changed, 1485 insertions(+), 332 deletions(-) delete mode 100644 docs/404.html delete mode 100644 docs/404/index.html delete mode 100644 docs/404/manifest.json delete mode 100644 docs/404/robots.txt delete mode 100644 docs/404/rss.xml delete mode 100644 docs/404/sitemap.xml delete mode 100644 docs/CNAME delete mode 100644 docs/browserconfig.xml delete mode 100644 docs/humans.txt delete mode 100644 docs/index.html delete mode 100644 docs/manifest.json delete mode 100644 docs/pain.001.001.03/index.html delete mode 100644 docs/pain.001.001.03/manifest.json delete mode 100644 docs/pain.001.001.03/robots.txt delete mode 100644 docs/pain.001.001.03/rss.xml delete mode 100644 docs/pain.001.001.03/sitemap.xml delete mode 100644 docs/pain.001.001.09/index.html delete mode 100644 docs/pain.001.001.09/manifest.json delete mode 100644 docs/pain.001.001.09/robots.txt delete mode 100644 docs/pain.001.001.09/rss.xml delete mode 100644 docs/pain.001.001.09/sitemap.xml delete mode 100644 docs/payments/index.html delete mode 100644 docs/payments/manifest.json delete mode 100644 docs/payments/robots.txt delete mode 100644 docs/payments/rss.xml delete mode 100644 docs/payments/sitemap.xml delete mode 100644 docs/robots.txt delete mode 100644 docs/rss.xml delete mode 100644 docs/sitemap.xml create mode 100644 templates/pain.001.001.04/pain.001.001.04.xml create mode 100644 templates/pain.001.001.04/pain.001.001.04.xsd create mode 100644 templates/pain.001.001.04/template.csv create mode 100644 templates/pain.001.001.04/template.db create mode 100644 templates/pain.001.001.04/template.xml diff --git a/README.md b/README.md index 209de8d..8e3b146 100644 --- a/README.md +++ b/README.md @@ -307,7 +307,7 @@ and monitor payments. | Status | Message type | Name | |---|---|---| | ✅ | [pain.001.001.03][pain.001.001.03] | Customer Credit Transfer Initiation | -| ⏳ | pain.001.001.04 | Customer Direct Debit Initiation | +| ✅ | [pain.001.001.04][pain.001.001.04] | Customer Direct Debit Initiation | | ⏳ | pain.001.001.05 | Customer Direct Debit Reversal | | ⏳ | pain.001.001.06 | Customer Credit Transfer Reversal | | ⏳ | pain.001.001.07 | Customer Account Notification | @@ -349,6 +349,7 @@ of [Pain001][5] for their help and support. [7]: 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.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/docs/404.html b/docs/404.html deleted file mode 100644 index a0d088c..0000000 --- a/docs/404.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/docs/404/index.html b/docs/404/index.html deleted file mode 100644 index 261fea7..0000000 --- a/docs/404/index.html +++ /dev/null @@ -1,8 +0,0 @@ -404 - Page not found
404 - Page not found

Sorry we can't find that page.

404 - Page not found

The page may have been removed or renamed. Please visit our homepage for more information.

Overview

This page is a 404 error, which means you have clicked on a bad link or you have asked for a page that does not exist. Please find some helpful links below to get you back on track.

  • Homepage - The homepage of this website.
\ No newline at end of file diff --git a/docs/404/manifest.json b/docs/404/manifest.json deleted file mode 100644 index 9d1eeb8..0000000 --- a/docs/404/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "background_color": "#ffffff", - "description": "The page may have been removed or renamed. Please visit our homepage for more information.", - "display": "standalone", - "icons": [ - { - "purpose": "any maskable", - "sizes": "512x512", - "src": "https://kura.pro/pain001/images/favicon.ico", - "type": "image/png" - } - ], - "name": "404 - Page not found", - "orientation": "portrait-primary", - "scope": "/", - "short_name": "404", - "start_url": ".", - "theme_color": "#000000" -} \ No newline at end of file diff --git a/docs/404/robots.txt b/docs/404/robots.txt deleted file mode 100644 index 647c4dc..0000000 --- a/docs/404/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Sitemap: https://pain001.com/404/index.html/sitemap.xml \ No newline at end of file diff --git a/docs/404/rss.xml b/docs/404/rss.xml deleted file mode 100644 index 11ed8bb..0000000 --- a/docs/404/rss.xml +++ /dev/null @@ -1 +0,0 @@ -404 - Page not foundhttps://pain001.com/404/index.htmlThe page may have been removed or renamed. Please visit our homepage for more information.Shokunin Static Site Generator (v0.0.13)en-GBFri, 09 June 2023 19:19:19 BSTFri, 09 June 2023 19:19:19 BST404 - Page not foundhttps://pain001.com/404/rss.xmlFri, 09 June 2023 19:19:19 BSThttps://pain001.com/404/index.htmlThe page may have been removed or renamed. Please visit our homepage for more information. \ No newline at end of file diff --git a/docs/404/sitemap.xml b/docs/404/sitemap.xml deleted file mode 100644 index dca90a8..0000000 --- a/docs/404/sitemap.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -https://pain001.com/404/index.html/payments/index.html -weekly - - - -https://pain001.com/404/index.html/index.html -weekly - - - -https://pain001.com/404/index.html/pain.001.001.03/index.html -weekly - - - -https://pain001.com/404/index.html/installation/index.html -weekly - - - -https://pain001.com/404/index.html/404/index.html -weekly - - - -https://pain001.com/404/index.html/pain.001.001.09/index.html -weekly - \ No newline at end of file diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 9bf6296..0000000 --- a/docs/CNAME +++ /dev/null @@ -1,2 +0,0 @@ -www.pain001.com -pain001.com \ No newline at end of file diff --git a/docs/browserconfig.xml b/docs/browserconfig.xml deleted file mode 100644 index a168612..0000000 --- a/docs/browserconfig.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - #0092a5 - - - - \ No newline at end of file diff --git a/docs/humans.txt b/docs/humans.txt deleted file mode 100644 index cc9c478..0000000 --- a/docs/humans.txt +++ /dev/null @@ -1 +0,0 @@ -Pain001 is a powerful Python library that enables you to create ISO 20022-compliant payment files directly from CSV or SQLite Data Files. \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 89ac628..0000000 --- a/docs/index.html +++ /dev/null @@ -1,8 +0,0 @@ -Pain001: Automate ISO 20022-Compliant Payment File Creation
Pain001: Automate ISO 20022-Compliant Payment File Creation

Simplify payment processing with Pain001, a Python library automating ISO 20022-compliant file creation

Pain001: Automate ISO 20022-Compliant Payment File Creation

Pain001 is a powerful Python library that enables you to create ISO 20022-compliant payment files directly from CSV or SQLite Data Files.

Overview

Today, the payment industry is experiencing a rapid evolution and transformation as it moves towards adopting ISO 20022 as the new norm. ISO 20022 is a global standard for sharing financial information across organisations. It provides a harmonised protocol used by banks, corporations, and financial institutions to automate and standardise payment transactions.

Here are some of the benefits of using ISO 20022:

  • Improved data quality: ISO 20022 messages are more structured and detailed than traditional payment messages, reducing errors and improving efficiency.
  • Increased transparency: ISO 20022 messages provide more information about the payment transaction, which can help to improve the visibility and traceability of payments.
  • Enhanced compliance: ISO 20022 messages can help organisations follow AML/CFT and PSD2 regulations.

Overall, ISO 20022 is a significant improvement over traditional payment messaging standards. It provides a more efficient, transparent, and compliant way to process payments.

Pain001 in action

The Python library Pain001 focuses specifically on payment initiation and advice messages, commonly known as pain. 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.

Pain001 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.

If you are seeking to simplify and automate your payment processing, consider leveraging the capabilities of Pain001.

Features

  • Easy to use: Both developers and non-developers can easily use the library, as it requires minimal coding knowledge.
  • 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, making sure that all information remains confidential.
  • Customizable: The library allows developers to customise 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.
  • Simplify ISO 20022-compliant payment initiation message creation by providing a standardised payment file format.
  • Reduce costs by removing manual data entry and file generation, reducing payment processing time, and reducing errors.
\ No newline at end of file diff --git a/docs/manifest.json b/docs/manifest.json deleted file mode 100644 index 22498c0..0000000 --- a/docs/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "background_color": "#ffffff", - "description": "Pain001 is a powerful Python library that enables you to create ISO 20022-compliant payment files directly from CSV or SQLite Data Files.", - "display": "standalone", - "icons": [ - { - "purpose": "any maskable", - "sizes": "512x512", - "src": "https://kura.pro/pain001/images/favicon.ico", - "type": "image/png" - } - ], - "name": "Pain001: Automate ISO 20022-Compliant Payment File Creation", - "orientation": "portrait-primary", - "scope": "/", - "short_name": "Pain001", - "start_url": ".", - "theme_color": "#0092a5" -} \ No newline at end of file diff --git a/docs/pain.001.001.03/index.html b/docs/pain.001.001.03/index.html deleted file mode 100644 index 0ccfce5..0000000 --- a/docs/pain.001.001.03/index.html +++ /dev/null @@ -1,10 +0,0 @@ -Customer Credit Transfer Initiation V3 (pain.001.001.03)
Customer Credit Transfer Initiation V3 (pain.001.001.03)

pain.001.001.03: A standardized XML message format for initiating credit transfers.

Customer Credit Transfer Initiation V3 (pain.001.001.03)

pain.001.001.03, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.

Overview

The Customer Credit Transfer Initiation V3 (pain.001.001.03) is an XML -based message format under the ISO 20022 standard, designed to streamline cross-border and domestic payment processes. With the increasing demand for efficient, secure, and standardized payment methods, financial institutions and their customers face challenges related to the complexity, speed, and cost of executing credit transfers.

Features/Benefits

  • Standardized Format: The pain.001.001.03 message format provides a consistent structure for initiating credit transfers, making it easier for financial institutions to process and manage transactions.
  • Increased Efficiency: By adopting the pain.001.001.03 format, financial institutions can automate and streamline the credit transfer initiation process, reducing manual intervention and errors.
  • Enhanced Remittance Data: The format allows for more extensive remittance information, providing clearer transaction details for both sender and receiver.
  • Improved Compliance: The standardized message structure helps organizations meet regulatory requirements and reduces the risk of non-compliance penalties.
  • Interoperability: The pain.001.001.03 format is compatible with other ISO 20022 messages, facilitating seamless communication between different financial institutions and systems.

Market Opportunity

The adoption of pain.001.001.03 presents a significant market opportunity for financial institutions.

By implementing this message format, organizations can:

  • Enhance customer experience by offering faster and more transparent transactions
  • Improve operational efficiency and reduce costs associated with manual processing
  • Position themselves as industry leaders in adopting global standards for payment processing
  • Leverage the ISO 20022 standard to explore new business opportunities and partnerships
  • Ensure compliance with evolving regulatory requirements and stay ahead of the competition
\ No newline at end of file diff --git a/docs/pain.001.001.03/manifest.json b/docs/pain.001.001.03/manifest.json deleted file mode 100644 index bb5a179..0000000 --- a/docs/pain.001.001.03/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "background_color": "#ffffff", - "description": "pain.001.001.03, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.", - "display": "standalone", - "icons": [ - { - "purpose": "any maskable", - "sizes": "512x512", - "src": "https://kura.pro/pain001/images/favicon.ico", - "type": "image/png" - } - ], - "name": "Customer Credit Transfer Initiation V3 (pain.001.001.03)", - "orientation": "portrait-primary", - "scope": "/", - "short_name": "pain.001.001.03", - "start_url": ".", - "theme_color": "#462232" -} \ No newline at end of file diff --git a/docs/pain.001.001.03/robots.txt b/docs/pain.001.001.03/robots.txt deleted file mode 100644 index 347d265..0000000 --- a/docs/pain.001.001.03/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Sitemap: https://pain001.com/pain.001.001.03/index.html/sitemap.xml \ No newline at end of file diff --git a/docs/pain.001.001.03/rss.xml b/docs/pain.001.001.03/rss.xml deleted file mode 100644 index f46cd72..0000000 --- a/docs/pain.001.001.03/rss.xml +++ /dev/null @@ -1 +0,0 @@ -Customer Credit Transfer Initiation V3 (pain.001.001.03)https://pain001.com/pain.001.001.03/index.htmlpain.001.001.03, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.Shokunin Static Site Generator (v0.0.13)en-GBFri, 09 June 2023 19:19:19 BSTFri, 09 June 2023 19:19:19 BSTCustomer Credit Transfer Initiation V3 (pain.001.001.03)https://pain001.com/pain.001.001.03/rss.xmlFri, 09 June 2023 19:19:19 BSThttps://pain001.com/pain.001.001.03/index.htmlpain.001.001.03, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes. \ No newline at end of file diff --git a/docs/pain.001.001.03/sitemap.xml b/docs/pain.001.001.03/sitemap.xml deleted file mode 100644 index f113b78..0000000 --- a/docs/pain.001.001.03/sitemap.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -https://pain001.com/pain.001.001.03/index.html/payments/index.html -weekly - - - -https://pain001.com/pain.001.001.03/index.html/index.html -weekly - - - -https://pain001.com/pain.001.001.03/index.html/pain.001.001.03/index.html -weekly - - - -https://pain001.com/pain.001.001.03/index.html/installation/index.html -weekly - - - -https://pain001.com/pain.001.001.03/index.html/404/index.html -weekly - - - -https://pain001.com/pain.001.001.03/index.html/pain.001.001.09/index.html -weekly - \ No newline at end of file diff --git a/docs/pain.001.001.09/index.html b/docs/pain.001.001.09/index.html deleted file mode 100644 index 7d88998..0000000 --- a/docs/pain.001.001.09/index.html +++ /dev/null @@ -1,9 +0,0 @@ -Customer Credit Transfer Initiation V9 (pain.001.001.09)
Customer Credit Transfer Initiation V9 (pain.001.001.09)

pain.001.001.09: A standardized XML message format that streamlines cross-border and domestic payments.

Customer Credit Transfer Initiation V9 (pain.001.001.09)

pain.001.001.09, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.

Overview

The Customer Credit Transfer Initiation V9 (pain.001.001.09) is an XML-based message format under the ISO 20022 standard, designed to streamline cross-border and domestic payment processes. It is the successor to the Customer Credit Transfer Initiation V9 (pain.001.001.09) message format, and includes a number of enhancements that improve the efficiency, security, and flexibility of payment processing.

Features/Benefits

The pain.001.001.09 message format offers a number of features and benefits over the previous version, including:

  • Enhanced data richness: The format includes additional data elements that provide more detailed information about the payment, such as the purpose of the payment, the tax identification numbers of the sender and receiver, and the reason for the payment.
  • Improved flexibility: The format allows for more flexible payment instructions, such as the ability to specify multiple payment beneficiaries and the ability to split payments between multiple accounts.
  • Increased security: The format includes a number of security features that help to protect payments from fraud and errors, such as digital signatures and encryption.
  • Improved interoperability: The format is compatible with other ISO 20022 messages, which facilitates seamless communication between different financial institutions and systems.

Market Opportunity

The adoption of pain.001.001.09 presents a significant market opportunity for financial institutions. By implementing this message format, organizations can:

  • Enhance customer experience by offering faster and more transparent payments
  • Improve operational efficiency and reduce costs associated with manual processing
  • Position themselves as industry leaders in adopting global standards for payment processing
  • Leverage the ISO 20022 standard to explore new business opportunities and partnerships
  • Ensure compliance with evolving regulatory requirements and stay ahead of the competition
\ No newline at end of file diff --git a/docs/pain.001.001.09/manifest.json b/docs/pain.001.001.09/manifest.json deleted file mode 100644 index 9078bfb..0000000 --- a/docs/pain.001.001.09/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "background_color": "#ffffff", - "description": "pain.001.001.09, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.", - "display": "standalone", - "icons": [ - { - "purpose": "any maskable", - "sizes": "512x512", - "src": "https://kura.pro/pain001/images/favicon.ico", - "type": "image/png" - } - ], - "name": "Customer Credit Transfer Initiation V9 (pain.001.001.09)", - "orientation": "portrait-primary", - "scope": "/", - "short_name": "pain.001.001.09", - "start_url": ".", - "theme_color": "#004957" -} \ No newline at end of file diff --git a/docs/pain.001.001.09/robots.txt b/docs/pain.001.001.09/robots.txt deleted file mode 100644 index 95be5e3..0000000 --- a/docs/pain.001.001.09/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Sitemap: https://pain001.com/pain.001.001.09/index.html/sitemap.xml \ No newline at end of file diff --git a/docs/pain.001.001.09/rss.xml b/docs/pain.001.001.09/rss.xml deleted file mode 100644 index d7a982d..0000000 --- a/docs/pain.001.001.09/rss.xml +++ /dev/null @@ -1 +0,0 @@ -Customer Credit Transfer Initiation V9 (pain.001.001.09)https://pain001.com/pain.001.001.09/index.htmlpain.001.001.09, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes.Shokunin Static Site Generator (v0.0.13)en-GBFri, 09 June 2023 19:19:19 BSTFri, 09 June 2023 19:19:19 BSTCustomer Credit Transfer Initiation V9 (pain.001.001.09)https://pain001.com/pain.001.001.09/rss.xmlFri, 09 June 2023 19:19:19 BSThttps://pain001.com/pain.001.001.09/index.htmlpain.001.001.09, is an XML-based message format under the ISO 20022 standard designed to streamline cross-border and domestic payment processes. \ No newline at end of file diff --git a/docs/pain.001.001.09/sitemap.xml b/docs/pain.001.001.09/sitemap.xml deleted file mode 100644 index 57952b0..0000000 --- a/docs/pain.001.001.09/sitemap.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -https://pain001.com/pain.001.001.09/index.html/payments/index.html -weekly - - - -https://pain001.com/pain.001.001.09/index.html/index.html -weekly - - - -https://pain001.com/pain.001.001.09/index.html/pain.001.001.03/index.html -weekly - - - -https://pain001.com/pain.001.001.09/index.html/installation/index.html -weekly - - - -https://pain001.com/pain.001.001.09/index.html/404/index.html -weekly - - - -https://pain001.com/pain.001.001.09/index.html/pain.001.001.09/index.html -weekly - \ No newline at end of file diff --git a/docs/payments/index.html b/docs/payments/index.html deleted file mode 100644 index f32ca48..0000000 --- a/docs/payments/index.html +++ /dev/null @@ -1,8 +0,0 @@ -Automate Payments Generation with Pain001
Automate Payments Generation with Pain001

A modern, open source solution for generating ISO 20022 compliant payments

Automate Payments Generation with Pain001

Streamline your payments with Pain001, a Python library that automates the creation of ISO 20022 payment messages.

Overview

Pain001 automates the creation of ISO 20022 payment messages, mitigating human errors and facilitating more efficient payment operations. The library simplifies the generation of ISO20022 messages and integrates seamlessly into your current systems, allowing for a simple adoption of ISO 20022.

The ISO 20022 Standard is a universally accepted, consensus-based standard for financial information. It helps banks, financial markets, businesses, and consumers by giving them a way to effectively and accurately exchange financial data.

The library generates Pain messages for SEPA and SWIFT payments. These messages initiate the process of transferring funds from one account to another. They have important information like the payer, payee, and amount to transfer.

Payment Messages

The following ISO 20022 Payment Initiation message types are currently supported:

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.

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.

Pain001 is a powerful tool that can help businesses and organizations to simplify and automate their payment processing by providing a simple and easy way to create ISO 20022-compliant payment files.

Whether your corporation has a centralised or decentralised structure, Pain001 will help you effectively manage your payments. We offer a wide range of payments to meet your needs, no matter the size or complexity of your payments needs.

\ No newline at end of file diff --git a/docs/payments/manifest.json b/docs/payments/manifest.json deleted file mode 100644 index 223e879..0000000 --- a/docs/payments/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "background_color": "#ffffff", - "description": "Streamline your payments with Pain001, a Python library that automates the creation of ISO 20022 payment messages.", - "display": "standalone", - "icons": [ - { - "purpose": "any maskable", - "sizes": "512x512", - "src": "https://kura.pro/pain001/images/favicon.ico", - "type": "image/png" - } - ], - "name": "Automate Payments Generation with Pain001", - "orientation": "portrait-primary", - "scope": "/", - "short_name": "payments", - "start_url": ".", - "theme_color": "#0092a5" -} \ No newline at end of file diff --git a/docs/payments/robots.txt b/docs/payments/robots.txt deleted file mode 100644 index f2d61f9..0000000 --- a/docs/payments/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Sitemap: https://pain001.com/payments/index.html/sitemap.xml \ No newline at end of file diff --git a/docs/payments/rss.xml b/docs/payments/rss.xml deleted file mode 100644 index 3e4803d..0000000 --- a/docs/payments/rss.xml +++ /dev/null @@ -1 +0,0 @@ -Automate Payments Generation with Pain001https://pain001.com/payments/index.htmlStreamline your payments with Pain001, a Python library that automates the creation of ISO 20022 payment messages.Shokunin Static Site Generator (v0.0.13)en-GBFri, 09 June 2023 19:19:19 BSTFri, 09 June 2023 19:19:19 BSTPaymentshttps://pain001.com/payments/rss.xmlFri, 09 June 2023 19:19:19 BSThttps://pain001.com/payments/index.htmlStreamline your payments with Pain001, a Python library that automates the creation of ISO 20022 payment messages. \ No newline at end of file diff --git a/docs/payments/sitemap.xml b/docs/payments/sitemap.xml deleted file mode 100644 index 8b11aea..0000000 --- a/docs/payments/sitemap.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -https://pain001.com/payments/index.html/payments/index.html -weekly - - - -https://pain001.com/payments/index.html/index.html -weekly - - - -https://pain001.com/payments/index.html/pain.001.001.03/index.html -weekly - - - -https://pain001.com/payments/index.html/installation/index.html -weekly - - - -https://pain001.com/payments/index.html/404/index.html -weekly - - - -https://pain001.com/payments/index.html/pain.001.001.09/index.html -weekly - \ No newline at end of file diff --git a/docs/robots.txt b/docs/robots.txt deleted file mode 100644 index cb1b11c..0000000 --- a/docs/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Sitemap: https://pain001.com//sitemap.xml \ No newline at end of file diff --git a/docs/rss.xml b/docs/rss.xml deleted file mode 100644 index 81ef91e..0000000 --- a/docs/rss.xml +++ /dev/null @@ -1 +0,0 @@ -Pain001: Automate ISO 20022-Compliant Payment File Creationhttps://pain001.com/Pain001 is a powerful Python library that enables you to create ISO 20022-compliant payment files directly from CSV or SQLite Data Files.Shokunin Static Site Generator (v0.0.13)en-GBFri, 09 June 2023 19:19:19 BSTFri, 09 June 2023 19:19:19 BSTPain001: Automate ISO 20022-Compliant Payment File Creationhttps://pain001.com/rss.xmlFri, 09 June 2023 19:19:19 BSThttps://pain001.com/index.htmlPain001 is a powerful Python library that enables you to create ISO 20022-compliant payment files directly from CSV or SQLite Data Files. \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml deleted file mode 100644 index 694379c..0000000 --- a/docs/sitemap.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -https://pain001.com//payments/index.html -weekly - - - -https://pain001.com//index.html -weekly - - - -https://pain001.com//pain.001.001.03/index.html -weekly - - - -https://pain001.com//installation/index.html -weekly - - - -https://pain001.com//404/index.html -weekly - - - -https://pain001.com//pain.001.001.09/index.html -weekly - \ No newline at end of file diff --git a/pain001/__init__.py b/pain001/__init__.py index 51a2f95..cfe080a 100644 --- a/pain001/__init__.py +++ b/pain001/__init__.py @@ -15,4 +15,4 @@ """The Python pain001 module.""" __all__ = ["pain001"] -__version__ = "0.0.20" +__version__ = "0.0.21" diff --git a/pain001/core/core.py b/pain001/core/core.py index 13b2b46..382264d 100644 --- a/pain001/core/core.py +++ b/pain001/core/core.py @@ -87,6 +87,9 @@ def process_files( logger.error(error_message) raise FileNotFoundError(error_message) + # Sanitize the path to the data file. + data_file_path = os.path.normpath(data_file_path) + # Check if the data file exists if not os.path.exists(data_file_path): error_message = ( diff --git a/pain001/xml/generate_xml.py b/pain001/xml/generate_xml.py index 73e64a2..b79aa62 100644 --- a/pain001/xml/generate_xml.py +++ b/pain001/xml/generate_xml.py @@ -194,6 +194,139 @@ def create_xml_v3(root, data, mapping): cstmr_cdt_trf_initn_element.append(PmtInf_element) +def create_xml_v4(root, data, mapping): + """Creates an XML document for the pain.001.001.04 format. + + Args: + root: The root element of the XML document. + data: A list of dictionaries containing the payment data. + mapping: A dictionary that maps XML element names to CSV column names. + + Returns: + The root element of the XML document. + """ + + # Create new "CstmrCdtTrfInitn" element in the XML tree + cstmr_cdt_trf_initn_element = ET.Element("CstmrCdtTrfInitn") + root.append(cstmr_cdt_trf_initn_element) + + # Create new "GrpHdr" element in the XML tree + GrpHdr_element = ET.Element("GrpHdr") + cstmr_cdt_trf_initn_element.append(GrpHdr_element) + + # Loop through the first row of the CSV file and create new + # "MsgId", "CreDtTm" and "NbOfTxs" elements in the XML tree + for xml_tag, csv_column in mapping.items(): + if xml_tag in ["MsgId", "CreDtTm", "NbOfTxs"]: + create_xml_element( + GrpHdr_element, xml_tag, data[0][csv_column] + ) + # Create new "InitgPty" element in the XML tree using data + InitgPty_element = ET.Element("InitgPty") + create_xml_element( + InitgPty_element, "Nm", data[0]["initiator_name"] + ) + GrpHdr_element.append(InitgPty_element) + + # Loop through the Data file and create new "PmtInf" elements + for row in data: + PmtInf_element = ET.Element("PmtInf") + cstmr_cdt_trf_initn_element.append(PmtInf_element) + + create_common_elements(PmtInf_element, row, mapping) + + create_xml_element( + PmtInf_element, "BtchBookg", row["batch_booking"].lower() + ) + + create_xml_element(PmtInf_element, "NbOfTxs", row["nb_of_txs"]) + + create_xml_element( + PmtInf_element, "CtrlSum", f"{row['control_sum']}" + ) + + PmtTpInf_element = ET.Element("PmtTpInf") + SvcLvl_element = ET.Element("SvcLvl") + Cd_element = ET.Element("Cd") + Cd_element.text = row["service_level_code"] + SvcLvl_element.append(Cd_element) + PmtTpInf_element.append(SvcLvl_element) + PmtInf_element.append(PmtTpInf_element) + + create_xml_element( + PmtInf_element, + "ReqdExctnDt", + row["requested_execution_date"], + ) + + Dbtr_element = ET.Element("Dbtr") + Nm_element = ET.Element("Nm") + Nm_element.text = row["debtor_name"] + Dbtr_element.append(Nm_element) + PmtInf_element.append(Dbtr_element) + + DbtrAcct_element = ET.Element("DbtrAcct") + Id_element = ET.Element("Id") + IBAN_element = ET.Element("IBAN") + IBAN_element.text = row["debtor_account_IBAN"] + Id_element.append(IBAN_element) + DbtrAcct_element.append(Id_element) + PmtInf_element.append(DbtrAcct_element) + + DbtrAgt_element = ET.Element("DbtrAgt") + FinInstnId_element = ET.Element("FinInstnId") + BIC_element = ET.Element("BICFI") + BIC_element.text = row["debtor_agent_BIC"] + FinInstnId_element.append(BIC_element) + DbtrAgt_element.append(FinInstnId_element) + PmtInf_element.append(DbtrAgt_element) + + CdtTrfTxInf_element = ET.Element("CdtTrfTxInf") + + PmtId_element = ET.Element("PmtId") + EndToEndId_element = ET.Element("EndToEndId") + EndToEndId_element.text = row["payment_id"] + PmtId_element.append(EndToEndId_element) + CdtTrfTxInf_element.append(PmtId_element) + + Amt_element = ET.Element("Amt") + InstdAmt_element = ET.Element("InstdAmt") + InstdAmt_element.text = row["payment_amount"] + InstdAmt_element.set("Ccy", row["currency"]) + Amt_element.append(InstdAmt_element) + CdtTrfTxInf_element.append(Amt_element) + + CdtrAgt_element = ET.Element("CdtrAgt") + FinInstnId_element = ET.Element("FinInstnId") + BIC_element = ET.Element("BICFI") + BIC_element.text = row["creditor_agent_BIC"] + FinInstnId_element.append(BIC_element) + CdtrAgt_element.append(FinInstnId_element) + CdtTrfTxInf_element.append(CdtrAgt_element) + + Cdtr_element = ET.Element("Cdtr") + Nm_element = ET.Element("Nm") + Nm_element.text = row["creditor_name"] + Cdtr_element.append(Nm_element) + CdtTrfTxInf_element.append(Cdtr_element) + + CdtrAcct_element = ET.Element("CdtrAcct") + Id_element = ET.Element("Id") + IBAN_element = ET.Element("IBAN") + IBAN_element.text = row["creditor_account_IBAN"] + Id_element.append(IBAN_element) + CdtrAcct_element.append(Id_element) + CdtTrfTxInf_element.append(CdtrAcct_element) + + RmtInf_element = ET.Element("RmtInf") + Ustrd_element = ET.Element("Ustrd") + Ustrd_element.text = row["remittance_information"] + RmtInf_element.append(Ustrd_element) + CdtTrfTxInf_element.append(RmtInf_element) + + PmtInf_element.append(CdtTrfTxInf_element) + + def create_xml_v9(root, data, mapping): print("XML v9") diff --git a/pain001/xml/write_xml_to_file.py b/pain001/xml/write_xml_to_file.py index 1655b04..1a40aba 100644 --- a/pain001/xml/write_xml_to_file.py +++ b/pain001/xml/write_xml_to_file.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from xml.dom import minidom +from defusedxml.minidom import parseString # Write XML to file with pretty formatting (indentation) @@ -26,5 +26,5 @@ def write_xml_to_file(xml_file_path, root): xml_declaration = '\n' xml_string = xml_declaration + xml_string.decode("utf-8") - dom = minidom.parseString(xml_string) + dom = parseString(xml_string) f.write(dom.toprettyxml()) diff --git a/pain001/xml/xml_generator.py b/pain001/xml/xml_generator.py index 2b90c4b..0c83a93 100644 --- a/pain001/xml/xml_generator.py +++ b/pain001/xml/xml_generator.py @@ -23,7 +23,11 @@ from pain001.xml.generate_updated_xml_file_path import ( generate_updated_xml_file_path, ) -from pain001.xml.generate_xml import create_xml_v3, create_xml_v9 +from pain001.xml.generate_xml import ( + create_xml_v3, + create_xml_v4, + create_xml_v9, +) from pain001.xml.validate_via_xsd import validate_via_xsd from pain001.xml.write_xml_to_file import write_xml_to_file @@ -42,6 +46,7 @@ def xml_generator( # Define a mapping between the XML types and the XML generators xml_generators = { "pain.001.001.03": create_xml_v3, + "pain.001.001.04": create_xml_v4, "pain.001.001.09": create_xml_v9, } @@ -73,6 +78,8 @@ def xml_generator( f"A new XML file has been created at {updated_xml_file_path}" ) + print(updated_xml_file_path) + # Validate the updated XML file against the XSD schema is_valid = validate_via_xsd( updated_xml_file_path, xsd_file_path diff --git a/pyproject.toml b/pyproject.toml index fa1ab4f..f9545f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pain001" -version = "0.0.20" +version = "0.0.21" 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/setup.cfg b/setup.cfg index fe30a67..66a5622 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ [metadata] name = pain001 -version = 0.0.20 +version = 0.0.21 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 diff --git a/setup.py b/setup.py index fb25d25..6829816 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ NAME = "pain001" URL = "https://github.com/sebastienrousseau/pain001" -VERSION = "0.0.20" +VERSION = "0.0.21" setup( name=NAME, diff --git a/templates/pain.001.001.04/pain.001.001.04.xml b/templates/pain.001.001.04/pain.001.001.04.xml new file mode 100644 index 0000000..a28dcaa --- /dev/null +++ b/templates/pain.001.001.04/pain.001.001.04.xml @@ -0,0 +1,263 @@ + + + + + 1 + 2023-03-10T15:30:47.000Z + 2 + + John Doe + + + + Payment-Info-12345 + TRF + true + 2 + 2 + + + SEPA + + + 2023-03-12 + + Acme Corp + + + + DE75512108001245126162 + + + + + BANKDEFFXXX + + + + + PaymentID6789 + + + 150.00 + + + + SPUEDE2UXXX + + + + Global Tech + + + + DE68210501700024690959 + + + + Invoice-98765 + + + + + Payment-Info-67890 + TRF + true + 3 + 3 + + + SEPA + + + 2023-03-14 + + Brown Industries + + + + DE44500105175407324931 + + + + + BANKDEFFXXX + + + + + PaymentID4321 + + + 300.00 + + + + SPUEDE2UXXX + + + + Green Energy + + + + DE89370400440532013008 + + + + Invoice-12345 + + + + + Payment-Info-24680 + TRF + true + 1 + 1 + + + SEPA + + + 2023-03-13 + + Alpha Electronics + + + + DE47500105175711000100 + + + + + BANKDEFFXXX + + + + + PaymentID1357 + + + 250.00 + + + + SPUEDE2UXXX + + + + Beta Chemicals + + + + DE44500105175407123457 + + + + Invoice-24680 + + + + + Payment-Info-86420 + TRF + true + 2 + 2 + + + SEPA + + + 2023-03-15 + + Delta Manufacturing + + + + DE25500105176602214896 + + + + + BANKDEFFXXX + + + + + PaymentID2468 + + + 175.00 + + + + SPUEDE2UXXX + + + + Gamma Logistics + + + + DE53500105176502098765 + + + + Invoice-86420 + + + + + Payment-Info-59162 + TRF + true + 3 + 3 + + + SEPA + + + 2023-03-16 + + Smart Solutions + + + + DE86500105174603245678 + + + + + BANKDEFFXXX + + + + + PaymentID4815 + + + 225.00 + + + + SPUEDE2UXXX + + + + Eco Innovations + + + + DE18500105175001478962 + + + + Invoice-59162 + + + + + diff --git a/templates/pain.001.001.04/pain.001.001.04.xsd b/templates/pain.001.001.04/pain.001.001.04.xsd new file mode 100644 index 0000000..da8ecde --- /dev/null +++ b/templates/pain.001.001.04/pain.001.001.04.xsd @@ -0,0 +1,968 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/pain.001.001.04/template.csv b/templates/pain.001.001.04/template.csv new file mode 100644 index 0000000..d2abde1 --- /dev/null +++ b/templates/pain.001.001.04/template.csv @@ -0,0 +1,6 @@ +id,date,nb_of_txs,initiator_name,payment_information_id,payment_method,batch_booking,control_sum,ultimate_debtor_name,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 +1,2023-03-10T15:30:47.000Z,2,John Doe,Payment-Info-12345,TRF,TRUE,2,Acme Corp,SEPA,2023-03-12,Acme Corp,DE75512108001245126162,BANKDEFFXXX,SLEV,PaymentID6789,150.00,EUR,SPUEDE2UXXX,Global Tech,DE68210501700024690959,Invoice-98765,FA98765 +2,2023-03-11T10:20:18.000Z,3,Jane Smith,Payment-Info-67890,TRF,TRUE,3,Brown Industries,SEPA,2023-03-14,Brown Industries,DE44500105175407324931,BANKDEFFXXX,SLEV,PaymentID4321,300.00,EUR,SPUEDE2UXXX,Green Energy,DE89370400440532013008,Invoice-12345,FA24680 +3,2023-03-11T11:45:23.000Z,1,Michael Johnson,Payment-Info-24680,TRF,TRUE,1,Alpha Electronics,SEPA,2023-03-13,Alpha Electronics,DE47500105175711000100,BANKDEFFXXX,SLEV,PaymentID1357,250.00,EUR,SPUEDE2UXXX,Beta Chemicals,DE44500105175407123457,Invoice-24680,FA13579 +4,2023-03-12T09:12:34.000Z,2,Emily Watson,Payment-Info-86420,TRF,TRUE,2,Delta Manufacturing,SEPA,2023-03-15,Delta Manufacturing,DE25500105176602214896,BANKDEFFXXX,SLEV,PaymentID2468,175.00,EUR,SPUEDE2UXXX,Gamma Logistics,DE53500105176502098765,Invoice-86420,FA86420 +5,2023-03-12T14:23:17.000Z,3,Robert Brown,Payment-Info-59162,TRF,TRUE,3,Smart Solutions,SEPA,2023-03-16,Smart Solutions,DE86500105174603245678,BANKDEFFXXX,SLEV,PaymentID4815,225.00,EUR,SPUEDE2UXXX,Eco Innovations,DE18500105175001478962,Invoice-59162,FA59162 \ No newline at end of file diff --git a/templates/pain.001.001.04/template.db b/templates/pain.001.001.04/template.db new file mode 100644 index 0000000000000000000000000000000000000000..3643a49890dc64937559c0c95b765052f46d6b37 GIT binary patch literal 8192 zcmeI0TW{Mo6vrL6U9e?s1{B6N1V!X#MOS2Qc@cFnFl`7D(}O_&+}$5;z|Ga2(~rxR6=GbA#4CsnzSX zZw;eXt8KzthgUrxK;^#rfO2D@ephv~_A+?#uo(RC&l>#nqX}pNnt&#t31|YEfF_^` zXabsmCh%Vf)V*R>{hQg`y1i)Q_b)a!Ki%2c_+vNc!&qGLC`AZYMg8#9>-e7GcMgs{ z<7w6U)cDefMuzX5`(GI&4r$@6nhpbb5#;YC)pwLedBk&>1u0L|peufph%^tPbe2m- zG7aX&RA(acu~aJzc^-~~p_IQw>1Aa)lxd#HIG9Y6s%0AI5u~Of7>VJ^k`s|#N1+H} zaV_E?lq01j6TeQyBp0JVyc6LxFSIQ9vu>$s;bADJ;6wkQ^L@3v>bWd@JLn%OonxL| zieM;sCbFtcIl1OFPYSDQ<}}Mh8s4bSOpKz!FTT2h>R4bLsu*`q2b50Zl*?&;&FAO+XXS1pW^MZtp$# zZ2Rl&XZUerd%w}#clR34KYzTp?>^sQ1QFUow1tU}%{HNJY`;VZ{Y+2gP-MArkjb~{ z$t=Zb^&!P+F&A6JKkfOaXC56S90m{+fp^lGTeMa>yPjh)NW~DtwrL?sOlH{* zWE|ghyQ-ZKE)VM@4VAwsYT%I~5y*XqhxZB^`$bH=YBXO}G+sbV&^Zn4W85|wghfdMzlp*z z7qRhLj?+~jg+c`ccjButH@sMckkqCiYzYTl>+X7{t#mURV~9X_?}C9Tvk60Mp>ZH! z7Y@ge4~9Gj7N$A3X(AgFYBF1~DCPD#g(>&8RxemI3l^7&79Ze^B7KvpF=4$V%U^pNy#dkq4DZv!2LpaKWNDVI) z+2swKIG5VUM94G|gMBS#I0``tq}M4){3bUF1WyVCyN%{1W7ejqZO*O; zQiOrgm0}4%X;mGJP6&UK9Lnr!Y5&Q*x$D`CVS + + + + {{id}} + {{date}} + {{nb_of_txs}} + + {{initiator_name}} + + {{initiator_street}} + {{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_BICFI}} + + + + + {{payment_instruction_id}} + {{payment_end_to_end_id}} + + + + {{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}} + + + + + + + + \ No newline at end of file From 704cfb805d8190e095f97dee8ab392c6f2687c29 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 19 Jun 2023 20:59:43 +0100 Subject: [PATCH 2/5] fix(pain001): added new unit tests --- tests/test_main.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index 7f76ca1..27f9819 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -152,3 +152,59 @@ def test_main_with_invalid_data_file(self): assert ( "The data file 'invalid' does not exist." in result.output ) + + def test_invalid_xml_template_file_path(self): + """ + Test that the `print(click.get_current_context().get_help())` line is executed + when the `xml_template_file_path` argument is set to an invalid value. + """ + + result = self.runner.invoke( + main, + [ + "--xml_message_type", + "pain.001.001.03", + "--xml_template_file_path", + "invalid", + "--xsd_schema_file_path", + self.xsd_file, + "--data_file_path", + self.csv_file, + ], + ) + + assert result.exit_code == 1 + assert ( + "The XML template file 'invalid' does not exist." + in result.output + ) + assert ( + "The XML template file 'invalid' does not exist." + in result.output + ) + + def test_non_existent_xml_template_file_path(self): + """ + Test that the `logger.info()` and `print()` lines are executed + when the `xml_template_file_path` argument is set to a non-existent file path. + """ + + result = self.runner.invoke( + main, + [ + "--xml_message_type", + "pain.001.001.03", + "--xml_template_file_path", + "non_existent_file.xml", + "--xsd_schema_file_path", + self.xsd_file, + "--data_file_path", + self.csv_file, + ], + ) + + assert result.exit_code == 1 + assert ( + "The XML template file 'non_existent_file.xml' does not exist." + in result.output + ) From 5b4b28bf0624ab48c4a14d06d22eba624219014b Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 19 Jun 2023 22:16:02 +0100 Subject: [PATCH 3/5] fix(pain001): tweaks on v3 --- pain001/xml/generate_xml.py | 9 --- templates/pain.001.001.03/pain.001.001.03.xml | 64 ++++++++-------- templates/pain.001.001.03/template.csv | 12 +-- templates/pain.001.001.03/template.db | Bin 8192 -> 8192 bytes templates/pain.001.001.03/template.xml | 69 +++++++++++------- 5 files changed, 83 insertions(+), 71 deletions(-) diff --git a/pain001/xml/generate_xml.py b/pain001/xml/generate_xml.py index b79aa62..0a58787 100644 --- a/pain001/xml/generate_xml.py +++ b/pain001/xml/generate_xml.py @@ -60,15 +60,6 @@ def create_xml_v3(root, data, mapping): create_common_elements(PmtInf_element, row, mapping) - # Add the PmtInfId and PmtMtd elements to the PmtInf element - # for xml_tag, csv_column in mapping.items(): - # if xml_tag in ["PmtInfId", "PmtMtd"]: - # create_xml_element( - # PmtInf_element, - # xml_tag, - # row[csv_column] - # ) - # Create new "BtchBookg" element in the XML tree using data # from the CSV file create_xml_element( diff --git a/templates/pain.001.001.03/pain.001.001.03.xml b/templates/pain.001.001.03/pain.001.001.03.xml index 39808ad..04f0b71 100644 --- a/templates/pain.001.001.03/pain.001.001.03.xml +++ b/templates/pain.001.001.03/pain.001.001.03.xml @@ -1,5 +1,7 @@ - - + + 1 @@ -14,7 +16,7 @@ TRF true 2 - 2 + 15000 SEPA @@ -51,7 +53,7 @@ Global Tech - Invoice-98765 + Invoice-12345 @@ -60,7 +62,7 @@ TRF true 2 - 2 + 15000 SEPA @@ -97,7 +99,7 @@ Global Tech - Invoice-98765 + Invoice-12345 @@ -106,7 +108,7 @@ TRF true 3 - 3 + 30000 SEPA @@ -143,7 +145,7 @@ Green Energy - Invoice-12345 + Invoice-67890 @@ -152,7 +154,7 @@ TRF true 3 - 3 + 30000 SEPA @@ -189,7 +191,7 @@ Green Energy - Invoice-12345 + Invoice-67890 @@ -198,7 +200,7 @@ TRF true 1 - 1 + 25000 SEPA @@ -244,7 +246,7 @@ TRF true 1 - 1 + 25000 SEPA @@ -286,11 +288,11 @@ - Payment-Info-86420 + Payment-Info-36912 TRF true 2 - 2 + 20000 SEPA @@ -298,11 +300,11 @@ 2023-03-15 - Delta Manufacturing + Zeta Services - DE25500105176602214896 + DE68120933300112345608 @@ -313,10 +315,10 @@ SLEV - PaymentID2468 + PaymentID8642 - 175.00 + 200.00 @@ -324,19 +326,19 @@ - Gamma Logistics + Theta Solutions - Invoice-86420 + Invoice-36912 - Payment-Info-86420 + Payment-Info-36912 TRF true 2 - 2 + 20000 SEPA @@ -344,11 +346,11 @@ 2023-03-15 - Delta Manufacturing + Zeta Services - DE25500105176602214896 + DE68120933300112345608 @@ -359,10 +361,10 @@ SLEV - PaymentID2468 + PaymentID8642 - 175.00 + 200.00 @@ -370,10 +372,10 @@ - Gamma Logistics + Theta Solutions - Invoice-86420 + Invoice-36912 @@ -382,7 +384,7 @@ TRF true 3 - 3 + 22500 SEPA @@ -428,7 +430,7 @@ TRF true 3 - 3 + 22500 SEPA @@ -470,4 +472,4 @@ - + \ No newline at end of file diff --git a/templates/pain.001.001.03/template.csv b/templates/pain.001.001.03/template.csv index d1e1ef5..8c000cd 100644 --- a/templates/pain.001.001.03/template.csv +++ b/templates/pain.001.001.03/template.csv @@ -1,6 +1,6 @@ -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 -1,2023-03-10T15:30:47.000Z,2,John Doe,Payment-Info-12345,TRF,TRUE,2,SEPA,2023-03-12,Acme Corp,DE75512108001245126162,BANKDEFFXXX,SLEV,PaymentID6789,150.00,EUR,SPUEDE2UXXX,Global Tech,DE68210501700024690959,Invoice-98765,FA98765 -2,2023-03-11T10:20:18.000Z,3,Jane Smith,Payment-Info-67890,TRF,TRUE,3,SEPA,2023-03-14,Brown Industries,DE44500105175407324931,BANKDEFFXXX,SLEV,PaymentID4321,300.00,EUR,SPUEDE2UXXX,Green Energy,DE89370400440532013008,Invoice-12345,FA24680 -3,2023-03-11T11:45:23.000Z,1,Michael Johnson,Payment-Info-24680,TRF,TRUE,1,SEPA,2023-03-13,Alpha Electronics,DE47500105175711000100,BANKDEFFXXX,SLEV,PaymentID1357,250.00,EUR,SPUEDE2UXXX,Beta Chemicals,DE44500105175407123457,Invoice-24680,FA13579 -4,2023-03-12T09:12:34.000Z,2,Emily Watson,Payment-Info-86420,TRF,TRUE,2,SEPA,2023-03-15,Delta Manufacturing,DE25500105176602214896,BANKDEFFXXX,SLEV,PaymentID2468,175.00,EUR,SPUEDE2UXXX,Gamma Logistics,DE53500105176502098765,Invoice-86420,FA86420 -5,2023-03-12T14:23:17.000Z,3,Robert Brown,Payment-Info-59162,TRF,TRUE,3,SEPA,2023-03-16,Smart Solutions,DE86500105174603245678,BANKDEFFXXX,SLEV,PaymentID4815,225.00,EUR,SPUEDE2UXXX,Eco Innovations,DE18500105175001478962,Invoice-59162,FA59162 \ 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,charge_bearer,payment_id,payment_amount,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 +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.00,EUR,15000,SPUEDE2UXXX,Global Tech,Global Street,3,11223,Global Town,DE,DE68210501700024690959,OTHR,Invoice-98765,2023-03-09,SEPA,SPUEDE2UXXX,Invoice-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,SLEV,PaymentID4321,300.00,EUR,30000,SPUEDE2UXXX,Green Energy,Green Street,30,78901,Green Town,DE,DE89370400440532013008,OTHR,Invoice-12345,2023-03-13,SEPA,SPUEDE2UXXX,Invoice-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.00,EUR,25000,SPUEDE2UXXX,Beta Chemicals,Beta Street,35,65432,Beta Town,DE,DE44500105175407123457,OTHR,Invoice-24680,2023-03-11,SEPA,SPUEDE2UXXX,Invoice-24680 +4,2023-03-12T09:12:34.000Z,2,Emily Wilson,Emily's Street,4,34567,Emily's Town,DE,Payment-Info-36912,TRF,TRUE,2023-03-15,Zeta Services,Zeta Street,8,98765,Zeta Town,DE,DE68120933300112345608,BANKDEFFXXX,SLEV,PaymentID8642,200.00,EUR,20000,SPUEDE2UXXX,Theta Solutions,Theta Street,38,54321,Theta Town,DE,DE75512108001245123456,OTHR,Invoice-36912,2023-03-14,SEPA,SPUEDE2UXXX,Invoice-36912 +5,2023-03-12T14:23:17.000Z,3,Robert Brown,Robert's Street,7,34567,Robert's Town,DE,Payment-Info-59162,TRF,TRUE,2023-03-16,Smart Solutions,Smart Street,12,76543,Smart Town,DE,DE86500105174603245678,BANKDEFFXXX,SLEV,PaymentID4815,225.00,EUR,22500,SPUEDE2UXXX,Eco Innovations,Eco Street,45,21098,Eco Town,DE,DE18500105175001478962,OTHR,Invoice-59162,2023-03-15,SEPA,SPUEDE2UXXX,Invoice-59162 diff --git a/templates/pain.001.001.03/template.db b/templates/pain.001.001.03/template.db index ab37c3259a5259dd24fc31165cd352d143beaab6..ef7477d689eaf16346d5a9179a1ca06d20db6e29 100644 GIT binary patch literal 8192 zcmeI0TW{Mo6vv&UmknFz8AV_eT~Vb*;00MalDZohuw0ZbUAASmvITw7WSNbH$xyhxF6PkY#lga{(fp?Jjq?~oxq`1v%y2*} zrO{|SgnJ$C;(7pudqoAFYnAe<;={&E@7W{P_|q>M@K;~80<{9Q0<{9Q0<{9Q0<{9Q z0<{AFp91$bWbBQ97C+*HzxJ^G^y%7PPjY`4(JMcU5yJAZe%N>RT}N^E4^AEBg|xm< zzEr}I;yM@ZSIWqTlZ7b8Loa#jPCWs;^!7HxnA?UKoqhQJBPDIkv(%q4_u| z20ZlhVC)T(;<` zFB!J<_yPBMCkOjK%ApjVOQy=f$)Pj{V?Vv5-jMofiKCEbK`(#8gf8BkrYVhso1&Tk zf+X^?>7=lvbQCgu{P~!Lqmn*BVOx~0bS)RJbT7(Ry5~Vnx+tiRue6y zZz0X{nq&G z!=trNl8^s}Vtv&L)C$xJ)C$xJ)C$xJ{3iu&AKc$*e$(9EZMM5D{CIO~ce~ZzYT2F5 z?vuyu&hA#L{j6ngcDFV=U7aAJ?jdy#6BlbeqV}-)5+U?P?I*C)&y|A|_V1$H&6EK@ zB$%qE8)j*Ap~aDNCbsT-C$M$j(`{@Jw}0&R&z&-YF_`$!;~@1M6su+o;6O3$&8H%9TDuS}7W?HsEesaI-pTyS*>;lEm$}#B! z=WM?cX{Ocf#yt*Vr`g`-AiAAq`}rLRfklAO$}WkE>>egPRpTItGYO*`<<~IEl9-oE z4jSiB*p^^W4I8-5VbI^u+*bx-Q=5qjXJFYDK;VW#48y_%*{Z676qvAZXe9y5&nXn|fWkmxxpyx?zP%G zoWj>L(_yF6VoU@Dwd@kR822mXl9wACdQyM+^ePqR&^65gMTEI+ZYiT`WmFBBoQPQ^!bf)}-wGnU)$PVQBeKb!uIk_!|NK|O+c*y2Rg*M3Zu0UWc&taL{L!75=RXV2G^ClR zOA1IVJ!~l~*9mP#4_KXS6|bVe@*Ad*pa6v#3a{XImsoLPnqJh%sM1tKH7r<;bc9Xl1CrQAwr*F2=WA!760%na&j!oZScX)Uygrcv=` zvoP4j#+aN3*!8Z4>;ZPOx7h9OcCi~DU?*uKEi4cYgyfvh_xH`^&gIT$_TFS95{c0} zye6*Jd1f-Q(a0s}qiEtLlDN4(`4qpt{1u&!6$Y=x@>gnd`rX~=ojI0`zHgJ2nI>Tq z<+$nCp6hfPz0)rF%5cO;$RsoCkuS5D95PArn_)NBxu)Zu8}942-D(&u%k~;iD!W`& zuUFUnGpFKP5hgvml31TX@vZBVhw*H`H#Ns>Gs`fUVp2;5C7)W&B=ZGjl_ek3D+_zZ zMVD?VCPpU(@*meNQES(;2dwDIFf{)pSiqwR*j-n+{j8ZRgDJ+K%1R zbSPs0Aiz-aS3!~$5moFnr)^q;9m{I4asPaBM8c0sQrV>!hSziKF^((>2n;#M=OBRi zBH)V)TQ&FJRCwq5g-HwDj`3z>9~7;xI~}DXYQKKcDcU6b3_mG>o!Fhsxg?VHLtn0dFFnd}CAO z51ZlOSO{M293L5+-my$tyiEb*@qCHAna^mNE(oCn3qXR17qApc{5YVjLLN&>---E> zrGcb4lq~!87IP2A>lJA=;XDWRe#m9X&s^!{=uBM8vN_$h+}4Gr%L*?60RTY&m_~y< z0CLC(P-QjH^sT7R$PE~aLq^_bd|$W^$7&6}`){pCHM$t~cd$F`Ls_Hnej1E_| c%p*+~Wki2B03`qbJzW6`Rzg%zSy>I1e^2W0IsgCw diff --git a/templates/pain.001.001.03/template.xml b/templates/pain.001.001.03/template.xml index 2313743..65980c6 100644 --- a/templates/pain.001.001.03/template.xml +++ b/templates/pain.001.001.03/template.xml @@ -9,6 +9,13 @@ {{nb_of_txs}} {{initiator_name}} + + {{initiator_street_name}} + {{initiator_building_number}} + {{initiator_postal_code}} + {{initiator_town_name}} + {{initiator_country_code}} + @@ -16,58 +23,70 @@ {{payment_method}} {{batch_booking}} - {{nb_of_txs}} - {{control_sum}} - - - {{service_level_code}} - - - - {{requested_execution_date}} + {{requested_execution_date}} {{debtor_name}} + + {{debtor_street_name}} + {{debtor_building_number}} + {{debtor_postal_code}} + {{debtor_town_name}} + {{debtor_country_code}} + - {{debtor_account_IBAN}} + + {{debtor_account_IBAN}} + - BANKXXXXX - Bank Name - - Country Code - Postal Code - Street Name - Building Number - Town Name - + {{debtor_agent_BIC}} {% for tx in transactions %} - {{tx.payment_id}} + TX-{{ loop.index }} + {{payment_id}} - {{tx.payment_amount}} + {{payment_amount}} + {{charge_bearer}} - {{tx.creditor_agent_BIC}} + {{creditor_agent_BIC}} - {{tx.creditor_name}} + {{creditor_name}} + + {{creditor_street_name}} + {{creditor_building_number}} + {{creditor_postal_code}} + {{creditor_town_name}} + {{creditor_country_code}} + - {{tx.creditor_account_IBAN}} + + {{creditor_account_IBAN}} + + + {{purpose_code}} + - {{tx.unstructured_remittance_info}} + + + {{reference_number}} + {{reference_date}} + + {% endfor %} From 8a8941fdf5c749143b6c1e30bac1390c59929156 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 19 Jun 2023 22:19:08 +0100 Subject: [PATCH 4/5] fix(pain001): E501 line too long --- tests/test_main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 27f9819..4a40e0e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -155,8 +155,9 @@ def test_main_with_invalid_data_file(self): def test_invalid_xml_template_file_path(self): """ - Test that the `print(click.get_current_context().get_help())` line is executed - when the `xml_template_file_path` argument is set to an invalid value. + Test that the `print(click.get_current_context().get_help())` line is + executed when the `xml_template_file_path` argument is set to an + invalid value. """ result = self.runner.invoke( @@ -186,7 +187,8 @@ def test_invalid_xml_template_file_path(self): def test_non_existent_xml_template_file_path(self): """ Test that the `logger.info()` and `print()` lines are executed - when the `xml_template_file_path` argument is set to a non-existent file path. + when the `xml_template_file_path` argument is set to a non-existent + file path. """ result = self.runner.invoke( From fcd31c5abdae5b78fa47adaae4b769e9f8b2f8a0 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 19 Jun 2023 22:59:07 +0100 Subject: [PATCH 5/5] doc(pain001): updated content for v04 --- README.md | 1 + pain001/__main__.py | 10 -- pain001/xml/generate_xml.py | 99 +++++++++++++------ pyproject.toml | 4 +- setup.py | 2 +- templates/pain.001.001.03/pain.001.001.03.xml | 8 +- 6 files changed, 74 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 8e3b146..1f78dc5 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ When running **Pain001**, you will need to specify four arguments: The currently supported types are: - pain.001.001.03 + - pain.001.001.04 - 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 diff --git a/pain001/__main__.py b/pain001/__main__.py index d0b313c..28716d5 100644 --- a/pain001/__main__.py +++ b/pain001/__main__.py @@ -184,16 +184,6 @@ def check_variable(variable, name): print(f"The data file '{data_file_path}' does not exist.") sys.exit(1) - # Validate the XML file and raise a SystemExit exception if invalid - # is_valid = validate_via_xsd( - # xml_template_file_path, xsd_schema_file_path - # ) - # if not is_valid: - # logger.error( - # f"Error: XML located at {xml_template_file_path} is invalid." - # ) - # sys.exit(1) - process_files( xml_message_type, xml_template_file_path, diff --git a/pain001/xml/generate_xml.py b/pain001/xml/generate_xml.py index 0a58787..8137102 100644 --- a/pain001/xml/generate_xml.py +++ b/pain001/xml/generate_xml.py @@ -21,13 +21,37 @@ def create_common_elements(parent, row, mapping): + """Create common elements "PmtInfId" and "PmtMtd" in the XML tree using + data from the CSV or SQLite Data Files. + + Parameters + ---------- + parent : xml.etree.ElementTree.Element + Parent element in the XML tree. + row : list + List of strings, each string is a row of the Data file. + mapping : dict + Dictionary with the mapping between XML tags and Data columns. + """ + for xml_tag, csv_column in mapping.items(): if xml_tag in ["PmtInfId", "PmtMtd"]: create_xml_element(parent, xml_tag, row[csv_column]) def create_xml_v3(root, data, mapping): - # print("XML v3") + """Create the XML tree for the pain.001.001.03 schema. + + Args: + root (ElementTree.Element): The root element of the XML tree. + data (list): A list of dictionaries containing the data to be added + to the XML document. + mapping (dict): A dictionary mapping the Data column names to the XML + element names. + + Returns: + The root element of the XML tree. + """ # Create CstmrCdtTrfInitn element cstmr_cdt_trf_initn_element = ET.Element("CstmrCdtTrfInitn") @@ -61,23 +85,23 @@ def create_xml_v3(root, data, mapping): create_common_elements(PmtInf_element, row, mapping) # Create new "BtchBookg" element in the XML tree using data - # from the CSV file + # from the Data file create_xml_element( PmtInf_element, "BtchBookg", row["batch_booking"].lower() ) # Create new "NbOfTxs" element in the XML tree using data from - # the CSV file + # the Data file create_xml_element(PmtInf_element, "NbOfTxs", row["nb_of_txs"]) # Create new "CtrlSum" element in the XML tree using data from - # the CSV file + # the Data file create_xml_element( PmtInf_element, "CtrlSum", f"{row['control_sum']}" ) # Create new "PmtTpInf" element in the XML tree using data from - # the CSV file + # the Data file PmtTpInf_element = ET.Element("PmtTpInf") child_element = ET.Element("SvcLvl") child_element2 = ET.Element("Cd") @@ -87,7 +111,7 @@ def create_xml_v3(root, data, mapping): PmtInf_element.append(PmtTpInf_element) # Create new "ReqdExctnDt" element in the XML tree using data - # from the CSV file + # from the Data file create_xml_element( PmtInf_element, "ReqdExctnDt", @@ -95,7 +119,7 @@ def create_xml_v3(root, data, mapping): ) # Create new "Dbtr" element in the XML tree using data from - # the CSV file + # the Data file Dbtr_element = ET.Element("Dbtr") child_element = ET.Element("Nm") child_element.text = row["debtor_name"] @@ -103,7 +127,7 @@ def create_xml_v3(root, data, mapping): PmtInf_element.append(Dbtr_element) # Create new "DbtrAcct" element in the XML tree using data - # from the CSV file + # from the Data file DbtrAcct_element = ET.Element("DbtrAcct") child_element = ET.Element("Id") child_element2 = ET.Element("IBAN") @@ -114,7 +138,7 @@ def create_xml_v3(root, data, mapping): PmtInf_element.append(DbtrAcct_element) # Create new "DbtrAgt" element in the XML tree using data - # from the CSV file + # from the Data file DbtrAgt_element = ET.Element("DbtrAgt") child_element = ET.Element("FinInstnId") child_element2 = ET.Element("BIC") @@ -125,18 +149,18 @@ def create_xml_v3(root, data, mapping): PmtInf_element.append(DbtrAgt_element) # Create new "ChrgBr" element in the XML tree using data - # from the CSV file + # from the Data file child_element = ET.Element("ChrgBr") # replace with the appropriate value child_element.text = row["charge_bearer"] PmtInf_element.append(child_element) # Create new "CdtTrfTxInf" element in the XML tree using data - # from the CSV file + # from the Data file CdtTrfTxInf_element = ET.Element("CdtTrfTxInf") # Create new "PmtId" element in the XML tree using data - # from the CSV file + # from the Data file PmtId_element = ET.Element("PmtId") child_element = ET.Element("EndToEndId") child_element.text = row["payment_id"] @@ -144,7 +168,7 @@ def create_xml_v3(root, data, mapping): CdtTrfTxInf_element.append(PmtId_element) # Create new "Amt" element in the XML tree using data - # from the CSV file + # from the Data file Amt_element = ET.Element("Amt") child_element = ET.Element("InstdAmt") child_element.text = row["payment_amount"] @@ -153,7 +177,7 @@ def create_xml_v3(root, data, mapping): CdtTrfTxInf_element.append(Amt_element) # Create new "CdtrAgt" element in the XML tree using data - # from the CSV file + # from the Data file CdtrAgt_element = ET.Element("CdtrAgt") child_element = ET.Element("FinInstnId") child_element2 = ET.Element("BIC") @@ -163,7 +187,7 @@ def create_xml_v3(root, data, mapping): CdtTrfTxInf_element.append(CdtrAgt_element) # Create new "Cdtr" element in the XML tree using data - # from the CSV file + # from the Data file Cdtr_element = ET.Element("Cdtr") child_element = ET.Element("Nm") child_element.text = row["creditor_name"] @@ -171,7 +195,7 @@ def create_xml_v3(root, data, mapping): CdtTrfTxInf_element.append(Cdtr_element) # Create new "RmtInf" element in the XML tree using data - # from the CSV file + # from the Data file RmtInf_element = ET.Element("RmtInf") child_element = ET.Element("Ustrd") child_element.text = row["remittance_information"] @@ -191,7 +215,7 @@ def create_xml_v4(root, data, mapping): Args: root: The root element of the XML document. data: A list of dictionaries containing the payment data. - mapping: A dictionary that maps XML element names to CSV column names. + mapping: A dictionary that maps XML element names to Data column names. Returns: The root element of the XML document. @@ -205,7 +229,7 @@ def create_xml_v4(root, data, mapping): GrpHdr_element = ET.Element("GrpHdr") cstmr_cdt_trf_initn_element.append(GrpHdr_element) - # Loop through the first row of the CSV file and create new + # Loop through the first row of the Data file and create new # "MsgId", "CreDtTm" and "NbOfTxs" elements in the XML tree for xml_tag, csv_column in mapping.items(): if xml_tag in ["MsgId", "CreDtTm", "NbOfTxs"]: @@ -319,7 +343,18 @@ def create_xml_v4(root, data, mapping): def create_xml_v9(root, data, mapping): - print("XML v9") + """Creates an XML document for the pain.001.001.09 schema. + + Args: + root (ElementTree.Element): The root element of the XML tree. + data (list): A list of dictionaries containing the data to be added + to the XML document. + mapping (dict): A dictionary mapping the Data column names to the XML + element names. + + Returns: + The root element of the XML tree. + """ # Create CstmrCdtTrfInitn element cstmr_cdt_trf_initn_element = ET.Element("CstmrCdtTrfInitn") @@ -337,7 +372,7 @@ def create_xml_v9(root, data, mapping): ) # Create new "InitgPty" element in the XML tree using data from the - # CSV file + # Data file InitgPty_element = ET.Element("InitgPty") create_xml_element( InitgPty_element, "Nm", data[0]["initiator_name"] @@ -346,7 +381,7 @@ def create_xml_v9(root, data, mapping): for row in data: # Create new "PmtInf" element in the XML tree using data from - # the CSV file + # the Data file PmtInf_element = ET.Element("PmtInf") cstmr_cdt_trf_initn_element.append(PmtInf_element) @@ -359,7 +394,7 @@ def create_xml_v9(root, data, mapping): PmtInf_element.append(Dbtr_element) # Create new "Dbtr" element in the XML tree using data from - # the CSV file + # the Data file Dbtr_element = ET.Element("Dbtr") child_element = ET.Element("Nm") child_element.text = row["debtor_name"] @@ -367,7 +402,7 @@ def create_xml_v9(root, data, mapping): PmtInf_element.append(Dbtr_element) # Create new "DbtrAcct" element in the XML tree using data - # from the CSV file + # from the Data file DbtrAcct_element = ET.Element("DbtrAcct") child_element = ET.Element("Id") child_element2 = ET.Element("IBAN") @@ -378,7 +413,7 @@ def create_xml_v9(root, data, mapping): PmtInf_element.append(DbtrAcct_element) # Create new "DbtrAgt" element in the XML tree using data - # from the CSV file + # from the Data file DbtrAgt_element = ET.Element("DbtrAgt") child_element = ET.Element("FinInstnId") child_element2 = ET.Element("BICFI") @@ -392,18 +427,18 @@ def create_xml_v9(root, data, mapping): PmtInf_element.append(DbtrAgt_element) # Create new "ChrgBr" element in the XML tree using data - # from the CSV file + # from the Data file child_element = ET.Element("ChrgBr") # replace with the appropriate value child_element.text = row["charge_bearer"] PmtInf_element.append(child_element) # Create new "CdtTrfTxInf" element in the XML tree using data - # from the CSV file + # from the Data file CdtTrfTxInf_element = ET.Element("CdtTrfTxInf") # Create new "PmtId" element in the XML tree using data - # from the CSV file + # from the Data file PmtId_element = ET.Element("PmtId") child_element = ET.Element("EndToEndId") child_element.text = row["payment_id"] @@ -411,7 +446,7 @@ def create_xml_v9(root, data, mapping): CdtTrfTxInf_element.append(PmtId_element) # Create new "Amt" element in the XML tree using data - # from the CSV file + # from the Data file Amt_element = ET.Element("Amt") child_element = ET.Element("InstdAmt") child_element.text = row["payment_amount"] @@ -420,7 +455,7 @@ def create_xml_v9(root, data, mapping): CdtTrfTxInf_element.append(Amt_element) # Create new "CdtrAgt" element in the XML tree using data - # from the CSV file + # from the Data file CdtrAgt_element = ET.Element("CdtrAgt") child_element = ET.Element("FinInstnId") child_element2 = ET.Element("BICFI") @@ -434,7 +469,7 @@ def create_xml_v9(root, data, mapping): CdtTrfTxInf_element.append(CdtrAgt_element) # Create new "Cdtr" element in the XML tree using data - # from the CSV file + # from the Data file Cdtr_element = ET.Element("Cdtr") child_element = ET.Element("Nm") child_element.text = row["creditor_name"] @@ -442,7 +477,7 @@ def create_xml_v9(root, data, mapping): CdtTrfTxInf_element.append(Cdtr_element) # Create new "RmtInf" element in the XML tree using data - # from the CSV file + # from the Data file RmtInf_element = ET.Element("RmtInf") child_element = ET.Element("Ustrd") child_element.text = row["remittance_information"] @@ -456,7 +491,7 @@ def create_xml_v9(root, data, mapping): cstmr_cdt_trf_initn_element.append(PmtInf_element) # Create new "SplmtryData" elements in the XML tree using data - # from the CSV file" + # from the Data file" # Create the main elements SplmtryData_element = ET.Element("SplmtryData") Envlp_element = ET.SubElement(SplmtryData_element, "Envlp") diff --git a/pyproject.toml b/pyproject.toml index f9545f0..665ea2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,11 +9,11 @@ repository = "https://github.com/sebastienrousseau/pain001" homepage = "https://pain001.com" [tool.poetry.dependencies] -python = "^3.9" -xmlschema = "^2.3.0" click = "^8.1.3" defusedxml = "^0.7.1" +python = "^3.9" rich = "^13.4.2" +xmlschema = "^2.3.1" [build-system] requires = ["poetry-core"] diff --git a/setup.py b/setup.py index 6829816..8173568 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ ] TEST_DEPENDENCIES = [ - "pytest>=7.3.1", + "pytest>=7.3.2", ] NAME = "pain001" diff --git a/templates/pain.001.001.03/pain.001.001.03.xml b/templates/pain.001.001.03/pain.001.001.03.xml index 04f0b71..54b7ea9 100644 --- a/templates/pain.001.001.03/pain.001.001.03.xml +++ b/templates/pain.001.001.03/pain.001.001.03.xml @@ -1,7 +1,5 @@ - - + + 1 @@ -472,4 +470,4 @@ - \ No newline at end of file +