csv2ofx 0.30.0__tar.gz → 0.31.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.31.0}/PKG-INFO +48 -18
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/README.md +28 -13
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/__init__.py +13 -2
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/main.py +26 -8
- csv2ofx-0.31.0/csv2ofx/mappings/amazon.py +61 -0
- csv2ofx-0.31.0/csv2ofx/mappings/ingesp.py +70 -0
- csv2ofx-0.31.0/csv2ofx/mappings/schwabchecking.py +67 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ubs-ch-fr.py +14 -9
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/ofx.py +280 -16
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/qif.py +2 -1
- {csv2ofx-0.30.0 → csv2ofx-0.31.0/csv2ofx.egg-info}/PKG-INFO +48 -18
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/SOURCES.txt +3 -7
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/requires.txt +1 -1
- csv2ofx-0.31.0/dev-requirements.txt +10 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/requirements.txt +1 -1
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/setup.cfg +4 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/tests/test.py +61 -3
- csv2ofx-0.30.0/csv2ofx/mappings/bnp.py +0 -17
- csv2ofx-0.30.0/csv2ofx/mappings/paychex.py +0 -24
- csv2ofx-0.30.0/csv2ofx/mappings/schwab.py +0 -19
- 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/tests/.DS_Store +0 -0
- csv2ofx-0.30.0/tests/pylintrc +0 -254
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/LICENSE +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/MANIFEST.in +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/bin/csv2ofx +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/__init__.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/abnamro.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/boursorama.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/capitalone.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/creditunion.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/custom.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/default.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/eqbank.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/exim.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/gls.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ingdirect.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mdb.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mint.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mint_extra.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mint_headerless.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mintapi.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/msmoneyreport.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/n26.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/outbank.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/pcmastercard.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/rabobank.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/split_account.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/starling.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/stripe.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ubs.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/xero.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/mappings/yodlee.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx/utils.py +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/dependency_links.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/not-zip-safe +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/top_level.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/OFX 2.1.1.pdf +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/OFXAudit.xls +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/OFX_Message_Support.doc +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_002.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_003.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_004.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_005.html +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/bootstrap.js +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/jquery.js +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/sitecss.css +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/docs/qif-file-format.txt +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/helpers/check-stage +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/helpers/clean +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/helpers/srcdist +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/helpers/wheel +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/pyproject.toml +0 -0
- {csv2ofx-0.30.0 → csv2ofx-0.31.0}/setup.py +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: csv2ofx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.0
|
|
4
4
|
Summary: converts a csv file of transactions to an ofx or qif file
|
|
5
5
|
Home-page: https://github.com/reubano/csv2ofx
|
|
6
|
+
Download-URL: https://github.com/reubano/csv2ofx/archive/v0.31.0.tar.gz
|
|
6
7
|
Author: Reuben Cummings
|
|
7
8
|
Author-email: reubano@gmail.com
|
|
9
|
+
Maintainer: Jason R. Coombs
|
|
10
|
+
Maintainer-email: jaraco@jaraco.com
|
|
8
11
|
License: MIT
|
|
9
|
-
Download-URL: https://github.com/reubano/csv2ofx/archive/v0.30.0.tar.gz
|
|
10
12
|
Keywords: csv2ofx,converts,a,csv,file,of,transactions,to,an,ofx,or,qif,file
|
|
11
13
|
Platform: MacOS X
|
|
12
14
|
Platform: Windows
|
|
@@ -29,10 +31,25 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
29
31
|
Classifier: Operating System :: Microsoft :: Windows
|
|
30
32
|
Description-Content-Type: text/markdown
|
|
31
33
|
License-File: LICENSE
|
|
34
|
+
Requires-Dist: meza<0.48.0,>=0.47.0
|
|
35
|
+
Requires-Dist: python-dateutil<3.0.0,>=2.7.2
|
|
36
|
+
Requires-Dist: requests<3.0.0,>=2.18.4
|
|
37
|
+
Dynamic: author
|
|
38
|
+
Dynamic: author-email
|
|
39
|
+
Dynamic: classifier
|
|
40
|
+
Dynamic: description
|
|
41
|
+
Dynamic: description-content-type
|
|
42
|
+
Dynamic: download-url
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: keywords
|
|
45
|
+
Dynamic: license
|
|
46
|
+
Dynamic: platform
|
|
47
|
+
Dynamic: requires-dist
|
|
48
|
+
Dynamic: summary
|
|
32
49
|
|
|
33
50
|
# csv2ofx
|
|
34
51
|
|
|
35
|
-
[](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
|
|
36
53
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
37
54
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
38
55
|
|
|
@@ -112,21 +129,23 @@ usage: csv2ofx [options] <source> <dest>
|
|
|
112
129
|
description: csv2ofx converts a csv file to ofx and qif
|
|
113
130
|
|
|
114
131
|
positional arguments:
|
|
115
|
-
source the source csv file (
|
|
116
|
-
dest the output file (
|
|
132
|
+
source the source csv file (default: stdin)
|
|
133
|
+
dest the output file (default: stdout)
|
|
117
134
|
|
|
118
135
|
optional arguments:
|
|
119
136
|
-h, --help show this help message and exit
|
|
120
137
|
-a TYPE, --account TYPE
|
|
121
138
|
default account type 'CHECKING' for OFX and 'Bank' for QIF.
|
|
122
|
-
-e DATE, --end DATE end date
|
|
139
|
+
-e DATE, --end DATE end date (default: today)
|
|
140
|
+
-B BALANCE, --ending-balance BALANCE
|
|
141
|
+
ending balance (default: None)
|
|
123
142
|
-l LANGUAGE, --language LANGUAGE
|
|
124
|
-
the language
|
|
143
|
+
the language (default: ENG)
|
|
125
144
|
-s DATE, --start DATE
|
|
126
145
|
the start date
|
|
127
146
|
-y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
|
|
128
|
-
-m
|
|
129
|
-
the account mapping
|
|
147
|
+
-m MAPPING_NAME, --mapping MAPPING_NAME
|
|
148
|
+
the account mapping (default: default)
|
|
130
149
|
-x FILE_PATH, --custom FILE_PATH
|
|
131
150
|
path to a custom mapping file
|
|
132
151
|
-c FIELD_NAME, --collapse FIELD_NAME
|
|
@@ -134,16 +153,17 @@ optional arguments:
|
|
|
134
153
|
-C ROWS, --chunksize ROWS
|
|
135
154
|
number of rows to process at a time (default: 2 ** 14)
|
|
136
155
|
-r ROWS, --first-row ROWS
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
the
|
|
156
|
+
the first row to process (zero based)
|
|
157
|
+
-R ROWS, --last-row ROWS
|
|
158
|
+
the last row to process (zero based, negative values count from the end)
|
|
140
159
|
-O COLS, --first-col COLS
|
|
141
|
-
|
|
160
|
+
the first column to process (zero based)
|
|
142
161
|
-L, --list-mappings list the available mappings
|
|
143
162
|
-V, --version show version and exit
|
|
144
163
|
-q, --qif enables 'QIF' output instead of 'OFX'
|
|
164
|
+
-M, --ms-money enables MS Money compatible 'OFX' output
|
|
145
165
|
-o, --overwrite overwrite destination file if it exists
|
|
146
|
-
-D
|
|
166
|
+
-D DATE, --server-date DATE
|
|
147
167
|
OFX server date (default: source file mtime)
|
|
148
168
|
-E ENCODING, --encoding ENCODING
|
|
149
169
|
File encoding (default: utf-8)
|
|
@@ -175,6 +195,17 @@ optional arguments:
|
|
|
175
195
|
|
|
176
196
|
csv2ofx -m yoodlee file.csv
|
|
177
197
|
|
|
198
|
+
|
|
199
|
+
#### Special cases
|
|
200
|
+
|
|
201
|
+
Some banks, like *UBS Switzerland*, may provide CSV exports that are not
|
|
202
|
+
readily tractable by csv2ofx because of extra header or trailing lines,
|
|
203
|
+
redundant or unwanted columns. These input files can be preprocessed with the
|
|
204
|
+
shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
|
|
205
|
+
|
|
206
|
+
csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
|
|
207
|
+
|
|
208
|
+
|
|
178
209
|
## CUSTOMIZATION
|
|
179
210
|
|
|
180
211
|
### Code modification
|
|
@@ -239,6 +270,7 @@ attribute | description | default field | default value | example
|
|
|
239
270
|
attribute | description | default value | example
|
|
240
271
|
----------|-------------|---------------|--------
|
|
241
272
|
`has_header`|does the csv file have a header row|True
|
|
273
|
+
`custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
|
|
242
274
|
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
243
275
|
`currency`|the currency ISO code|USD|GBP
|
|
244
276
|
`delimiter`|the csv field delimiter|,|;
|
|
@@ -283,7 +315,7 @@ cd csv2ofx
|
|
|
283
315
|
2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
|
|
284
316
|
|
|
285
317
|
```bash
|
|
286
|
-
mkvirtualenv
|
|
318
|
+
mkvirtualenv -i pkutils csv2ofx
|
|
287
319
|
activate csv2ofx
|
|
288
320
|
python setup.py develop
|
|
289
321
|
pip install -r dev-requirements.txt
|
|
@@ -310,5 +342,3 @@ How to contribute a mapping:
|
|
|
310
342
|
## License
|
|
311
343
|
|
|
312
344
|
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.31.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()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Import transactions from Amazon Order History
|
|
3
|
+
as exported by Amazon Order History Reporter
|
|
4
|
+
(https://chrome.google.com/webstore/detail/amazon-order-history-repo/mgkilgclilajckgnedgjgnfdokkgnibi).
|
|
5
|
+
|
|
6
|
+
Honors some environment variables:
|
|
7
|
+
|
|
8
|
+
- ``AMAZON_INCLUDE_CARDS``: comma-separated last-four digits
|
|
9
|
+
of cards or payment methods to include in the output. If not
|
|
10
|
+
supplied, defaults to all cards.
|
|
11
|
+
- ``AMAZON_EXCLUDE_CARDS``: comma-separated last-four digits
|
|
12
|
+
of cards or payment methods to exclude in the output (supersedes
|
|
13
|
+
include).
|
|
14
|
+
- ``AMAZON_PURCHASES_ACCOUNT``: The OFX "account id" to use.
|
|
15
|
+
Financial tools will use this account ID to associated with an
|
|
16
|
+
account. If unspecified, defaults to "100000001".
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
import functools
|
|
21
|
+
from operator import itemgetter
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
All = ['']
|
|
25
|
+
"""
|
|
26
|
+
A special value matching all cards.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@functools.lru_cache()
|
|
31
|
+
def exclude_cards():
|
|
32
|
+
setting = os.environ.get('AMAZON_EXCLUDE_CARDS', None)
|
|
33
|
+
return setting.split(',') if setting else []
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@functools.lru_cache()
|
|
37
|
+
def include_cards():
|
|
38
|
+
setting = os.environ.get('AMAZON_INCLUDE_CARDS', None)
|
|
39
|
+
return setting.split(',') if setting else All
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def filter_payment(row):
|
|
43
|
+
include = any(card in row['payments'] for card in include_cards())
|
|
44
|
+
exclude = any(card in row['payments'] for card in exclude_cards())
|
|
45
|
+
return include and not exclude
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
mapping = {
|
|
49
|
+
'has_header': True,
|
|
50
|
+
'delimiter': ',',
|
|
51
|
+
'bank': 'Amazon Purchases',
|
|
52
|
+
'account_id': os.environ.get('AMAZON_PURCHASES_ACCOUNT', '100000001'),
|
|
53
|
+
'date': itemgetter('date'),
|
|
54
|
+
'amount': itemgetter('total'),
|
|
55
|
+
'payee': 'Amazon',
|
|
56
|
+
'desc': itemgetter('items'),
|
|
57
|
+
'id': itemgetter('order id'),
|
|
58
|
+
'type': 'DEBIT',
|
|
59
|
+
'last_row': -1,
|
|
60
|
+
'filter': filter_payment,
|
|
61
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# vim: sw=4:ts=4:expandtab
|
|
3
|
+
# pylint: disable=invalid-name
|
|
4
|
+
"""
|
|
5
|
+
csv2ofx.mappings.ingdirect
|
|
6
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
7
|
+
|
|
8
|
+
Provides a mapping for transactions obtained via ING Direct
|
|
9
|
+
(Spanish bank)
|
|
10
|
+
"""
|
|
11
|
+
from operator import itemgetter
|
|
12
|
+
import json
|
|
13
|
+
import hashlib
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def find_type(transaction):
|
|
17
|
+
amount = float(transaction.get("amount"))
|
|
18
|
+
return "credit" if amount > 0 else "debit"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def gen_transaction_id(transaction):
|
|
22
|
+
hasher = hashlib.sha256()
|
|
23
|
+
stringified = json.dumps(transaction).encode("utf-8")
|
|
24
|
+
hasher.update(stringified)
|
|
25
|
+
return hasher.hexdigest()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_payee(transaction):
|
|
29
|
+
cadena = transaction.get('desc')
|
|
30
|
+
subcadenas = ['Abono por campaña', 'Devolución Tarjeta',
|
|
31
|
+
'Nomina recibida', 'Traspaso recibido', 'Pago en',
|
|
32
|
+
'Recibo', 'Reintegro efectivo', 'Transferencia Bizum emitida',
|
|
33
|
+
'Transferencia emitida a', 'Transferencia recibida de']
|
|
34
|
+
for subcadena in subcadenas:
|
|
35
|
+
if subcadena in cadena:
|
|
36
|
+
payee = cadena.replace(subcadena, '')
|
|
37
|
+
break
|
|
38
|
+
else:
|
|
39
|
+
payee = cadena
|
|
40
|
+
return payee
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_transaction_type(transaction):
|
|
44
|
+
cadena = transaction.get('desc')
|
|
45
|
+
subcadenas = ['Abono por campaña', 'Devolución Tarjeta',
|
|
46
|
+
'Nomina recibida', 'Traspaso recibido', 'Pago en',
|
|
47
|
+
'Recibo', 'Reintegro efectivo', 'Transferencia Bizum emitida',
|
|
48
|
+
'Transferencia emitida a', 'Transferencia recibida de']
|
|
49
|
+
for subcadena in subcadenas:
|
|
50
|
+
if subcadena in cadena:
|
|
51
|
+
notes = subcadena
|
|
52
|
+
return notes
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
mapping = {
|
|
56
|
+
"has_header": True,
|
|
57
|
+
"is_split": False,
|
|
58
|
+
"bank": "ING",
|
|
59
|
+
"currency": "EUR",
|
|
60
|
+
"delimiter": ",",
|
|
61
|
+
"account": "ING checking",
|
|
62
|
+
"type": find_type,
|
|
63
|
+
"date": itemgetter("date"),
|
|
64
|
+
"amount": itemgetter("amount"),
|
|
65
|
+
"payee": get_payee,
|
|
66
|
+
# 'desc': get_transaction_type,
|
|
67
|
+
"class": itemgetter("class"),
|
|
68
|
+
"id": gen_transaction_id,
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from __future__ import (
|
|
2
|
+
absolute_import, division, print_function, unicode_literals)
|
|
3
|
+
|
|
4
|
+
from operator import itemgetter
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
# Default value if account_id not found in header rows.
|
|
8
|
+
schwab_account_id = "12345"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_real(transaction):
|
|
12
|
+
# Filter-out header line & lines that only have one column
|
|
13
|
+
type = transaction.get('Type')
|
|
14
|
+
return type and (type != "Type")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def schwab_filter(transaction):
|
|
18
|
+
if is_real(transaction):
|
|
19
|
+
return True
|
|
20
|
+
|
|
21
|
+
# Sanity check header row in CSV matches custom_header
|
|
22
|
+
line = transaction.get(mapping["custom_header"][0])
|
|
23
|
+
if line in mapping["custom_header"]:
|
|
24
|
+
for column in mapping["custom_header"]:
|
|
25
|
+
found_col = transaction.get(column)
|
|
26
|
+
if found_col != column:
|
|
27
|
+
raise ValueError("Header row mismatch (expected: '" + column +
|
|
28
|
+
"', found: '" + found_col + "')")
|
|
29
|
+
|
|
30
|
+
# Look for account_id in one of the lines being filtered out
|
|
31
|
+
global schwab_account_id
|
|
32
|
+
match = re.search(r'^Transactions for .* account (\.*\d*) as of', line)
|
|
33
|
+
if match:
|
|
34
|
+
schwab_account_id = match.group(1)
|
|
35
|
+
return False
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_account_id(transaction):
|
|
39
|
+
global schwab_account_id
|
|
40
|
+
return schwab_account_id
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
mapping = {
|
|
44
|
+
# Technically Schwab Bank CSVs do have a header, but we want to extract
|
|
45
|
+
# the account_id from the line that comes before the header, so we use
|
|
46
|
+
# custom_header instead of parsing it from the second line of the CSV.
|
|
47
|
+
'custom_header': ["Date","Type","Check #","Description","Withdrawal (-)",
|
|
48
|
+
"Deposit (+)","RunningBalance"],
|
|
49
|
+
'has_header': False,
|
|
50
|
+
'filter': schwab_filter,
|
|
51
|
+
'is_split': False,
|
|
52
|
+
'bank': 'Charles Schwab Bank, N.A.',
|
|
53
|
+
'bank_id': '121202211',
|
|
54
|
+
'account_id': get_account_id,
|
|
55
|
+
'currency': 'USD',
|
|
56
|
+
'account': 'Charles Schwab Checking',
|
|
57
|
+
# Schwab Bank includes three lines of text in their CSV which otherwise
|
|
58
|
+
# break date parsing. Filtering by lines with no "Type" (and faking out
|
|
59
|
+
# the date for those lines) avoids the problem.
|
|
60
|
+
'date': lambda tr: tr.get('Date') if is_real(tr) else "1-1-1970",
|
|
61
|
+
'check_num': itemgetter('Check #'),
|
|
62
|
+
'payee': itemgetter('Description'),
|
|
63
|
+
'desc': itemgetter('Description'),
|
|
64
|
+
'type': lambda tr: 'debit' if tr.get('Withdrawal (-)') != '' else 'credit',
|
|
65
|
+
'amount': lambda tr: tr.get('Deposit (+)') or tr.get('Withdrawal (-)'),
|
|
66
|
+
'balance': itemgetter('RunningBalance'),
|
|
67
|
+
}
|
|
@@ -23,10 +23,10 @@ tricky:
|
|
|
23
23
|
"""
|
|
24
24
|
from operator import itemgetter
|
|
25
25
|
|
|
26
|
-
# Financial numbers are expressed as "2'045.56"
|
|
26
|
+
# Financial numbers are expressed as "2'045.56" in de/fr/it_CH (utf8 has some
|
|
27
|
+
# glitches, so we go for the default one)
|
|
27
28
|
import locale
|
|
28
|
-
|
|
29
|
-
locale.setlocale(locale.LC_ALL, "fr_CH.UTF-8")
|
|
29
|
+
locale.setlocale(locale.LC_NUMERIC, 'fr_CH')
|
|
30
30
|
|
|
31
31
|
__author__ = 'Marco "sphakka" Poleggi'
|
|
32
32
|
|
|
@@ -38,13 +38,18 @@ def fixdate(ds):
|
|
|
38
38
|
return ".".join((dmy[1], dmy[0], dmy[2]))
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
return
|
|
41
|
+
def map_descr(tr):
|
|
42
|
+
descr = tr["Description 2"] or tr["Description 1"]
|
|
43
|
+
return descr + (": " + tr["Description 3"] if tr["Description 3"] else "")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def map_class(tr):
|
|
47
|
+
clss = tr["Description 1"]
|
|
48
|
+
return clss + (": " + tr["Description 2"] if tr["Description 2"] else "")
|
|
44
49
|
|
|
45
50
|
|
|
46
51
|
def map_payee(tr):
|
|
47
|
-
return tr["Description 3"] if tr.get("Débit")
|
|
52
|
+
return tr["Description 3"] if tr.get("Débit") else tr["Description 2"]
|
|
48
53
|
|
|
49
54
|
|
|
50
55
|
mapping = {
|
|
@@ -60,12 +65,12 @@ mapping = {
|
|
|
60
65
|
"amount": lambda tr: locale.atof(tr["Débit"] or tr["Crédit"]),
|
|
61
66
|
# debits show _your_ notes in "Desc 2", whereas credits report the
|
|
62
67
|
# _payee_. Thus a better "class" value comes from "Desc 1" + "Desc 2"
|
|
63
|
-
"class":
|
|
68
|
+
"class": map_class,
|
|
64
69
|
"notes": itemgetter("Description 2"),
|
|
65
70
|
# switch day/month (maybe file a bug: always inverted when ambiguous like
|
|
66
71
|
# '01.02.2018')
|
|
67
72
|
"date": lambda tr: fixdate(tr["Date de valeur"]),
|
|
68
|
-
"desc":
|
|
73
|
+
"desc": map_descr,
|
|
69
74
|
"payee": map_payee,
|
|
70
75
|
"check_num": itemgetter("N° de transaction"),
|
|
71
76
|
"balance": lambda tr: locale.atof(tr["Solde"]),
|