csv2ofx 0.33.0__tar.gz → 0.34.0__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.
- {csv2ofx-0.33.0/csv2ofx.egg-info → csv2ofx-0.34.0}/PKG-INFO +7 -11
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/README.md +4 -8
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/__init__.py +21 -13
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/main.py +1 -1
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/amazon.py +9 -1
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/n26.py +1 -1
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/qif.py +6 -2
- {csv2ofx-0.33.0 → csv2ofx-0.34.0/csv2ofx.egg-info}/PKG-INFO +7 -11
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx.egg-info/SOURCES.txt +3 -1
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx.egg-info/requires.txt +0 -1
- csv2ofx-0.34.0/data/converted/n26.ofx +47 -0
- csv2ofx-0.34.0/data/test/amazon.csv +7 -0
- csv2ofx-0.34.0/data/test/n26.csv +3 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/pyproject.toml +1 -2
- csv2ofx-0.34.0/tests/test_cli.py +159 -0
- csv2ofx-0.33.0/data/test/amazon.csv +0 -5
- csv2ofx-0.33.0/tests/test.py +0 -222
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/LICENSE +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/MANIFEST.in +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/__main__.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/__init__.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/abnamro.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/boursorama.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/capitalone.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/creditunion.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/custom.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/default.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/eqbank.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/exim.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/gls.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/ingdirect.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/ingesp.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/mdb.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/mint.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/mint_extra.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/mint_headerless.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/mintapi.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/msmoneyreport.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/outbank.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/payoneer.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/pcmastercard.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/rabobank.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/schwabchecking.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/split_account.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/starling.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/stripe.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/ubs-ch-fr.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/ubs.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/xero.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/mappings/yodlee.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/ofx.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx/utils.py +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx.egg-info/dependency_links.txt +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx.egg-info/entry_points.txt +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/csv2ofx.egg-info/top_level.txt +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/amazon.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/creditunion.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/default.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/default.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/default_w_splits.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/default_w_splits.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/gls.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/ingesp.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/mint.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/mint.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/mint_alt.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/mint_extra.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/outbank.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/payoneer.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/pcmastercard.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case1.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case2.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case3.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case4.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case5.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case6.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-baltest-case7.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking-msmoney.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/schwab-checking.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/stripe-all.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/stripe-all.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/stripe-default.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/stripe-default.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/ubs-ch-fr.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/converted/xero.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/example/investment_example.qif +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/example/transaction_example.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/example/transfer_example.ofx +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/capitalone.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/creditunion.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/default.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/gls.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/ingesp.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/mint.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/mint_extra.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/mint_headerless.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/outbank.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/payoneer.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/pcmastercard.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case1.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case2.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case3.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case4.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case5.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case6.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking-baltest-case7.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/schwab-checking.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/stripe-all.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/stripe-default.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/ubs-ch-fr_trimmed.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/data/test/xero.csv +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/OFX 2.1.1.pdf +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/OFXAudit.xls +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/OFX_Message_Support.doc +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/a.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/a_002.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/a_003.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/a_004.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/a_005.html +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/bootstrap.js +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/jquery.js +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/QIF Specification_files/sitecss.css +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/docs/qif-file-format.txt +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/helpers/check-stage +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/helpers/clean +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/helpers/srcdist +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/helpers/wheel +0 -0
- {csv2ofx-0.33.0 → csv2ofx-0.34.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: csv2ofx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.34.0
|
|
4
4
|
Summary: converts a csv file of transactions to an ofx or qif file
|
|
5
5
|
Author-email: Reuben Cummings <reubano@gmail.com>
|
|
6
6
|
Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
|
|
@@ -21,10 +21,10 @@ Requires-Dist: python-dateutil<3.0.0,>=2.7.2
|
|
|
21
21
|
Requires-Dist: requests<3.0.0,>=2.18.4
|
|
22
22
|
Requires-Dist: meza<0.48.0,>=0.47.0
|
|
23
23
|
Provides-Extra: test
|
|
24
|
-
Requires-Dist: pygogo<2.0.0,>=0.13.2; extra == "test"
|
|
25
24
|
Requires-Dist: pytest; extra == "test"
|
|
26
25
|
Requires-Dist: pytest-enabler; extra == "test"
|
|
27
26
|
Requires-Dist: pytest-ruff; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
28
28
|
|
|
29
29
|
# csv2ofx
|
|
30
30
|
|
|
@@ -283,13 +283,9 @@ Either install [tox](https://tox.wiki) or install [pipx](https://pipx.pypa.io) a
|
|
|
283
283
|
tox
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
Tox will run the tests and other checks (linter) in different Python environments. It will create Python
|
|
286
|
+
Tox will run the tests and other checks (linter) in different Python environments. It will create a Python environment in `.tox/py` and install csv2ofx there.
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
tox -e py
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Feel free to activate one of those environments or create a separate one.
|
|
288
|
+
Feel free to activate that environment or create a separate one.
|
|
293
289
|
|
|
294
290
|
3. Create a branch for local development
|
|
295
291
|
|
|
@@ -306,8 +302,8 @@ How to contribute a mapping:
|
|
|
306
302
|
1. Add the mapping in `csv2ofx/mappings/`
|
|
307
303
|
2. Add a simple example CSV file in `data/test/`.
|
|
308
304
|
3. Add the OFX or QIF file that results from the mapping and example CSV file in `data/converted/`.
|
|
309
|
-
4. Add a `csv2ofx` call for your mapping to the tests in `tests/
|
|
310
|
-
5. Ensure
|
|
305
|
+
4. Add a `csv2ofx` call for your mapping to the tests in `tests/test_cli.py`, in `samples`. When adding an OFX (not QIF) converted file, pay attention to the `-e` (end date) and `-D` (server date) arguments in the test. Otherwise, tests may pass locally but fail on the build server.
|
|
306
|
+
5. Ensure the test succeeds (see above).
|
|
311
307
|
|
|
312
308
|
## License
|
|
313
309
|
|
|
@@ -255,13 +255,9 @@ Either install [tox](https://tox.wiki) or install [pipx](https://pipx.pypa.io) a
|
|
|
255
255
|
tox
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
Tox will run the tests and other checks (linter) in different Python environments. It will create Python
|
|
258
|
+
Tox will run the tests and other checks (linter) in different Python environments. It will create a Python environment in `.tox/py` and install csv2ofx there.
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
tox -e py
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Feel free to activate one of those environments or create a separate one.
|
|
260
|
+
Feel free to activate that environment or create a separate one.
|
|
265
261
|
|
|
266
262
|
3. Create a branch for local development
|
|
267
263
|
|
|
@@ -278,8 +274,8 @@ How to contribute a mapping:
|
|
|
278
274
|
1. Add the mapping in `csv2ofx/mappings/`
|
|
279
275
|
2. Add a simple example CSV file in `data/test/`.
|
|
280
276
|
3. Add the OFX or QIF file that results from the mapping and example CSV file in `data/converted/`.
|
|
281
|
-
4. Add a `csv2ofx` call for your mapping to the tests in `tests/
|
|
282
|
-
5. Ensure
|
|
277
|
+
4. Add a `csv2ofx` call for your mapping to the tests in `tests/test_cli.py`, in `samples`. When adding an OFX (not QIF) converted file, pay attention to the `-e` (end date) and `-D` (server date) arguments in the test. Otherwise, tests may pass locally but fail on the build server.
|
|
278
|
+
5. Ensure the test succeeds (see above).
|
|
283
279
|
|
|
284
280
|
## License
|
|
285
281
|
|
|
@@ -20,7 +20,6 @@ import hashlib
|
|
|
20
20
|
from datetime import datetime as dt
|
|
21
21
|
from decimal import Decimal
|
|
22
22
|
from functools import partial
|
|
23
|
-
from itertools import filterfalse
|
|
24
23
|
|
|
25
24
|
from dateutil.parser import parse
|
|
26
25
|
from meza.process import group, merge
|
|
@@ -68,7 +67,7 @@ class Content: # pylint: disable=too-many-instance-attributes
|
|
|
68
67
|
self.account = "N/A"
|
|
69
68
|
self.parse_fmt = kwargs.get("parse_fmt")
|
|
70
69
|
self.dayfirst = kwargs.get("dayfirst")
|
|
71
|
-
self.filter = kwargs.get("filter")
|
|
70
|
+
self.filter = kwargs.get("filter") or bool
|
|
72
71
|
self.ms_money = kwargs.get("ms_money")
|
|
73
72
|
self.split_account = None
|
|
74
73
|
self.inv_split_account = None
|
|
@@ -143,9 +142,10 @@ class Content: # pylint: disable=too-many-instance-attributes
|
|
|
143
142
|
|
|
144
143
|
return value
|
|
145
144
|
|
|
146
|
-
def
|
|
147
|
-
"""Determines whether a transaction should be
|
|
148
|
-
|
|
145
|
+
def include(self, trxn):
|
|
146
|
+
"""Determines whether a transaction should be included.
|
|
147
|
+
|
|
148
|
+
Included if within the specified date range and any custom filter.
|
|
149
149
|
|
|
150
150
|
Args:
|
|
151
151
|
trxn (dict): The transaction.
|
|
@@ -158,13 +158,21 @@ class Content: # pylint: disable=too-many-instance-attributes
|
|
|
158
158
|
>>> from datetime import datetime as dt
|
|
159
159
|
>>>
|
|
160
160
|
>>> trxn = {'Date': '06/12/10', 'Amount': 1000.00}
|
|
161
|
-
>>> Content(mapping, start=dt(2010, 1, 1)).
|
|
162
|
-
False
|
|
163
|
-
>>> Content(mapping, start=dt(2013, 1, 1)).skip_transaction(trxn)
|
|
161
|
+
>>> Content(mapping, start=dt(2010, 1, 1)).include(trxn)
|
|
164
162
|
True
|
|
163
|
+
>>> Content(mapping, start=dt(2013, 1, 1)).include(trxn)
|
|
164
|
+
False
|
|
165
165
|
"""
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
return all(
|
|
167
|
+
filter_(trxn)
|
|
168
|
+
for filter_ in (
|
|
169
|
+
self.filter,
|
|
170
|
+
self.in_range,
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
def in_range(self, trxn):
|
|
175
|
+
return self.start <= self.parse_date(trxn) <= self.end
|
|
168
176
|
|
|
169
177
|
def convert_amount(self, trxn):
|
|
170
178
|
"""Converts a string amount into a number
|
|
@@ -310,13 +318,13 @@ class Content: # pylint: disable=too-many-instance-attributes
|
|
|
310
318
|
for grp, trxns in groups:
|
|
311
319
|
_args = [trxns, self.convert_amount]
|
|
312
320
|
|
|
313
|
-
# if it's split, transaction
|
|
314
|
-
if self.is_split and self.
|
|
321
|
+
# if it's split, transaction inclusion is all or none
|
|
322
|
+
if self.is_split and not self.include(trxns[0]):
|
|
315
323
|
continue
|
|
316
324
|
elif self.is_split and not utils.verify_splits(*_args):
|
|
317
325
|
raise Exception("Splits do not sum to zero.")
|
|
318
326
|
elif not self.is_split:
|
|
319
|
-
filtered_trxns =
|
|
327
|
+
filtered_trxns = filter(self.include, trxns)
|
|
320
328
|
else:
|
|
321
329
|
filtered_trxns = trxns
|
|
322
330
|
|
|
@@ -292,7 +292,7 @@ def run(): # noqa: C901
|
|
|
292
292
|
msg += "Try again with `-c` option."
|
|
293
293
|
except ValueError as err:
|
|
294
294
|
# csv2ofx called with no arguments or broken mapping
|
|
295
|
-
msg = f"Possible mapping problem: {str(err)}.
|
|
295
|
+
msg = f"Possible mapping problem: {str(err)}."
|
|
296
296
|
parser.print_help()
|
|
297
297
|
except BalanceError as err:
|
|
298
298
|
msg = f"{err}. Try again with `--ending-balance` option."
|
|
@@ -44,6 +44,14 @@ def filter_payment(row):
|
|
|
44
44
|
return include and not exclude
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
def filter_pending(row):
|
|
48
|
+
return row['date'] != 'pending'
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def filter(row):
|
|
52
|
+
return filter_pending(row) and filter_payment(row)
|
|
53
|
+
|
|
54
|
+
|
|
47
55
|
mapping = {
|
|
48
56
|
'has_header': True,
|
|
49
57
|
'delimiter': ',',
|
|
@@ -56,5 +64,5 @@ mapping = {
|
|
|
56
64
|
'id': itemgetter('order id'),
|
|
57
65
|
'type': 'DEBIT',
|
|
58
66
|
'last_row': -1,
|
|
59
|
-
'filter':
|
|
67
|
+
'filter': filter,
|
|
60
68
|
}
|
|
@@ -23,7 +23,7 @@ mapping = {
|
|
|
23
23
|
"delimiter": ",",
|
|
24
24
|
"account": "N26 checking",
|
|
25
25
|
"type": find_type,
|
|
26
|
-
"date": itemgetter("Date"),
|
|
26
|
+
"date": itemgetter("Booking Date"),
|
|
27
27
|
"amount": itemgetter("Amount (EUR)"),
|
|
28
28
|
"payee": itemgetter("Payee"),
|
|
29
29
|
"notes": itemgetter("Payment reference"),
|
|
@@ -186,9 +186,13 @@ class QIF(Content):
|
|
|
186
186
|
>>> result = QIF().transaction(**kwargs)
|
|
187
187
|
>>> trxn == result.replace('\\n', '').replace('\\t', '')
|
|
188
188
|
True
|
|
189
|
+
|
|
190
|
+
>>> result = QIF().transaction(date_fmt="%Y-%m-%d", **kwargs)
|
|
191
|
+
>>> '2012-01-01' in result
|
|
192
|
+
True
|
|
189
193
|
"""
|
|
190
|
-
kwargs.get("date_fmt", self.date_fmt)
|
|
191
|
-
kwargs.update({"time_stamp": kwargs["date"].strftime(
|
|
194
|
+
date_fmt = kwargs.get("date_fmt", self.date_fmt)
|
|
195
|
+
kwargs.update({"time_stamp": kwargs["date"].strftime(date_fmt)})
|
|
192
196
|
is_investment = kwargs.get("is_investment")
|
|
193
197
|
is_transaction = not is_investment
|
|
194
198
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: csv2ofx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.34.0
|
|
4
4
|
Summary: converts a csv file of transactions to an ofx or qif file
|
|
5
5
|
Author-email: Reuben Cummings <reubano@gmail.com>
|
|
6
6
|
Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
|
|
@@ -21,10 +21,10 @@ Requires-Dist: python-dateutil<3.0.0,>=2.7.2
|
|
|
21
21
|
Requires-Dist: requests<3.0.0,>=2.18.4
|
|
22
22
|
Requires-Dist: meza<0.48.0,>=0.47.0
|
|
23
23
|
Provides-Extra: test
|
|
24
|
-
Requires-Dist: pygogo<2.0.0,>=0.13.2; extra == "test"
|
|
25
24
|
Requires-Dist: pytest; extra == "test"
|
|
26
25
|
Requires-Dist: pytest-enabler; extra == "test"
|
|
27
26
|
Requires-Dist: pytest-ruff; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
28
28
|
|
|
29
29
|
# csv2ofx
|
|
30
30
|
|
|
@@ -283,13 +283,9 @@ Either install [tox](https://tox.wiki) or install [pipx](https://pipx.pypa.io) a
|
|
|
283
283
|
tox
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
Tox will run the tests and other checks (linter) in different Python environments. It will create Python
|
|
286
|
+
Tox will run the tests and other checks (linter) in different Python environments. It will create a Python environment in `.tox/py` and install csv2ofx there.
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
tox -e py
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Feel free to activate one of those environments or create a separate one.
|
|
288
|
+
Feel free to activate that environment or create a separate one.
|
|
293
289
|
|
|
294
290
|
3. Create a branch for local development
|
|
295
291
|
|
|
@@ -306,8 +302,8 @@ How to contribute a mapping:
|
|
|
306
302
|
1. Add the mapping in `csv2ofx/mappings/`
|
|
307
303
|
2. Add a simple example CSV file in `data/test/`.
|
|
308
304
|
3. Add the OFX or QIF file that results from the mapping and example CSV file in `data/converted/`.
|
|
309
|
-
4. Add a `csv2ofx` call for your mapping to the tests in `tests/
|
|
310
|
-
5. Ensure
|
|
305
|
+
4. Add a `csv2ofx` call for your mapping to the tests in `tests/test_cli.py`, in `samples`. When adding an OFX (not QIF) converted file, pay attention to the `-e` (end date) and `-D` (server date) arguments in the test. Otherwise, tests may pass locally but fail on the build server.
|
|
306
|
+
5. Ensure the test succeeds (see above).
|
|
311
307
|
|
|
312
308
|
## License
|
|
313
309
|
|
|
@@ -58,6 +58,7 @@ data/converted/mint.ofx
|
|
|
58
58
|
data/converted/mint.qif
|
|
59
59
|
data/converted/mint_alt.qif
|
|
60
60
|
data/converted/mint_extra.qif
|
|
61
|
+
data/converted/n26.ofx
|
|
61
62
|
data/converted/outbank.ofx
|
|
62
63
|
data/converted/payoneer.ofx
|
|
63
64
|
data/converted/pcmastercard.ofx
|
|
@@ -88,6 +89,7 @@ data/test/ingesp.csv
|
|
|
88
89
|
data/test/mint.csv
|
|
89
90
|
data/test/mint_extra.csv
|
|
90
91
|
data/test/mint_headerless.csv
|
|
92
|
+
data/test/n26.csv
|
|
91
93
|
data/test/outbank.csv
|
|
92
94
|
data/test/payoneer.csv
|
|
93
95
|
data/test/pcmastercard.csv
|
|
@@ -120,4 +122,4 @@ helpers/check-stage
|
|
|
120
122
|
helpers/clean
|
|
121
123
|
helpers/srcdist
|
|
122
124
|
helpers/wheel
|
|
123
|
-
tests/
|
|
125
|
+
tests/test_cli.py
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
DATA:OFXSGML
|
|
2
|
+
ENCODING:UTF-8
|
|
3
|
+
<OFX>
|
|
4
|
+
<SIGNONMSGSRSV1>
|
|
5
|
+
<SONRS>
|
|
6
|
+
<STATUS>
|
|
7
|
+
<CODE>0</CODE>
|
|
8
|
+
<SEVERITY>INFO</SEVERITY>
|
|
9
|
+
</STATUS>
|
|
10
|
+
<DTSERVER>20161031112908</DTSERVER>
|
|
11
|
+
<LANGUAGE>ENG</LANGUAGE>
|
|
12
|
+
</SONRS>
|
|
13
|
+
</SIGNONMSGSRSV1>
|
|
14
|
+
<BANKMSGSRSV1>
|
|
15
|
+
<STMTTRNRS>
|
|
16
|
+
<TRNUID></TRNUID>
|
|
17
|
+
<STATUS>
|
|
18
|
+
<CODE>0</CODE>
|
|
19
|
+
<SEVERITY>INFO</SEVERITY>
|
|
20
|
+
</STATUS>
|
|
21
|
+
<STMTRS>
|
|
22
|
+
<CURDEF>EUR</CURDEF>
|
|
23
|
+
<BANKACCTFROM>
|
|
24
|
+
<BANKID>89754e66afae91f7bcba8b9cbbd3aee7</BANKID>
|
|
25
|
+
<ACCTID>57165337dd5eec7ef6c64f2b5ceb5a4d</ACCTID>
|
|
26
|
+
<ACCTTYPE>CHECKING</ACCTTYPE>
|
|
27
|
+
</BANKACCTFROM>
|
|
28
|
+
<BANKTRANLIST>
|
|
29
|
+
<DTSTART>19700101</DTSTART>
|
|
30
|
+
<DTEND>20250406</DTEND>
|
|
31
|
+
<STMTTRN>
|
|
32
|
+
<TRNTYPE>CREDIT</TRNTYPE>
|
|
33
|
+
<DTPOSTED>20200307000000</DTPOSTED>
|
|
34
|
+
<TRNAMT>328.00</TRNAMT>
|
|
35
|
+
<FITID>0f784b3d076143afe1fbcf8eb9338d31a6216da00d97de878f68409a5cf0534e</FITID>
|
|
36
|
+
</STMTTRN>
|
|
37
|
+
<STMTTRN>
|
|
38
|
+
<TRNTYPE>DEBIT</TRNTYPE>
|
|
39
|
+
<DTPOSTED>20200307000000</DTPOSTED>
|
|
40
|
+
<TRNAMT>-328.00</TRNAMT>
|
|
41
|
+
<FITID>9b7646a2be0e6aaa04a1154d7be039da00a8f0a34dd8623be4fc79ee8064cfbf</FITID>
|
|
42
|
+
</STMTTRN>
|
|
43
|
+
</BANKTRANLIST>
|
|
44
|
+
</STMTRS>
|
|
45
|
+
</STMTTRNRS>
|
|
46
|
+
</BANKMSGSRSV1>
|
|
47
|
+
</OFX>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
order id,order url,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments
|
|
2
|
+
112-1635210-7125801,https://www.amazon.com/...,"Goof Off Household Heavy Duty Remover, 4 fl. oz. Spray, For Spots, Stains, Marks, and Messes; ",John Doe,2022-12-20,4.22,0,0,0,0.24,0,"Visa ending in 1234: December 24, 2022: $4.22; "
|
|
3
|
+
111-3273904-8117030,https://www.amazon.com/...,"Darksteve - Violet Decorative Light Bulb - Edison Light Bulb, Antique Vintage Style Light, G80 Size, E26 Base, Non-Dimmable (3w/110v); ",John Doe,2022-12-20,7.42,0,0,0,0.42,0,"Visa ending in 5566: December 28, 2022: $7.42; "
|
|
4
|
+
114-5269613-6941034,https://www.amazon.com/...,"TOPGREENER Smart Wi-Fi In-Wall Tamper Resistant Dual USB Charger Outlet, Energy Monitoring, Compatible with Amazon Alexa and Google Assistant, Outlet; ",John Doe,2022-10-11,34.12,0,0,0,1.93,0,"Visa ending in 9876: October 12, 2022: $34.12; "
|
|
5
|
+
D01-1234567-8901234,https://www.amazon.com/...,,,pending,,,,,,,
|
|
6
|
+
D01-5678901-2345678,https://www.amazon.com/...,,,pending,,,,,,,
|
|
7
|
+
order id,order url,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"Booking Date","Value Date","Partner Name","Partner Iban",Type,"Payment Reference","Account Name","Amount (EUR)","Original Amount","Original Currency","Exchange Rate"
|
|
2
|
+
2020-03-07,,"Compte courant",DE27100110000000000000,"Credit Transfer",,"Coffre fort",328.00,,,
|
|
3
|
+
2020-03-07,,"Compte courant",DE27100110000000000000,"Debit Transfer",,"Coffre fort",-328.00,,,
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "csv2ofx"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.34.0"
|
|
8
8
|
description = "converts a csv file of transactions to an ofx or qif file"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -39,7 +39,6 @@ csv2ofx = "csv2ofx.main:run"
|
|
|
39
39
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
test = [
|
|
42
|
-
"pygogo>=0.13.2,<2.0.0",
|
|
43
42
|
"pytest",
|
|
44
43
|
"pytest-enabler",
|
|
45
44
|
"pytest-ruff",
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
import pathlib
|
|
3
|
+
import shlex
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
SERVER_DATE = "-D 20161031112908"
|
|
9
|
+
|
|
10
|
+
samples = [
|
|
11
|
+
(["-oq"], "default.csv", "default.qif"),
|
|
12
|
+
(["-oq", "-m split_account"], "default.csv", "default_w_splits.qif"),
|
|
13
|
+
(["-oqc Description", "-m xero"], "xero.csv", "xero.qif"),
|
|
14
|
+
(["-oq", "-m mint"], "mint.csv", "mint.qif"),
|
|
15
|
+
(["-oq", "-m mint_extra"], "mint_extra.csv", "mint_extra.qif"),
|
|
16
|
+
(["-oq", "-m mint_headerless"], "mint_headerless.csv", "mint.qif"),
|
|
17
|
+
(["-oqs20150613", "-e20150614", "-m mint"], "mint.csv", "mint_alt.qif"),
|
|
18
|
+
(["-oe 20150908", SERVER_DATE], "default.csv", "default.ofx"),
|
|
19
|
+
(["-o", "-m split_account", SERVER_DATE], "default.csv", "default_w_splits.ofx"),
|
|
20
|
+
(["-o", "-m mint", SERVER_DATE], "mint.csv", "mint.ofx"),
|
|
21
|
+
(["-oq", "-m creditunion"], "creditunion.csv", "creditunion.qif"),
|
|
22
|
+
(
|
|
23
|
+
["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
|
|
24
|
+
"stripe-default.csv",
|
|
25
|
+
"stripe-default.ofx",
|
|
26
|
+
),
|
|
27
|
+
(
|
|
28
|
+
["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
|
|
29
|
+
"stripe-all.csv",
|
|
30
|
+
"stripe-all.ofx",
|
|
31
|
+
),
|
|
32
|
+
(["-oq", "-m stripe"], "stripe-default.csv", "stripe-default.qif"),
|
|
33
|
+
(["-oq", "-m stripe"], "stripe-all.csv", "stripe-all.qif"),
|
|
34
|
+
(
|
|
35
|
+
["-E windows-1252", "-m gls", SERVER_DATE, "-e 20171111", "-o"],
|
|
36
|
+
"gls.csv",
|
|
37
|
+
"gls.ofx",
|
|
38
|
+
),
|
|
39
|
+
(
|
|
40
|
+
["-o", "-m pcmastercard", "-e 20190120", SERVER_DATE],
|
|
41
|
+
"pcmastercard.csv",
|
|
42
|
+
"pcmastercard.ofx",
|
|
43
|
+
),
|
|
44
|
+
# (
|
|
45
|
+
# # N.B. input file obtained by pre-processing with
|
|
46
|
+
# # bin/csvtrim ubs-ch-fr.csv > ubs-ch-fr_trimmed.csv
|
|
47
|
+
# ["-oq", "-m ubs-ch-fr"], "ubs-ch-fr_trimmed.csv", "ubs-ch-fr.qif"
|
|
48
|
+
# ),
|
|
49
|
+
(
|
|
50
|
+
["-o", "-m ingesp", "-e 20221231", SERVER_DATE],
|
|
51
|
+
"ingesp.csv",
|
|
52
|
+
"ingesp.ofx",
|
|
53
|
+
),
|
|
54
|
+
(
|
|
55
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
56
|
+
"schwab-checking.csv",
|
|
57
|
+
"schwab-checking.ofx",
|
|
58
|
+
),
|
|
59
|
+
(
|
|
60
|
+
["-o", "-M", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
61
|
+
"schwab-checking.csv",
|
|
62
|
+
"schwab-checking-msmoney.ofx",
|
|
63
|
+
),
|
|
64
|
+
(
|
|
65
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
66
|
+
"schwab-checking-baltest-case1.csv",
|
|
67
|
+
"schwab-checking-baltest-case1.ofx",
|
|
68
|
+
),
|
|
69
|
+
(
|
|
70
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
71
|
+
"schwab-checking-baltest-case2.csv",
|
|
72
|
+
"schwab-checking-baltest-case2.ofx",
|
|
73
|
+
),
|
|
74
|
+
(
|
|
75
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
76
|
+
"schwab-checking-baltest-case3.csv",
|
|
77
|
+
"schwab-checking-baltest-case3.ofx",
|
|
78
|
+
),
|
|
79
|
+
(
|
|
80
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
81
|
+
"schwab-checking-baltest-case4.csv",
|
|
82
|
+
"schwab-checking-baltest-case4.ofx",
|
|
83
|
+
),
|
|
84
|
+
(
|
|
85
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
86
|
+
"schwab-checking-baltest-case5.csv",
|
|
87
|
+
"schwab-checking-baltest-case5.ofx",
|
|
88
|
+
),
|
|
89
|
+
(
|
|
90
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
91
|
+
"schwab-checking-baltest-case6.csv",
|
|
92
|
+
"schwab-checking-baltest-case6.ofx",
|
|
93
|
+
),
|
|
94
|
+
(
|
|
95
|
+
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
96
|
+
"schwab-checking-baltest-case7.csv",
|
|
97
|
+
"schwab-checking-baltest-case7.ofx",
|
|
98
|
+
),
|
|
99
|
+
(
|
|
100
|
+
["-o", "-m amazon", "-e 20230604", SERVER_DATE],
|
|
101
|
+
"amazon.csv",
|
|
102
|
+
"amazon.ofx",
|
|
103
|
+
),
|
|
104
|
+
(
|
|
105
|
+
["-o", "-m payoneer", "-e 20220905", SERVER_DATE],
|
|
106
|
+
"payoneer.csv",
|
|
107
|
+
"payoneer.ofx",
|
|
108
|
+
),
|
|
109
|
+
(
|
|
110
|
+
['-m', 'n26', SERVER_DATE],
|
|
111
|
+
'n26.csv',
|
|
112
|
+
'n26.ofx',
|
|
113
|
+
),
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@pytest.fixture(autouse=True)
|
|
118
|
+
def amazon_env(monkeypatch):
|
|
119
|
+
# for Amazon import; excludes transaction 3/3
|
|
120
|
+
monkeypatch.setenv("AMAZON_EXCLUDE_CARDS", "9876")
|
|
121
|
+
# clear the purchases account if set
|
|
122
|
+
monkeypatch.delenv("AMAZON_PURCHASES_ACCOUNT", raising=False)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
data = pathlib.Path('data')
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def flatten_opts(opts):
|
|
129
|
+
return list(param for group in opts for param in shlex.split(group))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@pytest.mark.parametrize(['opts', 'in_filename', 'out_filename'], samples)
|
|
133
|
+
def test_sample(opts, in_filename, out_filename):
|
|
134
|
+
arguments = [str(data / 'test' / in_filename)]
|
|
135
|
+
command = list(itertools.chain(['csv2ofx'], flatten_opts(opts), arguments))
|
|
136
|
+
proc = subprocess.run(
|
|
137
|
+
command, capture_output=True, text=True, encoding='utf-8', check=True
|
|
138
|
+
)
|
|
139
|
+
output = proc.stdout
|
|
140
|
+
|
|
141
|
+
expected = data.joinpath("converted", out_filename).read_text(encoding='utf-8')
|
|
142
|
+
assert output == expected, (
|
|
143
|
+
f"Unexpected output from {subprocess.list2cmdline(command)}"
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_help():
|
|
148
|
+
"""
|
|
149
|
+
Assert help command completes and is present in the README.
|
|
150
|
+
"""
|
|
151
|
+
out = subprocess.check_output(['csv2ofx', '--help'], text=True)
|
|
152
|
+
assert out
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@pytest.mark.xfail("sys.version_info < (3, 13)")
|
|
156
|
+
def test_help_in_readme():
|
|
157
|
+
out = subprocess.check_output(['csv2ofx', '--help'], text=True)
|
|
158
|
+
readme = pathlib.Path('README.md').read_text()
|
|
159
|
+
assert out in readme, "README help is stale, please update."
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
order id,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments
|
|
2
|
-
112-1635210-7125801,"Goof Off Household Heavy Duty Remover, 4 fl. oz. Spray, For Spots, Stains, Marks, and Messes; ",John Doe,2022-12-20,4.22,0,0,0,0.24,0,"Visa ending in 1234: December 24, 2022: $4.22; "
|
|
3
|
-
111-3273904-8117030,"Darksteve - Violet Decorative Light Bulb - Edison Light Bulb, Antique Vintage Style Light, G80 Size, E26 Base, Non-Dimmable (3w/110v); ",John Doe,2022-12-20,7.42,0,0,0,0.42,0,"Visa ending in 5566: December 28, 2022: $7.42; "
|
|
4
|
-
114-5269613-6941034,"TOPGREENER Smart Wi-Fi In-Wall Tamper Resistant Dual USB Charger Outlet, Energy Monitoring, Compatible with Amazon Alexa and Google Assistant, Outlet; ",John Doe,2022-10-11,34.12,0,0,0,1.93,0,"Visa ending in 9876: October 12, 2022: $34.12; "
|
|
5
|
-
order id,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments
|
csv2ofx-0.33.0/tests/test.py
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# vim: sw=4:ts=4:expandtab
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
tests.test
|
|
6
|
-
~~~~~~~~~~
|
|
7
|
-
|
|
8
|
-
Provides scripttests to test csv2ofx CLI functionality.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import builtins
|
|
12
|
-
import itertools
|
|
13
|
-
import os
|
|
14
|
-
import shlex
|
|
15
|
-
import subprocess
|
|
16
|
-
import sys
|
|
17
|
-
from difflib import unified_diff
|
|
18
|
-
from io import StringIO
|
|
19
|
-
from os import path as p
|
|
20
|
-
from timeit import default_timer as timer
|
|
21
|
-
|
|
22
|
-
import pygogo as gogo
|
|
23
|
-
|
|
24
|
-
sys.path.append("../csv2ofx")
|
|
25
|
-
|
|
26
|
-
PARENT_DIR = p.abspath(p.dirname(p.dirname(__file__)))
|
|
27
|
-
EXAMPLE_DIR = p.join(PARENT_DIR, "data", "test")
|
|
28
|
-
CHECK_DIR = p.join(PARENT_DIR, "data", "converted")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def filter_output(outlines, debug_stmts=None):
|
|
32
|
-
"""Remove meza debugging statements"""
|
|
33
|
-
def_stmts = ["File was opened in", "Decoding file with encoding"]
|
|
34
|
-
debug_stmts = debug_stmts or def_stmts
|
|
35
|
-
|
|
36
|
-
for line in outlines:
|
|
37
|
-
if not any(stmt in line for stmt in debug_stmts):
|
|
38
|
-
yield line
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def flatten_opts(opts):
|
|
42
|
-
return list(param for group in opts for param in shlex.split(group))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def main(tests, verbose=False, stop=True):
|
|
46
|
-
"""
|
|
47
|
-
Returns 0 on success, 1 on failure
|
|
48
|
-
"""
|
|
49
|
-
failures = 0
|
|
50
|
-
logger = gogo.Gogo(__name__, verbose=verbose).logger
|
|
51
|
-
|
|
52
|
-
start = timer()
|
|
53
|
-
for pos, test in enumerate(tests):
|
|
54
|
-
num = pos + 1
|
|
55
|
-
opts, arguments, expected = test
|
|
56
|
-
resolved_args = list(itertools.chain(flatten_opts(opts), arguments))
|
|
57
|
-
command = ["csv2ofx"] + resolved_args
|
|
58
|
-
short_command = f"csv2ofx {subprocess.list2cmdline(resolved_args)}"
|
|
59
|
-
proc = subprocess.run(command, capture_output=True, text=True, encoding='utf-8')
|
|
60
|
-
output = proc.stdout
|
|
61
|
-
|
|
62
|
-
if isinstance(expected, bool):
|
|
63
|
-
text = StringIO(output).read()
|
|
64
|
-
outlines = [str(bool(text))]
|
|
65
|
-
checklines = StringIO(str(expected)).readlines()
|
|
66
|
-
elif p.isfile(expected):
|
|
67
|
-
outlines = StringIO(output).readlines()
|
|
68
|
-
|
|
69
|
-
with builtins.open(expected, encoding="utf-8") as f:
|
|
70
|
-
checklines = f.readlines()
|
|
71
|
-
else:
|
|
72
|
-
outlines = StringIO(output).readlines()
|
|
73
|
-
checklines = StringIO(expected).readlines()
|
|
74
|
-
|
|
75
|
-
args = [checklines, list(filter_output(outlines))]
|
|
76
|
-
kwargs = {"fromfile": "expected", "tofile": "got"}
|
|
77
|
-
diffs = "".join(unified_diff(*args, **kwargs))
|
|
78
|
-
|
|
79
|
-
if diffs:
|
|
80
|
-
failures += 1
|
|
81
|
-
msg = f"ERROR! Output from test #{num}:\n {short_command}\n"
|
|
82
|
-
msg += f"doesn't match:\n {expected}\n"
|
|
83
|
-
msg += diffs if diffs else ""
|
|
84
|
-
else:
|
|
85
|
-
logger.debug(output)
|
|
86
|
-
msg = f"Scripttest #{num}: {short_command} ... ok"
|
|
87
|
-
|
|
88
|
-
logger.info(msg)
|
|
89
|
-
|
|
90
|
-
if stop and failures:
|
|
91
|
-
break
|
|
92
|
-
|
|
93
|
-
time = timer() - start
|
|
94
|
-
logger.info("{}".format("-") * 70)
|
|
95
|
-
end = f"FAILED (failures={failures})" if failures else "OK"
|
|
96
|
-
logger.info(f"Ran {num} scripttests in {time:.3f}s\n\n{end}")
|
|
97
|
-
sys.exit(failures)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if __name__ == "__main__":
|
|
101
|
-
|
|
102
|
-
def gen_test(raw):
|
|
103
|
-
"""Generate test arguments"""
|
|
104
|
-
for opts, _in, _out in raw:
|
|
105
|
-
if _in and _out:
|
|
106
|
-
args = [p.join(EXAMPLE_DIR, _in)]
|
|
107
|
-
yield (opts, args, p.join(CHECK_DIR, _out))
|
|
108
|
-
else:
|
|
109
|
-
yield (opts, _in, _out)
|
|
110
|
-
|
|
111
|
-
MINT_ALT_OPTS = ["-oqs20150613", "-e20150614", "-m mint"]
|
|
112
|
-
SERVER_DATE = "-D 20161031112908"
|
|
113
|
-
SPLIT_OPTS = ["-o", "-m split_account", SERVER_DATE]
|
|
114
|
-
PRE_TESTS = [
|
|
115
|
-
(["--help"], [], True),
|
|
116
|
-
(["-oq"], "default.csv", "default.qif"),
|
|
117
|
-
(["-oq", "-m split_account"], "default.csv", "default_w_splits.qif"),
|
|
118
|
-
(["-oqc Description", "-m xero"], "xero.csv", "xero.qif"),
|
|
119
|
-
(["-oq", "-m mint"], "mint.csv", "mint.qif"),
|
|
120
|
-
(["-oq", "-m mint_extra"], "mint_extra.csv", "mint_extra.qif"),
|
|
121
|
-
(["-oq", "-m mint_headerless"], "mint_headerless.csv", "mint.qif"),
|
|
122
|
-
(MINT_ALT_OPTS, "mint.csv", "mint_alt.qif"),
|
|
123
|
-
(["-oe 20150908", SERVER_DATE], "default.csv", "default.ofx"),
|
|
124
|
-
(SPLIT_OPTS, "default.csv", "default_w_splits.ofx"),
|
|
125
|
-
(["-o", "-m mint", SERVER_DATE], "mint.csv", "mint.ofx"),
|
|
126
|
-
(["-oq", "-m creditunion"], "creditunion.csv", "creditunion.qif"),
|
|
127
|
-
(
|
|
128
|
-
["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
|
|
129
|
-
"stripe-default.csv",
|
|
130
|
-
"stripe-default.ofx",
|
|
131
|
-
),
|
|
132
|
-
(
|
|
133
|
-
["-o", "-m stripe", "-e", "20210505", SERVER_DATE],
|
|
134
|
-
"stripe-all.csv",
|
|
135
|
-
"stripe-all.ofx",
|
|
136
|
-
),
|
|
137
|
-
(["-oq", "-m stripe"], "stripe-default.csv", "stripe-default.qif"),
|
|
138
|
-
(["-oq", "-m stripe"], "stripe-all.csv", "stripe-all.qif"),
|
|
139
|
-
(
|
|
140
|
-
["-E windows-1252", "-m gls", SERVER_DATE, "-e 20171111", "-o"],
|
|
141
|
-
"gls.csv",
|
|
142
|
-
"gls.ofx",
|
|
143
|
-
),
|
|
144
|
-
(
|
|
145
|
-
["-o", "-m pcmastercard", "-e 20190120", SERVER_DATE],
|
|
146
|
-
"pcmastercard.csv",
|
|
147
|
-
"pcmastercard.ofx",
|
|
148
|
-
),
|
|
149
|
-
# (
|
|
150
|
-
# # N.B. input file obtained by pre-processing with
|
|
151
|
-
# # bin/csvtrim ubs-ch-fr.csv > ubs-ch-fr_trimmed.csv
|
|
152
|
-
# ["-oq", "-m ubs-ch-fr"], "ubs-ch-fr_trimmed.csv", "ubs-ch-fr.qif"
|
|
153
|
-
# ),
|
|
154
|
-
(
|
|
155
|
-
["-o", "-m ingesp", "-e 20221231", SERVER_DATE],
|
|
156
|
-
"ingesp.csv",
|
|
157
|
-
"ingesp.ofx",
|
|
158
|
-
),
|
|
159
|
-
(
|
|
160
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
161
|
-
"schwab-checking.csv",
|
|
162
|
-
"schwab-checking.ofx",
|
|
163
|
-
),
|
|
164
|
-
(
|
|
165
|
-
["-o", "-M", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
166
|
-
"schwab-checking.csv",
|
|
167
|
-
"schwab-checking-msmoney.ofx",
|
|
168
|
-
),
|
|
169
|
-
(
|
|
170
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
171
|
-
"schwab-checking-baltest-case1.csv",
|
|
172
|
-
"schwab-checking-baltest-case1.ofx",
|
|
173
|
-
),
|
|
174
|
-
(
|
|
175
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
176
|
-
"schwab-checking-baltest-case2.csv",
|
|
177
|
-
"schwab-checking-baltest-case2.ofx",
|
|
178
|
-
),
|
|
179
|
-
(
|
|
180
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
181
|
-
"schwab-checking-baltest-case3.csv",
|
|
182
|
-
"schwab-checking-baltest-case3.ofx",
|
|
183
|
-
),
|
|
184
|
-
(
|
|
185
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
186
|
-
"schwab-checking-baltest-case4.csv",
|
|
187
|
-
"schwab-checking-baltest-case4.ofx",
|
|
188
|
-
),
|
|
189
|
-
(
|
|
190
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
191
|
-
"schwab-checking-baltest-case5.csv",
|
|
192
|
-
"schwab-checking-baltest-case5.ofx",
|
|
193
|
-
),
|
|
194
|
-
(
|
|
195
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
196
|
-
"schwab-checking-baltest-case6.csv",
|
|
197
|
-
"schwab-checking-baltest-case6.ofx",
|
|
198
|
-
),
|
|
199
|
-
(
|
|
200
|
-
["-o", "-m schwabchecking", "-e 20220905", SERVER_DATE],
|
|
201
|
-
"schwab-checking-baltest-case7.csv",
|
|
202
|
-
"schwab-checking-baltest-case7.ofx",
|
|
203
|
-
),
|
|
204
|
-
(
|
|
205
|
-
["-o", "-m amazon", "-e 20230604", SERVER_DATE],
|
|
206
|
-
"amazon.csv",
|
|
207
|
-
"amazon.ofx",
|
|
208
|
-
),
|
|
209
|
-
(
|
|
210
|
-
["-o", "-m payoneer", "-e 20220905", SERVER_DATE],
|
|
211
|
-
"payoneer.csv",
|
|
212
|
-
"payoneer.ofx",
|
|
213
|
-
),
|
|
214
|
-
]
|
|
215
|
-
|
|
216
|
-
# for Amazon import; excludes transaction 3/3
|
|
217
|
-
os.environ["AMAZON_EXCLUDE_CARDS"] = "9876"
|
|
218
|
-
# clear the purchases account if set
|
|
219
|
-
os.environ.pop("AMAZON_PURCHASES_ACCOUNT", None)
|
|
220
|
-
assert "AMAZON_PURCHASES_ACCOUNT" not in os.environ
|
|
221
|
-
|
|
222
|
-
main(gen_test(PRE_TESTS))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|