csv2ofx 0.30.0__tar.gz → 0.32.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.30.0/csv2ofx.egg-info → csv2ofx-0.32.0}/PKG-INFO +37 -34
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/README.md +28 -13
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/__init__.py +13 -2
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/main.py +26 -8
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/ofx.py +280 -16
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/qif.py +2 -1
- {csv2ofx-0.30.0 → csv2ofx-0.32.0/csv2ofx.egg-info}/PKG-INFO +37 -34
- csv2ofx-0.32.0/csv2ofx.egg-info/SOURCES.txt +35 -0
- csv2ofx-0.32.0/csv2ofx.egg-info/entry_points.txt +2 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/requires.txt +1 -1
- csv2ofx-0.32.0/dev-requirements.txt +3 -0
- csv2ofx-0.32.0/pyproject.toml +39 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/requirements.txt +1 -1
- csv2ofx-0.32.0/setup.cfg +4 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/tests/test.py +66 -3
- csv2ofx-0.30.0/bin/csv2ofx +0 -16
- csv2ofx-0.30.0/csv2ofx/mappings/__init__.py +0 -6
- csv2ofx-0.30.0/csv2ofx/mappings/abnamro.py +0 -12
- csv2ofx-0.30.0/csv2ofx/mappings/bnp.py +0 -17
- csv2ofx-0.30.0/csv2ofx/mappings/boursorama.py +0 -18
- csv2ofx-0.30.0/csv2ofx/mappings/capitalone.py +0 -15
- csv2ofx-0.30.0/csv2ofx/mappings/creditunion.py +0 -14
- csv2ofx-0.30.0/csv2ofx/mappings/custom.py +0 -21
- csv2ofx-0.30.0/csv2ofx/mappings/default.py +0 -17
- csv2ofx-0.30.0/csv2ofx/mappings/eqbank.py +0 -14
- csv2ofx-0.30.0/csv2ofx/mappings/exim.py +0 -13
- csv2ofx-0.30.0/csv2ofx/mappings/gls.py +0 -25
- csv2ofx-0.30.0/csv2ofx/mappings/ingdirect.py +0 -20
- csv2ofx-0.30.0/csv2ofx/mappings/mdb.py +0 -22
- csv2ofx-0.30.0/csv2ofx/mappings/mint.py +0 -23
- csv2ofx-0.30.0/csv2ofx/mappings/mint_extra.py +0 -28
- csv2ofx-0.30.0/csv2ofx/mappings/mint_headerless.py +0 -22
- csv2ofx-0.30.0/csv2ofx/mappings/mintapi.py +0 -30
- csv2ofx-0.30.0/csv2ofx/mappings/msmoneyreport.py +0 -16
- csv2ofx-0.30.0/csv2ofx/mappings/n26.py +0 -34
- csv2ofx-0.30.0/csv2ofx/mappings/outbank.py +0 -23
- csv2ofx-0.30.0/csv2ofx/mappings/paychex.py +0 -24
- csv2ofx-0.30.0/csv2ofx/mappings/pcmastercard.py +0 -15
- csv2ofx-0.30.0/csv2ofx/mappings/rabobank.py +0 -31
- csv2ofx-0.30.0/csv2ofx/mappings/schwab.py +0 -19
- csv2ofx-0.30.0/csv2ofx/mappings/split_account.py +0 -18
- csv2ofx-0.30.0/csv2ofx/mappings/starling.py +0 -16
- csv2ofx-0.30.0/csv2ofx/mappings/stripe.py +0 -31
- csv2ofx-0.30.0/csv2ofx/mappings/ubs-ch-fr.py +0 -72
- csv2ofx-0.30.0/csv2ofx/mappings/ubs.py +0 -16
- csv2ofx-0.30.0/csv2ofx/mappings/xero.py +0 -14
- csv2ofx-0.30.0/csv2ofx/mappings/yodlee.py +0 -23
- csv2ofx-0.30.0/csv2ofx.egg-info/SOURCES.txt +0 -73
- csv2ofx-0.30.0/csv2ofx.egg-info/not-zip-safe +0 -1
- csv2ofx-0.30.0/dev-requirements.txt +0 -15
- csv2ofx-0.30.0/helpers/.DS_Store +0 -0
- csv2ofx-0.30.0/helpers/pippy +0 -61
- csv2ofx-0.30.0/pyproject.toml +0 -3
- csv2ofx-0.30.0/setup.cfg +0 -31
- csv2ofx-0.30.0/setup.py +0 -77
- csv2ofx-0.30.0/tests/.DS_Store +0 -0
- csv2ofx-0.30.0/tests/pylintrc +0 -254
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/LICENSE +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/MANIFEST.in +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/utils.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/dependency_links.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/top_level.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFX 2.1.1.pdf +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFXAudit.xls +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFX_Message_Support.doc +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_002.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_003.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_004.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_005.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/bootstrap.js +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/jquery.js +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/sitecss.css +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/qif-file-format.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/check-stage +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/clean +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/srcdist +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/wheel +0 -0
|
@@ -1,38 +1,28 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: csv2ofx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.32.0
|
|
4
4
|
Summary: converts a csv file of transactions to an ofx or qif file
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Download-URL: https://github.com/reubano/csv2ofx/archive/v0.30.0.tar.gz
|
|
10
|
-
Keywords: csv2ofx,converts,a,csv,file,of,transactions,to,an,ofx,or,qif,file
|
|
11
|
-
Platform: MacOS X
|
|
12
|
-
Platform: Windows
|
|
13
|
-
Platform: Linux
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Author-email: Reuben Cummings <reubano@gmail.com>
|
|
6
|
+
Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
|
|
7
|
+
Project-URL: Source, https://github.com/reubano/csv2ofx
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
9
|
Classifier: Natural Language :: English
|
|
17
10
|
Classifier: Programming Language :: Python :: 3
|
|
18
11
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
22
12
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
13
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
14
|
Classifier: Environment :: Console
|
|
25
15
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
16
|
Classifier: Intended Audience :: Developers
|
|
27
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
28
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
29
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
30
17
|
Description-Content-Type: text/markdown
|
|
31
18
|
License-File: LICENSE
|
|
19
|
+
Requires-Dist: python-dateutil<3.0.0,>=2.7.2
|
|
20
|
+
Requires-Dist: requests<3.0.0,>=2.18.4
|
|
21
|
+
Requires-Dist: meza<0.48.0,>=0.47.0
|
|
32
22
|
|
|
33
23
|
# csv2ofx
|
|
34
24
|
|
|
35
|
-
[](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
|
|
36
26
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
37
27
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
38
28
|
|
|
@@ -112,21 +102,23 @@ usage: csv2ofx [options] <source> <dest>
|
|
|
112
102
|
description: csv2ofx converts a csv file to ofx and qif
|
|
113
103
|
|
|
114
104
|
positional arguments:
|
|
115
|
-
source the source csv file (
|
|
116
|
-
dest the output file (
|
|
105
|
+
source the source csv file (default: stdin)
|
|
106
|
+
dest the output file (default: stdout)
|
|
117
107
|
|
|
118
108
|
optional arguments:
|
|
119
109
|
-h, --help show this help message and exit
|
|
120
110
|
-a TYPE, --account TYPE
|
|
121
111
|
default account type 'CHECKING' for OFX and 'Bank' for QIF.
|
|
122
|
-
-e DATE, --end DATE end date
|
|
112
|
+
-e DATE, --end DATE end date (default: today)
|
|
113
|
+
-B BALANCE, --ending-balance BALANCE
|
|
114
|
+
ending balance (default: None)
|
|
123
115
|
-l LANGUAGE, --language LANGUAGE
|
|
124
|
-
the language
|
|
116
|
+
the language (default: ENG)
|
|
125
117
|
-s DATE, --start DATE
|
|
126
118
|
the start date
|
|
127
119
|
-y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
|
|
128
|
-
-m
|
|
129
|
-
the account mapping
|
|
120
|
+
-m MAPPING_NAME, --mapping MAPPING_NAME
|
|
121
|
+
the account mapping (default: default)
|
|
130
122
|
-x FILE_PATH, --custom FILE_PATH
|
|
131
123
|
path to a custom mapping file
|
|
132
124
|
-c FIELD_NAME, --collapse FIELD_NAME
|
|
@@ -134,16 +126,17 @@ optional arguments:
|
|
|
134
126
|
-C ROWS, --chunksize ROWS
|
|
135
127
|
number of rows to process at a time (default: 2 ** 14)
|
|
136
128
|
-r ROWS, --first-row ROWS
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
the
|
|
129
|
+
the first row to process (zero based)
|
|
130
|
+
-R ROWS, --last-row ROWS
|
|
131
|
+
the last row to process (zero based, negative values count from the end)
|
|
140
132
|
-O COLS, --first-col COLS
|
|
141
|
-
|
|
133
|
+
the first column to process (zero based)
|
|
142
134
|
-L, --list-mappings list the available mappings
|
|
143
135
|
-V, --version show version and exit
|
|
144
136
|
-q, --qif enables 'QIF' output instead of 'OFX'
|
|
137
|
+
-M, --ms-money enables MS Money compatible 'OFX' output
|
|
145
138
|
-o, --overwrite overwrite destination file if it exists
|
|
146
|
-
-D
|
|
139
|
+
-D DATE, --server-date DATE
|
|
147
140
|
OFX server date (default: source file mtime)
|
|
148
141
|
-E ENCODING, --encoding ENCODING
|
|
149
142
|
File encoding (default: utf-8)
|
|
@@ -175,6 +168,17 @@ optional arguments:
|
|
|
175
168
|
|
|
176
169
|
csv2ofx -m yoodlee file.csv
|
|
177
170
|
|
|
171
|
+
|
|
172
|
+
#### Special cases
|
|
173
|
+
|
|
174
|
+
Some banks, like *UBS Switzerland*, may provide CSV exports that are not
|
|
175
|
+
readily tractable by csv2ofx because of extra header or trailing lines,
|
|
176
|
+
redundant or unwanted columns. These input files can be preprocessed with the
|
|
177
|
+
shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
|
|
178
|
+
|
|
179
|
+
csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
|
|
180
|
+
|
|
181
|
+
|
|
178
182
|
## CUSTOMIZATION
|
|
179
183
|
|
|
180
184
|
### Code modification
|
|
@@ -239,6 +243,7 @@ attribute | description | default field | default value | example
|
|
|
239
243
|
attribute | description | default value | example
|
|
240
244
|
----------|-------------|---------------|--------
|
|
241
245
|
`has_header`|does the csv file have a header row|True
|
|
246
|
+
`custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
|
|
242
247
|
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
243
248
|
`currency`|the currency ISO code|USD|GBP
|
|
244
249
|
`delimiter`|the csv field delimiter|,|;
|
|
@@ -283,7 +288,7 @@ cd csv2ofx
|
|
|
283
288
|
2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
|
|
284
289
|
|
|
285
290
|
```bash
|
|
286
|
-
mkvirtualenv
|
|
291
|
+
mkvirtualenv -i pkutils csv2ofx
|
|
287
292
|
activate csv2ofx
|
|
288
293
|
python setup.py develop
|
|
289
294
|
pip install -r dev-requirements.txt
|
|
@@ -310,5 +315,3 @@ How to contribute a mapping:
|
|
|
310
315
|
## License
|
|
311
316
|
|
|
312
317
|
csv2ofx is distributed under the [MIT License](http://opensource.org/licenses/MIT), the same as [meza](https://github.com/reubano/meza).
|
|
313
|
-
|
|
314
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# csv2ofx
|
|
2
2
|
|
|
3
|
-
[](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
|
|
4
4
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
5
5
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
6
6
|
|
|
@@ -80,21 +80,23 @@ usage: csv2ofx [options] <source> <dest>
|
|
|
80
80
|
description: csv2ofx converts a csv file to ofx and qif
|
|
81
81
|
|
|
82
82
|
positional arguments:
|
|
83
|
-
source the source csv file (
|
|
84
|
-
dest the output file (
|
|
83
|
+
source the source csv file (default: stdin)
|
|
84
|
+
dest the output file (default: stdout)
|
|
85
85
|
|
|
86
86
|
optional arguments:
|
|
87
87
|
-h, --help show this help message and exit
|
|
88
88
|
-a TYPE, --account TYPE
|
|
89
89
|
default account type 'CHECKING' for OFX and 'Bank' for QIF.
|
|
90
|
-
-e DATE, --end DATE end date
|
|
90
|
+
-e DATE, --end DATE end date (default: today)
|
|
91
|
+
-B BALANCE, --ending-balance BALANCE
|
|
92
|
+
ending balance (default: None)
|
|
91
93
|
-l LANGUAGE, --language LANGUAGE
|
|
92
|
-
the language
|
|
94
|
+
the language (default: ENG)
|
|
93
95
|
-s DATE, --start DATE
|
|
94
96
|
the start date
|
|
95
97
|
-y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
|
|
96
|
-
-m
|
|
97
|
-
the account mapping
|
|
98
|
+
-m MAPPING_NAME, --mapping MAPPING_NAME
|
|
99
|
+
the account mapping (default: default)
|
|
98
100
|
-x FILE_PATH, --custom FILE_PATH
|
|
99
101
|
path to a custom mapping file
|
|
100
102
|
-c FIELD_NAME, --collapse FIELD_NAME
|
|
@@ -102,16 +104,17 @@ optional arguments:
|
|
|
102
104
|
-C ROWS, --chunksize ROWS
|
|
103
105
|
number of rows to process at a time (default: 2 ** 14)
|
|
104
106
|
-r ROWS, --first-row ROWS
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
the
|
|
107
|
+
the first row to process (zero based)
|
|
108
|
+
-R ROWS, --last-row ROWS
|
|
109
|
+
the last row to process (zero based, negative values count from the end)
|
|
108
110
|
-O COLS, --first-col COLS
|
|
109
|
-
|
|
111
|
+
the first column to process (zero based)
|
|
110
112
|
-L, --list-mappings list the available mappings
|
|
111
113
|
-V, --version show version and exit
|
|
112
114
|
-q, --qif enables 'QIF' output instead of 'OFX'
|
|
115
|
+
-M, --ms-money enables MS Money compatible 'OFX' output
|
|
113
116
|
-o, --overwrite overwrite destination file if it exists
|
|
114
|
-
-D
|
|
117
|
+
-D DATE, --server-date DATE
|
|
115
118
|
OFX server date (default: source file mtime)
|
|
116
119
|
-E ENCODING, --encoding ENCODING
|
|
117
120
|
File encoding (default: utf-8)
|
|
@@ -143,6 +146,17 @@ optional arguments:
|
|
|
143
146
|
|
|
144
147
|
csv2ofx -m yoodlee file.csv
|
|
145
148
|
|
|
149
|
+
|
|
150
|
+
#### Special cases
|
|
151
|
+
|
|
152
|
+
Some banks, like *UBS Switzerland*, may provide CSV exports that are not
|
|
153
|
+
readily tractable by csv2ofx because of extra header or trailing lines,
|
|
154
|
+
redundant or unwanted columns. These input files can be preprocessed with the
|
|
155
|
+
shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
|
|
156
|
+
|
|
157
|
+
csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
|
|
158
|
+
|
|
159
|
+
|
|
146
160
|
## CUSTOMIZATION
|
|
147
161
|
|
|
148
162
|
### Code modification
|
|
@@ -207,6 +221,7 @@ attribute | description | default field | default value | example
|
|
|
207
221
|
attribute | description | default value | example
|
|
208
222
|
----------|-------------|---------------|--------
|
|
209
223
|
`has_header`|does the csv file have a header row|True
|
|
224
|
+
`custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
|
|
210
225
|
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
211
226
|
`currency`|the currency ISO code|USD|GBP
|
|
212
227
|
`delimiter`|the csv field delimiter|,|;
|
|
@@ -251,7 +266,7 @@ cd csv2ofx
|
|
|
251
266
|
2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
|
|
252
267
|
|
|
253
268
|
```bash
|
|
254
|
-
mkvirtualenv
|
|
269
|
+
mkvirtualenv -i pkutils csv2ofx
|
|
255
270
|
activate csv2ofx
|
|
256
271
|
python setup.py develop
|
|
257
272
|
pip install -r dev-requirements.txt
|
|
@@ -37,7 +37,7 @@ __package_name__ = "csv2ofx"
|
|
|
37
37
|
__author__ = "Reuben Cummings"
|
|
38
38
|
__description__ = "converts a csv file of transactions to an ofx or qif file"
|
|
39
39
|
__email__ = "reubano@gmail.com"
|
|
40
|
-
__version__ = "0.
|
|
40
|
+
__version__ = "0.32.0"
|
|
41
41
|
__license__ = "MIT"
|
|
42
42
|
__copyright__ = "Copyright 2015 Reuben Cummings"
|
|
43
43
|
|
|
@@ -46,6 +46,12 @@ __copyright__ = "Copyright 2015 Reuben Cummings"
|
|
|
46
46
|
md5 = lambda content: hashlib.md5(content.encode("utf-8")).hexdigest()
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
class BalanceError(Exception):
|
|
50
|
+
"""Raised if no ending balance when MS Money compatible output requested"""
|
|
51
|
+
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
49
55
|
class Content(object): # pylint: disable=too-many-instance-attributes
|
|
50
56
|
"""A transaction holding object"""
|
|
51
57
|
|
|
@@ -76,6 +82,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
76
82
|
self.parse_fmt = kwargs.get("parse_fmt")
|
|
77
83
|
self.dayfirst = kwargs.get("dayfirst")
|
|
78
84
|
self.filter = kwargs.get("filter")
|
|
85
|
+
self.ms_money = kwargs.get("ms_money")
|
|
79
86
|
self.split_account = None
|
|
80
87
|
self.inv_split_account = None
|
|
81
88
|
self.id = None
|
|
@@ -226,7 +233,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
226
233
|
... 'split_account': 'Checking', 'type': 'DEBIT',
|
|
227
234
|
... 'category': '', 'amount': Decimal('-1000.00'),
|
|
228
235
|
... 'memo': 'description notes', 'inv_split_account': None,
|
|
229
|
-
... 'x_action': ''}
|
|
236
|
+
... 'x_action': '', 'balance': None}
|
|
230
237
|
True
|
|
231
238
|
"""
|
|
232
239
|
account = self.get("account", trxn)
|
|
@@ -251,6 +258,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
251
258
|
symbol = self.get("symbol", trxn, "")
|
|
252
259
|
price = Decimal(self.get("price", trxn, 0))
|
|
253
260
|
invest = shares or (symbol and symbol != "N/A") or "invest" in category
|
|
261
|
+
balance = self.get("balance", trxn)
|
|
262
|
+
if balance is not None:
|
|
263
|
+
balance = utils.convert_amount(balance)
|
|
254
264
|
|
|
255
265
|
if invest:
|
|
256
266
|
amount = abs(amount)
|
|
@@ -288,6 +298,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
288
298
|
"id": self.get("id", trxn, check_num) or md5(details),
|
|
289
299
|
"check_num": check_num,
|
|
290
300
|
"type": _type,
|
|
301
|
+
"balance": balance,
|
|
291
302
|
}
|
|
292
303
|
|
|
293
304
|
def gen_trxns(self, groups, collapse=False):
|
|
@@ -16,13 +16,13 @@ Examples:
|
|
|
16
16
|
Attributes:
|
|
17
17
|
ENCODING (str): Default file encoding.
|
|
18
18
|
"""
|
|
19
|
+
|
|
19
20
|
import time
|
|
20
21
|
import itertools as it
|
|
21
22
|
import traceback
|
|
22
23
|
|
|
23
24
|
from sys import stdin, stdout, exit
|
|
24
|
-
from importlib import import_module
|
|
25
|
-
from imp import find_module, load_module
|
|
25
|
+
from importlib import import_module, util
|
|
26
26
|
from pkgutil import iter_modules
|
|
27
27
|
from operator import itemgetter
|
|
28
28
|
from os import path as p
|
|
@@ -41,7 +41,7 @@ from builtins import *
|
|
|
41
41
|
from dateutil.parser import parse
|
|
42
42
|
from meza.io import read_csv, IterStringIO, write
|
|
43
43
|
|
|
44
|
-
from . import utils
|
|
44
|
+
from . import BalanceError, utils
|
|
45
45
|
from .ofx import OFX
|
|
46
46
|
from .qif import QIF
|
|
47
47
|
|
|
@@ -77,6 +77,13 @@ parser.add_argument(
|
|
|
77
77
|
help="end date (default: today)",
|
|
78
78
|
default=str(dt.now()),
|
|
79
79
|
)
|
|
80
|
+
parser.add_argument(
|
|
81
|
+
"-B",
|
|
82
|
+
"--ending-balance",
|
|
83
|
+
metavar="BALANCE",
|
|
84
|
+
type=float,
|
|
85
|
+
help="ending balance (default: None)",
|
|
86
|
+
)
|
|
80
87
|
parser.add_argument(
|
|
81
88
|
"-l", "--language", help="the language (default: ENG)", default="ENG"
|
|
82
89
|
)
|
|
@@ -104,8 +111,7 @@ parser.add_argument(
|
|
|
104
111
|
"--collapse",
|
|
105
112
|
metavar="FIELD_NAME",
|
|
106
113
|
help=(
|
|
107
|
-
"field used to combine transactions within a split for double entry "
|
|
108
|
-
"statements"
|
|
114
|
+
"field used to combine transactions within a split for double entry statements"
|
|
109
115
|
),
|
|
110
116
|
)
|
|
111
117
|
parser.add_argument(
|
|
@@ -157,6 +163,13 @@ parser.add_argument(
|
|
|
157
163
|
action="store_true",
|
|
158
164
|
default=False,
|
|
159
165
|
)
|
|
166
|
+
parser.add_argument(
|
|
167
|
+
"-M",
|
|
168
|
+
"--ms-money",
|
|
169
|
+
help="enables MS Money compatible 'OFX' output",
|
|
170
|
+
action="store_true",
|
|
171
|
+
default=False,
|
|
172
|
+
)
|
|
160
173
|
parser.add_argument(
|
|
161
174
|
"-o",
|
|
162
175
|
"--overwrite",
|
|
@@ -205,8 +218,9 @@ def run(): # noqa: C901
|
|
|
205
218
|
|
|
206
219
|
if args.custom:
|
|
207
220
|
name = p.splitext(p.split(args.custom)[1])[0]
|
|
208
|
-
|
|
209
|
-
module =
|
|
221
|
+
spec = util.spec_from_file_location(name, args.custom)
|
|
222
|
+
module = util.module_from_spec(spec)
|
|
223
|
+
spec.loader.exec_module(module)
|
|
210
224
|
else:
|
|
211
225
|
module = import_module("csv2ofx.mappings.%s" % args.mapping)
|
|
212
226
|
|
|
@@ -216,6 +230,7 @@ def run(): # noqa: C901
|
|
|
216
230
|
"def_type": args.account_type or "Bank" if args.qif else "CHECKING",
|
|
217
231
|
"start": parse(args.start, dayfirst=args.dayfirst) if args.start else None,
|
|
218
232
|
"end": parse(args.end, dayfirst=args.dayfirst) if args.end else None,
|
|
233
|
+
"ms_money": args.ms_money,
|
|
219
234
|
}
|
|
220
235
|
|
|
221
236
|
cont = QIF(mapping, **okwargs) if args.qif else OFX(mapping, **okwargs)
|
|
@@ -223,6 +238,7 @@ def run(): # noqa: C901
|
|
|
223
238
|
|
|
224
239
|
ckwargs = {
|
|
225
240
|
"has_header": cont.has_header,
|
|
241
|
+
"custom_header": getattr(cont, "custom_header", None),
|
|
226
242
|
"delimiter": mapping.get("delimiter", ","),
|
|
227
243
|
"first_row": mapping.get("first_row", args.first_row),
|
|
228
244
|
"last_row": mapping.get("last_row", args.last_row),
|
|
@@ -248,7 +264,7 @@ def run(): # noqa: C901
|
|
|
248
264
|
server_date = dt.fromtimestamp(mtime)
|
|
249
265
|
|
|
250
266
|
header = cont.header(date=server_date, language=args.language)
|
|
251
|
-
footer = cont.footer(date=server_date)
|
|
267
|
+
footer = cont.footer(date=server_date, balance=args.ending_balance)
|
|
252
268
|
filtered = filter(None, [header, body, footer])
|
|
253
269
|
content = it.chain.from_iterable(filtered)
|
|
254
270
|
kwargs = {
|
|
@@ -277,6 +293,8 @@ def run(): # noqa: C901
|
|
|
277
293
|
# csv2ofx called with no arguments or broken mapping
|
|
278
294
|
msg = "Possible mapping problem: %s. " % str(err)
|
|
279
295
|
parser.print_help()
|
|
296
|
+
except BalanceError as err:
|
|
297
|
+
msg = "%s. Try again with `--ending-balance` option." % err
|
|
280
298
|
except Exception: # pylint: disable=broad-except
|
|
281
299
|
msg = 1
|
|
282
300
|
traceback.print_exc()
|