ofxstatement-nordigen 0.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
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/plugin.py +23 -5
- ofxstatement_nordigen/schemas.py +12 -11
- {ofxstatement_nordigen-0.1.dist-info → ofxstatement_nordigen-0.1.2.dist-info}/METADATA +13 -4
- ofxstatement_nordigen-0.1.2.dist-info/RECORD +8 -0
- {ofxstatement_nordigen-0.1.dist-info → ofxstatement_nordigen-0.1.2.dist-info}/WHEEL +1 -1
- ofxstatement_nordigen-0.1.dist-info/RECORD +0 -8
- {ofxstatement_nordigen-0.1.dist-info → ofxstatement_nordigen-0.1.2.dist-info}/entry_points.txt +0 -0
- {ofxstatement_nordigen-0.1.dist-info → ofxstatement_nordigen-0.1.2.dist-info}/top_level.txt +0 -0
ofxstatement_nordigen/plugin.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Iterable
|
|
3
|
-
|
|
2
|
+
from typing import Iterable, Optional
|
|
3
|
+
from datetime import datetime
|
|
4
4
|
from ofxstatement.plugin import Plugin
|
|
5
5
|
from ofxstatement.parser import StatementParser
|
|
6
6
|
from ofxstatement.statement import Statement, StatementLine
|
|
@@ -12,15 +12,24 @@ class NordigenPlugin(Plugin):
|
|
|
12
12
|
"""Retrieves Nordigen transactions and converts them to OFX format."""
|
|
13
13
|
|
|
14
14
|
def get_parser(self, filename: str) -> "NordigenParser":
|
|
15
|
-
|
|
15
|
+
default_ccy = self.settings.get("currency")
|
|
16
|
+
account_id = self.settings.get("account")
|
|
17
|
+
return NordigenParser(filename, default_ccy, account_id)
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
class NordigenParser(StatementParser[str]):
|
|
19
|
-
def __init__(
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
filename: str,
|
|
24
|
+
currency: Optional[str] = None,
|
|
25
|
+
account_id: Optional[str] = None,
|
|
26
|
+
) -> None:
|
|
20
27
|
super().__init__()
|
|
21
28
|
if not filename.endswith(".json"):
|
|
22
29
|
raise ValueError("Only JSON files are supported")
|
|
23
30
|
self.filename = filename
|
|
31
|
+
self.currency = currency
|
|
32
|
+
self.account_id = account_id
|
|
24
33
|
|
|
25
34
|
def parse(self) -> Statement:
|
|
26
35
|
"""Main entry point for parsers
|
|
@@ -29,7 +38,16 @@ class NordigenParser(StatementParser[str]):
|
|
|
29
38
|
process the file.
|
|
30
39
|
"""
|
|
31
40
|
with open(self.filename, "r"):
|
|
32
|
-
|
|
41
|
+
statement = super().parse()
|
|
42
|
+
dates = [
|
|
43
|
+
line.date for line in statement.lines if isinstance(line.date, datetime)
|
|
44
|
+
]
|
|
45
|
+
if len(dates) > 0:
|
|
46
|
+
statement.start_date = min(dates)
|
|
47
|
+
statement.end_date = max(dates)
|
|
48
|
+
statement.account_id = self.account_id
|
|
49
|
+
statement.currency = self.currency or statement.currency
|
|
50
|
+
return statement
|
|
33
51
|
|
|
34
52
|
def split_records(self) -> Iterable[str]:
|
|
35
53
|
"""Return iterable object consisting of a line per transaction"""
|
ofxstatement_nordigen/schemas.py
CHANGED
|
@@ -22,24 +22,25 @@ class Amount(BaseModel):
|
|
|
22
22
|
return value
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class
|
|
26
|
-
|
|
25
|
+
class Account(BaseModel):
|
|
26
|
+
bban: Optional[str] = None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CurrencyExchange(BaseModel):
|
|
27
30
|
sourceCurrency: Optional[Currency] = None
|
|
31
|
+
targetCurrency: Optional[Currency] = None
|
|
32
|
+
unitCurrency: Optional[Currency] = None
|
|
28
33
|
exchangeRate: Optional[float] = None
|
|
34
|
+
instructedAmount: Optional[Amount] = None
|
|
29
35
|
|
|
30
|
-
@field_validator("targetCurrency", "
|
|
36
|
+
@field_validator("sourceCurrency", "targetCurrency", "unitCurrency", mode="before")
|
|
31
37
|
def validate_currency(cls, value):
|
|
32
38
|
if isinstance(value, str):
|
|
33
39
|
return Currency(value)
|
|
34
40
|
return value
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
bban: Optional[str] = None
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class ReportExchangeRate(BaseModel):
|
|
42
|
-
instructedAmount: Optional[InstructedAmount] = None
|
|
42
|
+
class Config:
|
|
43
|
+
arbitrary_types_allowed = True
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
class NordigenTransactionModel(BaseModel):
|
|
@@ -56,7 +57,7 @@ class NordigenTransactionModel(BaseModel):
|
|
|
56
57
|
creditorAgent: Optional[str] = None
|
|
57
58
|
creditorId: Optional[str] = None
|
|
58
59
|
creditorName: Optional[str] = None
|
|
59
|
-
currencyExchange: Optional[
|
|
60
|
+
currencyExchange: Optional[CurrencyExchange] = None
|
|
60
61
|
debtorAccount: Optional[Account] = None
|
|
61
62
|
debtorAgent: Optional[str] = None
|
|
62
63
|
debtorName: Optional[str] = None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ofxstatement-nordigen
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: ofxstatement plugin for Nordigen bank statements
|
|
5
5
|
Author-email: Jimmy Stammers <jimmy.stammers@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/jstammers/ofxstatement-nordigen/
|
|
@@ -57,18 +57,18 @@ To verify that the plugin is installed correctly, you can run:
|
|
|
57
57
|
|
|
58
58
|
ofxstatement --list-plugins
|
|
59
59
|
|
|
60
|
-
This should list the
|
|
60
|
+
This should list the ``nordigen`` plugin among other plugins.
|
|
61
61
|
|
|
62
62
|
Usage
|
|
63
63
|
================
|
|
64
64
|
|
|
65
|
-
To use the plugin, you can run the
|
|
65
|
+
To use the plugin, you can run the ``ofxstatement`` command with the ``--plugin`` option:
|
|
66
66
|
|
|
67
67
|
.. code-block:: shell
|
|
68
68
|
|
|
69
69
|
ofxstatement convert -t nordigen <input_file> <output_file>
|
|
70
70
|
|
|
71
|
-
Replace
|
|
71
|
+
Replace ``<input_file>`` with the path to your input file and ``<output_file>`` with the desired output file name.
|
|
72
72
|
|
|
73
73
|
The input file should be a JSON of transactions from GoCardless that has the schema defined `here`_.
|
|
74
74
|
|
|
@@ -76,6 +76,15 @@ The input file should be a JSON of transactions from GoCardless that has the sch
|
|
|
76
76
|
|
|
77
77
|
The output file will be an OFX file that can be imported into GnuCash or other financial software.
|
|
78
78
|
|
|
79
|
+
Configuration
|
|
80
|
+
================
|
|
81
|
+
|
|
82
|
+
Configuration can be edited using the ``ofxstatement edit-config`` command.
|
|
83
|
+
The following parameters are available:
|
|
84
|
+
|
|
85
|
+
- ``account_id``: The account ID to use for the transactions. This is required.
|
|
86
|
+
- ``currency``: The currency to use for the account. If not specified, the currency will be determined from the transactions.
|
|
87
|
+
|
|
79
88
|
After you are done
|
|
80
89
|
==================
|
|
81
90
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ofxstatement_nordigen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
ofxstatement_nordigen/plugin.py,sha256=hc50YssCzdUzzgORsQijs2b7219ExXLFY9gD1Z5s0Eg,3282
|
|
3
|
+
ofxstatement_nordigen/schemas.py,sha256=15XdqsSBhyEDbk-gaCwlkaEDkPIfXuSYxfF0iEWaC0U,2606
|
|
4
|
+
ofxstatement_nordigen-0.1.2.dist-info/METADATA,sha256=WwUKWj3ZS4rBy1BVyHwjXY5elG0b8R9Dn5ExMlJBJwE,3044
|
|
5
|
+
ofxstatement_nordigen-0.1.2.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
6
|
+
ofxstatement_nordigen-0.1.2.dist-info/entry_points.txt,sha256=u2VbBVZyOs-NBZwsS0wBZMwiczusBhgkWBrhSrcckvA,70
|
|
7
|
+
ofxstatement_nordigen-0.1.2.dist-info/top_level.txt,sha256=gxcEQgvstWr0jhEqaT70JODD71i507SJ06YeA5KIUj4,22
|
|
8
|
+
ofxstatement_nordigen-0.1.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
ofxstatement_nordigen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ofxstatement_nordigen/plugin.py,sha256=P74OSBt-4SkXHuHa0MREMayd9Um_mwp0jKgPndMAhb0,2533
|
|
3
|
-
ofxstatement_nordigen/schemas.py,sha256=8n4iXQjnHHHrKF_ZdEJRs6zcKCbidWu61PQmyVfzUUI,2561
|
|
4
|
-
ofxstatement_nordigen-0.1.dist-info/METADATA,sha256=QNFTJR7YfNTr3Oiu2K06SFsRezFSaDIccqF0wSW0A1M,2676
|
|
5
|
-
ofxstatement_nordigen-0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
6
|
-
ofxstatement_nordigen-0.1.dist-info/entry_points.txt,sha256=u2VbBVZyOs-NBZwsS0wBZMwiczusBhgkWBrhSrcckvA,70
|
|
7
|
-
ofxstatement_nordigen-0.1.dist-info/top_level.txt,sha256=gxcEQgvstWr0jhEqaT70JODD71i507SJ06YeA5KIUj4,22
|
|
8
|
-
ofxstatement_nordigen-0.1.dist-info/RECORD,,
|
{ofxstatement_nordigen-0.1.dist-info → ofxstatement_nordigen-0.1.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|