Skip to main content

Swiss DTA payment record (TA 836) generator library

Project description

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.

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…)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for swissdta, version 1.0.1
Filename, size & hash File type Python version Upload date
swissdta-1.0.1-py3-none-any.whl (32.7 kB) View hashes Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page