├── src
├── __init__.py
├── test
│ ├── __init__.py
│ ├── testdata
│ │ ├── debitum.csv
│ │ ├── swaper.csv
│ │ ├── robocash.csv
│ │ ├── bondora.csv
│ │ ├── viainvest.csv
│ │ ├── estateguru.csv
│ │ ├── mintos.csv
│ │ ├── mintos_several_months.csv
│ │ └── lande.csv
│ ├── test_statement.py
│ ├── test_portfolio_writer.py
│ └── test_p2p_statement_parser.py
├── portfolio_writer.py
├── p2p_config.py
├── statement.py
└── p2p_statement_parser.py
├── .coveragerc
├── requirements.txt
├── .git-blame-ignore-revs
├── .github
├── bors.toml
├── dependabot.yml
└── workflows
│ ├── integration.yml
│ └── codeql-analysis.yml
├── .vscode
└── settings.json
├── tox.ini
├── .codeclimate.yml
├── Pipfile
├── config
├── debitumnetwork.yml
├── lande.yml
├── robocash.yml
├── swaper.yml
├── bondora_go_grow.yml
├── estateguru.yml
├── viainvest.yml
├── estateguru_en.yml
├── bondora.yml
└── mintos.yml
├── setup.py
├── pyproject.toml
├── .pre-commit-config.yaml
├── .gitignore
├── dev-requirements.txt
├── parse-account-statements.py
├── README.md
└── LICENSE
/src/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | omit = src/test/*
3 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | -i https://pypi.org/simple
2 | pyyaml==6.0
3 |
--------------------------------------------------------------------------------
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # Migrate code style to Black
2 | 762062158a11874f2b6eb3fc72d3857daacf7318
3 |
--------------------------------------------------------------------------------
/.github/bors.toml:
--------------------------------------------------------------------------------
1 | status = ["build (3.8)", "build (3.9)", "build (3.10)", "build (3.11)"]
2 | delete_merged_branches = true
3 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: pip
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | open-pull-requests-limit: 10
8 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.testing.pytestArgs": [
3 | "-v",
4 | "--doctest-modules",
5 | "--cov=src",
6 | "--cov-report=xml",
7 | "--cov-report=html",
8 | ".",
9 | ],
10 | "python.testing.unittestEnabled": false,
11 | "python.testing.pytestEnabled": true
12 | }
13 |
--------------------------------------------------------------------------------
/src/test/testdata/debitum.csv:
--------------------------------------------------------------------------------
1 | Date,Transaction ID,Asset ID,Transaction Type,Turnover
2 | 2020-08-25,405eea2a-7745-4588-8f08-5c1512987324,NA,DEPOSIT,121.91
3 | 2020-09-07,b9da7662-de61-43d1-a179-c300d5695587,6c4a6d93-faea-4d96-856c-7cdd3fb3023b,REPAYMENT,10.03
4 | 2020-09-07,7260c567-fdb4-44d4-84ce-4256c7d7fb80,NA,INVITED_REFERRAL_REWARD,10
5 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [pep8]
2 | max-line-length = 119
3 | [flake8]
4 | max-line-length = 119
5 | ignore = E203, E266, E501, W503
6 | max-complexity = 10
7 | select = B,C,E,F,W,T4,B9
8 | [pytest]
9 | junit_suite_name = PP-P2P-Parser
10 | junit_logging = all
11 | junit_log_passing_tests = true
12 | junit_duration_report = call
13 | junit_family = xunit2
14 |
--------------------------------------------------------------------------------
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 | plugins:
3 | fixme:
4 | enabled: true
5 | git-legal:
6 | enabled: true
7 | radon:
8 | enabled: true
9 | config:
10 | threshold: "C"
11 | sonar-python:
12 | enabled: true
13 | config:
14 | tests_patterns:
15 | - src/test/**
16 | exclude_patterns:
17 | - "src/test/"
18 |
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | name = "pypi"
3 | url = "https://pypi.org/simple"
4 | verify_ssl = true
5 |
6 | [dev-packages]
7 | black = "==23.3.0"
8 | codacy-coverage = "==1.3.11"
9 | coverage = "==7.2.4"
10 | flake8 = "==6.0.0"
11 | pre-commit = "==3.3.3"
12 | pylint = "==2.17.3"
13 | pytest = "==7.3.1"
14 | pytest-cov = "==4.0.0"
15 |
16 | [packages]
17 | PyYAML = "==6.0"
18 |
--------------------------------------------------------------------------------
/config/debitumnetwork.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^DEPOSIT|^INVITED_REFERRAL_REWARD"
4 | withdraw: "^WITHDRAW"
5 | interest: "^REPAYMENT"
6 |
7 | csv_fieldnames:
8 | booking_date: 'Date'
9 | booking_date_format: '%Y-%m-%d'
10 | booking_id: 'Transaction ID'
11 | booking_type: 'Transaction Type'
12 | booking_value: 'Turnover'
13 | booking_details: 'Asset ID'
14 |
--------------------------------------------------------------------------------
/config/lande.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^Bank transfer deposit$"
4 | withdraw: "^Withdraw.*"
5 | interest: "(.*Interest$)|(^Affiliate-Bonus$)|(^Empfehlungsbonus$)"
6 |
7 | csv_fieldnames:
8 | booking_date: 'Date'
9 | booking_date_format: '%d.%m.%Y'
10 | booking_details: 'Loan ID'
11 | booking_id: 'Transaction ID'
12 | booking_type: 'Type'
13 | booking_value: 'Amount'
14 |
--------------------------------------------------------------------------------
/config/robocash.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^Adding funds.*"
4 | withdraw: "^Withdraw application.*"
5 | interest: "(^Paying interest.*)"
6 |
7 | csv_fieldnames: !!map
8 | booking_date: 'Date and time'
9 | booking_date_format: '%Y-%m-%d %H:%M:%S'
10 | booking_details: 'Credit part ID'
11 | booking_id: 'Transaction ID'
12 | booking_type: 'Operation'
13 | booking_value: 'Amount'
14 |
--------------------------------------------------------------------------------
/config/swaper.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^FUNDING.*"
4 | withdraw: "^Withdraw application.*"
5 | interest: "(^EXTENSION_INTEREST.*)|(^REPAYMENT_INTEREST.*)|(^BUYBACK_INTEREST.*)"
6 |
7 | csv_fieldnames:
8 | booking_date: 'Booking date'
9 | booking_date_format: '%d.%m.%Y'
10 | booking_details: 'Loan id'
11 | booking_id: 'Loan number'
12 | booking_type: 'Transaction type'
13 | booking_value: 'Amount'
14 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """
2 | setup.py for creating packages
3 | """
4 | from setuptools import setup
5 |
6 | setup(
7 | name="PP-P2P-Parser",
8 | version="1.0",
9 | packages=["src", "src.test"],
10 | url="https://github.com/ChrisRBe/PP-P2P-Parser",
11 | license="GPL-3.0",
12 | author="ChrisRBe",
13 | author_email="chrisrbe@outlook.com",
14 | description="Parser for P2P services like mintos.com for Portfolio Performance.",
15 | )
16 |
--------------------------------------------------------------------------------
/config/bondora_go_grow.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "(^TransferGoGrow$)"
4 | withdraw: "(^TransferGoGrowMainRepaiment$)"
5 | interest: "(^$)"
6 | fee: "(^$)"
7 |
8 | csv_fieldnames:
9 | booking_date: 'TransferDate'
10 | booking_date_format: '%d.%m.%Y %H:%M'
11 | booking_details: 'Description'
12 | booking_id: 'LoanNumber'
13 | booking_type: 'Description'
14 | booking_value: 'Amount'
15 | booking_currency: 'Currency'
16 |
--------------------------------------------------------------------------------
/src/test/testdata/swaper.csv:
--------------------------------------------------------------------------------
1 | Booking date;Transaction type;Amount;Processing time;Loan id;Loan number
2 | 01.05.2018;BUYBACK_PRINCIPAL;10;;119113;PL-84587
3 | 01.05.2018;BUYBACK_INTEREST;0,1;;119113;PL-84587
4 | 30.04.2018;REPAYMENT_PRINCIPAL;10;;116800;PL-82794
5 | 30.04.2018;REPAYMENT_INTEREST;0,12;;116800;PL-82794
6 | 29.04.2018;INVESTMENT;-10;;128099;PL-91444
7 | 26.04.2018;EXTENSION_INTEREST;0,11;;117251;GL-22989301
8 | 24.01.2018;FUNDING;2000;24.01.2018 09:04;;
9 |
--------------------------------------------------------------------------------
/config/estateguru.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^Einzahlung.*"
4 | withdraw: "^Auszahlung.*"
5 | interest: "(^Empfehlungsbonus.*)|(^Zins.*)|(^Sondervergütung.*)|(^Empfehlung.*)|(^Bonus.*)"
6 |
7 | csv_fieldnames: !!map
8 | booking_date: 'Zahlungsdatum'
9 | booking_date_format: '%d/%m/%Y %H:%M'
10 | booking_details: 'Projektname'
11 | booking_id: 'UniqueId'
12 | booking_type: 'Cashflow-Typ'
13 | booking_value: 'Betrag'
14 | booking_currency: 'Währung'
15 |
--------------------------------------------------------------------------------
/config/viainvest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "(Amount of funds deposited)"
4 | withdraw: ""
5 | interest: "(Amount of interest payment received)"
6 | ignorable_entry: "(Amount invested in loan)|(Amount of principal repayment received)"
7 |
8 | csv_fieldnames:
9 | booking_date: 'Value date'
10 | booking_date_format: '%m/%d/%Y'
11 | booking_details: 'Loan ID'
12 | booking_id: 'Loan ID'
13 | booking_type: 'Transaction type'
14 | booking_value: 'Credit (€)'
15 |
--------------------------------------------------------------------------------
/config/estateguru_en.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "^Deposit.*"
4 | withdraw: "^Withdrawal.*"
5 | interest: "(^Interest.*)|(^Indemnity.*)|(^Referral.*)|(^EG Bonus.*)|(^Secondary Market Profit.*)"
6 | fee: "(^Secondary Market Loss.*)|(^Fee.*)"
7 |
8 | csv_fieldnames: !!map
9 | booking_date: 'Payment Date'
10 | booking_date_format: '%d/%m/%Y %H:%M'
11 | booking_details: 'Loan Code'
12 | booking_id: 'ID'
13 | booking_type: 'Cash Flow Type'
14 | booking_value: 'Amount'
15 | booking_currency: 'Currency'
16 |
--------------------------------------------------------------------------------
/config/bondora.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "(^TransferDeposit.*)|(^TransferGoGrowMainRepaiment.*)"
4 | withdraw: "(^Withdraw.*)|(^TransferGoGrow$)"
5 | interest: "(^TransferInterestRepaiment.*)|(^TransferExtraInterestRepaiment.*)"
6 | fee: "(^FX commission.*)"
7 |
8 | csv_fieldnames:
9 | booking_date: 'TransferDate'
10 | booking_date_format: '%d.%m.%Y %H:%M'
11 | booking_details: 'Description'
12 | booking_id: 'LoanNumber'
13 | booking_type: 'Description'
14 | booking_value: 'Amount'
15 | booking_currency: 'Currency'
16 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.black]
2 | line-length = 119
3 | target-version = ['py36', 'py37', 'py38']
4 | include = '\.pyi?$'
5 | exclude = '''
6 |
7 | (
8 | /(
9 | \.eggs # exclude a few common directories in the
10 | | \.git # root of the project
11 | | \.hg
12 | | \.mypy_cache
13 | | \.tox
14 | | \.venv
15 | | _build
16 | | buck-out
17 | | build
18 | | dist
19 | )/
20 | | foo.py # also separately exclude a file named foo.py in
21 | # the root of the project
22 | )
23 | '''
24 |
--------------------------------------------------------------------------------
/src/test/testdata/robocash.csv:
--------------------------------------------------------------------------------
1 | Transaction ID;Date and time;Operation type;Operation;Credit part ID;Sender ID;Receiver ID;Amount;Investor's balance (3246);"""baloon"" balance (3262)";"""baloon"" loans (3262)"
2 | 2438244;2018-02-15 09:52:35;0;Adding funds;;;3246;2000;2000;0;0
3 | 2442794;2018-02-15 15:13:37;2;Creating a portfolio;;3246;3262;2000;0;2000;0
4 | 2443032;2018-02-15 15:35:33;5;Purchasing a loan;856832;3262;1;10;0;1990;10
5 | 2458794;2018-02-16 15:43:20;6;Returning a loan;856836;1;3262;10;0;1690;310
6 | 2458795;2018-02-16 15:43:20;16;Paying interest;856836;1;3262;0,003835616;0;1690,003836;310
7 |
--------------------------------------------------------------------------------
/src/test/testdata/bondora.csv:
--------------------------------------------------------------------------------
1 | TransferDate;Currency;Amount;Number;Description;LoanNumber;Counterparty;BalanceAfterPayment
2 | 01.01.2019 00:01;EUR;100;1000000001;TransferDeposit|DE1111000000111111;;InvestorTrustly;100
3 | 02.01.2019 00:02;EUR;-100;1000000002;TransferGoGrow;;GoGrow;0
4 | 03.01.2019 00:03;EUR;100;1000000003;TransferDeposit|Wirecard;;Wirecard;100
5 | 04.01.2019 00:04;EUR;0,0067920792;1000000004;TransferInterestRepaiment;1111111-111111112;Bondora Capital;100,0067920792
6 | 05.01.2019 00:05;EUR;7,05883E-05;1000000005;TransferExtraInterestRepaiment;1111111-111111113;Bondora Capital;100,0068626675
7 |
--------------------------------------------------------------------------------
/src/test/testdata/viainvest.csv:
--------------------------------------------------------------------------------
1 | Transaction date;Value date;Transaction type;Country;Loan ID;Loan Type;Credit (€);Debit (€)
2 | 12/13/2020;12/13/2020;Amount of funds deposited;;;;1.000,00;
3 | 12/13/2020;12/13/2020;Amount invested in loan;PL;05-3248349;Short-term loan;;10,00
4 | 12/14/2020;12/14/2020;Amount of principal repayment received;LV;04-1246342;Credit line;0,24;
5 | 12/14/2020;12/14/2020;Amount of interest payment received;LV;04-1246342;Credit line;0,10;
6 | 12/14/2020;12/14/2020;Amount of principal repayment received;PL;05-3233341;Short-term loan;10,00;
7 | 12/14/2020;12/14/2020;Amount of interest payment received;PL;05-3233341;Short-term loan;0,09;
8 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/psf/black
3 | rev: 23.3.0
4 | hooks:
5 | - id: black
6 | language_version: python3
7 | - repo: https://github.com/PyCQA/flake8
8 | rev: 6.0.0
9 | hooks:
10 | - id: flake8
11 | - repo: https://github.com/pre-commit/pre-commit-hooks
12 | rev: v4.4.0
13 | hooks:
14 | - id: check-docstring-first
15 | - id: check-merge-conflict
16 | - id: check-toml
17 | - id: check-yaml
18 | - id: end-of-file-fixer
19 | - id: no-commit-to-branch
20 | - id: trailing-whitespace
21 | - repo: https://github.com/asottile/reorder-python-imports
22 | rev: v3.9.0
23 | hooks:
24 | - id: reorder-python-imports
25 | args: [--py36-plus]
26 |
--------------------------------------------------------------------------------
/config/mintos.yml:
--------------------------------------------------------------------------------
1 | ---
2 | type_regex: !!map
3 | deposit: "(Deposits)|(^Incoming client.*)|(^Incoming currency exchange.*)|(^Affiliate partner bonus$)"
4 | withdraw: "(^Withdraw application.*)|(Outgoing currency.*)|(Withdrawal)"
5 | interest: "(^Delayed interest.*)|(^Late payment.*)|(^Interest income.*)|(^Cashback.*)|(^.*[Ii]nterest received.*)|(^.*late fees received$)"
6 | fee: "(^FX commission.*)|(.*secondary market fee$)"
7 | ignorable_entry: ".*investment in loan.*|.*[Pp]rincipal received.*|.*secondary market transaction.*"
8 | special_entry: "(.*discount/premium.*)"
9 |
10 | csv_fieldnames:
11 | booking_date: 'Date'
12 | booking_date_format: '%Y-%m-%d %H:%M:%S'
13 | booking_details: 'Details'
14 | booking_id: 'Transaction ID:'
15 | booking_type: 'Details'
16 | booking_value: 'Turnover'
17 | booking_currency: 'Currency'
18 |
--------------------------------------------------------------------------------
/src/test/test_statement.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Unit test for the p2p statement class
4 |
5 | Copyright 2021-12-12 AlexanderLill
6 | """
7 | import unittest
8 |
9 | from src.statement import Statement
10 |
11 |
12 | class TestStatement(unittest.TestCase):
13 | """Test case implementation for Statement"""
14 |
15 | def test_value_parsing(self):
16 | """test parsing of amount value"""
17 |
18 | test_data = [
19 | ("1.2", 1.2),
20 | ("1,1", 1.1),
21 | ("1.000,30", 1000.3),
22 | ("1,000.30", 1000.3),
23 | ("1000.30", 1000.3),
24 | ]
25 |
26 | for item in test_data:
27 | test_input = item[0]
28 | expected_output = item[1]
29 | self.assertEqual(expected_output, Statement._parse_value(test_input))
30 |
31 |
32 | if __name__ == "__main__":
33 | unittest.main()
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | venv/
12 | env/
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .coverage
43 | .coverage.*
44 | .cache
45 | nosetests.xml
46 | coverage.xml
47 | pytest-result.xml
48 | *.cover
49 | .hypothesis/
50 |
51 | # Sphinx documentation
52 | docs/_build/
53 |
54 | # PyBuilder
55 | target/
56 |
57 | # pyenv
58 | .python-version
59 | Pipfile.lock
60 |
61 | # mkdocs documentation
62 | /site
63 |
64 | # mypy
65 | .mypy_cache/
66 |
67 | # pycharm
68 | .idea/
69 | .pytest_cache/
70 |
--------------------------------------------------------------------------------
/src/test/testdata/estateguru.csv:
--------------------------------------------------------------------------------
1 | "UniqueId","Zahlungsdatum","Bestätigungsdatum","Cashflow-Typ","Cashflow-Status","Projektname","Währung","Betrag","Verfügbar für Investitionen"
2 | "18012018204714DEP","18/01/2018 20:47","22/01/2018 10:24","Einzahlung(Bank Transfer)","Genehmigt",,"EUR","1000.0","1000.0"
3 | "23012018002800INVEE3304","23/01/2018 00:28","23/01/2018 00:28","Investition","Zurückgekehrt","Sangla bridge loan","EUR","50.0",""
4 | "23012018092020DEP","23/01/2018 09:20","23/01/2018 09:20","Einzahlung(Admin)","Genehmigt",,"EUR","1000.0","2000.0"
5 | "24012018000000REFEE5975","24/01/2018 00:00","24/01/2018 00:00","Empfehlungsbonus","Genehmigt","Kaerepere business loan 2. stage","EUR","0.25","2000.25"
6 | "24012018000346WIT","24/01/2018 00:03","24/01/2018 08:49","Auszahlung","Genehmigt",,"EUR","-1000.0","1000.25"
7 | "24012018115422INVEE4182","24/01/2018 11:54","24/01/2018 11:54","Investition(Auto Invest)","Genehmigt","Laiamäe bridge loan","EUR","-50.0","950.25"
8 | "30012018000000REFEE4182","30/01/2018 00:00","30/01/2018 00:00","Empfehlungsbonus","Genehmigt","Laiamäe bridge loan","EUR","0.5","800.75"
9 | "24022018000000INTEE5975","24/02/2018 00:00","26/02/2018 10:27","Zins","Genehmigt","Kaerepere business loan 2. stage","EUR","0.46","107.63"
10 | "27022018225240DEP","27/02/2018 22:52","01/03/2018 09:17","Einzahlung(Bank Transfer)","Genehmigt",,"EUR","1000.0","1060.05"
11 | "01032018000000BONLT2293","01/03/2018 00:00","01/03/2018 13:43","Sondervergütung","Genehmigt","Grevitas construction loan","EUR","0.47","960.52"
12 | "15032018000000INTLT0689","15/03/2018 00:00","19/03/2018 14:00","Zins","Genehmigt","Užutekio bridge loan","EUR","0.59","71.5"
13 | "08042018000000INTEE3186","08/04/2018 00:00","09/04/2018 11:03","Zins","Genehmigt","Pärnaõie st bridge loan","EUR","0.46","24.82"
14 |
--------------------------------------------------------------------------------
/dev-requirements.txt:
--------------------------------------------------------------------------------
1 | -i https://pypi.org/simple
2 | astroid==2.12.13 ; python_full_version >= '3.7.2'
3 | attrs==22.2.0 ; python_version >= '3.6'
4 | black==23.1.0
5 | certifi==2022.12.7 ; python_version >= '3.6'
6 | cfgv==3.3.1 ; python_full_version >= '3.6.1'
7 | charset-normalizer==2.1.1 ; python_full_version >= '3.6.0'
8 | click==8.1.3 ; python_version >= '3.7'
9 | codacy-coverage==1.3.11
10 | colorama==0.4.6 ; sys_platform == 'win32'
11 | coverage==7.2.1
12 | dill==0.3.6 ; python_version < '3.11'
13 | distlib==0.3.6
14 | exceptiongroup==1.1.0 ; python_version < '3.11'
15 | filelock==3.9.0 ; python_version >= '3.7'
16 | flake8==6.0.0
17 | identify==2.5.12 ; python_version >= '3.7'
18 | idna==3.4 ; python_version >= '3.5'
19 | iniconfig==1.1.1
20 | isort==5.11.4 ; python_full_version >= '3.7.0'
21 | lazy-object-proxy==1.9.0 ; python_version >= '3.7'
22 | mccabe==0.7.0 ; python_version >= '3.6'
23 | mypy-extensions==0.4.3
24 | nodeenv==1.7.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'
25 | packaging==22.0 ; python_version >= '3.7'
26 | pathspec==0.10.3 ; python_version >= '3.7'
27 | platformdirs==2.6.2 ; python_version >= '3.7'
28 | pluggy==1.0.0 ; python_version >= '3.6'
29 | pre-commit==2.21.0
30 | pycodestyle==2.10.0 ; python_version >= '3.6'
31 | pyflakes==3.0.1 ; python_version >= '3.6'
32 | pylint==2.15.9
33 | pytest==7.2.0
34 | pytest-cov==4.0.0
35 | pyyaml==6.0
36 | requests==2.28.1 ; python_version >= '3.7' and python_version < '4'
37 | setuptools==65.6.3 ; python_version >= '3.7'
38 | tomli==2.0.1 ; python_full_version < '3.11.0a7'
39 | tomlkit==0.11.6 ; python_version >= '3.6'
40 | typing-extensions==4.4.0 ; python_version < '3.10'
41 | urllib3==1.26.13 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
42 | virtualenv==20.17.1 ; python_version >= '3.6'
43 | wrapt==1.14.1 ; python_version < '3.11'
44 |
--------------------------------------------------------------------------------
/src/test/testdata/mintos.csv:
--------------------------------------------------------------------------------
1 | "Transaction ID:";Date;Details;Turnover;Balance;Currency
2 | 236659674;2018-01-17 11:26:03;Incoming client payment;20;20;EUR
3 | 236695922;2018-01-17 21:07:02;Investment principal increase Loan ID: 2202100-01;-10;10;EUR
4 | 236695923;2018-01-17 21:07:02;Investment principal increase Loan ID: 2019703-02;-10;0;EUR
5 | 237395070;2018-01-17 23:30:00;Investment principal repayment Loan ID: 2058850-01;0,047334437;0,047334437;EUR
6 | 237457477;2018-01-18 08:22:40;Investment principal rebuy Rebuy purpose: agreement_amendment Loan ID: 2199001-01;10;10,04733444;EUR
7 | 237458669;2018-01-18 08:24:51;Investment principal rebuy Rebuy purpose: agreement_prolongation Loan ID: 2026474-02;10;10,04733444;EUR
8 | 237974500;2018-01-18 23:30:00;Interest income Loan ID: 2049443-01;0,005555556;0,052889992;EUR
9 | 238028129;2018-01-18 23:30:00;Investment principal repayment Loan ID: 2101801-01;0,095608625;0,540594138;EUR
10 | 238112163;2018-01-19 07:58:35;Interest income on rebuy Rebuy purpose: agreement_amendment Loan ID: 2198495-01;0,003777778;0,544371916;EUR
11 | 238112984;2018-01-19 07:59:40;Interest income on rebuy Rebuy purpose: early_repayment Loan ID: 2202538-01;0,003083333;10,54745525;EUR
12 | 238112996;2018-01-19 07:59:40;Investment principal rebuy Rebuy purpose: early_repayment Loan ID: 2202538-01;10;20,54745525;EUR
13 | 238505006;2018-01-19 23:30:00;Investment principal repayment Loan ID: 1953317-01;0,049807697;0,668273698;EUR
14 | 241699935;2018-01-25 23:30:00;Late payment fee income Loan ID: 1529173-01;0,001214211;8,460085025;EUR
15 | 243559685;2018-01-29 11:23:17;Delayed interest income on rebuy Rebuy purpose: agreement_amendment Loan ID: 2198503-01;0,000342077;5,177127496;EUR
16 | 260918485;2018-02-27 15:32:53;Cashback bonus;0,3;9,16072334;EUR
17 | 115013710;2016-09-28 16:47:05;Withdraw application;-20;199,9539516;EUR
18 | 178363724;2020-04-10 20:23:27;Loan 28375000-01 - discount/premium for secondary market transaction 178363274.;-0,14545454545455;161.68581373945;EUR
19 | 178363725;2020-04-10 20:23:27;Loan 28375000-01 - discount/premium for secondary market transaction 178363275.;0,50545454545455;161.68581373945;EUR
20 | 127373922;;Loan 35287609-01 - interest received (no date for testing);0,50;1337,50;EUR
21 |
--------------------------------------------------------------------------------
/src/test/testdata/mintos_several_months.csv:
--------------------------------------------------------------------------------
1 | "Transaction ID:";Date;Details;Turnover;Balance;Currency
2 | 436695922;2018-03-02 21:07:02;Investment principal increase Loan ID: 3402100-01;-10;10;EUR
3 | 446695922;2018-03-03 21:07:02;Investment principal increase Loan ID: 4302100-01;-10;10;EUR
4 | 336695922;2018-02-02 21:07:02;Investment principal increase Loan ID: 3202100-01;-10;10;EUR
5 | 346695922;2018-02-03 21:07:02;Investment principal increase Loan ID: 3302100-01;-10;10;EUR
6 | 236659674;2018-02-18 11:26:03;Incoming client payment;20;20;EUR
7 | 236659674;2018-01-17 11:26:03;Incoming client payment;20;20;EUR
8 | 236695922;2018-01-17 21:07:02;Investment principal increase Loan ID: 2202100-01;-10;10;EUR
9 | 236695923;2018-01-17 21:07:02;Investment principal increase Loan ID: 2019703-02;-10;0;EUR
10 | 237395070;2018-01-17 23:30:00;Investment principal repayment Loan ID: 2058850-01;0,047334437;0,047334437;EUR
11 | 237457477;2018-01-18 08:22:40;Investment principal rebuy Rebuy purpose: agreement_amendment Loan ID: 2199001-01;10;10,04733444;EUR
12 | 237458669;2018-01-18 08:24:51;Investment principal rebuy Rebuy purpose: agreement_prolongation Loan ID: 2026474-02;10;10,04733444;EUR
13 | 237974500;2018-01-18 23:30:00;Interest income Loan ID: 2049443-01;0,005555556;0,052889992;EUR
14 | 238028129;2018-01-18 23:30:00;Investment principal repayment Loan ID: 2101801-01;0,095608625;0,540594138;EUR
15 | 238112163;2018-01-19 07:58:35;Interest income on rebuy Rebuy purpose: agreement_amendment Loan ID: 2198495-01;0,003777778;0,544371916;EUR
16 | 238112984;2018-01-19 07:59:40;Interest income on rebuy Rebuy purpose: early_repayment Loan ID: 2202538-01;0,003083333;10,54745525;EUR
17 | 238112996;2018-01-19 07:59:40;Investment principal rebuy Rebuy purpose: early_repayment Loan ID: 2202538-01;10;20,54745525;EUR
18 | 238505006;2018-01-19 23:30:00;Investment principal repayment Loan ID: 1953317-01;0,049807697;0,668273698;EUR
19 | 241699935;2018-01-25 23:30:00;Late payment fee income Loan ID: 1529173-01;0,001214211;8,460085025;EUR
20 | 243559685;2018-01-29 11:23:17;Delayed interest income on rebuy Rebuy purpose: agreement_amendment Loan ID: 2198503-01;0,000342077;5,177127496;EUR
21 | 260918485;2018-02-27 15:32:53;Cashback bonus;0,3;9,16072334;EUR
22 | 115013710;2016-09-28 16:47:05;Withdraw application;-20;199,9539516;EUR
23 |
--------------------------------------------------------------------------------
/.github/workflows/integration.yml:
--------------------------------------------------------------------------------
1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3 |
4 | name: Integration
5 |
6 | on:
7 | push:
8 | branches: [ master, staging, trying ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 | strategy:
17 | matrix:
18 | python-version: ["3.8", "3.9", "3.10", "3.11"]
19 |
20 | steps:
21 | - uses: actions/checkout@v3
22 | - name: Set up Python ${{ matrix.python-version }}
23 | uses: actions/setup-python@v4
24 | with:
25 | python-version: ${{ matrix.python-version }}
26 | - name: Install dependencies
27 | run: |
28 | python -m pip install --upgrade pip
29 | pip install -U pipenv
30 | pipenv install --system --skip-lock --dev --site-packages
31 | - name: Install additional locale
32 | run: |
33 | sudo apt-get update && sudo apt-get install tzdata locales -y && sudo locale-gen de_DE.UTF-8
34 | sudo update-locale
35 | echo "Testing language settings"
36 | echo "All languages..."
37 | locale -a
38 | echo "Actual locale"
39 | locale
40 | echo "Actual numeric settings"
41 | locale -c -k LC_NUMERIC
42 | - name: Format with black
43 | run: |
44 | black -l 119 --check --diff .
45 | - name: Lint with flake8
46 | run: |
47 | # stop the build if there are Python syntax errors or undefined names
48 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
49 | # exit-zero treats all errors as warnings.
50 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=119 --statistics
51 | - name: Code Climate Coverage Action
52 | uses: paambaati/codeclimate-action@v3.2.0
53 | env:
54 | CC_TEST_REPORTER_ID: 9fbcedc83021dae40df55ed23b48c4eb2a5b0b3a41047097e283c5df385e0b16
55 | with:
56 | coverageCommand: |
57 | pytest -v --doctest-modules --cov=src --cov-report=xml --junit-xml=pytest-result-${{ matrix.python-version }}.xml
58 | coverageLocations: 'coverage.xml:coverage.py'
59 | debug: true
60 |
--------------------------------------------------------------------------------
/src/test/testdata/lande.csv:
--------------------------------------------------------------------------------
1 | #,Transaction ID,Loan ID,Type,Amount,Date,Balance
2 | 1,97b1a146-1c3f-47e5-8ac3-10ade56765ec,,Bank transfer deposit,"500,00 €",08.11.2022,"500,00 €"
3 | 2,97b20e47-dd65-47dd-b6cf-1a780c209e3a,221108-366978,Investment,"50,00 €",08.11.2022,"450,00 €"
4 | 3,97b20fa6-c6cd-4c08-8f4a-b25f120ec583,221108-366978,Affiliate-Bonus,"0,50 €",08.11.2022,"450,50 €"
5 | 4,97b7d881-aef2-4f95-96f2-22a460bf3151,221109-297724,Investment,"50,00 €",11.11.2022,"400,50 €"
6 | 5,97b7d986-c414-427f-90a2-c05e98641900,221109-297724,Affiliate-Bonus,"0,50 €",11.11.2022,"401,00 €"
7 | 6,97b8278c-a275-4320-9078-245b77b4bc56,221108-142849,Investment,"50,00 €",11.11.2022,"351,00 €"
8 | 7,97b8289e-fd86-4312-84de-f50631fb571f,221108-142849,Affiliate-Bonus,"0,50 €",11.11.2022,"351,50 €"
9 | 8,97b832ff-aa8a-4def-a536-fa758a603a4e,221101-847953,Investment,"50,00 €",11.11.2022,"301,50 €"
10 | 9,97b833cf-9d9f-4ff2-a800-a2b1ebaea865,221101-847953,Affiliate-Bonus,"0,50 €",11.11.2022,"302,00 €"
11 | 10,97be0c09-761b-4c9a-bcf9-45eae2f6f07f,220929-309009,Investment,"50,00 €",14.11.2022,"252,00 €"
12 | 11,97be0c31-7d4b-41e8-8c8d-77e9e9b25529,220926-944705,Investment,"50,00 €",14.11.2022,"202,00 €"
13 | 12,97be0c4f-a4d1-4e7d-aeff-f07e7c446d7e,220929-309009,Affiliate-Bonus,"0,50 €",14.11.2022,"202,50 €"
14 | 13,97be0c55-bf7b-46f9-ba2b-0f2ab5abeb71,221011-882308,Investment,"50,00 €",14.11.2022,"152,50 €"
15 | 14,97be0c91-0f2c-4616-9920-c0049c282c87,221012-476486,Investment,"50,00 €",14.11.2022,"102,50 €"
16 | 15,97be0ca1-0c64-498f-9a47-bc2c7f1ca1ed,220926-944705,Affiliate-Bonus,"0,50 €",14.11.2022,"103,00 €"
17 | 16,97be0cfb-3ceb-4bdc-9411-b25acae80a6e,221011-882308,Affiliate-Bonus,"0,50 €",14.11.2022,"103,50 €"
18 | 17,97be0d0b-4920-48bb-b0f6-fad461ba1ebe,221101-842051,Investment,"50,00 €",14.11.2022,"53,50 €"
19 | 18,97be0d40-9237-4683-a6d9-be836ba90580,221012-476486,Affiliate-Bonus,"0,50 €",14.11.2022,"54,00 €"
20 | 19,97be0d93-81a0-428b-9ea3-23be8ff7cfca,221101-842051,Affiliate-Bonus,"0,50 €",14.11.2022,"54,50 €"
21 | 20,97be4839-e560-4084-9357-bed0787b9002,221114-968949,Investment,"50,00 €",14.11.2022,"4,50 €"
22 | 21,97be48c7-c79d-4a35-a440-4048b74b17c8,221114-968949,Affiliate-Bonus,"0,50 €",14.11.2022,"5,00 €"
23 | 22,97e065db-dcad-4a29-8738-5adbfc74fc49,221011-882308,Interest,"0,50 €",01.12.2022,"5,50 €"
24 | ,,,Initial amount on 08.11.2022,,,
25 | ,,,Final amount on 01.12.2022,,,"5,50 €"
26 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ master ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ master ]
20 | schedule:
21 | - cron: '26 4 * * 3'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 |
28 | strategy:
29 | fail-fast: false
30 | matrix:
31 | language: [ 'python' ]
32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33 | # Learn more:
34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35 |
36 | steps:
37 | - name: Checkout repository
38 | uses: actions/checkout@v2
39 |
40 | # Initializes the CodeQL tools for scanning.
41 | - name: Initialize CodeQL
42 | uses: github/codeql-action/init@v1
43 | with:
44 | languages: ${{ matrix.language }}
45 | # If you wish to specify custom queries, you can do so here or in a config file.
46 | # By default, queries listed here will override any specified in a config file.
47 | # Prefix the list here with "+" to use these queries and those in the config file.
48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
49 |
50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51 | # If this step fails, then you should remove it and run the build manually (see below)
52 | - name: Autobuild
53 | uses: github/codeql-action/autobuild@v1
54 |
55 | # ℹ️ Command-line programs to run using the OS shell.
56 | # 📚 https://git.io/JvXDl
57 |
58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59 | # and modify them (or add more) to build your code if your project
60 | # uses a compiled language
61 |
62 | #- run: |
63 | # make bootstrap
64 | # make release
65 |
66 | - name: Perform CodeQL Analysis
67 | uses: github/codeql-action/analyze@v1
68 |
--------------------------------------------------------------------------------
/src/portfolio_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Module for the portfolio performance writer
4 |
5 | Copyright 2018-04-29 ChrisRBe
6 | """
7 | import codecs
8 | import csv
9 | import io
10 | import locale
11 | import logging
12 | from decimal import Decimal
13 |
14 |
15 | PP_FIELDNAMES = ["Datum", "Wert", "Buchungswährung", "Typ", "Notiz"]
16 | logger = logging.getLogger(__name__)
17 |
18 |
19 | class PortfolioPerformanceWriter(object):
20 | """
21 | Writing parsed Peer-to-Peer lending account statements to Portfolio Performance compatible format
22 | """
23 |
24 | def __init__(self, dialect="excel"):
25 | """
26 | constructor for class
27 |
28 | :param dialect: translates to the used CSV dialect, defaults to excel
29 | """
30 | self.dialect = dialect
31 | self.out_csv_fieldnames = PP_FIELDNAMES
32 | self.out_string_stream = io.StringIO()
33 | self.out_csv_writer = None
34 |
35 | def init_output(self):
36 | """
37 | Initialize output csv file
38 | """
39 | if not self.out_csv_writer:
40 | self.out_csv_writer = csv.DictWriter(
41 | f=self.out_string_stream,
42 | fieldnames=self.out_csv_fieldnames,
43 | dialect=self.dialect,
44 | )
45 | self.out_csv_writer.writeheader()
46 |
47 | def update_output(self, statement_dict):
48 | """
49 | Add a new line to the portfolio performance output file; format is a dictionary
50 |
51 | :param statement_dict: dictionary containing the fieldnames of the output file and the respective content as
52 | key value pair
53 | :return:
54 | """
55 | logger.debug("Current locale: %s", locale.getlocale())
56 | if statement_dict:
57 | value = Decimal(statement_dict[PP_FIELDNAMES[1]])
58 | statement_dict[PP_FIELDNAMES[1]] = f"{value:.8n}"
59 | self.out_csv_writer.writerow(statement_dict)
60 |
61 | def write_pp_csv_file(self, outfile="portfolio_performance.csv"):
62 | """
63 | Write the content of the complete string stream into the actual output file.
64 | Should be called after the parsed account statement has been written to the stream.
65 |
66 | :param outfile: specifies the path and name of the output file, defaults to portfolio_performance.csv
67 | :return:
68 | """
69 | with codecs.open(outfile, "w", encoding="utf-8") as csv_output:
70 | stream_content = self.out_string_stream.getvalue()
71 | logger.debug(stream_content)
72 | csv_output.write(stream_content.strip())
73 |
--------------------------------------------------------------------------------
/src/test/test_portfolio_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Unit test for the portfolio performance writer module
4 |
5 | Copyright 2018-04-29 ChrisRBe
6 | """
7 | import codecs
8 | import locale
9 | import os
10 | import tempfile
11 | from unittest import TestCase
12 |
13 | from src.portfolio_writer import PortfolioPerformanceWriter
14 | from src.portfolio_writer import PP_FIELDNAMES
15 |
16 |
17 | class TestPortfolioPerformanceWriter(TestCase):
18 | """Test case implementation for PortfolioPerformanceWriter"""
19 |
20 | def setUp(self):
21 | """test case setUp, run for each test case"""
22 | self.pp_writer = PortfolioPerformanceWriter()
23 | self.pp_writer.init_output()
24 |
25 | def test_init_output(self):
26 | """test init_output"""
27 | self.assertEqual(",".join(PP_FIELDNAMES), self.pp_writer.out_string_stream.getvalue().strip())
28 |
29 | def test_update_output(self):
30 | """test update_output"""
31 | locale.setlocale(locale.LC_ALL, "de_DE.utf-8")
32 | test_entry = {
33 | PP_FIELDNAMES[0]: "date",
34 | PP_FIELDNAMES[1]: 123.456789,
35 | PP_FIELDNAMES[2]: "currency",
36 | PP_FIELDNAMES[3]: "category",
37 | PP_FIELDNAMES[4]: "note",
38 | }
39 | self.pp_writer.update_output(test_entry)
40 | self.assertEqual(
41 | 'Datum,Wert,Buchungswährung,Typ,Notiz\r\ndate,"123,45679",currency,category,note',
42 | self.pp_writer.out_string_stream.getvalue().strip(),
43 | )
44 |
45 | def test_update_output_umlaut(self):
46 | """test update_output with umlauts"""
47 | locale.setlocale(locale.LC_ALL, "de_DE.utf-8")
48 | test_entry = {
49 | PP_FIELDNAMES[0]: "date",
50 | PP_FIELDNAMES[1]: 0.123456789,
51 | PP_FIELDNAMES[2]: "currency",
52 | PP_FIELDNAMES[3]: "category",
53 | PP_FIELDNAMES[4]: "Laiamäe Pärnaõie Užutekio",
54 | }
55 | self.pp_writer.update_output(test_entry)
56 | self.assertEqual(
57 | 'Datum,Wert,Buchungswährung,Typ,Notiz\r\ndate,"0,12345679",currency,category,Laiamäe Pärnaõie Užutekio',
58 | self.pp_writer.out_string_stream.getvalue().strip(),
59 | )
60 |
61 | def test_update_output_umlaut_en_us(self):
62 | """test update_output with umlauts"""
63 | locale.setlocale(locale.LC_ALL, "en_US.utf-8")
64 | test_entry = {
65 | PP_FIELDNAMES[0]: "date",
66 | PP_FIELDNAMES[1]: 0.123456789,
67 | PP_FIELDNAMES[2]: "currency",
68 | PP_FIELDNAMES[3]: "category",
69 | PP_FIELDNAMES[4]: "Laiamäe Pärnaõie Užutekio",
70 | }
71 | self.pp_writer.update_output(test_entry)
72 | self.assertEqual(
73 | "Datum,Wert,Buchungswährung,Typ,Notiz\r\ndate,0.12345679,currency,category,Laiamäe Pärnaõie Užutekio",
74 | self.pp_writer.out_string_stream.getvalue().strip(),
75 | )
76 |
77 | def test_write_pp_csv_file(self):
78 | """test write_pp_csv_file"""
79 | with tempfile.TemporaryDirectory() as tmpdirname:
80 | fname = os.path.join(tmpdirname, "output")
81 | self.pp_writer.write_pp_csv_file(fname)
82 | with codecs.open(fname, "r", encoding="utf-8") as testfile:
83 | self.assertEqual(",".join(PP_FIELDNAMES), testfile.read().strip())
84 |
--------------------------------------------------------------------------------
/src/p2p_config.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Module for holding the configuration of a platform.
4 |
5 | Copyright 2018-04-29 ChrisRBe
6 | """
7 | import logging
8 | import re
9 |
10 |
11 | logger = logging.getLogger(__name__)
12 |
13 |
14 | class Config:
15 | """
16 | Implementation of the configuration
17 | """
18 |
19 | def __init__(self, config):
20 | """
21 | Constructor for Config
22 | """
23 | logger.info("Setup config for statement parser. Run with --debug to see config values")
24 | logger.debug("Config settings: %s", config)
25 | self._relevant_invest_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "deposit"])
26 | self._relevant_payment_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "withdraw"])
27 | self._relevant_income_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "interest"])
28 |
29 | self._relevant_fee_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "fee"])
30 | self._ignorable_entry_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "ignorable_entry"])
31 | self._special_entry_regex = Config.__get_compiled_regex_or_none(config, ["type_regex", "special_entry"])
32 |
33 | self._booking_date = config["csv_fieldnames"]["booking_date"]
34 | self._booking_date_format = config["csv_fieldnames"]["booking_date_format"]
35 | self._booking_details = config["csv_fieldnames"]["booking_details"]
36 | self._booking_id = config["csv_fieldnames"]["booking_id"]
37 | self._booking_type = config["csv_fieldnames"]["booking_type"]
38 | self._booking_value = config["csv_fieldnames"]["booking_value"]
39 | if "booking_currency" in config["csv_fieldnames"]:
40 | self._booking_currency = config["csv_fieldnames"]["booking_currency"]
41 | else:
42 | self._booking_currency = ""
43 | logger.info("Config done.")
44 |
45 | def get_relevant_invest_regex(self):
46 | """get the relevant_invest_regex"""
47 | return self._relevant_invest_regex
48 |
49 | def get_relevant_payment_regex(self):
50 | """get the relevant_payment_regex"""
51 | return self._relevant_payment_regex
52 |
53 | def get_relevant_income_regex(self):
54 | """get the relevant_income_regex"""
55 | return self._relevant_income_regex
56 |
57 | def get_relevant_fee_regex(self):
58 | """get the relevant_fee_regex"""
59 | return self._relevant_fee_regex
60 |
61 | def get_ignorable_entry_regex(self):
62 | """get the ignorable_entry regex"""
63 | return self._ignorable_entry_regex
64 |
65 | def get_special_entry_regex(self):
66 | """get the special_entry regex"""
67 | return self._special_entry_regex
68 |
69 | def get_booking_date(self):
70 | """get the booking_date"""
71 | return self._booking_date
72 |
73 | def get_booking_date_format(self):
74 | """get the booking_date_format"""
75 | return self._booking_date_format
76 |
77 | def get_booking_details(self):
78 | """get the booking_details"""
79 | return self._booking_details
80 |
81 | def get_booking_id(self):
82 | """get the booking_id"""
83 | return self._booking_id
84 |
85 | def get_booking_type(self):
86 | """get the booking_type"""
87 | return self._booking_type
88 |
89 | def get_booking_value(self):
90 | """get the booking_value"""
91 | return self._booking_value
92 |
93 | def get_booking_currency(self):
94 | """get the booking_currency"""
95 | return self._booking_currency
96 |
97 | @staticmethod
98 | def __get_element_or_none(obj, path):
99 | for item in path:
100 | if item in obj:
101 | obj = obj[item]
102 | else:
103 | return None
104 | return obj
105 |
106 | @staticmethod
107 | def __get_compiled_regex_or_none(obj, path):
108 | regex_string = Config.__get_element_or_none(obj, path)
109 | if regex_string:
110 | return re.compile(regex_string)
111 | return None
112 |
--------------------------------------------------------------------------------
/parse-account-statements.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | An application to read account statement files from different peer to peer lending sites, e.g. Mintos.com and creates
5 | a Portfolio Performance readable csv file.
6 |
7 | NOTE: The output only contains interest and interest like payments received. No other statements are currently parsed.
8 |
9 | List of currently supported providers:
10 | - Bondora
11 | - Bondora Grow Go
12 | - Estateguru
13 | - Mintos
14 | - Robocash
15 | - Swaper
16 | - Debitum Network
17 | - Viainvest
18 |
19 | Control the way how account statements are processed via the aggregate parameter:
20 | - transaction: Currently does not process the input data beyond making it Portfolio Performance compatible.
21 | - daily: This aggregates all bookings of the same type into one statement per type and day.
22 | - monthly: This aggregates all bookings of the same type into one statement per type and month. Sets
23 | the last day of the month as transaction date.
24 |
25 | Default behaviour for now is 'transaction'.
26 |
27 | Copyright 2018-03-17 ChrisRBe
28 | """
29 | import argparse
30 | import logging
31 | import os
32 | import sys
33 |
34 | from src import p2p_statement_parser
35 | from src import portfolio_writer
36 |
37 |
38 | root_logger = logging.getLogger()
39 | logger = logging.getLogger("parse-account-statements")
40 |
41 |
42 | def setup_logging(loglevel=logging.INFO):
43 | """
44 | Configure the logging module for this app.
45 | """
46 | log_format = "%(asctime)s %(name)-30s %(levelname)-8s %(message)s"
47 | root_logger.setLevel(loglevel)
48 |
49 | stdout_hdlr = logging.StreamHandler(stream=sys.stdout)
50 | stdout_hdlr.setFormatter(logging.Formatter(log_format))
51 | stdout_hdlr.setLevel(loglevel)
52 | root_logger.addHandler(stdout_hdlr)
53 |
54 |
55 | def parse_args():
56 | """
57 | Parse command line arguments
58 |
59 | :return: list of parsed command line arguments
60 | """
61 | arg_parser = argparse.ArgumentParser(
62 | usage=__doc__,
63 | )
64 | arg_parser.add_argument(
65 | "infile",
66 | type=str,
67 | help="CSV file containing the downloaded data from the P2P site",
68 | )
69 | arg_parser.add_argument(
70 | "--aggregate",
71 | type=str,
72 | help="specify how account statements should be summarized",
73 | choices=["transaction", "daily", "monthly"],
74 | default="transaction",
75 | )
76 | arg_parser.add_argument(
77 | "--type",
78 | type=str,
79 | help="Specifies the p2p lending operator",
80 | choices=[
81 | "bondora_go_grow",
82 | "bondora",
83 | "debitumnetwork",
84 | "estateguru",
85 | "mintos",
86 | "robocash",
87 | "swaper",
88 | "lande",
89 | "viainvest",
90 | "estateguru_en",
91 | ],
92 | default="mintos",
93 | )
94 | arg_parser.add_argument(
95 | "--debug",
96 | action="store_const",
97 | dest="loglevel",
98 | const=logging.DEBUG,
99 | default=logging.INFO,
100 | help="enables debug level logging if set",
101 | )
102 |
103 | return arg_parser.parse_args()
104 |
105 |
106 | def platform_factory(infile, operator_name="mintos"):
107 | """
108 | Return an object for the required Peer-to-Peer lending platform
109 |
110 | :param operator_name: name of the P2P lending site, defaults to Mintos
111 |
112 | :return: object for the actual lending platform parser, None if not supported
113 | """
114 | logger.info("Loading config for %s", operator_name)
115 | config = os.path.join(os.path.dirname(__file__), "config", f"{operator_name}.yml")
116 | if os.path.exists(config):
117 | platform_parser = p2p_statement_parser.PeerToPeerPlatformParser(config, infile)
118 | return platform_parser
119 | else:
120 | logging.error("The provided platform %s is currently not supported", operator_name)
121 | return None
122 |
123 |
124 | def main():
125 | """
126 | Processes the provided input file with the rules defined for the given platform.
127 | Outputs a CSV file readable by Portfolio Performance
128 |
129 | :return: True, False if an error occurred.
130 | """
131 | options = parse_args()
132 |
133 | setup_logging(loglevel=options.loglevel)
134 |
135 | infile = options.infile
136 | p2p_operator_name = options.type
137 | aggregate = options.aggregate
138 |
139 | logger.info("Parsing peer to peer lending site account statements with the following options:")
140 | logger.info("Account statement file: %s", infile)
141 | logger.info("Peer to peer platform: %s", p2p_operator_name.upper())
142 | logger.info("Aggregation type: %s", aggregate.upper())
143 |
144 | if not os.path.exists(infile):
145 | logger.error("provided file %s does not exist", infile)
146 | return False
147 |
148 | platform_parser = platform_factory(infile, p2p_operator_name)
149 | if not platform_parser:
150 | return False
151 |
152 | statement_list = platform_parser.parse_account_statement(aggregate=aggregate)
153 |
154 | if not statement_list:
155 | logger.warning(
156 | "No statements were found in the input file. Re-run with --debug to check for any unexpected statements"
157 | )
158 | return False
159 |
160 | logger.info("Account statement parsing finished. Found (and aggregated) %s transactions", len(statement_list))
161 | logger.info("Writing Portfolio Performance compatible CSV file.")
162 |
163 | writer = portfolio_writer.PortfolioPerformanceWriter()
164 | writer.init_output()
165 | for entry in statement_list:
166 | writer.update_output(entry)
167 | writer.write_pp_csv_file(
168 | os.path.join(
169 | os.path.dirname(infile),
170 | f"portfolio_performance__{p2p_operator_name}.csv",
171 | )
172 | )
173 | return True
174 |
175 |
176 | if __name__ == "__main__":
177 | sys.exit(main())
178 |
--------------------------------------------------------------------------------
/src/statement.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Module for holding a platform account statement.
4 |
5 | Copyright 2018-10-16 ChrisRBe
6 | """
7 | import logging
8 | from datetime import datetime
9 |
10 |
11 | logger = logging.getLogger(__name__)
12 |
13 |
14 | class Statement:
15 | """
16 | Implementation of the statement
17 | """
18 |
19 | def __init__(self, config, statement):
20 | """
21 | Constructor for Statement
22 | """
23 | self._config = config
24 | self._statement = statement
25 |
26 | def get_category(self):
27 | """
28 | Check the category of the given statement.
29 |
30 | :return: category of the statement; if ignored on purpose return 'Ignored', if unknown return the empty string
31 | """
32 | booking_type = self._statement[self._config.get_booking_type()]
33 | value = self.get_value()
34 |
35 | regex_to_category_mappings = [
36 | {"regex": self._config.get_relevant_income_regex(), "category": "Zinsen"},
37 | {"regex": self._config.get_relevant_invest_regex(), "category": "Einlage"},
38 | {"regex": self._config.get_relevant_payment_regex(), "category": "Entnahme"},
39 | {"regex": self._config.get_relevant_fee_regex(), "category": "Gebühren"},
40 | {"regex": self._config.get_special_entry_regex(), "category": "Undecided"},
41 | {"regex": self._config.get_ignorable_entry_regex(), "category": "Ignored"},
42 | ]
43 |
44 | category = ""
45 | for mapping in regex_to_category_mappings:
46 | category = self.__match_category(mapping, booking_type, value)
47 | if category:
48 | break
49 |
50 | if not category:
51 | logger.debug("Unexpected statement: %s", self._statement)
52 |
53 | return category
54 |
55 | def get_date(self):
56 | """
57 | get the date of the statement
58 |
59 | :return: statement date as datetime object
60 | """
61 | if self._statement[self._config.get_booking_date()]:
62 | statement_date = datetime.strptime(
63 | self._statement[self._config.get_booking_date()], self._config.get_booking_date_format()
64 | ).date()
65 | else:
66 | statement_date = datetime(1970, 1, 1).date()
67 | return statement_date
68 |
69 | def get_value(self):
70 | """
71 | get the value of the statement
72 |
73 | :return: value of the current statement as float.
74 | """
75 | raw_value = self._statement[self._config.get_booking_value()]
76 | return Statement._parse_value(raw_value)
77 |
78 | def get_note(self):
79 | """
80 | get the note of the statement
81 |
82 | :return: any note added in the original csv.
83 | """
84 | return "{id}: {details}".format(
85 | id=self._statement[self._config.get_booking_id()],
86 | details=self._statement[self._config.get_booking_details()],
87 | )
88 |
89 | def get_currency(self):
90 | """
91 | Check the currency of the given statement.
92 |
93 | :return: currency of the statement; if unknown return 'EUR'
94 | """
95 | if self._config.get_booking_currency():
96 | return self._statement[self._config.get_booking_currency()]
97 | else:
98 | return "EUR"
99 |
100 | @staticmethod
101 | def _parse_value(value):
102 | """
103 | Parse statement value from string to float.
104 | Includes handling of commas and dots for decimal separators and
105 | digit grouping, such as 1.000,00 and 1,000.00.
106 |
107 | :param value: the statement value as string
108 |
109 | :return: parsed value of the statement as float.
110 | """
111 | if not value:
112 | return None
113 |
114 | value = value.strip("€")
115 |
116 | dot_pos = value.find(".")
117 | comma_pos = value.find(",")
118 |
119 | if dot_pos == -1 or comma_pos == -1:
120 | # Did not find both comma and dot, just replace comma with dot
121 | value = value.replace(",", ".")
122 | return float(value)
123 |
124 | # Check position of . and , to replace them in the right order
125 | if dot_pos < comma_pos:
126 | # dot is used for digit grouping, comma for decimal
127 | value = value.replace(".", "")
128 | value = value.replace(",", ".")
129 | return float(value)
130 | else:
131 | # comma is used for digit grouping, dot for decimal
132 | value = value.replace(",", "")
133 | return float(value)
134 |
135 | @staticmethod
136 | def __match_category(mapping, booking_type, value):
137 | """
138 | takes a dict of format {"regex": "compiled regex", "category": "category"} and returns the correct mapping for
139 | the category.
140 |
141 | :param mapping: dict of type {"regex": "compiled regex", "category": "category"}
142 | :param booking_type: string containing the relevant loan information to determine category of entry.
143 | :param value: value of the transaction, only required to handle special cases for mintos premium discount
144 |
145 | :return: category
146 | """
147 | category = ""
148 | if mapping["regex"] and mapping["regex"].match(booking_type):
149 | category = mapping["category"]
150 | if category == "Undecided":
151 | category = Statement.__handle_special_case_mintos_discount_premium(value)
152 | return category
153 |
154 | @staticmethod
155 | def __handle_special_case_mintos_discount_premium(value):
156 | """
157 | This is currently a special case for the Mintos "discount/premium" secondary market transactions parsing,
158 | where an entry might be a fee or an income depending on its sign.
159 |
160 | :param value: how much money was returned/paid
161 |
162 | :return: Zinsen if value >= 0 Gebühren in any other case
163 | """
164 |
165 | if value >= 0:
166 | return "Zinsen"
167 | else:
168 | return "Gebühren"
169 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
PP-P2P-Parser
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ## Introduction
13 |
14 | Application to read account statement files from different peer to peer lending sites,
15 | e.g. mintos.com, and produces a Portfolio Performance readable csv file.
16 |
17 | Input format needs to be a csv file as well!
18 |
19 | ## Usage
20 |
21 | ```text
22 | parse-account-statements.py --help
23 | usage:
24 | An application to read account statement files from different peer to peer lending sites, e.g. Mintos.com and creates
25 | a Portfolio Performance readable csv file.
26 |
27 | NOTE: The output only contains interest and interest like payments received. No other statements are currently parsed.
28 |
29 | List of currently supported providers:
30 | - Bondora
31 | - Bondora Grow Go
32 | - Estateguru
33 | - Lande
34 | - Mintos
35 | - Robocash
36 | - Swaper
37 | - Debitum Network
38 | - Viainvest
39 |
40 | Control the way how account statements are processed via the aggregate parameter:
41 | - transaction: Currently does not process the input data beyond making it Portfolio Performance compatible.
42 | - daily: This aggregates all bookings of the same type into one statement per type and day.
43 | - monthly: This aggregates all bookings of the same type into one statement per type and month. Sets
44 | the last day of the month as transaction date.
45 |
46 | Default behaviour for now is 'transaction'.
47 |
48 | Copyright 2018-03-17 ChrisRBe
49 |
50 | positional arguments:
51 | infile CSV file containing the downloaded data from the P2P site
52 |
53 | optional arguments:
54 | -h, --help show this help message and exit
55 | --aggregate {transaction,daily,monthly}
56 | specify how account statements should be summarized
57 | --type TYPE Specifies the p2p lending operator
58 | --debug enables debug level logging if set
59 | ```
60 |
61 | ### Example
62 |
63 | ```shell
64 | ./parse-account-statements.py --type mintos src/test/testdata/mintos.csv
65 | ```
66 |
67 | ## ⚠ Information
68 |
69 | ⚠ If you are using the --aggregate=monthly option, please note that this aggregates account activities
70 | always on then last day of the month. This can lead to import issues in Portfolio Performance when importing
71 | data for the current month.
72 |
73 | E.g. import date is the 15th of a July, the account statement contains data with a date of 31st of July.
74 |
75 | Account activity for a "future date" will be ignored/ not imported by Portfolio Performance.
76 |
77 | Please note, that this behaviour on application side is intentional to avoid importing account activity
78 | multiple times in Portfolio Performance.
79 |
80 | ## Currently supported formats
81 |
82 | * `mintos` - Supports current account-statement.csv file format
83 | * `estateguru` - Supports current German layout account statement csv file format
84 | * `estateguru_en` - Adaptation for the English account statement csv file format
85 | * `robocash` - Supports current account statement format (as of 2018-05-01) exported to csv
86 | * `swaper` - Supports current account statement format (as of 2018-05-01) exported to csv
87 | * `bondora` - Supports current account statement format (as of 2019-10-12); exported to csv
88 | * `bondora_go_grow` - Supports current account statement format (as of 2019-10-12); exported to csv
89 | * `debitumnetwork` - Supports current account statement format (as of 2020-09-08) exported to csv
90 | * `viainvest` - Supports current account statement (as of 2021-12-12) exported as csv (Withdrawals do not work yet)
91 | * `lande` - Supports current account statement (as of 2022-12-01) exported as csv (Withdrawals not tested yet)
92 |
93 | ### Alternative solution for Auxmoney
94 |
95 | Unfortunately, the output file of Auxmoney's reports is not suitable for being parsed by PP-P2P-Parser in a meaningful way.
96 | As an alternative, you can check out the [PP-Auxmoney-Parser](https://github.com/StegSchreck/PP-Auxmoney-Parser) project.
97 |
98 | ## Configuration files
99 |
100 | Configuration for this script is stored in yaml files located under the config subdirectory.
101 | The content directly reflects the format of the source account statement files.
102 |
103 | Example:
104 |
105 | ```yaml
106 | ---
107 | type_regex: !!map
108 | deposit: "(Deposits)|(^Incoming client.*)|(^Incoming currency exchange.*)|(^Affiliate partner bonus$)"
109 | withdraw: "(^Withdraw application.*)|(Outgoing currency.*)|(Withdrawal)"
110 | interest: "(^Delayed interest.*)|(^Late payment.*)|(^Interest income.*)|(^Cashback.*)|(^.*[Ii]nterest received.*)|(^.*late fees received$)"
111 | fee: "(^FX commission.*)|(.*secondary market fee$)"
112 | ignorable_entry: ".*investment in loan.*|.*[Pp]rincipal received.*|.*secondary market transaction.*"
113 | special_entry: "(.*discount/premium.*)"
114 |
115 | csv_fieldnames:
116 | booking_date: 'Date'
117 | booking_date_format: '%Y-%m-%d %H:%M:%S'
118 | booking_details: 'Details'
119 | booking_id: 'Transaction ID'
120 | booking_type: 'Details'
121 | booking_value: 'Turnover'
122 |
123 | ```
124 |
125 | ## Output
126 |
127 | CSV file format compatible with Performance Portfolio (German language setting).
128 |
129 | ## Dependencies
130 |
131 | To use this application the following dependencies need to be installed:
132 |
133 | * Python 3.8+ (unit tests are run against Python 3.8, 3.9, 3.10, 3.11)
134 | * virtualenv
135 | * pipenv
136 |
137 | Installation of Python dependencies can be handled in two ways:
138 |
139 | * Install dependencies via `pip install -r requirements.txt`
140 | * Create a virtual environment using pipenv (**preferred way**)
141 |
142 | ```shell
143 | pipenv install
144 | pipenv shell
145 | ```
146 |
147 | ## Development
148 |
149 | To set up a local development environment for this project please use either
150 | of these two options:
151 |
152 | * Using plain pip
153 |
154 | ```shell
155 | pip install -r dev-requirements.txt
156 | ```
157 |
158 | * Using pipenv
159 |
160 | ```shell
161 | pipenv install --dev
162 | pipenv shell
163 | ```
164 |
165 | ## Legal
166 |
167 | I'm not a lawyer. This project is in no way affiliated with
168 | [Portfolio Performance](http://www.portfolio-performance.info/portfolio/),
169 | but intended to be used with it.
170 |
--------------------------------------------------------------------------------
/src/p2p_statement_parser.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Module for a generic peer to peer loan account statement parser.
4 |
5 | Copyright 2018-04-29 ChrisRBe
6 | """
7 | import calendar
8 | import codecs
9 | import csv
10 | import logging
11 |
12 | from yaml import safe_load
13 |
14 | from src.p2p_config import Config
15 | from src.portfolio_writer import PP_FIELDNAMES
16 | from src.statement import Statement
17 |
18 |
19 | logger = logging.getLogger(__name__)
20 |
21 |
22 | class PeerToPeerPlatformParser(object):
23 | """
24 | Implementation of a generic p2p investment platform account statement parser.
25 | Actual configuration for the individual services is done via a yml config file.
26 | """
27 |
28 | def __init__(self, config, infile):
29 | """
30 | Constructor for PeerToPeerPlatformParser
31 | """
32 | self._account_statement_file = infile
33 | self._config_file = config
34 |
35 | self.config = None
36 | self.output_list = []
37 | self.aggregation_data = {}
38 |
39 | @property
40 | def account_statement_file(self):
41 | """account statement file property"""
42 | return self._account_statement_file
43 |
44 | @account_statement_file.setter
45 | def account_statement_file(self, value):
46 | """account statement file property setter"""
47 | self._account_statement_file = value
48 |
49 | @property
50 | def config_file(self):
51 | """config file property"""
52 | return self._config_file
53 |
54 | @config_file.setter
55 | def config_file(self, value):
56 | """config file property setter"""
57 | self._config_file = value
58 |
59 | def __aggregate_statements(self, formatted_account_entry, comment, monthly=True):
60 | entry_date = formatted_account_entry[PP_FIELDNAMES[0]]
61 | if monthly:
62 | last_day = calendar.monthrange(entry_date.year, entry_date.month)[1]
63 | entry_date = entry_date.replace(day=last_day)
64 |
65 | entry_type = formatted_account_entry[PP_FIELDNAMES[3]]
66 | entry_value = formatted_account_entry[PP_FIELDNAMES[1]]
67 | entry_currency = formatted_account_entry[PP_FIELDNAMES[2]]
68 |
69 | logger.debug("entry type is %s. new entry date is %s. value of entry: %s", entry_type, entry_date, entry_value)
70 | if entry_date not in self.aggregation_data:
71 | self.aggregation_data[entry_date] = {}
72 | if entry_type in self.aggregation_data[entry_date]:
73 | logger.debug("add to existing entry")
74 | self.aggregation_data[entry_date][entry_type][PP_FIELDNAMES[1]] += entry_value
75 | else:
76 | self.aggregation_data[entry_date][entry_type] = {
77 | PP_FIELDNAMES[0]: entry_date,
78 | PP_FIELDNAMES[1]: entry_value,
79 | PP_FIELDNAMES[2]: entry_currency,
80 | PP_FIELDNAMES[3]: entry_type,
81 | PP_FIELDNAMES[4]: comment,
82 | }
83 |
84 | def __aggregate_statements_daily(self, formatted_account_entry):
85 | self.__aggregate_statements(formatted_account_entry, "Tageszusammenfassung", False)
86 |
87 | def __aggregate_statements_monthly(self, formatted_account_entry):
88 | self.__aggregate_statements(formatted_account_entry, "Monatszusammenfassung", True)
89 |
90 | def __format_statement(self, statement):
91 | """
92 | Formats a given statement into a dictionary containing the relevant data for Portfolio Performance.
93 |
94 | :param statement: contains a line from the given CSV file
95 |
96 | :return: dictionary containing the formatted account entry
97 | """
98 | statement = Statement(self.config, statement)
99 | category = statement.get_category()
100 |
101 | if not category or category == "Ignored":
102 | return
103 |
104 | formatted_account_entry = {
105 | PP_FIELDNAMES[0]: statement.get_date(),
106 | PP_FIELDNAMES[1]: round(statement.get_value(), 9),
107 | PP_FIELDNAMES[2]: statement.get_currency(),
108 | PP_FIELDNAMES[3]: category,
109 | PP_FIELDNAMES[4]: statement.get_note(),
110 | }
111 | return formatted_account_entry
112 |
113 | def __migrate_data_to_output(self):
114 | """
115 | Iterates over the data collected for the aggregation of account statement data and adds it to the output list.
116 | :return:
117 | """
118 | for _, booking_type in self.aggregation_data.items():
119 | for _, entry in booking_type.items():
120 | entry[PP_FIELDNAMES[1]] = round(entry[PP_FIELDNAMES[1]], 9)
121 | self.output_list.append(entry)
122 |
123 | def __parse_service_config(self):
124 | """
125 | Parse the YAML configuration file containing specific settings for the individual p2p loan platform
126 | """
127 | with open(self.config_file, "r", encoding="utf-8") as ymlconfig:
128 | config = safe_load(ymlconfig)
129 | self.config = Config(config)
130 |
131 | def __process_statement(self, statement, aggregate="transaction"):
132 | """
133 | Processes each statement read from the account statement file. First, format in into the dictionary.
134 | Then check what aggregation should be applied.
135 |
136 | - transaction: add directly to the output list.
137 | - daily: add it to intermediate aggregation collection.
138 | - monthly: add it to intermediate aggregation collection.
139 |
140 | :param statement: Contains one line from the account statement file
141 | :param aggregate: specify the aggregation format; e.g. daily or monthly. Defaults to transaction.
142 |
143 | :return:
144 | """
145 | formatted_account_entry = self.__format_statement(statement)
146 | if formatted_account_entry:
147 | if aggregate == "transaction":
148 | self.output_list.append(formatted_account_entry)
149 | elif aggregate == "daily":
150 | self.__aggregate_statements_daily(formatted_account_entry)
151 | elif aggregate == "monthly":
152 | self.__aggregate_statements_monthly(formatted_account_entry)
153 |
154 | def parse_account_statement(self, aggregate="transaction"):
155 | """
156 | read a platform account statement csv file and filter the content according to the given configuration file.
157 | If aggregation is selected the output data will be post processed in the following way:
158 |
159 | - aggregate="transaction": return the list of processed statements as is.
160 | - aggregate="daily": return a list of post-processed statements aggregating on daily basis for each
161 | booking type.
162 | - aggregate="monthly": return a list of post-processed statements aggregating on monthly basis for each
163 | booking type.
164 |
165 | :param aggregate: specifies the aggregation period. defaults to daily.
166 | :return: list of account statement entries ready for use in Portfolio Performance
167 | """
168 | if aggregate == "transaction" or aggregate == "daily" or aggregate == "monthly":
169 | logger.info("Aggregating data on a {} basis".format(aggregate))
170 | else:
171 | logger.error("Aggregating data on a {} basis not supported.".format(aggregate))
172 | return
173 |
174 | self.__parse_service_config()
175 |
176 | logger.info("Loading account statement")
177 | with codecs.open(self._account_statement_file, "r", encoding="utf-8-sig") as infile:
178 | dialect = csv.Sniffer().sniff(infile.readline())
179 | infile.seek(0)
180 | account_statement = csv.DictReader(infile, dialect=dialect)
181 |
182 | for statement in account_statement:
183 | self.__process_statement(aggregate=aggregate, statement=statement)
184 |
185 | if aggregate == "daily" or aggregate == "monthly":
186 | self.__migrate_data_to_output()
187 | return self.output_list
188 |
--------------------------------------------------------------------------------
/src/test/test_p2p_statement_parser.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Unit test for the p2p account statement parser module
4 |
5 | Copyright 2018-05-01 ChrisRBe
6 | """
7 | import datetime
8 | import os
9 | import unittest
10 |
11 | from src.p2p_statement_parser import PeerToPeerPlatformParser
12 |
13 |
14 | class TestBaseParser(unittest.TestCase):
15 | """Test case implementation for PeerToPeerPlatformParser"""
16 |
17 | def setUp(self):
18 | """test case setUp, run for each test case"""
19 | self.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "mintos.csv")
20 | self.config_file = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml")
21 | self.base_parser = PeerToPeerPlatformParser(infile=self.account_statement_file, config=self.config_file)
22 | self.maxDiff = None
23 |
24 | def test_account_statement_file(self):
25 | """test account statement file property"""
26 | self.assertEqual(
27 | os.path.join(os.path.dirname(__file__), "testdata", "mintos.csv"),
28 | self.base_parser.account_statement_file,
29 | )
30 |
31 | def test_config_file(self):
32 | """test config file property"""
33 | self.assertEqual(
34 | os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml"),
35 | self.base_parser.config_file,
36 | )
37 |
38 | def test_bondora_parsing(self):
39 | """test parse_account_statement for bondora"""
40 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "bondora.csv")
41 | self.base_parser.config_file = os.path.join(
42 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "bondora.yml"
43 | )
44 | expected_statement = [
45 | {
46 | "Buchungswährung": "EUR",
47 | "Datum": datetime.date(2019, 1, 1),
48 | "Notiz": ": TransferDeposit|DE1111000000111111",
49 | "Typ": "Einlage",
50 | "Wert": 100.0,
51 | },
52 | {
53 | "Buchungswährung": "EUR",
54 | "Datum": datetime.date(2019, 1, 2),
55 | "Notiz": ": TransferGoGrow",
56 | "Typ": "Entnahme",
57 | "Wert": -100.0,
58 | },
59 | {
60 | "Buchungswährung": "EUR",
61 | "Datum": datetime.date(2019, 1, 3),
62 | "Notiz": ": TransferDeposit|Wirecard",
63 | "Typ": "Einlage",
64 | "Wert": 100.0,
65 | },
66 | {
67 | "Buchungswährung": "EUR",
68 | "Datum": datetime.date(2019, 1, 4),
69 | "Notiz": "1111111-111111112: TransferInterestRepaiment",
70 | "Typ": "Zinsen",
71 | "Wert": 0.006792079,
72 | },
73 | {
74 | "Buchungswährung": "EUR",
75 | "Datum": datetime.date(2019, 1, 5),
76 | "Notiz": "1111111-111111113: TransferExtraInterestRepaiment",
77 | "Typ": "Zinsen",
78 | "Wert": 7.0588e-05,
79 | },
80 | ]
81 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
82 |
83 | def test_bondora_go_grow_parsing(self):
84 | """test parse_account_statement for bondora"""
85 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "bondora.csv")
86 | self.base_parser.config_file = os.path.join(
87 | os.path.dirname(__file__),
88 | os.pardir,
89 | os.pardir,
90 | "config",
91 | "bondora_go_grow.yml",
92 | )
93 | expected_statement = [
94 | {
95 | "Datum": datetime.date(2019, 1, 2),
96 | "Notiz": ": TransferGoGrow",
97 | "Typ": "Einlage",
98 | "Wert": -100.0,
99 | "Buchungswährung": "EUR",
100 | }
101 | ]
102 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
103 |
104 | def test_estateguru_parsing(self):
105 | """test parse_account_statement for estateguru"""
106 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "estateguru.csv")
107 | self.base_parser.config_file = os.path.join(
108 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "estateguru.yml"
109 | )
110 | expected_statement = [
111 | {
112 | "Buchungswährung": "EUR",
113 | "Datum": datetime.date(2018, 1, 18),
114 | "Notiz": "18012018204714DEP: ",
115 | "Typ": "Einlage",
116 | "Wert": 1000.0,
117 | },
118 | {
119 | "Buchungswährung": "EUR",
120 | "Datum": datetime.date(2018, 1, 23),
121 | "Notiz": "23012018092020DEP: ",
122 | "Typ": "Einlage",
123 | "Wert": 1000.0,
124 | },
125 | {
126 | "Buchungswährung": "EUR",
127 | "Datum": datetime.date(2018, 1, 24),
128 | "Notiz": "24012018000000REFEE5975: Kaerepere business loan 2. stage",
129 | "Typ": "Zinsen",
130 | "Wert": 0.25,
131 | },
132 | {
133 | "Buchungswährung": "EUR",
134 | "Datum": datetime.date(2018, 1, 24),
135 | "Notiz": "24012018000346WIT: ",
136 | "Typ": "Entnahme",
137 | "Wert": -1000.0,
138 | },
139 | {
140 | "Buchungswährung": "EUR",
141 | "Datum": datetime.date(2018, 1, 30),
142 | "Notiz": "30012018000000REFEE4182: Laiamäe bridge loan",
143 | "Typ": "Zinsen",
144 | "Wert": 0.5,
145 | },
146 | {
147 | "Buchungswährung": "EUR",
148 | "Datum": datetime.date(2018, 2, 24),
149 | "Notiz": "24022018000000INTEE5975: Kaerepere business loan 2. stage",
150 | "Typ": "Zinsen",
151 | "Wert": 0.46,
152 | },
153 | {
154 | "Buchungswährung": "EUR",
155 | "Datum": datetime.date(2018, 2, 27),
156 | "Notiz": "27022018225240DEP: ",
157 | "Typ": "Einlage",
158 | "Wert": 1000.0,
159 | },
160 | {
161 | "Buchungswährung": "EUR",
162 | "Datum": datetime.date(2018, 3, 1),
163 | "Notiz": "01032018000000BONLT2293: Grevitas construction loan",
164 | "Typ": "Zinsen",
165 | "Wert": 0.47,
166 | },
167 | {
168 | "Buchungswährung": "EUR",
169 | "Datum": datetime.date(2018, 3, 15),
170 | "Notiz": "15032018000000INTLT0689: Užutekio bridge loan",
171 | "Typ": "Zinsen",
172 | "Wert": 0.59,
173 | },
174 | {
175 | "Buchungswährung": "EUR",
176 | "Datum": datetime.date(2018, 4, 8),
177 | "Notiz": "08042018000000INTEE3186: Pärnaõie st bridge loan",
178 | "Typ": "Zinsen",
179 | "Wert": 0.46,
180 | },
181 | ]
182 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
183 |
184 | def test_mintos_parsing(self):
185 | """test parse_account_statement for mintos"""
186 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "mintos.csv")
187 | self.base_parser.config_file = os.path.join(
188 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml"
189 | )
190 | expected_statement = [
191 | {
192 | "Buchungswährung": "EUR",
193 | "Datum": datetime.date(2018, 1, 17),
194 | "Notiz": "236659674: Incoming client payment",
195 | "Typ": "Einlage",
196 | "Wert": 20.0,
197 | },
198 | {
199 | "Buchungswährung": "EUR",
200 | "Datum": datetime.date(2018, 1, 18),
201 | "Notiz": "237974500: Interest income Loan ID: 2049443-01",
202 | "Typ": "Zinsen",
203 | "Wert": 0.005555556,
204 | },
205 | {
206 | "Buchungswährung": "EUR",
207 | "Datum": datetime.date(2018, 1, 19),
208 | "Notiz": "238112163: Interest income on rebuy Rebuy purpose: "
209 | "agreement_amendment Loan ID: 2198495-01",
210 | "Typ": "Zinsen",
211 | "Wert": 0.003777778,
212 | },
213 | {
214 | "Buchungswährung": "EUR",
215 | "Datum": datetime.date(2018, 1, 19),
216 | "Notiz": "238112984: Interest income on rebuy Rebuy purpose: early_repayment " "Loan ID: 2202538-01",
217 | "Typ": "Zinsen",
218 | "Wert": 0.003083333,
219 | },
220 | {
221 | "Buchungswährung": "EUR",
222 | "Datum": datetime.date(2018, 1, 25),
223 | "Notiz": "241699935: Late payment fee income Loan ID: 1529173-01",
224 | "Typ": "Zinsen",
225 | "Wert": 0.001214211,
226 | },
227 | {
228 | "Buchungswährung": "EUR",
229 | "Datum": datetime.date(2018, 1, 29),
230 | "Notiz": "243559685: Delayed interest income on rebuy Rebuy purpose: "
231 | "agreement_amendment Loan ID: 2198503-01",
232 | "Typ": "Zinsen",
233 | "Wert": 0.000342077,
234 | },
235 | {
236 | "Buchungswährung": "EUR",
237 | "Datum": datetime.date(2018, 2, 27),
238 | "Notiz": "260918485: Cashback bonus",
239 | "Typ": "Zinsen",
240 | "Wert": 0.3,
241 | },
242 | {
243 | "Buchungswährung": "EUR",
244 | "Datum": datetime.date(2016, 9, 28),
245 | "Notiz": "115013710: Withdraw application",
246 | "Typ": "Entnahme",
247 | "Wert": -20.0,
248 | },
249 | {
250 | "Buchungswährung": "EUR",
251 | "Datum": datetime.date(2020, 4, 10),
252 | "Notiz": "178363724: Loan 28375000-01 - discount/premium for secondary market transaction 178363274.",
253 | "Typ": "Gebühren",
254 | "Wert": -0.145454545,
255 | },
256 | {
257 | "Buchungswährung": "EUR",
258 | "Datum": datetime.date(2020, 4, 10),
259 | "Notiz": "178363725: Loan 28375000-01 - discount/premium for secondary market transaction 178363275.",
260 | "Typ": "Zinsen",
261 | "Wert": 0.505454545,
262 | },
263 | {
264 | "Buchungswährung": "EUR",
265 | "Datum": datetime.date(1970, 1, 1),
266 | "Notiz": "127373922: Loan 35287609-01 - interest received (no date for testing)",
267 | "Typ": "Zinsen",
268 | "Wert": 0.5,
269 | },
270 | ]
271 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
272 |
273 | def test_mintos_parsing_daily_aggregation(self):
274 | """test parse_account_statement for mintos"""
275 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "mintos.csv")
276 | self.base_parser.config_file = os.path.join(
277 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml"
278 | )
279 | expected_statement = [
280 | {
281 | "Buchungswährung": "EUR",
282 | "Datum": datetime.date(2018, 1, 17),
283 | "Notiz": "Tageszusammenfassung",
284 | "Typ": "Einlage",
285 | "Wert": 20.0,
286 | },
287 | {
288 | "Buchungswährung": "EUR",
289 | "Datum": datetime.date(2018, 1, 18),
290 | "Notiz": "Tageszusammenfassung",
291 | "Typ": "Zinsen",
292 | "Wert": 0.005555556,
293 | },
294 | {
295 | "Buchungswährung": "EUR",
296 | "Datum": datetime.date(2018, 1, 19),
297 | "Notiz": "Tageszusammenfassung",
298 | "Typ": "Zinsen",
299 | "Wert": 0.006861111,
300 | },
301 | {
302 | "Buchungswährung": "EUR",
303 | "Datum": datetime.date(2018, 1, 25),
304 | "Notiz": "Tageszusammenfassung",
305 | "Typ": "Zinsen",
306 | "Wert": 0.001214211,
307 | },
308 | {
309 | "Buchungswährung": "EUR",
310 | "Datum": datetime.date(2018, 1, 29),
311 | "Notiz": "Tageszusammenfassung",
312 | "Typ": "Zinsen",
313 | "Wert": 0.000342077,
314 | },
315 | {
316 | "Buchungswährung": "EUR",
317 | "Datum": datetime.date(2018, 2, 27),
318 | "Notiz": "Tageszusammenfassung",
319 | "Typ": "Zinsen",
320 | "Wert": 0.3,
321 | },
322 | {
323 | "Buchungswährung": "EUR",
324 | "Datum": datetime.date(2016, 9, 28),
325 | "Notiz": "Tageszusammenfassung",
326 | "Typ": "Entnahme",
327 | "Wert": -20.0,
328 | },
329 | {
330 | "Buchungswährung": "EUR",
331 | "Datum": datetime.date(2020, 4, 10),
332 | "Notiz": "Tageszusammenfassung",
333 | "Typ": "Gebühren",
334 | "Wert": -0.145454545,
335 | },
336 | {
337 | "Buchungswährung": "EUR",
338 | "Datum": datetime.date(2020, 4, 10),
339 | "Notiz": "Tageszusammenfassung",
340 | "Typ": "Zinsen",
341 | "Wert": 0.505454545,
342 | },
343 | {
344 | "Buchungswährung": "EUR",
345 | "Datum": datetime.date(1970, 1, 1),
346 | "Notiz": "Tageszusammenfassung",
347 | "Typ": "Zinsen",
348 | "Wert": 0.5,
349 | },
350 | ]
351 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement(aggregate="daily"))
352 |
353 | def test_mintos_parsing_transaction_aggregation(self):
354 | """test parse_account_statement for mintos"""
355 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "mintos.csv")
356 | self.base_parser.config_file = os.path.join(
357 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml"
358 | )
359 | expected_statement = [
360 | {
361 | "Buchungswährung": "EUR",
362 | "Datum": datetime.date(2018, 1, 17),
363 | "Notiz": "236659674: Incoming client payment",
364 | "Typ": "Einlage",
365 | "Wert": 20.0,
366 | },
367 | {
368 | "Buchungswährung": "EUR",
369 | "Datum": datetime.date(2018, 1, 18),
370 | "Notiz": "237974500: Interest income Loan ID: 2049443-01",
371 | "Typ": "Zinsen",
372 | "Wert": 0.005555556,
373 | },
374 | {
375 | "Buchungswährung": "EUR",
376 | "Datum": datetime.date(2018, 1, 19),
377 | "Notiz": "238112163: Interest income on rebuy Rebuy purpose: "
378 | "agreement_amendment Loan ID: 2198495-01",
379 | "Typ": "Zinsen",
380 | "Wert": 0.003777778,
381 | },
382 | {
383 | "Buchungswährung": "EUR",
384 | "Datum": datetime.date(2018, 1, 19),
385 | "Notiz": "238112984: Interest income on rebuy Rebuy purpose: early_repayment " "Loan ID: 2202538-01",
386 | "Typ": "Zinsen",
387 | "Wert": 0.003083333,
388 | },
389 | {
390 | "Buchungswährung": "EUR",
391 | "Datum": datetime.date(2018, 1, 25),
392 | "Notiz": "241699935: Late payment fee income Loan ID: 1529173-01",
393 | "Typ": "Zinsen",
394 | "Wert": 0.001214211,
395 | },
396 | {
397 | "Buchungswährung": "EUR",
398 | "Datum": datetime.date(2018, 1, 29),
399 | "Notiz": "243559685: Delayed interest income on rebuy Rebuy purpose: "
400 | "agreement_amendment Loan ID: 2198503-01",
401 | "Typ": "Zinsen",
402 | "Wert": 0.000342077,
403 | },
404 | {
405 | "Buchungswährung": "EUR",
406 | "Datum": datetime.date(2018, 2, 27),
407 | "Notiz": "260918485: Cashback bonus",
408 | "Typ": "Zinsen",
409 | "Wert": 0.3,
410 | },
411 | {
412 | "Buchungswährung": "EUR",
413 | "Datum": datetime.date(2016, 9, 28),
414 | "Notiz": "115013710: Withdraw application",
415 | "Typ": "Entnahme",
416 | "Wert": -20.0,
417 | },
418 | {
419 | "Buchungswährung": "EUR",
420 | "Datum": datetime.date(2020, 4, 10),
421 | "Notiz": "178363724: Loan 28375000-01 - discount/premium for secondary market transaction 178363274.",
422 | "Typ": "Gebühren",
423 | "Wert": -0.145454545,
424 | },
425 | {
426 | "Buchungswährung": "EUR",
427 | "Datum": datetime.date(2020, 4, 10),
428 | "Notiz": "178363725: Loan 28375000-01 - discount/premium for secondary market transaction 178363275.",
429 | "Typ": "Zinsen",
430 | "Wert": 0.505454545,
431 | },
432 | {
433 | "Buchungswährung": "EUR",
434 | "Datum": datetime.date(1970, 1, 1),
435 | "Notiz": "127373922: Loan 35287609-01 - interest received (no date for testing)",
436 | "Typ": "Zinsen",
437 | "Wert": 0.5,
438 | },
439 | ]
440 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement(aggregate="transaction"))
441 |
442 | def test_mintos_parsing_monthly_aggregation(self):
443 | """test parse_account_statement for mintos"""
444 | self.base_parser.account_statement_file = os.path.join(
445 | os.path.dirname(__file__), "testdata", "mintos_several_months.csv"
446 | )
447 | self.base_parser.config_file = os.path.join(
448 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "mintos.yml"
449 | )
450 | expected_statement = [
451 | {
452 | "Buchungswährung": "EUR",
453 | "Datum": datetime.date(2018, 2, 28),
454 | "Notiz": "Monatszusammenfassung",
455 | "Typ": "Einlage",
456 | "Wert": 20.0,
457 | },
458 | {
459 | "Buchungswährung": "EUR",
460 | "Datum": datetime.date(2018, 2, 28),
461 | "Notiz": "Monatszusammenfassung",
462 | "Typ": "Zinsen",
463 | "Wert": 0.3,
464 | },
465 | {
466 | "Buchungswährung": "EUR",
467 | "Datum": datetime.date(2018, 1, 31),
468 | "Notiz": "Monatszusammenfassung",
469 | "Typ": "Einlage",
470 | "Wert": 20.0,
471 | },
472 | {
473 | "Buchungswährung": "EUR",
474 | "Datum": datetime.date(2018, 1, 31),
475 | "Notiz": "Monatszusammenfassung",
476 | "Typ": "Zinsen",
477 | "Wert": 0.013972955,
478 | },
479 | {
480 | "Buchungswährung": "EUR",
481 | "Datum": datetime.date(2016, 9, 30),
482 | "Notiz": "Monatszusammenfassung",
483 | "Typ": "Entnahme",
484 | "Wert": -20.0,
485 | },
486 | ]
487 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement(aggregate="monthly"))
488 |
489 | def test_viainvest_parsing_transaction_aggregation(self):
490 | """test parse_account_statement for viainvest"""
491 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "viainvest.csv")
492 | self.base_parser.config_file = os.path.join(
493 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "viainvest.yml"
494 | )
495 | expected_statement = [
496 | {
497 | "Buchungswährung": "EUR",
498 | "Datum": datetime.date(2020, 12, 13),
499 | "Notiz": ": ",
500 | "Typ": "Einlage",
501 | "Wert": 1000.0,
502 | },
503 | {
504 | "Buchungswährung": "EUR",
505 | "Datum": datetime.date(2020, 12, 14),
506 | "Notiz": "04-1246342: 04-1246342",
507 | "Typ": "Zinsen",
508 | "Wert": 0.10,
509 | },
510 | {
511 | "Buchungswährung": "EUR",
512 | "Datum": datetime.date(2020, 12, 14),
513 | "Notiz": "05-3233341: 05-3233341",
514 | "Typ": "Zinsen",
515 | "Wert": 0.09,
516 | },
517 | ]
518 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement(aggregate="transaction"))
519 |
520 | @unittest.skip("Currently not checking if infile exists.")
521 | def test_no_statement_file(self):
522 | """test parse_account_statement with non existent file"""
523 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "not_existing.csv")
524 | self.assertFalse(self.base_parser.parse_account_statement())
525 |
526 | def test_robocash_parsing(self):
527 | """test parse_account_statement for robocash"""
528 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "robocash.csv")
529 | self.base_parser.config_file = os.path.join(
530 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "robocash.yml"
531 | )
532 | expected_statement = [
533 | {
534 | "Buchungswährung": "EUR",
535 | "Datum": datetime.date(2018, 2, 15),
536 | "Notiz": "2438244: ",
537 | "Typ": "Einlage",
538 | "Wert": 2000.0,
539 | },
540 | {
541 | "Buchungswährung": "EUR",
542 | "Datum": datetime.date(2018, 2, 16),
543 | "Notiz": "2458795: 856836",
544 | "Typ": "Zinsen",
545 | "Wert": 0.003835616,
546 | },
547 | ]
548 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
549 |
550 | def test_swaper_parsing(self):
551 | """test parse_account_statement for swaper"""
552 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "swaper.csv")
553 | self.base_parser.config_file = os.path.join(
554 | os.path.dirname(__file__), os.pardir, os.pardir, "config", "swaper.yml"
555 | )
556 | expected_statement = [
557 | {
558 | "Buchungswährung": "EUR",
559 | "Datum": datetime.date(2018, 5, 1),
560 | "Notiz": "PL-84587: 119113",
561 | "Typ": "Zinsen",
562 | "Wert": 0.1,
563 | },
564 | {
565 | "Buchungswährung": "EUR",
566 | "Datum": datetime.date(2018, 4, 30),
567 | "Notiz": "PL-82794: 116800",
568 | "Typ": "Zinsen",
569 | "Wert": 0.12,
570 | },
571 | {
572 | "Buchungswährung": "EUR",
573 | "Datum": datetime.date(2018, 4, 26),
574 | "Notiz": "GL-22989301: 117251",
575 | "Typ": "Zinsen",
576 | "Wert": 0.11,
577 | },
578 | {
579 | "Buchungswährung": "EUR",
580 | "Datum": datetime.date(2018, 1, 24),
581 | "Notiz": ": ",
582 | "Typ": "Einlage",
583 | "Wert": 2000.0,
584 | },
585 | ]
586 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
587 |
588 | def test_debitumnetwork_parsing(self):
589 | """test parse_account_statement for debitum network"""
590 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "debitum.csv")
591 | self.base_parser.config_file = os.path.join(
592 | os.path.dirname(__file__),
593 | os.pardir,
594 | os.pardir,
595 | "config",
596 | "debitumnetwork.yml",
597 | )
598 | expected_statement = [
599 | {
600 | "Buchungswährung": "EUR",
601 | "Datum": datetime.date(2020, 8, 25),
602 | "Notiz": "405eea2a-7745-4588-8f08-5c1512987324: NA",
603 | "Typ": "Einlage",
604 | "Wert": 121.91,
605 | },
606 | {
607 | "Buchungswährung": "EUR",
608 | "Datum": datetime.date(2020, 9, 7),
609 | "Notiz": "b9da7662-de61-43d1-a179-c300d5695587: " "6c4a6d93-faea-4d96-856c-7cdd3fb3023b",
610 | "Typ": "Zinsen",
611 | "Wert": 10.03,
612 | },
613 | {
614 | "Buchungswährung": "EUR",
615 | "Datum": datetime.date(2020, 9, 7),
616 | "Notiz": "7260c567-fdb4-44d4-84ce-4256c7d7fb80: NA",
617 | "Typ": "Einlage",
618 | "Wert": 10.0,
619 | },
620 | ]
621 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
622 |
623 | def test_lande_parsing(self):
624 | """test parse_account_statement for lande.finance"""
625 | self.base_parser.account_statement_file = os.path.join(os.path.dirname(__file__), "testdata", "lande.csv")
626 | self.base_parser.config_file = os.path.join(
627 | os.path.dirname(__file__),
628 | os.pardir,
629 | os.pardir,
630 | "config",
631 | "lande.yml",
632 | )
633 | expected_statement = [
634 | {
635 | "Buchungswährung": "EUR",
636 | "Datum": datetime.date(2022, 11, 8),
637 | "Notiz": "97b1a146-1c3f-47e5-8ac3-10ade56765ec: ",
638 | "Typ": "Einlage",
639 | "Wert": 500.0,
640 | },
641 | {
642 | "Buchungswährung": "EUR",
643 | "Datum": datetime.date(2022, 11, 8),
644 | "Notiz": "97b20fa6-c6cd-4c08-8f4a-b25f120ec583: 221108-366978",
645 | "Typ": "Zinsen",
646 | "Wert": 0.5,
647 | },
648 | {
649 | "Buchungswährung": "EUR",
650 | "Datum": datetime.date(2022, 11, 11),
651 | "Notiz": "97b7d986-c414-427f-90a2-c05e98641900: 221109-297724",
652 | "Typ": "Zinsen",
653 | "Wert": 0.5,
654 | },
655 | {
656 | "Buchungswährung": "EUR",
657 | "Datum": datetime.date(2022, 11, 11),
658 | "Notiz": "97b8289e-fd86-4312-84de-f50631fb571f: 221108-142849",
659 | "Typ": "Zinsen",
660 | "Wert": 0.5,
661 | },
662 | {
663 | "Buchungswährung": "EUR",
664 | "Datum": datetime.date(2022, 11, 11),
665 | "Notiz": "97b833cf-9d9f-4ff2-a800-a2b1ebaea865: 221101-847953",
666 | "Typ": "Zinsen",
667 | "Wert": 0.5,
668 | },
669 | {
670 | "Buchungswährung": "EUR",
671 | "Datum": datetime.date(2022, 11, 14),
672 | "Notiz": "97be0c4f-a4d1-4e7d-aeff-f07e7c446d7e: 220929-309009",
673 | "Typ": "Zinsen",
674 | "Wert": 0.5,
675 | },
676 | {
677 | "Buchungswährung": "EUR",
678 | "Datum": datetime.date(2022, 11, 14),
679 | "Notiz": "97be0ca1-0c64-498f-9a47-bc2c7f1ca1ed: 220926-944705",
680 | "Typ": "Zinsen",
681 | "Wert": 0.5,
682 | },
683 | {
684 | "Buchungswährung": "EUR",
685 | "Datum": datetime.date(2022, 11, 14),
686 | "Notiz": "97be0cfb-3ceb-4bdc-9411-b25acae80a6e: 221011-882308",
687 | "Typ": "Zinsen",
688 | "Wert": 0.5,
689 | },
690 | {
691 | "Buchungswährung": "EUR",
692 | "Datum": datetime.date(2022, 11, 14),
693 | "Notiz": "97be0d40-9237-4683-a6d9-be836ba90580: 221012-476486",
694 | "Typ": "Zinsen",
695 | "Wert": 0.5,
696 | },
697 | {
698 | "Buchungswährung": "EUR",
699 | "Datum": datetime.date(2022, 11, 14),
700 | "Notiz": "97be0d93-81a0-428b-9ea3-23be8ff7cfca: 221101-842051",
701 | "Typ": "Zinsen",
702 | "Wert": 0.5,
703 | },
704 | {
705 | "Buchungswährung": "EUR",
706 | "Datum": datetime.date(2022, 11, 14),
707 | "Notiz": "97be48c7-c79d-4a35-a440-4048b74b17c8: 221114-968949",
708 | "Typ": "Zinsen",
709 | "Wert": 0.5,
710 | },
711 | {
712 | "Buchungswährung": "EUR",
713 | "Datum": datetime.date(2022, 12, 1),
714 | "Notiz": "97e065db-dcad-4a29-8738-5adbfc74fc49: 221011-882308",
715 | "Typ": "Zinsen",
716 | "Wert": 0.5,
717 | },
718 | ]
719 | self.assertEqual(expected_statement, self.base_parser.parse_account_statement())
720 |
721 | def test_aggregation_not_supported(self):
722 | """test if unsopported aggregation is correctly handled"""
723 | self.assertFalse(self.base_parser.parse_account_statement(aggregate="yearly"))
724 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------