|
|
|
@ -316,6 +316,7 @@ class Nordigen(util.Base):
|
|
|
|
|
existing_entry = loads(settings.Nordigen.Maps)
|
|
|
|
|
self.banks = existing_entry
|
|
|
|
|
|
|
|
|
|
@inlineCallbacks
|
|
|
|
|
def map_account(self, account_id): # TODO: inlineCallbacks?
|
|
|
|
|
"""
|
|
|
|
|
Map an account_id at a bank to an account_name.
|
|
|
|
@ -323,7 +324,7 @@ class Nordigen(util.Base):
|
|
|
|
|
Data type: {"monzo": [account, ids, here],
|
|
|
|
|
"revolut": [account, ids, here]}
|
|
|
|
|
"""
|
|
|
|
|
account_data = self.get_account(account_id)
|
|
|
|
|
account_data = yield self.get_account(account_id)
|
|
|
|
|
currency = account_data["currency"]
|
|
|
|
|
|
|
|
|
|
existing_entry = loads(settings.Nordigen.Maps)
|
|
|
|
@ -445,7 +446,7 @@ class Nordigen(util.Base):
|
|
|
|
|
obj = AccountBalancesRoot.from_json(r.content)
|
|
|
|
|
except ValidationError as err:
|
|
|
|
|
self.log.error(f"Validation error: {err}")
|
|
|
|
|
return
|
|
|
|
|
return (False, False)
|
|
|
|
|
parsed = obj.to_dict()["balances"]
|
|
|
|
|
total = 0
|
|
|
|
|
currency = None
|
|
|
|
@ -453,7 +454,7 @@ class Nordigen(util.Base):
|
|
|
|
|
if currency:
|
|
|
|
|
if not currency == entry["balanceAmount"]["currency"]:
|
|
|
|
|
self.log.error("Different currencies in balance query.")
|
|
|
|
|
return
|
|
|
|
|
return (False, False)
|
|
|
|
|
if not entry["balanceType"] == "interimBooked":
|
|
|
|
|
continue
|
|
|
|
|
total += float(entry["balanceAmount"]["amount"])
|
|
|
|
@ -471,6 +472,8 @@ class Nordigen(util.Base):
|
|
|
|
|
currency, amount = self.get_balance(account_id)
|
|
|
|
|
if not amount:
|
|
|
|
|
continue
|
|
|
|
|
if not currency:
|
|
|
|
|
continue
|
|
|
|
|
if currency in totals:
|
|
|
|
|
totals[currency] += amount
|
|
|
|
|
else:
|
|
|
|
|