tariochbctools 1.5.0__py2.py3-none-any.whl → 1.5.1__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.
- tariochbctools/importers/truelayer/importer.py +60 -32
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/METADATA +1 -1
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/RECORD +7 -7
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/WHEEL +0 -0
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/entry_points.txt +0 -0
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/licenses/LICENSE.txt +0 -0
- {tariochbctools-1.5.0.dist-info → tariochbctools-1.5.1.dist-info}/top_level.txt +0 -0
@@ -10,6 +10,8 @@ import yaml
|
|
10
10
|
from beancount.core import amount, data
|
11
11
|
from beancount.core.number import D
|
12
12
|
|
13
|
+
from tariochbctools.importers.general.deduplication import ReferenceDuplicatesComparator
|
14
|
+
|
13
15
|
# https://docs.truelayer.com/#retrieve-account-transactions
|
14
16
|
|
15
17
|
TX_MANDATORY_ID_FIELDS = ("transaction_id",)
|
@@ -125,6 +127,17 @@ class Importer(beangulp.Importer):
|
|
125
127
|
logging.warning("Ignoring account ID %s", accountId)
|
126
128
|
continue
|
127
129
|
|
130
|
+
r = requests.get(
|
131
|
+
f"https://api.{self.domain}/data/v1/{endpoint}/{accountId}/balance",
|
132
|
+
headers=headers,
|
133
|
+
)
|
134
|
+
balances = r.json()["results"]
|
135
|
+
|
136
|
+
for balance in balances:
|
137
|
+
entries.extend(
|
138
|
+
self._extract_balance(balance, local_account, invert_sign)
|
139
|
+
)
|
140
|
+
|
128
141
|
r = requests.get(
|
129
142
|
f"https://api.{self.domain}/data/v1/{endpoint}/{accountId}/transactions",
|
130
143
|
headers=headers,
|
@@ -148,7 +161,7 @@ class Importer(beangulp.Importer):
|
|
148
161
|
invert_sign: bool,
|
149
162
|
) -> data.Transaction:
|
150
163
|
entries = []
|
151
|
-
metakv = {}
|
164
|
+
metakv: dict[str, Any] = {}
|
152
165
|
|
153
166
|
id_meta_kvs = {
|
154
167
|
k: trx["meta"][k] for k in TX_OPTIONAL_META_ID_FIELDS if trx["meta"].get(k)
|
@@ -193,37 +206,52 @@ class Importer(beangulp.Importer):
|
|
193
206
|
)
|
194
207
|
entries.append(entry)
|
195
208
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
209
|
+
return entries
|
210
|
+
|
211
|
+
def _extract_balance(
|
212
|
+
self,
|
213
|
+
result: dict[str, Any],
|
214
|
+
local_account: data.Account,
|
215
|
+
invert_sign: bool,
|
216
|
+
) -> data.Transaction:
|
217
|
+
entries = []
|
218
|
+
|
219
|
+
meta = data.new_metadata("", 0)
|
220
|
+
|
221
|
+
balance = D(str(result["current"]))
|
222
|
+
# avoid pylint invalid-unary-operand-type
|
223
|
+
signed_balance = -1 * balance if invert_sign else balance
|
224
|
+
balance_date = dateutil.parser.parse(result["update_timestamp"]).date()
|
225
|
+
|
226
|
+
entries.append(
|
227
|
+
data.Balance(
|
228
|
+
meta,
|
229
|
+
balance_date + timedelta(days=1),
|
230
|
+
local_account,
|
231
|
+
amount.Amount(signed_balance, result["currency"]),
|
232
|
+
None,
|
233
|
+
None,
|
234
|
+
)
|
235
|
+
)
|
236
|
+
|
237
|
+
if "last_statement_balance" in result:
|
238
|
+
statement_balance = D(str(result["last_statement_balance"]))
|
239
|
+
signed_statement_balance = (
|
240
|
+
-1 * statement_balance if invert_sign else statement_balance
|
241
|
+
)
|
242
|
+
statement_date = dateutil.parser.parse(result["last_statement_date"]).date()
|
243
|
+
|
244
|
+
entries.append(
|
245
|
+
data.Balance(
|
246
|
+
meta,
|
247
|
+
statement_date,
|
248
|
+
local_account,
|
249
|
+
amount.Amount(signed_statement_balance, result["currency"]),
|
250
|
+
None,
|
251
|
+
None,
|
227
252
|
)
|
253
|
+
)
|
228
254
|
|
229
255
|
return entries
|
256
|
+
|
257
|
+
cmp = ReferenceDuplicatesComparator(TX_MANDATORY_ID_FIELDS)
|
@@ -41,7 +41,7 @@ tariochbctools/importers/swisscard/importer.py,sha256=84nyAHzz5Y8mHw-zCkoUE0CsaE
|
|
41
41
|
tariochbctools/importers/transferwise/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
42
|
tariochbctools/importers/transferwise/importer.py,sha256=IdtNmrLHKxrBBBVLf8Qgysw0Mx8XswF4cZv9iRl2b3g,6312
|
43
43
|
tariochbctools/importers/truelayer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
-
tariochbctools/importers/truelayer/importer.py,sha256=
|
44
|
+
tariochbctools/importers/truelayer/importer.py,sha256=rHJdbqP9wT1BackBq7lIoLAT04D-MM0Bc3-YtQSZF1c,7875
|
45
45
|
tariochbctools/importers/viseca/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
46
46
|
tariochbctools/importers/viseca/importer.py,sha256=U9HHmRyIutJYuAtS-W3gHW4kJYEfnyJmnrOVVMmZQAY,3346
|
47
47
|
tariochbctools/importers/zak/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -53,9 +53,9 @@ tariochbctools/plugins/check_portfolio_sum.py,sha256=naJ2j6BFpQhJhT2c-gfjyIdcYe0
|
|
53
53
|
tariochbctools/plugins/generate_base_ccy_prices.py,sha256=4CDzUosjMWCZfsBJMLrf-i5WNCHexI2rdm5vIDYW-AI,1314
|
54
54
|
tariochbctools/plugins/prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
55
|
tariochbctools/plugins/prices/ibkr.py,sha256=GYCjnlF-MK-ZFPEr0M6T4iO3Etq0tMmrMlsHGInXUO8,1405
|
56
|
-
tariochbctools-1.5.
|
57
|
-
tariochbctools-1.5.
|
58
|
-
tariochbctools-1.5.
|
59
|
-
tariochbctools-1.5.
|
60
|
-
tariochbctools-1.5.
|
61
|
-
tariochbctools-1.5.
|
56
|
+
tariochbctools-1.5.1.dist-info/licenses/LICENSE.txt,sha256=VR2hkz3p9Sw4hSXc7S5iZTOXGeV4h-i8AO_q0zEmtkE,1074
|
57
|
+
tariochbctools-1.5.1.dist-info/METADATA,sha256=ByXtYGQYJRS1tEQFArWce0cdpm13CHQmQBH-r7yJ8zY,2180
|
58
|
+
tariochbctools-1.5.1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
59
|
+
tariochbctools-1.5.1.dist-info/entry_points.txt,sha256=bo7wO1u-PIDHNuqsTEekC56VCAmn2i2vTRcKXxqc770,158
|
60
|
+
tariochbctools-1.5.1.dist-info/top_level.txt,sha256=CiA_NepCI6zDNsaORA55zmpuJFSnTvLESraIL13xiOQ,15
|
61
|
+
tariochbctools-1.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|