Skip to main content

beangulp-mt940

beangulp importer for SWIFT MT940 bank statements (tested against UBS Switzerland exports), built on the mt-940 parser.

What it does

  • Drafts one beancount transaction per :61: statement line, with the bank's unique entry reference (the part after //) as mt940_ref: metadata. extract() skips references already present anywhere in the existing ledger — re-running an import is safe. A line without a reference (empty, or SWIFT's NONREF filler) gets no key and is never skipped; if it is imported twice, the closing balance assertion fails.
  • Refuses a file with statements for more than one account (:25:) — export one file per account. Several statements for the same account are fine.
  • Books reversals with the right sign: RC (reversal of credit) is a debit, RD (reversal of debit) a credit.
  • Takes the currency from the statement's balances; a statement without any needs currency= on the importer, otherwise extract() raises.
  • Emits a balance assertion from the :62F: closing balance, dated the day after (beancount balances are beginning-of-day).
  • Skips zero-amount noise entries (e.g. UBS "Balance closing of service prices").
  • Optional payee_rules draft the counter leg: an iterable of (regex, account, flag) matched case-insensitively against the payee and the full :86: details. Unmatched entries keep the ! review flag and the cash leg only — classification, VAT treatment, and document evidence stay a human decision.

Usage

from beangulp_mt940 import Importer

importer = Importer(
    "Assets:Bank:Checking",
    iban="CH93 0076 2011 6238 5295 7",   # identify() filter, optional
    payee_rules=(
        (r"client ag", "Assets:Receivable", "*"),
        (r"hosting",   "Expenses:IT:Hosting", "!"),
    ),
)
entries = importer.extract("statement.mt940", existing=ledger_entries)

Works standalone (as above) or as a regular importer in a beangulp import_config.py.

Notes on UBS specifics

  • UBS puts the counterparty in :86: after a transaction code and ? (DE1?Google Workspace …); the importer's payee heuristic handles both this and plain details.
  • The supplementary line under :61: ("Debit card payment", "e-banking credit", …) becomes the narration.
  • Transaction dates use the value date; the entry (booking) date is available in the source if you need it.

Metadata

Release files for beangulp-mt940 0.2.0

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

Source distribution (sdist)

Source distribution for beangulp-mt940 0.2.0
File Size Uploaded
beangulp_mt940-0.2.0.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for beangulp-mt940 0.2.0
File Interpreter ABI Platform
beangulp_mt940-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / beangulp_mt940-0.2.0.tar.gz

Download URL beangulp_mt940-0.2.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0973fe7d8f366e88a56769f5b3496ed3c194c06938883aa6dec9ae288ed9dd04
BLAKE2b-256 checksum
How to use checksums
6cf71758cdd6fc22a51ae648c9490f70ce48368e876ccc9e56411076e119573c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / beangulp_mt940-0.2.0-py3-none-any.whl

Download URL beangulp_mt940-0.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3cc41b86d6377739cf19fefd79a191396197a7753a497878c6c718736189835
BLAKE2b-256 checksum
How to use checksums
48397587780727fef737dd1cbcb652ea70d58fa6383203cae963585e09e17f36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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