tariochbctools 0.37__py2.py3-none-any.whl → 0.38__py2.py3-none-any.whl

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.
@@ -4,7 +4,7 @@ from datetime import timedelta
4
4
  from io import StringIO
5
5
 
6
6
  from beancount.core import amount, data
7
- from beancount.core.number import D
7
+ from beancount.core.number import ZERO, D
8
8
  from beancount.ingest import importer
9
9
  from beancount.ingest.importers.mixins import identifier
10
10
  from dateutil.parser import parse
@@ -13,10 +13,11 @@ from dateutil.parser import parse
13
13
  class Importer(identifier.IdentifyMixin, importer.ImporterProtocol):
14
14
  """An importer for Revolut CSV files."""
15
15
 
16
- def __init__(self, regexps, account, currency):
16
+ def __init__(self, regexps, account, currency, fee=None):
17
17
  identifier.IdentifyMixin.__init__(self, matchers=[("filename", regexps)])
18
18
  self.account = account
19
19
  self.currency = currency
20
+ self._fee = fee
20
21
 
21
22
  def name(self):
22
23
  return super().name() + self.account
@@ -46,6 +47,7 @@ class Importer(identifier.IdentifyMixin, importer.ImporterProtocol):
46
47
  skipinitialspace=True,
47
48
  )
48
49
  next(reader)
50
+ is_fee_mode = self._fee is not None
49
51
  for row in reader:
50
52
  try:
51
53
  bal = D(row["Balance"].replace("'", "").strip())
@@ -53,37 +55,58 @@ class Importer(identifier.IdentifyMixin, importer.ImporterProtocol):
53
55
  amt = amount.Amount(amount_raw, row["Currency"])
54
56
  balance = amount.Amount(bal, self.currency)
55
57
  book_date = parse(row["Completed Date"].strip()).date()
58
+ fee_amt_raw = D(row["Fee"].replace("'", "").strip())
59
+ fee = amount.Amount(-fee_amt_raw, row["Currency"])
56
60
  except Exception as e:
57
61
  logging.warning(e)
58
62
  continue
59
63
 
64
+ if is_fee_mode and fee_amt_raw == ZERO:
65
+ continue
66
+
67
+ postings = [
68
+ data.Posting(self.account, amt, None, None, None, None),
69
+ ]
70
+ description = row["Description"].strip()
71
+ if is_fee_mode:
72
+ postings = [
73
+ data.Posting(self.account, fee, None, None, None, None),
74
+ data.Posting(
75
+ self._fee["account"], -fee, None, None, None, None
76
+ ),
77
+ ]
78
+ description = f"Fees for {description}"
79
+
80
+ assert isinstance(
81
+ description, str
82
+ ), "Actual type of description is " + str(type(description))
83
+
60
84
  entry = data.Transaction(
61
85
  data.new_metadata(file.name, 0, {}),
62
86
  book_date,
63
87
  "*",
64
88
  "",
65
- row["Description"].strip(),
89
+ description,
66
90
  data.EMPTY_SET,
67
91
  data.EMPTY_SET,
68
- [
69
- data.Posting(self.account, amt, None, None, None, None),
70
- ],
92
+ postings,
71
93
  )
72
94
  entries.append(entry)
73
95
 
74
- # only add balance after the last (newest) transaction
75
- try:
76
- book_date = book_date + timedelta(days=1)
77
- entry = data.Balance(
78
- data.new_metadata(file.name, 0, {}),
79
- book_date,
80
- self.account,
81
- balance,
82
- None,
83
- None,
84
- )
85
- entries.append(entry)
86
- except NameError:
87
- pass
96
+ if not is_fee_mode:
97
+ # only add balance after the last (newest) transaction
98
+ try:
99
+ book_date = book_date + timedelta(days=1)
100
+ entry = data.Balance(
101
+ data.new_metadata(file.name, 0, {}),
102
+ book_date,
103
+ self.account,
104
+ balance,
105
+ None,
106
+ None,
107
+ )
108
+ entries.append(entry)
109
+ except NameError:
110
+ pass
88
111
 
89
112
  return entries
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tariochbctools
3
- Version: 0.37
3
+ Version: 0.38
4
4
  Summary: Importers, plugins and price fetchers for Beancount
5
5
  Home-page: https://github.com/tarioch/beancounttools/
6
6
  Author: Patrick Ruckstuhl
@@ -19,7 +19,7 @@ Classifier: Topic :: Office/Business :: Financial :: Investment
19
19
  Classifier: License :: OSI Approved :: MIT License
20
20
  Description-Content-Type: text/x-rst; charset=UTF-8
21
21
  License-File: LICENSE.txt
22
- Requires-Dist: beancount <3,>=2
22
+ Requires-Dist: beancount<3,>=2
23
23
  Requires-Dist: bitstampclient
24
24
  Requires-Dist: mt-940
25
25
  Requires-Dist: pyyaml
@@ -30,14 +30,14 @@ Requires-Dist: opencv-python
30
30
  Requires-Dist: blockcypher
31
31
  Requires-Dist: imap-tools
32
32
  Requires-Dist: undictify
33
- Requires-Dist: importlib-metadata ; python_version < "3.8"
33
+ Requires-Dist: importlib-metadata; python_version < "3.8"
34
34
  Provides-Extra: testing
35
- Requires-Dist: pytest ; extra == 'testing'
36
- Requires-Dist: pytest-cov ; extra == 'testing'
37
- Requires-Dist: pytest-mock ; extra == 'testing'
38
- Requires-Dist: flake8 ; extra == 'testing'
39
- Requires-Dist: black ; extra == 'testing'
40
- Requires-Dist: isort ; extra == 'testing'
35
+ Requires-Dist: pytest; extra == "testing"
36
+ Requires-Dist: pytest-cov; extra == "testing"
37
+ Requires-Dist: pytest-mock; extra == "testing"
38
+ Requires-Dist: flake8; extra == "testing"
39
+ Requires-Dist: black; extra == "testing"
40
+ Requires-Dist: isort; extra == "testing"
41
41
 
42
42
  .. image:: https://img.shields.io/pypi/l/tariochbctools.svg
43
43
  :target: https://pypi.python.org/pypi/tariochbctools
@@ -27,7 +27,7 @@ tariochbctools/importers/quickfile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
27
27
  tariochbctools/importers/quickfile/importer.py,sha256=0HRVl-OXkCq8T5Uz04gGCGlkRXZ3Mp1y8AldW8ezBHg,6544
28
28
  tariochbctools/importers/raiffeisench/importer.py,sha256=L6X0vlAuL8__DmZbs_T-r-A8SH9VH05KLkL7SubFouA,995
29
29
  tariochbctools/importers/revolut/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- tariochbctools/importers/revolut/importer.py,sha256=TUjTnvvnYgc0j4z86KIohoMmw13UdNYjapNGPC63ILI,2886
30
+ tariochbctools/importers/revolut/importer.py,sha256=TtGzHl5v_i7IYBNFkdNosIvpBRO6_p5i_7qU2Cml2L0,3885
31
31
  tariochbctools/importers/schedule/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  tariochbctools/importers/schedule/importer.py,sha256=g1q7NwGzwkj25LknOguf3b7iJ0v4JXET01a8N3cWu2U,1526
33
33
  tariochbctools/importers/swisscard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -47,9 +47,9 @@ tariochbctools/plugins/check_portfolio_sum.py,sha256=naJ2j6BFpQhJhT2c-gfjyIdcYe0
47
47
  tariochbctools/plugins/generate_base_ccy_prices.py,sha256=Phw314qox3jpNgC5-GcnmyYcLkMkrd8xsWS-wYwdj6o,1236
48
48
  tariochbctools/plugins/prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  tariochbctools/plugins/prices/ibkr.py,sha256=9OwaZvI55bCj7H80K2iLZVsGLpuCyaoCnyuTS9e1_-c,1294
50
- tariochbctools-0.37.dist-info/LICENSE.txt,sha256=VR2hkz3p9Sw4hSXc7S5iZTOXGeV4h-i8AO_q0zEmtkE,1074
51
- tariochbctools-0.37.dist-info/METADATA,sha256=m2PiA0wx0xM-qtsTiJVZVtvk4G8fQCcc2l2eqaTeKUE,2110
52
- tariochbctools-0.37.dist-info/WHEEL,sha256=0XQbNV6JE5ziJsWjIU8TRRv0N6SohNonLWgP86g5fiI,109
53
- tariochbctools-0.37.dist-info/entry_points.txt,sha256=9xrCCY1wx2zCIsQUOWZelLHDmHw9Oc-ZBAKUIY9lKTA,88
54
- tariochbctools-0.37.dist-info/top_level.txt,sha256=CiA_NepCI6zDNsaORA55zmpuJFSnTvLESraIL13xiOQ,15
55
- tariochbctools-0.37.dist-info/RECORD,,
50
+ tariochbctools-0.38.dist-info/LICENSE.txt,sha256=VR2hkz3p9Sw4hSXc7S5iZTOXGeV4h-i8AO_q0zEmtkE,1074
51
+ tariochbctools-0.38.dist-info/METADATA,sha256=mJlkfUq-CmYt8LqpxguxQaUesNmH_zVQlY9wUexmLlI,2102
52
+ tariochbctools-0.38.dist-info/WHEEL,sha256=XRxW4r1PNiVhMpP4bT9oWtu3HyndxpJ84SkubFgzp_Y,109
53
+ tariochbctools-0.38.dist-info/entry_points.txt,sha256=9xrCCY1wx2zCIsQUOWZelLHDmHw9Oc-ZBAKUIY9lKTA,88
54
+ tariochbctools-0.38.dist-info/top_level.txt,sha256=CiA_NepCI6zDNsaORA55zmpuJFSnTvLESraIL13xiOQ,15
55
+ tariochbctools-0.38.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.2.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any