ofxstatement-nordigen 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ofxstatement-nordigen might be problematic. Click here for more details.
- ofxstatement_nordigen-0.1/MANIFEST.in +1 -0
- ofxstatement_nordigen-0.1/PKG-INFO +84 -0
- ofxstatement_nordigen-0.1/README.rst +62 -0
- ofxstatement_nordigen-0.1/pyproject.toml +36 -0
- ofxstatement_nordigen-0.1/setup.cfg +4 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen/__init__.py +0 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen/plugin.py +61 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen/schemas.py +79 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/PKG-INFO +84 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/SOURCES.txt +14 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/dependency_links.txt +1 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/entry_points.txt +2 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/requires.txt +4 -0
- ofxstatement_nordigen-0.1/src/ofxstatement_nordigen.egg-info/top_level.txt +1 -0
- ofxstatement_nordigen-0.1/tests/test_sample.py +42 -0
- ofxstatement_nordigen-0.1/tests/test_schemas.py +49 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include README.rst
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ofxstatement-nordigen
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: ofxstatement plugin for Nordigen bank statements
|
|
5
|
+
Author-email: Jimmy Stammers <jimmy.stammers@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/jstammers/ofxstatement-nordigen/
|
|
7
|
+
Keywords: ofx,banking,statement,plugin,ofxstatement
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
12
|
+
Classifier: Topic :: Utilities
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
Requires-Dist: ofxstatement
|
|
19
|
+
Requires-Dist: pydantic
|
|
20
|
+
Requires-Dist: requests
|
|
21
|
+
Requires-Dist: requests-cache
|
|
22
|
+
|
|
23
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
24
|
+
ofxstatement-nordigen
|
|
25
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
26
|
+
|
|
27
|
+
A plugin for `ofxstatement`_ to parse transaction data from GoCardless (previously known as Nordigen).
|
|
28
|
+
|
|
29
|
+
`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format,
|
|
30
|
+
suitable for importing to GnuCash. Plugin for ofxstatement parses a
|
|
31
|
+
particular proprietary bank statement format and produces common data
|
|
32
|
+
structure, that is then formatted into an OFX file.
|
|
33
|
+
|
|
34
|
+
.. _ofxstatement: https://github.com/kedder/ofxstatement
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Installation
|
|
38
|
+
================
|
|
39
|
+
|
|
40
|
+
To install the plugin, you can use `pip`_:
|
|
41
|
+
|
|
42
|
+
.. _pip: https://pypi.org/project/pip/
|
|
43
|
+
|
|
44
|
+
.. code-block:: shell
|
|
45
|
+
|
|
46
|
+
pip install ofxstatement-nordigen
|
|
47
|
+
|
|
48
|
+
or, if you want to install it in editable mode (for development), use:
|
|
49
|
+
|
|
50
|
+
.. code-block:: shell
|
|
51
|
+
|
|
52
|
+
pip install -e ./
|
|
53
|
+
|
|
54
|
+
To verify that the plugin is installed correctly, you can run:
|
|
55
|
+
|
|
56
|
+
.. code-block:: shell
|
|
57
|
+
|
|
58
|
+
ofxstatement --list-plugins
|
|
59
|
+
|
|
60
|
+
This should list the `nordigen` plugin among other plugins.
|
|
61
|
+
|
|
62
|
+
Usage
|
|
63
|
+
================
|
|
64
|
+
|
|
65
|
+
To use the plugin, you can run the `ofxstatement` command with the `--plugin` option:
|
|
66
|
+
|
|
67
|
+
.. code-block:: shell
|
|
68
|
+
|
|
69
|
+
ofxstatement convert -t nordigen <input_file> <output_file>
|
|
70
|
+
|
|
71
|
+
Replace `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
|
|
72
|
+
|
|
73
|
+
The input file should be a JSON of transactions from GoCardless that has the schema defined `here`_.
|
|
74
|
+
|
|
75
|
+
.. _here: https://developer.gocardless.com/bank-account-data/transactions
|
|
76
|
+
|
|
77
|
+
The output file will be an OFX file that can be imported into GnuCash or other financial software.
|
|
78
|
+
|
|
79
|
+
After you are done
|
|
80
|
+
==================
|
|
81
|
+
|
|
82
|
+
After your plugin is ready, feel free to open an issue on `ofxstatement`_
|
|
83
|
+
project to include your plugin in "known plugin list". That would hopefully
|
|
84
|
+
make life of other clients of your bank easier.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
2
|
+
ofxstatement-nordigen
|
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
A plugin for `ofxstatement`_ to parse transaction data from GoCardless (previously known as Nordigen).
|
|
6
|
+
|
|
7
|
+
`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format,
|
|
8
|
+
suitable for importing to GnuCash. Plugin for ofxstatement parses a
|
|
9
|
+
particular proprietary bank statement format and produces common data
|
|
10
|
+
structure, that is then formatted into an OFX file.
|
|
11
|
+
|
|
12
|
+
.. _ofxstatement: https://github.com/kedder/ofxstatement
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Installation
|
|
16
|
+
================
|
|
17
|
+
|
|
18
|
+
To install the plugin, you can use `pip`_:
|
|
19
|
+
|
|
20
|
+
.. _pip: https://pypi.org/project/pip/
|
|
21
|
+
|
|
22
|
+
.. code-block:: shell
|
|
23
|
+
|
|
24
|
+
pip install ofxstatement-nordigen
|
|
25
|
+
|
|
26
|
+
or, if you want to install it in editable mode (for development), use:
|
|
27
|
+
|
|
28
|
+
.. code-block:: shell
|
|
29
|
+
|
|
30
|
+
pip install -e ./
|
|
31
|
+
|
|
32
|
+
To verify that the plugin is installed correctly, you can run:
|
|
33
|
+
|
|
34
|
+
.. code-block:: shell
|
|
35
|
+
|
|
36
|
+
ofxstatement --list-plugins
|
|
37
|
+
|
|
38
|
+
This should list the `nordigen` plugin among other plugins.
|
|
39
|
+
|
|
40
|
+
Usage
|
|
41
|
+
================
|
|
42
|
+
|
|
43
|
+
To use the plugin, you can run the `ofxstatement` command with the `--plugin` option:
|
|
44
|
+
|
|
45
|
+
.. code-block:: shell
|
|
46
|
+
|
|
47
|
+
ofxstatement convert -t nordigen <input_file> <output_file>
|
|
48
|
+
|
|
49
|
+
Replace `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
|
|
50
|
+
|
|
51
|
+
The input file should be a JSON of transactions from GoCardless that has the schema defined `here`_.
|
|
52
|
+
|
|
53
|
+
.. _here: https://developer.gocardless.com/bank-account-data/transactions
|
|
54
|
+
|
|
55
|
+
The output file will be an OFX file that can be imported into GnuCash or other financial software.
|
|
56
|
+
|
|
57
|
+
After you are done
|
|
58
|
+
==================
|
|
59
|
+
|
|
60
|
+
After your plugin is ready, feel free to open an issue on `ofxstatement`_
|
|
61
|
+
project to include your plugin in "known plugin list". That would hopefully
|
|
62
|
+
make life of other clients of your bank easier.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ofxstatement-nordigen"
|
|
7
|
+
version = "0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Jimmy Stammers", email="jimmy.stammers@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "ofxstatement plugin for Nordigen bank statements"
|
|
12
|
+
readme = "README.rst"
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Natural Language :: English",
|
|
18
|
+
"Topic :: Office/Business :: Financial :: Accounting",
|
|
19
|
+
"Topic :: Utilities",
|
|
20
|
+
"Environment :: Console",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
23
|
+
]
|
|
24
|
+
keywords = ["ofx", "banking", "statement", "plugin", "ofxstatement"]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"ofxstatement",
|
|
27
|
+
"pydantic",
|
|
28
|
+
"requests",
|
|
29
|
+
"requests-cache"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/jstammers/ofxstatement-nordigen/"
|
|
34
|
+
|
|
35
|
+
[project.entry-points."ofxstatement"]
|
|
36
|
+
nordigen = "ofxstatement_nordigen.plugin:NordigenPlugin"
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Iterable
|
|
3
|
+
|
|
4
|
+
from ofxstatement.plugin import Plugin
|
|
5
|
+
from ofxstatement.parser import StatementParser
|
|
6
|
+
from ofxstatement.statement import Statement, StatementLine
|
|
7
|
+
|
|
8
|
+
from ofxstatement_nordigen.schemas import NordigenTransactionModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class NordigenPlugin(Plugin):
|
|
12
|
+
"""Retrieves Nordigen transactions and converts them to OFX format."""
|
|
13
|
+
|
|
14
|
+
def get_parser(self, filename: str) -> "NordigenParser":
|
|
15
|
+
return NordigenParser(filename)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class NordigenParser(StatementParser[str]):
|
|
19
|
+
def __init__(self, filename: str) -> None:
|
|
20
|
+
super().__init__()
|
|
21
|
+
if not filename.endswith(".json"):
|
|
22
|
+
raise ValueError("Only JSON files are supported")
|
|
23
|
+
self.filename = filename
|
|
24
|
+
|
|
25
|
+
def parse(self) -> Statement:
|
|
26
|
+
"""Main entry point for parsers
|
|
27
|
+
|
|
28
|
+
super() implementation will call to split_records and parse_record to
|
|
29
|
+
process the file.
|
|
30
|
+
"""
|
|
31
|
+
with open(self.filename, "r"):
|
|
32
|
+
return super().parse()
|
|
33
|
+
|
|
34
|
+
def split_records(self) -> Iterable[str]:
|
|
35
|
+
"""Return iterable object consisting of a line per transaction"""
|
|
36
|
+
data = json.load(open(self.filename, "r"))
|
|
37
|
+
transactions = data.get("transactions", {})
|
|
38
|
+
booked_transactions = transactions.get("booked", [])
|
|
39
|
+
return [json.dumps(transaction) for transaction in booked_transactions]
|
|
40
|
+
|
|
41
|
+
def parse_record(self, line: str) -> StatementLine:
|
|
42
|
+
"""Parse given transaction line and return StatementLine object"""
|
|
43
|
+
|
|
44
|
+
# TODO: Infer transaction type from transaction data
|
|
45
|
+
statement = StatementLine()
|
|
46
|
+
transaction = json.loads(line)
|
|
47
|
+
transaction_data = NordigenTransactionModel(**transaction)
|
|
48
|
+
statement.id = transaction_data.transactionId
|
|
49
|
+
statement.date = transaction_data.bookingDateTime
|
|
50
|
+
statement.amount = transaction_data.transactionAmount.amount
|
|
51
|
+
statement.memo = transaction_data.remittanceInformationUnstructured
|
|
52
|
+
statement.payee = transaction_data.creditorName or transaction_data.debtorName
|
|
53
|
+
statement.date_user = transaction_data.valueDateTime
|
|
54
|
+
statement.check_no = transaction_data.checkId
|
|
55
|
+
statement.refnum = transaction_data.internalTransactionId
|
|
56
|
+
statement.currency = transaction_data.transactionAmount.currency
|
|
57
|
+
if transaction_data.currencyExchange and hasattr(
|
|
58
|
+
transaction_data.currencyExchange, "sourceCurrency"
|
|
59
|
+
):
|
|
60
|
+
statement.orig_currency = transaction_data.currencyExchange.sourceCurrency
|
|
61
|
+
return statement
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
from ofxstatement.statement import Currency
|
|
5
|
+
from decimal import Decimal
|
|
6
|
+
from typing import List, Optional, Union
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, field_validator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Amount(BaseModel):
|
|
12
|
+
amount: Decimal
|
|
13
|
+
currency: Currency
|
|
14
|
+
|
|
15
|
+
class Config:
|
|
16
|
+
arbitrary_types_allowed = True
|
|
17
|
+
|
|
18
|
+
@field_validator("currency", mode="before")
|
|
19
|
+
def validate_currency(cls, value):
|
|
20
|
+
if isinstance(value, str):
|
|
21
|
+
return Currency(value)
|
|
22
|
+
return value
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InstructedAmount(Amount):
|
|
26
|
+
targetCurrency: Optional[Currency] = None
|
|
27
|
+
sourceCurrency: Optional[Currency] = None
|
|
28
|
+
exchangeRate: Optional[float] = None
|
|
29
|
+
|
|
30
|
+
@field_validator("targetCurrency", "sourceCurrency", mode="before")
|
|
31
|
+
def validate_currency(cls, value):
|
|
32
|
+
if isinstance(value, str):
|
|
33
|
+
return Currency(value)
|
|
34
|
+
return value
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Account(BaseModel):
|
|
38
|
+
bban: Optional[str] = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ReportExchangeRate(BaseModel):
|
|
42
|
+
instructedAmount: Optional[InstructedAmount] = None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class NordigenTransactionModel(BaseModel):
|
|
46
|
+
"""
|
|
47
|
+
Nordigen data transaction model.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
balanceAfterTransaction: Optional[float] = None
|
|
51
|
+
bankTransactionCode: Optional[str] = None
|
|
52
|
+
bookingDate: Optional[datetime.date] = None
|
|
53
|
+
bookingDateTime: Optional[datetime.datetime] = None
|
|
54
|
+
checkId: Optional[str] = None
|
|
55
|
+
creditorAccount: Optional[Account] = None
|
|
56
|
+
creditorAgent: Optional[str] = None
|
|
57
|
+
creditorId: Optional[str] = None
|
|
58
|
+
creditorName: Optional[str] = None
|
|
59
|
+
currencyExchange: Optional[Union[ReportExchangeRate, InstructedAmount]] = None
|
|
60
|
+
debtorAccount: Optional[Account] = None
|
|
61
|
+
debtorAgent: Optional[str] = None
|
|
62
|
+
debtorName: Optional[str] = None
|
|
63
|
+
endToEndId: Optional[str] = None
|
|
64
|
+
entryReference: Optional[str] = None
|
|
65
|
+
internalTransactionId: Optional[str] = None
|
|
66
|
+
mandateId: Optional[str] = None
|
|
67
|
+
merchantCategoryCode: Optional[str] = None
|
|
68
|
+
proprietaryBankTransactionCode: Optional[str] = None
|
|
69
|
+
purposeCode: Optional[str] = None
|
|
70
|
+
remittanceInformationStructured: Optional[str] = None
|
|
71
|
+
remittanceInformationStructuredArray: Optional[List[str]] = None
|
|
72
|
+
remittanceInformationUnstructured: Optional[str] = None
|
|
73
|
+
remmittanceInformationUnstructuredArray: Optional[List[str]] = None
|
|
74
|
+
transactionAmount: Amount
|
|
75
|
+
transactionId: Optional[str] = None
|
|
76
|
+
ultimateCreditor: Optional[str] = None
|
|
77
|
+
ultimateDebtor: Optional[str] = None
|
|
78
|
+
valueDate: Optional[datetime.date] = None
|
|
79
|
+
valueDateTime: Optional[datetime.datetime] = None
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ofxstatement-nordigen
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: ofxstatement plugin for Nordigen bank statements
|
|
5
|
+
Author-email: Jimmy Stammers <jimmy.stammers@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/jstammers/ofxstatement-nordigen/
|
|
7
|
+
Keywords: ofx,banking,statement,plugin,ofxstatement
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
12
|
+
Classifier: Topic :: Utilities
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
Requires-Dist: ofxstatement
|
|
19
|
+
Requires-Dist: pydantic
|
|
20
|
+
Requires-Dist: requests
|
|
21
|
+
Requires-Dist: requests-cache
|
|
22
|
+
|
|
23
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
24
|
+
ofxstatement-nordigen
|
|
25
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
26
|
+
|
|
27
|
+
A plugin for `ofxstatement`_ to parse transaction data from GoCardless (previously known as Nordigen).
|
|
28
|
+
|
|
29
|
+
`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format,
|
|
30
|
+
suitable for importing to GnuCash. Plugin for ofxstatement parses a
|
|
31
|
+
particular proprietary bank statement format and produces common data
|
|
32
|
+
structure, that is then formatted into an OFX file.
|
|
33
|
+
|
|
34
|
+
.. _ofxstatement: https://github.com/kedder/ofxstatement
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Installation
|
|
38
|
+
================
|
|
39
|
+
|
|
40
|
+
To install the plugin, you can use `pip`_:
|
|
41
|
+
|
|
42
|
+
.. _pip: https://pypi.org/project/pip/
|
|
43
|
+
|
|
44
|
+
.. code-block:: shell
|
|
45
|
+
|
|
46
|
+
pip install ofxstatement-nordigen
|
|
47
|
+
|
|
48
|
+
or, if you want to install it in editable mode (for development), use:
|
|
49
|
+
|
|
50
|
+
.. code-block:: shell
|
|
51
|
+
|
|
52
|
+
pip install -e ./
|
|
53
|
+
|
|
54
|
+
To verify that the plugin is installed correctly, you can run:
|
|
55
|
+
|
|
56
|
+
.. code-block:: shell
|
|
57
|
+
|
|
58
|
+
ofxstatement --list-plugins
|
|
59
|
+
|
|
60
|
+
This should list the `nordigen` plugin among other plugins.
|
|
61
|
+
|
|
62
|
+
Usage
|
|
63
|
+
================
|
|
64
|
+
|
|
65
|
+
To use the plugin, you can run the `ofxstatement` command with the `--plugin` option:
|
|
66
|
+
|
|
67
|
+
.. code-block:: shell
|
|
68
|
+
|
|
69
|
+
ofxstatement convert -t nordigen <input_file> <output_file>
|
|
70
|
+
|
|
71
|
+
Replace `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
|
|
72
|
+
|
|
73
|
+
The input file should be a JSON of transactions from GoCardless that has the schema defined `here`_.
|
|
74
|
+
|
|
75
|
+
.. _here: https://developer.gocardless.com/bank-account-data/transactions
|
|
76
|
+
|
|
77
|
+
The output file will be an OFX file that can be imported into GnuCash or other financial software.
|
|
78
|
+
|
|
79
|
+
After you are done
|
|
80
|
+
==================
|
|
81
|
+
|
|
82
|
+
After your plugin is ready, feel free to open an issue on `ofxstatement`_
|
|
83
|
+
project to include your plugin in "known plugin list". That would hopefully
|
|
84
|
+
make life of other clients of your bank easier.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.rst
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/ofxstatement_nordigen/__init__.py
|
|
5
|
+
src/ofxstatement_nordigen/plugin.py
|
|
6
|
+
src/ofxstatement_nordigen/schemas.py
|
|
7
|
+
src/ofxstatement_nordigen.egg-info/PKG-INFO
|
|
8
|
+
src/ofxstatement_nordigen.egg-info/SOURCES.txt
|
|
9
|
+
src/ofxstatement_nordigen.egg-info/dependency_links.txt
|
|
10
|
+
src/ofxstatement_nordigen.egg-info/entry_points.txt
|
|
11
|
+
src/ofxstatement_nordigen.egg-info/requires.txt
|
|
12
|
+
src/ofxstatement_nordigen.egg-info/top_level.txt
|
|
13
|
+
tests/test_sample.py
|
|
14
|
+
tests/test_schemas.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ofxstatement_nordigen
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
from ofxstatement.ui import UI
|
|
4
|
+
|
|
5
|
+
from ofxstatement_nordigen.plugin import NordigenPlugin, NordigenParser
|
|
6
|
+
from ofxstatement import ofx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_sample() -> None:
|
|
10
|
+
plugin = NordigenPlugin(UI(), {})
|
|
11
|
+
here = os.path.dirname(__file__)
|
|
12
|
+
for filename in os.listdir(here):
|
|
13
|
+
if filename.endswith(".json"):
|
|
14
|
+
sample_filename = os.path.join(here, filename)
|
|
15
|
+
parser = plugin.get_parser(sample_filename)
|
|
16
|
+
statement = parser.parse()
|
|
17
|
+
assert len(statement.lines) > 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.mark.parametrize("filename", ["test_date.json"])
|
|
21
|
+
def test_parse_record(filename: str) -> None:
|
|
22
|
+
here = os.path.dirname(__file__)
|
|
23
|
+
sample_filename = os.path.join(here, "data", filename)
|
|
24
|
+
expected_filename = sample_filename.replace(".json", ".ofx")
|
|
25
|
+
|
|
26
|
+
parser = NordigenParser(sample_filename)
|
|
27
|
+
statement = parser.parse()
|
|
28
|
+
|
|
29
|
+
expected = open(expected_filename, "r").read()
|
|
30
|
+
writer = ofx.OfxWriter(statement)
|
|
31
|
+
result = writer.toxml(pretty=True)
|
|
32
|
+
|
|
33
|
+
# Get everything between the <STMTTRNRS> and </STMTTRNRS> tags
|
|
34
|
+
result = result[
|
|
35
|
+
result.index("<STMTTRNRS>") : result.index("</STMTTRNRS>") + len("</STMTTRNRS>")
|
|
36
|
+
]
|
|
37
|
+
expected = expected[
|
|
38
|
+
expected.index("<STMTTRNRS>") : expected.index("</STMTTRNRS>")
|
|
39
|
+
+ len("</STMTTRNRS>")
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
assert result == expected
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from ofxstatement_nordigen.schemas import NordigenTransactionModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.parametrize(
|
|
7
|
+
"data",
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
"transactionId": "123456789",
|
|
11
|
+
"transactionAmount": {"amount": 100.0, "currency": "EUR"},
|
|
12
|
+
"valueDate": "2023-10-01",
|
|
13
|
+
"valueDateTime": "2023-10-01T12:00:00Z",
|
|
14
|
+
"remittanceInformationStructured": "Payment for invoice #12345",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"transactionId": "987654321",
|
|
18
|
+
"entryReference": "REF123456",
|
|
19
|
+
"bookingDate": "2025-03-31",
|
|
20
|
+
"bookingDateTime": "2025-03-31T00:00:00+00:00",
|
|
21
|
+
"transactionAmount": {"amount": "-1521.00", "currency": "GBP"},
|
|
22
|
+
"remittanceInformationUnstructured": "Payment for invoice #67890",
|
|
23
|
+
"additionalInformation": "Payment received",
|
|
24
|
+
"proprietaryBankTransactionCode": "BP",
|
|
25
|
+
"internalTransactionId": "INT123456",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"transactionId": "anonymized_transaction_id",
|
|
29
|
+
"entryReference": "anonymized_entry_reference",
|
|
30
|
+
"bookingDate": "2025-04-05",
|
|
31
|
+
"valueDate": "2025-04-05",
|
|
32
|
+
"bookingDateTime": "2025-04-05T00:00:00+00:00",
|
|
33
|
+
"valueDateTime": "2025-04-05T00:00:00+00:00",
|
|
34
|
+
"transactionAmount": {"amount": "0.00", "currency": "XXX"},
|
|
35
|
+
"currencyExchange": {"sourceCurrency": "XXX", "exchangeRate": "0.0"},
|
|
36
|
+
"remittanceInformationUnstructured": "anonymized_remittance_information",
|
|
37
|
+
"additionalInformation": "anonymized_additional_information",
|
|
38
|
+
"additionalDataStructured": {
|
|
39
|
+
"CardSchemeName": "anonymized_card_scheme",
|
|
40
|
+
"Name": "anonymized_name",
|
|
41
|
+
"Identification": "anonymized_identification",
|
|
42
|
+
},
|
|
43
|
+
"internalTransactionId": "anonymized_internal_transaction_id",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
def test_go_cardless_transaction_model(data):
|
|
48
|
+
validated = NordigenTransactionModel(**data)
|
|
49
|
+
assert validated is not None
|