ofxstatement-nordigen 0.1.1__tar.gz → 0.1.2__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.

Files changed (16) hide show
  1. {ofxstatement_nordigen-0.1.1/src/ofxstatement_nordigen.egg-info → ofxstatement_nordigen-0.1.2}/PKG-INFO +13 -4
  2. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/README.rst +12 -3
  3. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/pyproject.toml +1 -1
  4. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen/plugin.py +23 -5
  5. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2/src/ofxstatement_nordigen.egg-info}/PKG-INFO +13 -4
  6. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/tests/test_sample.py +23 -4
  7. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/MANIFEST.in +0 -0
  8. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/setup.cfg +0 -0
  9. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen/__init__.py +0 -0
  10. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen/schemas.py +0 -0
  11. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen.egg-info/SOURCES.txt +0 -0
  12. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen.egg-info/dependency_links.txt +0 -0
  13. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen.egg-info/entry_points.txt +0 -0
  14. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen.egg-info/requires.txt +0 -0
  15. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/src/ofxstatement_nordigen.egg-info/top_level.txt +0 -0
  16. {ofxstatement_nordigen-0.1.1 → ofxstatement_nordigen-0.1.2}/tests/test_schemas.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ofxstatement-nordigen
3
- Version: 0.1.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 `nordigen` plugin among other plugins.
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 `ofxstatement` command with the `--plugin` option:
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 `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
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
 
@@ -35,18 +35,18 @@ To verify that the plugin is installed correctly, you can run:
35
35
 
36
36
  ofxstatement --list-plugins
37
37
 
38
- This should list the `nordigen` plugin among other plugins.
38
+ This should list the ``nordigen`` plugin among other plugins.
39
39
 
40
40
  Usage
41
41
  ================
42
42
 
43
- To use the plugin, you can run the `ofxstatement` command with the `--plugin` option:
43
+ To use the plugin, you can run the ``ofxstatement`` command with the ``--plugin`` option:
44
44
 
45
45
  .. code-block:: shell
46
46
 
47
47
  ofxstatement convert -t nordigen <input_file> <output_file>
48
48
 
49
- Replace `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
49
+ Replace ``<input_file>`` with the path to your input file and ``<output_file>`` with the desired output file name.
50
50
 
51
51
  The input file should be a JSON of transactions from GoCardless that has the schema defined `here`_.
52
52
 
@@ -54,6 +54,15 @@ The input file should be a JSON of transactions from GoCardless that has the sch
54
54
 
55
55
  The output file will be an OFX file that can be imported into GnuCash or other financial software.
56
56
 
57
+ Configuration
58
+ ================
59
+
60
+ Configuration can be edited using the ``ofxstatement edit-config`` command.
61
+ The following parameters are available:
62
+
63
+ - ``account_id``: The account ID to use for the transactions. This is required.
64
+ - ``currency``: The currency to use for the account. If not specified, the currency will be determined from the transactions.
65
+
57
66
  After you are done
58
67
  ==================
59
68
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ofxstatement-nordigen"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  authors = [
9
9
  { name="Jimmy Stammers", email="jimmy.stammers@gmail.com" },
10
10
  ]
@@ -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
- return NordigenParser(filename)
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__(self, filename: str) -> None:
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
- return super().parse()
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"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ofxstatement-nordigen
3
- Version: 0.1.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 `nordigen` plugin among other plugins.
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 `ofxstatement` command with the `--plugin` option:
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 `<input_file>` with the path to your input file and `<output_file>` with the desired output file name.
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
 
@@ -6,6 +6,24 @@ from ofxstatement_nordigen.plugin import NordigenPlugin, NordigenParser
6
6
  from ofxstatement import ofx
7
7
 
8
8
 
9
+ def test_config_sets_account_and_currency() -> None:
10
+ """Test that account and currency are set correctly when provided in config."""
11
+ # Create a plugin with specific account and currency settings
12
+ settings = {"account": "test-account-123", "currency": "EUR"}
13
+ plugin = NordigenPlugin(UI(), settings)
14
+
15
+ here = os.path.dirname(__file__)
16
+ sample_filename = os.path.join(here, "sample-statement.json")
17
+ parser = plugin.get_parser(sample_filename)
18
+
19
+ assert parser.account_id == settings["account"]
20
+ assert parser.currency == settings["currency"]
21
+
22
+ statement = parser.parse()
23
+ assert statement.account_id == settings["account"]
24
+ assert statement.currency == settings["currency"]
25
+
26
+
9
27
  def test_sample() -> None:
10
28
  plugin = NordigenPlugin(UI(), {})
11
29
  here = os.path.dirname(__file__)
@@ -15,6 +33,8 @@ def test_sample() -> None:
15
33
  parser = plugin.get_parser(sample_filename)
16
34
  statement = parser.parse()
17
35
  assert len(statement.lines) > 0
36
+ assert statement.start_date is not None
37
+ assert statement.end_date is not None
18
38
 
19
39
 
20
40
  @pytest.mark.parametrize("filename", ["test_date.json"])
@@ -30,13 +50,12 @@ def test_parse_record(filename: str) -> None:
30
50
  writer = ofx.OfxWriter(statement)
31
51
  result = writer.toxml(pretty=True)
32
52
 
33
- # Get everything between the <STMTTRNRS> and </STMTTRNRS> tags
53
+ # Get everything between the <STMTTRN> and </STMTTRN> tags
34
54
  result = result[
35
- result.index("<STMTTRNRS>") : result.index("</STMTTRNRS>") + len("</STMTTRNRS>")
55
+ result.index("<STMTTRN>") : result.index("</STMTTRN>") + len("</STMTTRN>")
36
56
  ]
37
57
  expected = expected[
38
- expected.index("<STMTTRNRS>") : expected.index("</STMTTRNRS>")
39
- + len("</STMTTRNRS>")
58
+ expected.index("<STMTTRN>") : expected.index("</STMTTRN>") + len("</STMTTRN>")
40
59
  ]
41
60
 
42
61
  assert result == expected