tariochbctools 0.36__tar.gz → 0.38__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 (91) hide show
  1. {tariochbctools-0.36 → tariochbctools-0.38}/.pre-commit-config.yaml +5 -5
  2. {tariochbctools-0.36/src/tariochbctools.egg-info → tariochbctools-0.38}/PKG-INFO +1 -1
  3. {tariochbctools-0.36 → tariochbctools-0.38}/docs/importers.rst +24 -1
  4. {tariochbctools-0.36 → tariochbctools-0.38}/setup.py +1 -0
  5. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/general/priceLookup.py +12 -3
  6. tariochbctools-0.38/src/tariochbctools/importers/netbenefits/importer.py +173 -0
  7. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/revolut/importer.py +43 -20
  8. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/plugins/check_portfolio_sum.py +1 -0
  9. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/plugins/generate_base_ccy_prices.py +1 -0
  10. {tariochbctools-0.36 → tariochbctools-0.38/src/tariochbctools.egg-info}/PKG-INFO +1 -1
  11. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/SOURCES.txt +2 -0
  12. tariochbctools-0.38/tests/tariochbctools/plugins/__init__.py +0 -0
  13. {tariochbctools-0.36 → tariochbctools-0.38}/.coveragerc +0 -0
  14. {tariochbctools-0.36 → tariochbctools-0.38}/.isort.cfg +0 -0
  15. {tariochbctools-0.36 → tariochbctools-0.38}/.readthedocs.yml +0 -0
  16. {tariochbctools-0.36 → tariochbctools-0.38}/LICENSE.txt +0 -0
  17. {tariochbctools-0.36 → tariochbctools-0.38}/MANIFEST.in +0 -0
  18. {tariochbctools-0.36 → tariochbctools-0.38}/README.rst +0 -0
  19. {tariochbctools-0.36 → tariochbctools-0.38}/docs/_static/.gitignore +0 -0
  20. {tariochbctools-0.36 → tariochbctools-0.38}/docs/conf.py +0 -0
  21. {tariochbctools-0.36 → tariochbctools-0.38}/docs/index.rst +0 -0
  22. {tariochbctools-0.36 → tariochbctools-0.38}/docs/installation.rst +0 -0
  23. {tariochbctools-0.36 → tariochbctools-0.38}/docs/license.rst +0 -0
  24. {tariochbctools-0.36 → tariochbctools-0.38}/docs/plugins.rst +0 -0
  25. {tariochbctools-0.36 → tariochbctools-0.38}/docs/price_fetchers.rst +0 -0
  26. {tariochbctools-0.36 → tariochbctools-0.38}/docs/requirements.txt +0 -0
  27. {tariochbctools-0.36 → tariochbctools-0.38}/pyproject.toml +0 -0
  28. {tariochbctools-0.36 → tariochbctools-0.38}/setup.cfg +0 -0
  29. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/__init__.py +0 -0
  30. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/__init__.py +0 -0
  31. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/bcge/__init__.py +0 -0
  32. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/bcge/importer.py +0 -0
  33. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/bitst/__init__.py +0 -0
  34. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/bitst/importer.py +0 -0
  35. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/blockchain/__init__.py +0 -0
  36. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/blockchain/importer.py +0 -0
  37. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/cembrastatement/__init__.py +0 -0
  38. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/cembrastatement/importer.py +0 -0
  39. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/general/__init__.py +0 -0
  40. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/general/mailAdapterImporter.py +0 -0
  41. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/general/mt940importer.py +0 -0
  42. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/ibkr/__init__.py +0 -0
  43. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/ibkr/importer.py +0 -0
  44. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/neon/__init__.py +0 -0
  45. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/neon/importer.py +0 -0
  46. {tariochbctools-0.36/src/tariochbctools/importers/nordigen → tariochbctools-0.38/src/tariochbctools/importers/netbenefits}/__init__.py +0 -0
  47. {tariochbctools-0.36/src/tariochbctools/importers/postfinance → tariochbctools-0.38/src/tariochbctools/importers/nordigen}/__init__.py +0 -0
  48. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/nordigen/importer.py +0 -0
  49. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/nordigen/nordigen_config.py +0 -0
  50. {tariochbctools-0.36/src/tariochbctools/importers/quickfile → tariochbctools-0.38/src/tariochbctools/importers/postfinance}/__init__.py +0 -0
  51. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/postfinance/importer.py +0 -0
  52. {tariochbctools-0.36/src/tariochbctools/importers/revolut → tariochbctools-0.38/src/tariochbctools/importers/quickfile}/__init__.py +0 -0
  53. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/quickfile/importer.py +0 -0
  54. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/raiffeisench/importer.py +0 -0
  55. {tariochbctools-0.36/src/tariochbctools/importers/schedule → tariochbctools-0.38/src/tariochbctools/importers/revolut}/__init__.py +0 -0
  56. {tariochbctools-0.36/src/tariochbctools/importers/swisscard → tariochbctools-0.38/src/tariochbctools/importers/schedule}/__init__.py +0 -0
  57. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/schedule/importer.py +0 -0
  58. {tariochbctools-0.36/src/tariochbctools/importers/transferwise → tariochbctools-0.38/src/tariochbctools/importers/swisscard}/__init__.py +0 -0
  59. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/swisscard/importer.py +0 -0
  60. {tariochbctools-0.36/src/tariochbctools/importers/truelayer → tariochbctools-0.38/src/tariochbctools/importers/transferwise}/__init__.py +0 -0
  61. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/transferwise/importer.py +0 -0
  62. {tariochbctools-0.36/src/tariochbctools/importers/viseca → tariochbctools-0.38/src/tariochbctools/importers/truelayer}/__init__.py +0 -0
  63. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/truelayer/importer.py +0 -0
  64. {tariochbctools-0.36/src/tariochbctools/importers/zak → tariochbctools-0.38/src/tariochbctools/importers/viseca}/__init__.py +0 -0
  65. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/viseca/importer.py +0 -0
  66. {tariochbctools-0.36/src/tariochbctools/importers/zkb → tariochbctools-0.38/src/tariochbctools/importers/zak}/__init__.py +0 -0
  67. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/zak/importer.py +0 -0
  68. {tariochbctools-0.36/src/tariochbctools/plugins/prices → tariochbctools-0.38/src/tariochbctools/importers/zkb}/__init__.py +0 -0
  69. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/importers/zkb/importer.py +0 -0
  70. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/plugins/__init__.py +0 -0
  71. {tariochbctools-0.36/tests → tariochbctools-0.38/src/tariochbctools/plugins/prices}/__init__.py +0 -0
  72. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools/plugins/prices/ibkr.py +0 -0
  73. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/dependency_links.txt +0 -0
  74. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/entry_points.txt +0 -0
  75. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/not-zip-safe +0 -0
  76. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/requires.txt +0 -0
  77. {tariochbctools-0.36 → tariochbctools-0.38}/src/tariochbctools.egg-info/top_level.txt +0 -0
  78. {tariochbctools-0.36/tests/tariochbctools → tariochbctools-0.38/tests}/__init__.py +0 -0
  79. {tariochbctools-0.36 → tariochbctools-0.38}/tests/conftest.py +0 -0
  80. {tariochbctools-0.36/tests/tariochbctools/importers → tariochbctools-0.38/tests/tariochbctools}/__init__.py +0 -0
  81. {tariochbctools-0.36/tests/tariochbctools/plugins → tariochbctools-0.38/tests/tariochbctools/importers}/__init__.py +0 -0
  82. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/importers/test_quickfile.py +0 -0
  83. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/importers/test_truelayer.py +0 -0
  84. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/entry_already_exists_expected.beancount +0 -0
  85. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/entry_already_exists_input.beancount +0 -0
  86. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/missing_fx_expected.beancount +0 -0
  87. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/missing_fx_input.beancount +0 -0
  88. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/normal_expected.beancount +0 -0
  89. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/data/generate_base_ccy_prices/normal_input.beancount +0 -0
  90. {tariochbctools-0.36 → tariochbctools-0.38}/tests/tariochbctools/plugins/test_generate_base_ccy_prices.py +0 -0
  91. {tariochbctools-0.36 → tariochbctools-0.38}/tox.ini +0 -0
@@ -2,7 +2,7 @@ exclude: '^docs/conf.py'
2
2
 
3
3
  repos:
4
4
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
- rev: v4.5.0
5
+ rev: v4.6.0
6
6
  hooks:
7
7
  - id: trailing-whitespace
8
8
  - id: check-added-large-files
@@ -23,19 +23,19 @@ repos:
23
23
  - id: isort
24
24
 
25
25
  - repo: https://github.com/psf/black
26
- rev: 23.12.1
26
+ rev: 24.4.2
27
27
  hooks:
28
28
  - id: black
29
29
  language_version: python3
30
30
 
31
31
  - repo: https://github.com/asottile/blacken-docs
32
- rev: 1.16.0
32
+ rev: 1.18.0
33
33
  hooks:
34
34
  - id: blacken-docs
35
35
  additional_dependencies: [black]
36
36
 
37
37
  - repo: https://github.com/PyCQA/flake8
38
- rev: 7.0.0
38
+ rev: 7.1.0
39
39
  hooks:
40
40
  - id: flake8
41
41
  additional_dependencies: [flake8-print]
@@ -49,7 +49,7 @@ repos:
49
49
  files: README.rst
50
50
 
51
51
  - repo: https://github.com/pre-commit/mirrors-mypy
52
- rev: v1.8.0
52
+ rev: v1.10.1
53
53
  hooks:
54
54
  - id: mypy
55
55
  args: [--install-types, --non-interactive, --ignore-missing-imports]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tariochbctools
3
- Version: 0.36
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
@@ -402,10 +402,33 @@ Import mt940 from `BCGE <https://www.bcge.ch/>`__
402
402
  Swisscard cards
403
403
  ---------------
404
404
 
405
- Import Swisscard's `Cashback Cards <https://www.cashback-cards.ch/>` transactions from a CSV export.__
405
+ Import Swisscard's `Cashback Cards <https://www.cashback-cards.ch/>` transactions from a CSV export.
406
406
 
407
407
  .. code-block:: python
408
408
 
409
409
  from tariochbctools.importers.swisscard import importer as swisscard
410
410
 
411
411
  CONFIG = [swisscard.SwisscardImporter("swisscard/.*\.csv", "Liabilities:Cashback")]
412
+
413
+ Fidelity Netbenefits
414
+ --------------------
415
+
416
+ Import Fidelity Netbenefits `<https://netbenefits.fidelity.com/>` transactions from a CSV export of the activities.
417
+
418
+ .. code-block:: python
419
+
420
+ from tariochbctools.importers.netbenefits import importer as netbenefits
421
+
422
+ CONFIG = [
423
+ netbenefits.Importer(
424
+ regexps="Transaction history\.csv",
425
+ cashAccount="Assets:Netbenefits:USD",
426
+ investmentAccount="Assets:Netbenefits:SYMBOL",
427
+ dividendAccount="Income:Interest",
428
+ taxAccount="Expenses:Tax",
429
+ capGainAccount="Income:Capitalgain",
430
+ symbol="SYMBOL",
431
+ ignoreTypes=["REINVESTMENT REINVEST @ $1.000"],
432
+ baseCcy="CHF",
433
+ )
434
+ ]
@@ -6,6 +6,7 @@
6
6
  PyScaffold helps you to put up the scaffold of your new Python project.
7
7
  Learn more under: https://pyscaffold.org/
8
8
  """
9
+
9
10
  from setuptools import setup
10
11
 
11
12
  if __name__ == "__main__":
@@ -1,16 +1,25 @@
1
1
  from datetime import date
2
2
 
3
3
  from beancount.core import amount, prices
4
+ from beancount.core.number import D
4
5
 
5
6
 
6
7
  class PriceLookup:
7
8
  def __init__(self, existing_entries, baseCcy: str):
8
- self.priceMap = prices.build_price_map(existing_entries)
9
+ if existing_entries:
10
+ self.priceMap = prices.build_price_map(existing_entries)
11
+ else:
12
+ self.priceMap = None
9
13
  self.baseCcy = baseCcy
10
14
 
11
15
  def fetchPriceAmount(self, instrument: str, date: date):
12
- price = prices.get_price(self.priceMap, tuple([instrument, self.baseCcy]), date)
13
- return price[1]
16
+ if self.priceMap:
17
+ price = prices.get_price(
18
+ self.priceMap, tuple([instrument, self.baseCcy]), date
19
+ )
20
+ return price[1]
21
+ else:
22
+ return D(1)
14
23
 
15
24
  def fetchPrice(self, instrument: str, date: date):
16
25
  if instrument == self.baseCcy:
@@ -0,0 +1,173 @@
1
+ import csv
2
+ from collections.abc import Iterable
3
+ from datetime import date
4
+ from io import StringIO
5
+
6
+ from beancount.core import amount, data
7
+ from beancount.core.number import D
8
+ from beancount.core.position import CostSpec
9
+ from beancount.ingest import importer
10
+ from beancount.ingest.importers.mixins import identifier
11
+ from dateutil.parser import parse
12
+
13
+ from tariochbctools.importers.general.priceLookup import PriceLookup
14
+
15
+
16
+ class Importer(identifier.IdentifyMixin, importer.ImporterProtocol):
17
+ """An importer for Fidelity Netbenefits Activity CSV files."""
18
+
19
+ def __init__(
20
+ self,
21
+ regexps: str | Iterable[str],
22
+ cashAccount: str,
23
+ investmentAccount: str,
24
+ dividendAccount: str,
25
+ taxAccount: str,
26
+ capGainAccount: str,
27
+ symbol: str,
28
+ ignoreTypes: Iterable[str],
29
+ baseCcy: str,
30
+ ):
31
+ identifier.IdentifyMixin.__init__(self, matchers=[("filename", regexps)])
32
+ self.cashAccount = cashAccount
33
+ self.investmentAccount = investmentAccount
34
+ self.dividendAccount = dividendAccount
35
+ self.taxAccount = taxAccount
36
+ self.capGainAccount = capGainAccount
37
+ self.symbol = symbol
38
+ self.ignoreTypes = ignoreTypes
39
+ self.baseCcy = baseCcy
40
+
41
+ def name(self):
42
+ return super().name() + self.cashAccount
43
+
44
+ def file_account(self, file):
45
+ return self.cashAccount
46
+
47
+ def extract(self, file, existing_entries):
48
+ entries = []
49
+
50
+ self.priceLookup = PriceLookup(existing_entries, self.baseCcy)
51
+
52
+ with StringIO(file.contents()) as csvfile:
53
+ reader = csv.DictReader(
54
+ csvfile,
55
+ [
56
+ "Transaction date",
57
+ "Transaction type",
58
+ "Investment name",
59
+ "Shares",
60
+ "Amount",
61
+ ],
62
+ delimiter=",",
63
+ skipinitialspace=True,
64
+ )
65
+ next(reader)
66
+ for row in reader:
67
+ if not row["Transaction type"]:
68
+ break
69
+
70
+ if row["Transaction type"] in self.ignoreTypes:
71
+ continue
72
+
73
+ book_date = parse(row["Transaction date"].strip()).date()
74
+ amt = amount.Amount(D(row["Amount"].replace("$", "")), "USD")
75
+ shares = None
76
+ if row["Shares"] != "-":
77
+ shares = amount.Amount(D(row["Shares"]), self.symbol)
78
+
79
+ metakv = {}
80
+
81
+ if not amt and not shares:
82
+ continue
83
+
84
+ meta = data.new_metadata(file.name, 0, metakv)
85
+ description = row["Transaction type"].strip()
86
+
87
+ if "TAX" in description:
88
+ postings = self.__createDividend(amt, book_date, self.taxAccount)
89
+ elif "DIVIDEND" in description:
90
+ postings = self.__createDividend(
91
+ amt, book_date, self.dividendAccount
92
+ )
93
+ elif "YOU BOUGHT" in description:
94
+ postings = self.__createBuy(amt, shares, book_date)
95
+ elif "YOU SOLD" in description:
96
+ postings = self.__createSell(amt, shares, book_date)
97
+ else:
98
+ postings = [
99
+ data.Posting(self.cashAccount, amt, None, None, None, None),
100
+ ]
101
+
102
+ if shares is not None:
103
+ postings.append(
104
+ data.Posting(
105
+ self.investmentAccount, shares, None, None, None, None
106
+ ),
107
+ )
108
+
109
+ entry = data.Transaction(
110
+ meta,
111
+ book_date,
112
+ "*",
113
+ "",
114
+ description,
115
+ data.EMPTY_SET,
116
+ data.EMPTY_SET,
117
+ postings,
118
+ )
119
+ entries.append(entry)
120
+
121
+ return entries
122
+
123
+ def __createBuy(self, amt: amount, shares: amount, book_date: date):
124
+ price = self.priceLookup.fetchPrice("USD", book_date)
125
+ cost = CostSpec(
126
+ number_per=None,
127
+ number_total=round(-amt.number * price.number, 2),
128
+ currency=self.baseCcy,
129
+ date=None,
130
+ label=None,
131
+ merge=None,
132
+ )
133
+ postings = [
134
+ data.Posting(self.investmentAccount, shares, cost, None, None, None),
135
+ data.Posting(self.cashAccount, amt, None, price, None, None),
136
+ ]
137
+
138
+ return postings
139
+
140
+ def __createSell(self, amt: amount, shares: amount, book_date: date):
141
+ price = self.priceLookup.fetchPrice("USD", book_date)
142
+ cost = CostSpec(
143
+ number_per=None,
144
+ number_total=None,
145
+ currency=None,
146
+ date=None,
147
+ label=None,
148
+ merge=None,
149
+ )
150
+ postings = [
151
+ data.Posting(self.investmentAccount, shares, cost, None, None, None),
152
+ data.Posting(self.cashAccount, amt, None, price, None, None),
153
+ data.Posting(self.capGainAccount, None, None, None, None, None),
154
+ ]
155
+
156
+ return postings
157
+
158
+ def __createDividend(self, amt: amount, book_date: date, incomeAccount: str):
159
+ price = self.priceLookup.fetchPrice("USD", book_date)
160
+ postings = [
161
+ data.Posting(
162
+ self.investmentAccount,
163
+ amount.Amount(D(0), self.symbol),
164
+ None,
165
+ None,
166
+ None,
167
+ None,
168
+ ),
169
+ data.Posting(self.cashAccount, amt, None, price, None, None),
170
+ data.Posting(incomeAccount, None, None, None, None, None),
171
+ ]
172
+
173
+ return postings
@@ -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,7 @@
1
1
  """A plugin that verifies that on each transaction, all the "portfolios" have
2
2
  the same weight.
3
3
  """
4
+
4
5
  import collections
5
6
  from collections import defaultdict
6
7
  from decimal import Decimal
@@ -1,6 +1,7 @@
1
1
  """A plugin that inserts an additional price to the base rate by applying
2
2
  fx rate to a price.
3
3
  """
4
+
4
5
  from beancount.core import amount, data, prices
5
6
 
6
7
  __plugins__ = ["generate"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tariochbctools
3
- Version: 0.36
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
@@ -43,6 +43,8 @@ src/tariochbctools/importers/ibkr/__init__.py
43
43
  src/tariochbctools/importers/ibkr/importer.py
44
44
  src/tariochbctools/importers/neon/__init__.py
45
45
  src/tariochbctools/importers/neon/importer.py
46
+ src/tariochbctools/importers/netbenefits/__init__.py
47
+ src/tariochbctools/importers/netbenefits/importer.py
46
48
  src/tariochbctools/importers/nordigen/__init__.py
47
49
  src/tariochbctools/importers/nordigen/importer.py
48
50
  src/tariochbctools/importers/nordigen/nordigen_config.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes