csv2ofx 0.34.2__tar.gz → 0.35.1__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.
Files changed (132) hide show
  1. {csv2ofx-0.34.2/csv2ofx.egg-info → csv2ofx-0.35.1}/PKG-INFO +6 -5
  2. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/README.md +2 -1
  3. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/__init__.py +12 -11
  4. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/main.py +9 -13
  5. csv2ofx-0.35.1/csv2ofx/mappings/c24.py +95 -0
  6. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/schwabchecking.py +1 -1
  7. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/ubs-ch-fr.py +1 -1
  8. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/ofx.py +2 -6
  9. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/qif.py +1 -2
  10. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/utils.py +0 -1
  11. {csv2ofx-0.34.2 → csv2ofx-0.35.1/csv2ofx.egg-info}/PKG-INFO +6 -5
  12. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx.egg-info/SOURCES.txt +5 -1
  13. csv2ofx-0.35.1/csv2ofx.egg-info/requires.txt +9 -0
  14. csv2ofx-0.35.1/data/converted/c24.ofx +71 -0
  15. csv2ofx-0.35.1/data/test/c24.csv +4 -0
  16. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/pyproject.toml +4 -4
  17. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/tests/test_cli.py +27 -1
  18. csv2ofx-0.35.1/tests/test_dates.py +28 -0
  19. csv2ofx-0.34.2/csv2ofx.egg-info/requires.txt +0 -9
  20. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/LICENSE +0 -0
  21. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/MANIFEST.in +0 -0
  22. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/__main__.py +0 -0
  23. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/__init__.py +0 -0
  24. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/abnamro.py +0 -0
  25. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/amazon.py +0 -0
  26. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/boursorama.py +0 -0
  27. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/capitalone.py +0 -0
  28. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/creditunion.py +0 -0
  29. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/custom.py +0 -0
  30. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/default.py +0 -0
  31. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/eqbank.py +0 -0
  32. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/exim.py +0 -0
  33. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/gls.py +0 -0
  34. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/ingdirect.py +0 -0
  35. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/ingesp.py +0 -0
  36. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/mdb.py +0 -0
  37. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/mint.py +0 -0
  38. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/mint_extra.py +0 -0
  39. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/mint_headerless.py +0 -0
  40. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/mintapi.py +0 -0
  41. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/msmoneyreport.py +0 -0
  42. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/n26.py +0 -0
  43. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/outbank.py +0 -0
  44. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/payoneer.py +0 -0
  45. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/pcmastercard.py +0 -0
  46. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/rabobank.py +0 -0
  47. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/split_account.py +0 -0
  48. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/starling.py +0 -0
  49. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/stripe.py +0 -0
  50. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/ubs.py +0 -0
  51. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/xero.py +0 -0
  52. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx/mappings/yodlee.py +0 -0
  53. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx.egg-info/dependency_links.txt +0 -0
  54. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx.egg-info/entry_points.txt +0 -0
  55. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/csv2ofx.egg-info/top_level.txt +0 -0
  56. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/amazon.ofx +0 -0
  57. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/creditunion.qif +0 -0
  58. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/default.ofx +0 -0
  59. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/default.qif +0 -0
  60. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/default_w_splits.ofx +0 -0
  61. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/default_w_splits.qif +0 -0
  62. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/gls.ofx +0 -0
  63. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/ingesp.ofx +0 -0
  64. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/mint.ofx +0 -0
  65. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/mint.qif +0 -0
  66. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/mint_alt.qif +0 -0
  67. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/mint_extra.qif +0 -0
  68. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/n26.ofx +0 -0
  69. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/outbank.ofx +0 -0
  70. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/payoneer.ofx +0 -0
  71. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/pcmastercard.ofx +0 -0
  72. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case1.ofx +0 -0
  73. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case2.ofx +0 -0
  74. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case3.ofx +0 -0
  75. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case4.ofx +0 -0
  76. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case5.ofx +0 -0
  77. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case6.ofx +0 -0
  78. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-baltest-case7.ofx +0 -0
  79. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking-msmoney.ofx +0 -0
  80. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/schwab-checking.ofx +0 -0
  81. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/stripe-all.ofx +0 -0
  82. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/stripe-all.qif +0 -0
  83. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/stripe-default.ofx +0 -0
  84. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/stripe-default.qif +0 -0
  85. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/ubs-ch-fr.qif +0 -0
  86. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/converted/xero.qif +0 -0
  87. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/example/investment_example.qif +0 -0
  88. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/example/transaction_example.ofx +0 -0
  89. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/example/transfer_example.ofx +0 -0
  90. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/amazon.csv +0 -0
  91. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/capitalone.csv +0 -0
  92. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/creditunion.csv +0 -0
  93. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/default.csv +0 -0
  94. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/gls.csv +0 -0
  95. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/ingesp.csv +0 -0
  96. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/mint.csv +0 -0
  97. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/mint_extra.csv +0 -0
  98. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/mint_headerless.csv +0 -0
  99. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/n26-fr.csv +0 -0
  100. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/outbank.csv +0 -0
  101. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/payoneer.csv +0 -0
  102. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/pcmastercard.csv +0 -0
  103. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case1.csv +0 -0
  104. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case2.csv +0 -0
  105. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case3.csv +0 -0
  106. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case4.csv +0 -0
  107. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case5.csv +0 -0
  108. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case6.csv +0 -0
  109. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking-baltest-case7.csv +0 -0
  110. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/schwab-checking.csv +0 -0
  111. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/stripe-all.csv +0 -0
  112. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/stripe-default.csv +0 -0
  113. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/ubs-ch-fr_trimmed.csv +0 -0
  114. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/data/test/xero.csv +0 -0
  115. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/OFX 2.1.1.pdf +0 -0
  116. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/OFXAudit.xls +0 -0
  117. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/OFX_Message_Support.doc +0 -0
  118. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification.html +0 -0
  119. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/a.html +0 -0
  120. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/a_002.html +0 -0
  121. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/a_003.html +0 -0
  122. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/a_004.html +0 -0
  123. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/a_005.html +0 -0
  124. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/bootstrap.js +0 -0
  125. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/jquery.js +0 -0
  126. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/QIF Specification_files/sitecss.css +0 -0
  127. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/docs/qif-file-format.txt +0 -0
  128. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/helpers/check-stage +0 -0
  129. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/helpers/clean +0 -0
  130. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/helpers/srcdist +0 -0
  131. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/helpers/wheel +0 -0
  132. {csv2ofx-0.34.2 → csv2ofx-0.35.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv2ofx
3
- Version: 0.34.2
3
+ Version: 0.35.1
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>
@@ -17,9 +17,9 @@ Classifier: Intended Audience :: Developers
17
17
  Requires-Python: >=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: python-dateutil<3.0.0,>=2.7.2
21
- Requires-Dist: requests<3.0.0,>=2.18.4
22
- Requires-Dist: meza<0.48.0,>=0.47.0
20
+ Requires-Dist: python-dateutil>=2.7.2
21
+ Requires-Dist: requests>=2.18.4
22
+ Requires-Dist: meza>=0.47.0
23
23
  Provides-Extra: test
24
24
  Requires-Dist: pytest; extra == "test"
25
25
  Requires-Dist: pytest-enabler; extra == "test"
@@ -200,7 +200,8 @@ mapping = {
200
200
  'bank': 'BetterBank',
201
201
  'account': itemgetter('Account'),
202
202
  'date': itemgetter('Date'),
203
- 'amount': itemgetter('Amount')}
203
+ 'amount': itemgetter('Amount'),
204
+ }
204
205
  ```
205
206
 
206
207
  But more complex parsing is also possible, e.g.,
@@ -171,7 +171,8 @@ mapping = {
171
171
  'bank': 'BetterBank',
172
172
  'account': itemgetter('Account'),
173
173
  'date': itemgetter('Date'),
174
- 'amount': itemgetter('Amount')}
174
+ 'amount': itemgetter('Amount'),
175
+ }
175
176
  ```
176
177
 
177
178
  But more complex parsing is also possible, e.g.,
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python
2
1
  # vim: sw=4:ts=4:expandtab
3
2
 
4
3
  """
@@ -35,8 +34,6 @@ def md5(content):
35
34
  class BalanceError(Exception):
36
35
  """Raised if no ending balance when MS Money compatible output requested"""
37
36
 
38
- pass
39
-
40
37
 
41
38
  class Content: # pylint: disable=too-many-instance-attributes
42
39
  """A transaction holding object"""
@@ -89,12 +86,16 @@ class Content: # pylint: disable=too-many-instance-attributes
89
86
  self.end = kwargs.get("end") or dt.now()
90
87
 
91
88
  def parse_date(self, trxn):
92
- if self.parse_fmt:
93
- parsed = dt.strptime(self.get("date", trxn), self.parse_fmt)
94
- else:
95
- parsed = parse(self.get("date", trxn), dayfirst=self.dayfirst)
96
-
97
- return parsed
89
+ value = self.get("date", trxn)
90
+ try:
91
+ if self.parse_fmt:
92
+ return dt.strptime(value, self.parse_fmt)
93
+ return parse(value, dayfirst=self.dayfirst)
94
+ except (TypeError, ValueError, OverflowError) as err:
95
+ raise ValueError(
96
+ "Cannot parse transaction date. Check the date mapping "
97
+ "and parse_fmt option."
98
+ ) from err
98
99
 
99
100
  def get(self, name, trxn=None, default=None):
100
101
  """Gets an attribute which could be either a normal attribute,
@@ -322,7 +323,7 @@ class Content: # pylint: disable=too-many-instance-attributes
322
323
  if self.is_split and not self.include(trxns[0]):
323
324
  continue
324
325
  elif self.is_split and not utils.verify_splits(*_args):
325
- raise Exception("Splits do not sum to zero.")
326
+ raise Exception("Splits do not sum to zero.") # noqa: TRY002 (callers expect a plain Exception)
326
327
  elif not self.is_split:
327
328
  filtered_trxns = filter(self.include, trxns)
328
329
  else:
@@ -335,7 +336,7 @@ class Content: # pylint: disable=too-many-instance-attributes
335
336
 
336
337
  # pylint: disable=cell-var-from-loop
337
338
  def keyfunc(enum):
338
- return enum[0] != main_pos
339
+ return enum[0] != main_pos # noqa: B023 (only used within this iteration)
339
340
 
340
341
  sorted_trxns = sorted(enumerate(filtered_trxns), key=keyfunc)
341
342
  yield (grp, main_pos, sorted_trxns)
@@ -16,6 +16,7 @@ Attributes:
16
16
  ENCODING (str): Default file encoding.
17
17
  """
18
18
 
19
+ import builtins
19
20
  import itertools as it
20
21
  import os.path
21
22
  import pathlib
@@ -30,13 +31,6 @@ from operator import itemgetter
30
31
  from pkgutil import iter_modules
31
32
  from pprint import pprint
32
33
 
33
- try:
34
- FileNotFoundError
35
- except NameError:
36
- FileNotFoundError = IOError
37
-
38
- import builtins
39
-
40
34
  from dateutil.parser import parse
41
35
  from meza.io import IterStringIO, read_csv, write
42
36
 
@@ -249,7 +243,9 @@ def run(args=None): # noqa: C901
249
243
 
250
244
  cont = QIF(mapping, **okwargs) if args.qif else OFX(mapping, **okwargs)
251
245
  source = (
252
- builtins.open(args.source, encoding=args.encoding) if args.source else sys.stdin
246
+ builtins.open(args.source, encoding=args.encoding) # noqa: SIM115 (closed in finally)
247
+ if args.source
248
+ else sys.stdin
253
249
  )
254
250
 
255
251
  ckwargs = {
@@ -288,12 +284,12 @@ def run(args=None): # noqa: C901
288
284
  "chunksize": args.chunksize,
289
285
  "encoding": args.encoding,
290
286
  }
291
- except Exception as err: # pylint: disable=broad-except
287
+ except Exception as err: # pylint: disable=broad-except # noqa: BLE001 (CLI reports any error)
292
288
  source.close() if args.source else None
293
289
  sys.exit(err)
294
290
 
295
291
  dest = (
296
- builtins.open(args.dest, "w", encoding=args.encoding)
292
+ builtins.open(args.dest, "w", encoding=args.encoding) # noqa: SIM115 (closed in finally)
297
293
  if args.dest
298
294
  else sys.stdout
299
295
  )
@@ -303,7 +299,7 @@ def run(args=None): # noqa: C901
303
299
  except KeyError as err:
304
300
  msg = f"Field {err} is missing from file. Check `mapping` option."
305
301
  except TypeError as err:
306
- msg = f"No data to write. {str(err)}. "
302
+ msg = f"No data to write. {err!s}. "
307
303
 
308
304
  if args.collapse:
309
305
  msg += "Check `start` and `end` options."
@@ -311,11 +307,11 @@ def run(args=None): # noqa: C901
311
307
  msg += "Try again with `-c` option."
312
308
  except ValueError as err:
313
309
  # csv2ofx called with no arguments or broken mapping
314
- msg = f"Possible mapping problem: {str(err)}."
310
+ msg = f"Possible mapping problem: {err!s}."
315
311
  parser.print_help()
316
312
  except BalanceError as err:
317
313
  msg = f"{err}. Try again with `--ending-balance` option."
318
- except Exception: # pylint: disable=broad-except
314
+ except Exception: # pylint: disable=broad-except # noqa: BLE001 (CLI reports any error)
319
315
  msg = 1
320
316
  traceback.print_exc()
321
317
  else:
@@ -0,0 +1,95 @@
1
+ """Mapping for the German C24 bank.
2
+
3
+ The C24 bank supports sub-accounts. Every transaction in the CSV file has a
4
+ user-configurable account name "Kontoname". Transactions from all sub-accounts
5
+ are stored chronologically in this list. The transaction list includes both
6
+ intrabank transfers between these accounts ("internal") as well as all other
7
+ transactions ("external").
8
+
9
+ OFX files have a special way of identifying intrabank transfers `<INTRATRNRS>`
10
+ but the file can either only include intrabank transfers or normal ones. The
11
+ expected behaviour would be to list all transactions, with intrabank and normal
12
+ transactions having the same formatting. In some cases however, the user may
13
+ want to have a properly formatted list of intrabank transfers as well. Toward
14
+ this, the environment variable `TRANSACTIONS` can be used.
15
+
16
+ Possible `TRANSACTIONS` env var values:
17
+ - "all" (default): Include all transactions as normal statements. There is no
18
+ way to differentiate intrabank transfers.
19
+ - "internal": Only include intrabank transfers.
20
+ - "external": Only include normal transfers. Accounts will have weird balances.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ from operator import itemgetter
26
+ from os import environ
27
+ from sys import stderr
28
+
29
+ _INCLUDE_INTERNAL_TX = True
30
+ _INCLUDE_EXTERNAL_TX = True
31
+ tmp = environ.get("TRANSACTIONS", "all").lower()
32
+ if tmp == "internal":
33
+ _INCLUDE_INTERNAL_TX = True
34
+ _INCLUDE_EXTERNAL_TX = False
35
+ elif tmp == "external":
36
+ _INCLUDE_INTERNAL_TX = False
37
+ _INCLUDE_EXTERNAL_TX = True
38
+ elif tmp != "all":
39
+ print("TRANSACTIONS: invalid environment variable value!", file=stderr)
40
+
41
+
42
+ # "Pocket-Umbuchung" is a manual transfer between sub accounts, "Sparen" is when
43
+ # the user configured automatic transfer rules at certain events.
44
+ def _is_split_tx(tx: dict[str, str]) -> bool:
45
+ tx_type = tx["Transaktionstyp"]
46
+ return tx_type in {"Pocket-Umbuchung", "Sparen"}
47
+
48
+
49
+ def _get_split_recipient(tx: dict[str, str]) -> str | None:
50
+ if not _is_split_tx(tx):
51
+ return None
52
+ split_recipient = tx["Zahlungsempfänger"]
53
+ return split_recipient
54
+
55
+
56
+ def _filter_tx(tx: dict[str, str]) -> bool:
57
+ is_split = _is_split_tx(tx)
58
+ if is_split:
59
+ return _INCLUDE_INTERNAL_TX
60
+ else:
61
+ return _INCLUDE_EXTERNAL_TX
62
+
63
+
64
+ # We MUST NOT use the "Kontonummer" as account ID, because for transfers between
65
+ # sub accounts there is no recipient "Kontonummer". By using the default
66
+ # generated hash of the sender name "Kontoname" and the recipient name
67
+ # "Zahlungsempfänger", internal transfers can be associated correctly.
68
+ mapping = {
69
+ "has_header": True,
70
+ "currency": "EUR",
71
+ "delimiter": ",",
72
+ "bank": "C24",
73
+ "account": itemgetter("Kontoname"),
74
+ "date": itemgetter("Buchungsdatum"),
75
+ "parse_fmt": "%d.%m.%Y",
76
+ "amount": lambda tx: tx["Betrag"].replace(".", "").replace(",", "."),
77
+ "desc": itemgetter("Verwendungszweck"),
78
+ "payee": itemgetter("Zahlungsempfänger"),
79
+ "filter": _filter_tx,
80
+ # Setting this entry to anything other than `None` implicitly toggles the
81
+ # intrabank transfer output, which cannot include normal/external
82
+ # statements. Sets this getter only when not including these normal
83
+ # statements.
84
+ "split_account": _get_split_recipient if not _INCLUDE_EXTERNAL_TX else None,
85
+ # I don't like how the values below just get added to the memo. Feel free
86
+ # to re-include them.
87
+ #
88
+ # An automatic/manual categorization of the transaction.
89
+ # "class": itemgetter("Unterkategorie"),
90
+ #
91
+ # This seems to be a more human-readable name of the payee. In credit card
92
+ # statements, this may be the name of the credit card owner while the payee
93
+ # ("Zahlungsempfänger") is the name of the credit card provider.
94
+ # "notes": itemgetter("Beschreibung"),
95
+ }
@@ -2,7 +2,7 @@ from operator import itemgetter
2
2
 
3
3
  mapping = {
4
4
  'has_header': True,
5
- 'filter': lambda tr: True if tr.get('Status') == 'Posted' else False,
5
+ 'filter': lambda tr: tr.get('Status') == 'Posted',
6
6
  'is_split': False,
7
7
  'bank': 'Charles Schwab Bank, N.A.',
8
8
  'bank_id': '121202211',
@@ -1,4 +1,4 @@
1
- # vim: sw=4:ts=4:expandtab
1
+ # vim: sw=4:ts=4:expandtab # noqa: N999 (mapping name is user-facing)
2
2
  # pylint: disable=invalid-name
3
3
  """
4
4
  csv2ofx.mappings.ubs-ch-fr
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python
2
1
  # vim: sw=4:ts=4:expandtab
3
2
  # pylint: disable=no-self-use
4
3
 
@@ -547,7 +546,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
547
546
  content += f"\t\t</{self.resp_type}>\n\t</BANKMSGSRSV1>\n</OFX>\n"
548
547
  yield content
549
548
 
550
- def gen_body(self, data): # noqa: C901
549
+ def gen_body(self, data):
551
550
  """Generate the OFX body"""
552
551
  for datum in data:
553
552
  grp = datum["group"]
@@ -637,10 +636,7 @@ ENCODING:USASCIICHARSET:1252COMPRESSION:NONEOLDFILEUID:NONENEWFILEUID:NONE\
637
636
  >>> ofx.latest_date_count
638
637
  1
639
638
  """
640
- if self.latest_trxn is None:
641
- self.latest_trxn = trxn
642
- self.latest_date_count = 1
643
- elif trxn['date'] > self.latest_trxn['date']:
639
+ if self.latest_trxn is None or trxn['date'] > self.latest_trxn['date']:
644
640
  self.latest_trxn = trxn
645
641
  self.latest_date_count = 1
646
642
  elif trxn['date'] == self.latest_trxn['date']:
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python
2
1
  # vim: sw=4:ts=4:expandtab
3
2
  # pylint: disable=no-self-use
4
3
 
@@ -62,7 +61,7 @@ class QIF(Content):
62
61
 
63
62
  def header(self, **kwargs): # pylint: disable=unused-argument
64
63
  """Get the QIF header"""
65
- return None
64
+ return
66
65
 
67
66
  def transaction_data(self, tr):
68
67
  """gets QIF transaction data
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python
2
1
  # vim: sw=4:ts=4:expandtab
3
2
 
4
3
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv2ofx
3
- Version: 0.34.2
3
+ Version: 0.35.1
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>
@@ -17,9 +17,9 @@ Classifier: Intended Audience :: Developers
17
17
  Requires-Python: >=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: python-dateutil<3.0.0,>=2.7.2
21
- Requires-Dist: requests<3.0.0,>=2.18.4
22
- Requires-Dist: meza<0.48.0,>=0.47.0
20
+ Requires-Dist: python-dateutil>=2.7.2
21
+ Requires-Dist: requests>=2.18.4
22
+ Requires-Dist: meza>=0.47.0
23
23
  Provides-Extra: test
24
24
  Requires-Dist: pytest; extra == "test"
25
25
  Requires-Dist: pytest-enabler; extra == "test"
@@ -200,7 +200,8 @@ mapping = {
200
200
  'bank': 'BetterBank',
201
201
  'account': itemgetter('Account'),
202
202
  'date': itemgetter('Date'),
203
- 'amount': itemgetter('Amount')}
203
+ 'amount': itemgetter('Amount'),
204
+ }
204
205
  ```
205
206
 
206
207
  But more complex parsing is also possible, e.g.,
@@ -18,6 +18,7 @@ csv2ofx/mappings/__init__.py
18
18
  csv2ofx/mappings/abnamro.py
19
19
  csv2ofx/mappings/amazon.py
20
20
  csv2ofx/mappings/boursorama.py
21
+ csv2ofx/mappings/c24.py
21
22
  csv2ofx/mappings/capitalone.py
22
23
  csv2ofx/mappings/creditunion.py
23
24
  csv2ofx/mappings/custom.py
@@ -47,6 +48,7 @@ csv2ofx/mappings/ubs.py
47
48
  csv2ofx/mappings/xero.py
48
49
  csv2ofx/mappings/yodlee.py
49
50
  data/converted/amazon.ofx
51
+ data/converted/c24.ofx
50
52
  data/converted/creditunion.qif
51
53
  data/converted/default.ofx
52
54
  data/converted/default.qif
@@ -81,6 +83,7 @@ data/example/investment_example.qif
81
83
  data/example/transaction_example.ofx
82
84
  data/example/transfer_example.ofx
83
85
  data/test/amazon.csv
86
+ data/test/c24.csv
84
87
  data/test/capitalone.csv
85
88
  data/test/creditunion.csv
86
89
  data/test/default.csv
@@ -122,4 +125,5 @@ helpers/check-stage
122
125
  helpers/clean
123
126
  helpers/srcdist
124
127
  helpers/wheel
125
- tests/test_cli.py
128
+ tests/test_cli.py
129
+ tests/test_dates.py
@@ -0,0 +1,9 @@
1
+ python-dateutil>=2.7.2
2
+ requests>=2.18.4
3
+ meza>=0.47.0
4
+
5
+ [test]
6
+ pytest
7
+ pytest-enabler
8
+ pytest-ruff
9
+ freezegun
@@ -0,0 +1,71 @@
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>78a1d6227c674fedd66d7165ce318750</BANKID>
25
+ <ACCTID>6eea69609b81079b892c61e79829798b</ACCTID>
26
+ <ACCTTYPE>CHECKING</ACCTTYPE>
27
+ </BANKACCTFROM>
28
+ <BANKTRANLIST>
29
+ <DTSTART>19700101</DTSTART>
30
+ <DTEND>20260118</DTEND>
31
+ <STMTTRN>
32
+ <TRNTYPE>DEBIT</TRNTYPE>
33
+ <DTPOSTED>20251205000000</DTPOSTED>
34
+ <TRNAMT>-123.45</TRNAMT>
35
+ <FITID>50424a98e3219cee1726a03dd03b52f1</FITID>
36
+ <NAME>My savings account</NAME>
37
+ <MEMO>To be donated</MEMO>
38
+ </STMTTRN>
39
+ </BANKTRANLIST>
40
+ </STMTRS>
41
+ <STMTRS>
42
+ <CURDEF>EUR</CURDEF>
43
+ <BANKACCTFROM>
44
+ <BANKID>78a1d6227c674fedd66d7165ce318750</BANKID>
45
+ <ACCTID>011a79ab1760c0682e01cdf35eb5ed71</ACCTID>
46
+ <ACCTTYPE>SAVINGS</ACCTTYPE>
47
+ </BANKACCTFROM>
48
+ <BANKTRANLIST>
49
+ <DTSTART>19700101</DTSTART>
50
+ <DTEND>20260118</DTEND>
51
+ <STMTTRN>
52
+ <TRNTYPE>CREDIT</TRNTYPE>
53
+ <DTPOSTED>20251205000000</DTPOSTED>
54
+ <TRNAMT>123.45</TRNAMT>
55
+ <FITID>2021f0587851c9d9f868034f5ea0854d</FITID>
56
+ <NAME>My main account</NAME>
57
+ <MEMO>To be donated</MEMO>
58
+ </STMTTRN>
59
+ <STMTTRN>
60
+ <TRNTYPE>DEBIT</TRNTYPE>
61
+ <DTPOSTED>20260105000000</DTPOSTED>
62
+ <TRNAMT>-50.00</TRNAMT>
63
+ <FITID>80e455fe30ba0c2243aa64f0b0ce5a31</FITID>
64
+ <NAME>Ärzte ohne Grenzen</NAME>
65
+ <MEMO>Ihre Spendernummer 1234567 SEPA-Mandat 1234567-001 Vielen Dank für Ihre Spende</MEMO>
66
+ </STMTTRN>
67
+ </BANKTRANLIST>
68
+ </STMTRS>
69
+ </STMTTRNRS>
70
+ </BANKMSGSRSV1>
71
+ </OFX>
@@ -0,0 +1,4 @@
1
+ Transaktionstyp,Buchungsdatum,Karteneinsatz,Betrag,Zahlungsempfänger,IBAN,BIC,Verwendungszweck,Beschreibung,Kontonummer,Kontoname,Kategorie,Unterkategorie,Bargeldabhebung
2
+ Pocket-Umbuchung,05.12.2025,,"-123,45 €",My savings account,,,To be donated,,0987654321,My main account,Umbuchung,Umbuchung
3
+ Pocket-Umbuchung,05.12.2025,,"123,45 €",My main account,,,To be donated,FULL_LEGAL_NAME,1234567890,My savings account,Umbuchung,Umbuchung
4
+ SEPA-Lastschrift,05.01.2026,,"-50,00 €",Ärzte ohne Grenzen,PAYEE_IBAN,PAYEE_BIC,Ihre Spendernummer 1234567 SEPA-Mandat 1234567-001 Vielen Dank für Ihre Spende,"Medecins Sans Frontieres (MSF) - Ärzte ohne Grenzen, Dt. Sektion",1234567890,My savings account,Finanzen & Steuern,Spende
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "csv2ofx"
7
- version = "0.34.2"
7
+ version = "0.35.1"
8
8
  description = "converts a csv file of transactions to an ofx or qif file"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -25,9 +25,9 @@ classifiers = [
25
25
  "Intended Audience :: Developers",
26
26
  ]
27
27
  dependencies = [
28
- "python-dateutil>=2.7.2,<3.0.0",
29
- "requests>=2.18.4,<3.0.0",
30
- "meza>=0.47.0,<0.48.0",
28
+ "python-dateutil>=2.7.2",
29
+ "requests>=2.18.4",
30
+ "meza>=0.47.0",
31
31
  ]
32
32
  requires-python = ">=3.9"
33
33
 
@@ -114,6 +114,11 @@ samples = [
114
114
  'n26-fr.csv',
115
115
  'n26.ofx',
116
116
  ),
117
+ (
118
+ ['-o', '-m c24', "-e 20260118"],
119
+ 'c24.csv',
120
+ 'c24.ofx',
121
+ ),
117
122
  ]
118
123
 
119
124
 
@@ -129,7 +134,7 @@ data = pathlib.Path('data')
129
134
 
130
135
 
131
136
  def flatten_opts(opts):
132
- return list(param for group in opts for param in shlex.split(group))
137
+ return [param for group in opts for param in shlex.split(group)]
133
138
 
134
139
 
135
140
  @pytest.mark.parametrize(['opts', 'in_filename', 'out_filename'], samples)
@@ -163,3 +168,24 @@ def test_help_in_readme():
163
168
  out = subprocess.check_output(['csv2ofx', '--help'], text=True, env=env)
164
169
  readme = pathlib.Path('README.md').read_text()
165
170
  assert out in readme, "README help is stale, please update."
171
+
172
+
173
+ @pytest.mark.parametrize("options", [[], ["-c", "Description"]])
174
+ @pytest.mark.parametrize(
175
+ "csv_data",
176
+ [
177
+ "Description,Amount,Account\nExample,10,Checking\n",
178
+ "Date,Description,Amount,Account\n2147483648-01-01,Example,10,Checking\n",
179
+ ],
180
+ )
181
+ def test_invalid_date_reports_mapping_problem(tmp_path, capsys, options, csv_data):
182
+ """Missing and overflowing dates report mapping errors, e.g. year 2147483648."""
183
+ source = tmp_path / "invalid-date.csv"
184
+ source.write_text(csv_data, encoding="utf-8")
185
+ with pytest.raises(SystemExit) as exc:
186
+ csv2ofx.main.run([*options, str(source)])
187
+ message = str(exc.value.code)
188
+ assert "transaction date" in message
189
+ assert "date mapping" in message
190
+ assert "Try again with `-c`" not in message
191
+ assert "Traceback" not in capsys.readouterr().err
@@ -0,0 +1,28 @@
1
+ from datetime import datetime
2
+
3
+ import pytest
4
+
5
+ from csv2ofx import Content
6
+
7
+
8
+ @pytest.mark.parametrize("parse_fmt", [None, "%Y-%m-%d"])
9
+ @pytest.mark.parametrize("value", [None, "", "not-a-date", 42, "2147483648-01-01"])
10
+ def test_invalid_transaction_date_explains_mapping(value, parse_fmt):
11
+ """Invalid dates, such as None, identify the date mapping to check."""
12
+ content = Content({"date": lambda row: value}, parse_fmt=parse_fmt)
13
+ with pytest.raises(ValueError, match="transaction date.*date mapping"):
14
+ content.parse_date({})
15
+
16
+
17
+ @pytest.mark.parametrize(
18
+ "options, value, expected",
19
+ [
20
+ ({}, "2024-01-31", datetime(2024, 1, 31)),
21
+ ({"dayfirst": True}, "01/02/2024", datetime(2024, 2, 1)),
22
+ ({"parse_fmt": "%d.%m.%Y"}, "31.01.2024", datetime(2024, 1, 31)),
23
+ ],
24
+ )
25
+ def test_valid_transaction_dates(options, value, expected):
26
+ """Valid dates keep existing parsing, e.g. day-first 01/02 means February 1."""
27
+ content = Content({"date": lambda row: value}, **options)
28
+ assert content.parse_date({}) == expected
@@ -1,9 +0,0 @@
1
- python-dateutil<3.0.0,>=2.7.2
2
- requests<3.0.0,>=2.18.4
3
- meza<0.48.0,>=0.47.0
4
-
5
- [test]
6
- pytest
7
- pytest-enabler
8
- pytest-ruff
9
- freezegun
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