Skip to main content

Swiss DTA

Version License https://img.shields.io/pypi/pyversions/swissdta.svg Build Status Codecov contributors

Generator library for Swiss DTA (“Datenträgeraustauschverfahren”) electronic payment records loosely inspired by python-dta.

Author

Jacques Dafflon <jacques@bity.com>

Contributors

Disclaimer

Please review and test the library with your infrastructure before using it.

The author does not guarantee that this library will generate valid DTA records and is in no way responsible for any financial issues (including but not limited to: failure of payments, payments to wrong party, incorrect payment amount, financial lost).

By using this library you agree to this disclaimer.

License

Distributed under the MIT License

Features

  • Support for transaction types 836, 890

  • Implements most of the validations rules specified in the DTA Standards and Formats.

  • Supports Decimal, date and IBAN with or without blanks as input values

  • Automatic generation of TA 890 record

  • Automatically handle sequence numbers

  • Automatically use the sender identification for the first 5 characters of the reference (TA 836)

  • Currency code check (via iso4217)

  • Clipping of overlong Alphanumeric fields (such as addresses or purpose)

  • Automatic conversion of permitted ISO Latincode 8859-1 characters

  • Enum for fields with a constrained of valid values (e.g. swissdta.constants.IdentificationPurpose)

  • Sane default values

  • Generates a sequence of properly (latin-1) encoded bytes

  • Type annotations

Getting Started

Generate a DTA file containing a single transaction of type 836:

from datetime import datetime, timedelta
from decimal import Decimal

from swissdta import ChargesRule, DTAFile, IdentificationPurpose


dta_file = DTAFile(sender_id='ABC12', client_clearing='8888')
dta_file.add_836_record(reference='01234567890',  # only 11 chars, the first 5 (sender id) are added automatically
                        client_account='CH38 0888 8123 4567 8901 2',
                        processing_date=datetime.now() + timedelta(days=1),  # next day
                        currency='CHF',
                        amount=Decimal(10),
                        client_address=('Alphabet Inc', 'Brandschenkestrasse 110', '8002 Zürich'),
                        recipient_iban='CH9300762011623852957',
                        recipient_name='Herr Peter Haller',
                        recipient_address=('Marktplaz 4', '9400 Rorschach'),
                        identification_purpose=IdentificationPurpose.UNSTRUCTURED,
                        purpose=('DTA lib example', '', ''),
                        charges_rules=ChargesRule.OUR
                        )
print(dta_file.generate().decode('latin-1'))

"""
>>> print(dta_file.generate().decode('latin-1'))
01000000            000001708308888   ABC120000183600ABC1201234567890CH3808888123456789012   170831CHF10,
02            Alphabet Inc                       Brandschenkestrasse 110            8002 Zuerich
03D                                                                      CH9300762011623852957
04Herr Peter Haller                  Marktplaz 4                        9400 Rorschach
05UDTA lib example                                                                                          0
01000000            00000170830       ABC12000028900010,

"""

Documentation and Testing

To build the documentation and run tests install the dev dependencies:

pipenv install --dev

Run detox

pipenv run detox

To only build the documentation

pipenv run tox -e docs

To only run the tests

pipenv run tox -e py36

To only lint the code

pipenv run tox -e pylint-tests,pylint

Limitations

  • The account to be debited (client_account) for TA 836 only accepts IBAN

  • The benificiary’s bank clearing number is not validated against a registry of banks to check if it is valid (TA 836).

  • No IPI reference validation if the identification purpose is set to structured (TA 836).

  • No parsing functionality of existing DTA files or records

  • Lack of tests (should be fixed soon…)

Metadata

Release files for swissdta 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for swissdta 1.0.1
File Interpreter ABI Platform Actions
swissdta-1.0.1-py3-none-any.whl Python 3 none any Details for swissdta-1.0.1-py3-none-any.whl

Release files / swissdta-1.0.1-py3-none-any.whl

Download URL swissdta-1.0.1-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
354b22a87ba76b4624c3f7b741a4517c9f72197d1b58342d7948fa1fda29a3bf
BLAKE2b-256 checksum
How to use checksums
16f6980d83ac7fc3a31d0c00267e1520a794f26d71fb7568310cc73580755cdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for swissdta 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page