Show pending transactions
This commit is contained in:
@@ -247,7 +247,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||
totals[currency] = amount
|
||||
return totals
|
||||
|
||||
def normalise_transactions(self, transactions):
|
||||
def normalise_transactions(self, transactions, state=None):
|
||||
for transaction in transactions:
|
||||
# Rename ID
|
||||
if "transactionId" in transaction:
|
||||
@@ -275,6 +275,8 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||
|
||||
transaction["amount"] = float(transaction["transactionAmount"]["amount"])
|
||||
transaction["currency"] = transaction["transactionAmount"]["currency"]
|
||||
if state:
|
||||
transaction["state"] = state
|
||||
del transaction["transactionAmount"]
|
||||
|
||||
if transaction["remittanceInformationUnstructuredArray"]:
|
||||
@@ -289,7 +291,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||
else:
|
||||
raise Exception(f"No way to get reference: {transaction}")
|
||||
|
||||
async def get_transactions(self, account_id, process=False):
|
||||
async def get_transactions(self, account_id, process=False, pending=False):
|
||||
"""
|
||||
Get all transactions for an account.
|
||||
:param account_id: account to fetch transactions for
|
||||
@@ -298,9 +300,15 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||
"""
|
||||
path = f"accounts/{account_id}/transactions"
|
||||
response = await self.call(path, schema="Transactions")
|
||||
|
||||
print("RESP", response["pending"])
|
||||
parsed = response["booked"]
|
||||
self.normalise_transactions(parsed)
|
||||
self.normalise_transactions(parsed, state="booked")
|
||||
|
||||
if process:
|
||||
await self.process_transactions(parsed)
|
||||
if pending:
|
||||
parsed_pending = response["pending"]
|
||||
self.normalise_transactions(parsed_pending, state="pending")
|
||||
parsed_pending.extend(parsed)
|
||||
parsed = parsed_pending
|
||||
return parsed
|
||||
|
||||
Reference in New Issue
Block a user