egli / iso-20022-to-ledger-cli

Convert ISO 20022 to the ledger-cli plain text accounting format or to csv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ISO 20022 to ledger-cli

Convert ISO 20022 to the ledger-cli plain text accounting format or optionally to plain old csv.

Obviously this goes without saying: This software is provided “as is” without warranty of any kind. If your ledger statements are incorrect and you believe you found a bug in the converter please file an issue or even better a pull request.

Usage

You can use the tool in two ways: You can either directly run it via clojure or you can compile it to a jar file first and then run it via java.

Run clojure directly

clojure -m iso-to-ledger iso_20022.xml > plain_text.ledger

If you’d rather just have a csv file and import that with one of the many ledger import tools you can convert the iso 20022 file to a csv as follows:

clojure -m iso-to-csv iso_20022.xml > transactions.csv

This will generate a csv along the lines of

amountamount-intypebooking-datecurrencyreferencebalanceamount-outinfovalue-date
8.00:debit2020-01-02CHF12345100.008.00txn info2019-01-02
10.0010.00:credit2020-01-03CHF67890102.00txn info2019-01-03

See below how this csv can be imported.

Creating a jar

You can create a jar file as follows:

clojure -X:uberjar :jar iso-20022-to-ledger.jar

After that you can run the tool as follows:

java -jar iso-20022-to-ledger.jar iso_20022.xml > transactions.csv

This will give you a csv file that you can import.

Importing the csv

You can import the generated csv using hledger and the following rules file

hledger -f 2020.journal import transactions.csv
account1 Assets:Postcheck

fields _, amount-in, _, date, _, reference, balance, amount-out, comment, date2

skip 1

currency CHF 

Requirements

You will need clj to run this code. Install as described in Getting Started.

Todo

  • [ ] Add some machine learning to classify the transactions, i.e. assign the right account and payee to a transaction.
  • banks2ledger can infer account names via simple Bayesian inference based on an existing ledger file. Generally it seems well thought out and maintained. So maybe we should
    • join forces, i.e. reduce this package to just iso to csv
    • use their classifier code
      • the classifier needs to parse existing ledger files. For that it has a simple hand-crafted parser. It might be interesting to look into a parser that is based on instaparse such as ledger.parser

Feedback

If you have any suggestions or problems let me know. Issues and Pull Requests are very welcome.

References

The conversion is mostly based on classic reverse engineering of sample xml data. When in doubt also some official implementation guidelines were consulted.

License

GPLv3+

About

Convert ISO 20022 to the ledger-cli plain text accounting format or to csv

License:GNU General Public License v3.0


Languages

Language:Clojure 100.0%