From 8d5924fa8b4822ae3740ae2b95aee078927161dd Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 10 Sep 2020 09:22:02 +0100 Subject: [PATCH 1/8] add initial support for debitum network --- README.md | 5 +++-- config/debitumnetwork.yml | 13 +++++++++++++ parse-account-statements.py | 1 + src/test/testdata/debitum.csv | 5 +++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 config/debitumnetwork.yml mode change 100644 => 100755 parse-account-statements.py create mode 100644 src/test/testdata/debitum.csv diff --git a/README.md b/README.md index 088b769..0a67d67 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Python 3 (implemented with python 3.6.4) ## Dependencies The configuration for this application is stored in yaml files. The module used for -loading yaml files is [ruamel.yaml](https://yaml.readthedocs.io/en/latest/). +loading yaml files is [ruamel.yaml](https://yaml.readthedocs.io/en/latest/). Install via: `pip install ruamel.yaml` @@ -51,13 +51,14 @@ parse-account-statements.py --type mintos src/test/testdata/mintos.csv * swaper - Supports current account statement format (as of 2018-05-01) exported to csv * bondora - Supports current account statement format (as of 2019-10-12); exported to csv * bondora go & grow - Supports current account statement format (as of 2019-10-12); exported to csv +* debitumnetwork - Supports current account statement format (as of 2020-09-08) exported to csv ### Alternative solution for Auxmoney Unfortunately, the output file of Auxmoney's reports is not suitable for being parsed by PP-P2P-Parser in a senseful way. As an alternative, you can check out the [PP-Auxmoney-Parser](https://github.com/StegSchreck/PP-Auxmoney-Parser) project. ## Configuration files -Configuration for this script is stored in yaml files located under the config subdirectory. +Configuration for this script is stored in yaml files located under the config subdirectory. The content directly reflects the format of the source account statement files. Example: diff --git a/config/debitumnetwork.yml b/config/debitumnetwork.yml new file mode 100644 index 0000000..2aa9acb --- /dev/null +++ b/config/debitumnetwork.yml @@ -0,0 +1,13 @@ +--- +type_regex: !!map + deposit: "^DEPOSIT" + withdraw: "^WITHDRAW" + interest: "^REPAYMENT" + +csv_fieldnames: + booking_date: 'Date' + booking_date_format: '%Y-%m-%d' + booking_id: 'Transaction ID' + booking_type: 'Transaction Type' + booking_value: 'Turnover' + booking_details: 'Asset ID' diff --git a/parse-account-statements.py b/parse-account-statements.py old mode 100644 new mode 100755 index 84e8b9a..1ab93e4 --- a/parse-account-statements.py +++ b/parse-account-statements.py @@ -13,6 +13,7 @@ - Mintos - Robocash - Swaper + - Debitum Network Copyright 2018-03-17 ChrisRBe """ diff --git a/src/test/testdata/debitum.csv b/src/test/testdata/debitum.csv new file mode 100644 index 0000000..fbb1476 --- /dev/null +++ b/src/test/testdata/debitum.csv @@ -0,0 +1,5 @@ +Date,Transaction ID,Asset ID,Transaction Type,Turnover +2020-08-25,405eea2a-7745-4588-8f08-5c1512987324,NA,DEPOSIT,121.91 +2020-08-25,6e71160a-d8f6-4063-b710-ded06d7599bb,6c4a6d93-faea-4d96-856c-7cdd3fb3023b,INVESTMENT,-10 +2020-09-07,b9da7662-de61-43d1-a179-c300d5695587,6c4a6d93-faea-4d96-856c-7cdd3fb3023b,REPAYMENT,10.03 +2020-09-07,7260c567-fdb4-44d4-84ce-4256c7d7fb80,NA,INVITED_REFERRAL_REWARD,10 From 00024b7fc649fd9d2001481db1df49b4747eb293 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:04:53 +0200 Subject: [PATCH 2/8] add debitum network test --- config/debitumnetwork.yml | 2 +- src/test/test_p2p_account_statement_parser.py | 25 +++++++++++++++++++ src/test/testdata/debitum.csv | 1 - 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config/debitumnetwork.yml b/config/debitumnetwork.yml index 2aa9acb..5729d19 100644 --- a/config/debitumnetwork.yml +++ b/config/debitumnetwork.yml @@ -1,6 +1,6 @@ --- type_regex: !!map - deposit: "^DEPOSIT" + deposit: "^DEPOSIT|^INVITED_REFERRAL_REWARD" withdraw: "^WITHDRAW" interest: "^REPAYMENT" diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index ae1c1d7..66a5c7e 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -244,3 +244,28 @@ def test_swaper_parsing(self): 'Wert': '2000', 'Buchungswährung': 'EUR'}] self.assertEqual(expected_statement, self.base_parser.parse_account_statement()) + + def test_debitumnetwork_parsing(self): + """test parse_account_statement for debitum network""" + self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), 'testdata', 'debitum.csv') + self.base_parser.config_file = os.path.join(os.path.dirname(__file__), + os.pardir, + os.pardir, + 'config', + 'debitumnetwork.yml') + expected_statement = [{'Datum': datetime.date(2020, 8, 25), + 'Notiz': '405eea2a-7745-4588-8f08-5c1512987324', + 'Typ': 'Einlage', + 'Wert': '121,91', + 'Buchungswährung': 'EUR'}, + {'Datum': datetime.date(2020, 9, 07), + 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587', + 'Typ': 'Zinsen', + 'Wert': '10,03', + 'Buchungswährung': 'EUR'}, + {'Datum': datetime.date(2020, 9, 07), + 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80', + 'Typ': 'Einlage', + 'Wert': '10', + 'Buchungswährung': 'EUR'}] + self.assertEqual(expected_statement, self.base_parser.parse_account_statement()) diff --git a/src/test/testdata/debitum.csv b/src/test/testdata/debitum.csv index fbb1476..1635648 100644 --- a/src/test/testdata/debitum.csv +++ b/src/test/testdata/debitum.csv @@ -1,5 +1,4 @@ Date,Transaction ID,Asset ID,Transaction Type,Turnover 2020-08-25,405eea2a-7745-4588-8f08-5c1512987324,NA,DEPOSIT,121.91 -2020-08-25,6e71160a-d8f6-4063-b710-ded06d7599bb,6c4a6d93-faea-4d96-856c-7cdd3fb3023b,INVESTMENT,-10 2020-09-07,b9da7662-de61-43d1-a179-c300d5695587,6c4a6d93-faea-4d96-856c-7cdd3fb3023b,REPAYMENT,10.03 2020-09-07,7260c567-fdb4-44d4-84ce-4256c7d7fb80,NA,INVITED_REFERRAL_REWARD,10 From 1e44ca0ee2c80b7ecc29c5423fec158371a9646a Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:06:50 +0200 Subject: [PATCH 3/8] indentation --- src/test/test_p2p_account_statement_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index 66a5c7e..0fdd4f8 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -245,7 +245,7 @@ def test_swaper_parsing(self): 'Buchungswährung': 'EUR'}] self.assertEqual(expected_statement, self.base_parser.parse_account_statement()) - def test_debitumnetwork_parsing(self): + def test_debitumnetwork_parsing(self): """test parse_account_statement for debitum network""" self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), 'testdata', 'debitum.csv') self.base_parser.config_file = os.path.join(os.path.dirname(__file__), From 853a0264609a2eb1e49f427f83d86ad1cc51749b Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:08:02 +0200 Subject: [PATCH 4/8] remove zeros in days --- src/test/test_p2p_account_statement_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index 0fdd4f8..d134d88 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -258,12 +258,12 @@ def test_debitumnetwork_parsing(self): 'Typ': 'Einlage', 'Wert': '121,91', 'Buchungswährung': 'EUR'}, - {'Datum': datetime.date(2020, 9, 07), + {'Datum': datetime.date(2020, 9, 7), 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587', 'Typ': 'Zinsen', 'Wert': '10,03', 'Buchungswährung': 'EUR'}, - {'Datum': datetime.date(2020, 9, 07), + {'Datum': datetime.date(2020, 9, 7), 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80', 'Typ': 'Einlage', 'Wert': '10', From f530ced4f636a871eb53121816976013b8161353 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:23:07 +0200 Subject: [PATCH 5/8] fix debitumnetwork test? --- src/test/test_p2p_account_statement_parser.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index d134d88..2b461f8 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -254,18 +254,18 @@ def test_debitumnetwork_parsing(self): 'config', 'debitumnetwork.yml') expected_statement = [{'Datum': datetime.date(2020, 8, 25), - 'Notiz': '405eea2a-7745-4588-8f08-5c1512987324', - 'Typ': 'Einlage', 'Wert': '121,91', - 'Buchungswährung': 'EUR'}, + 'Buchungswährung': 'EUR', + 'Typ': 'Einlage', + 'Notiz': '405eea2a-7745-4588-8f08-5c1512987324: NA', {'Datum': datetime.date(2020, 9, 7), - 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587', - 'Typ': 'Zinsen', 'Wert': '10,03', - 'Buchungswährung': 'EUR'}, + 'Buchungswährung': 'EUR', + 'Typ': 'Zinsen', + 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587: 6c4a6d93-faea-4d96-856c-7cdd3fb3023b', {'Datum': datetime.date(2020, 9, 7), - 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80', - 'Typ': 'Einlage', 'Wert': '10', - 'Buchungswährung': 'EUR'}] + 'Buchungswährung': 'EUR'} + 'Typ': 'Einlage', + 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80: NA'}], self.assertEqual(expected_statement, self.base_parser.parse_account_statement()) From 877efedf64adc170b65f2eb871137354599c5ae0 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:24:54 +0200 Subject: [PATCH 6/8] braces --- src/test/test_p2p_account_statement_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index 2b461f8..8ab0511 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -257,12 +257,12 @@ def test_debitumnetwork_parsing(self): 'Wert': '121,91', 'Buchungswährung': 'EUR', 'Typ': 'Einlage', - 'Notiz': '405eea2a-7745-4588-8f08-5c1512987324: NA', + 'Notiz': '405eea2a-7745-4588-8f08-5c1512987324: NA'}, {'Datum': datetime.date(2020, 9, 7), 'Wert': '10,03', 'Buchungswährung': 'EUR', 'Typ': 'Zinsen', - 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587: 6c4a6d93-faea-4d96-856c-7cdd3fb3023b', + 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587: 6c4a6d93-faea-4d96-856c-7cdd3fb3023b'}, {'Datum': datetime.date(2020, 9, 7), 'Wert': '10', 'Buchungswährung': 'EUR'} From 47d2a829ce89bbc54d878a8ce9c3a30489641b63 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 30 Sep 2020 07:26:27 +0200 Subject: [PATCH 7/8] more brackets --- src/test/test_p2p_account_statement_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index 8ab0511..c5ac7b0 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -265,7 +265,7 @@ def test_debitumnetwork_parsing(self): 'Notiz': 'b9da7662-de61-43d1-a179-c300d5695587: 6c4a6d93-faea-4d96-856c-7cdd3fb3023b'}, {'Datum': datetime.date(2020, 9, 7), 'Wert': '10', - 'Buchungswährung': 'EUR'} + 'Buchungswährung': 'EUR', 'Typ': 'Einlage', 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80: NA'}], self.assertEqual(expected_statement, self.base_parser.parse_account_statement()) From ea872c5b9141533abcf0df4051ca75338ad1d8e3 Mon Sep 17 00:00:00 2001 From: Patrick Schratz Date: Wed, 30 Sep 2020 15:07:06 +0200 Subject: [PATCH 8/8] Update src/test/test_p2p_account_statement_parser.py Co-authored-by: ChrisRBe <31167512+ChrisRBe@users.noreply.github.com> --- src/test/test_p2p_account_statement_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_p2p_account_statement_parser.py b/src/test/test_p2p_account_statement_parser.py index c5ac7b0..82f317f 100644 --- a/src/test/test_p2p_account_statement_parser.py +++ b/src/test/test_p2p_account_statement_parser.py @@ -267,5 +267,5 @@ def test_debitumnetwork_parsing(self): 'Wert': '10', 'Buchungswährung': 'EUR', 'Typ': 'Einlage', - 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80: NA'}], + 'Notiz': '7260c567-fdb4-44d4-84ce-4256c7d7fb80: NA'}] self.assertEqual(expected_statement, self.base_parser.parse_account_statement())