Show pending transactions
This commit is contained in:
parent
77dcd4dd8f
commit
1c0cbba855
|
@ -247,7 +247,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
totals[currency] = amount
|
totals[currency] = amount
|
||||||
return totals
|
return totals
|
||||||
|
|
||||||
def normalise_transactions(self, transactions):
|
def normalise_transactions(self, transactions, state=None):
|
||||||
for transaction in transactions:
|
for transaction in transactions:
|
||||||
# Rename ID
|
# Rename ID
|
||||||
if "transactionId" in transaction:
|
if "transactionId" in transaction:
|
||||||
|
@ -275,6 +275,8 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
|
|
||||||
transaction["amount"] = float(transaction["transactionAmount"]["amount"])
|
transaction["amount"] = float(transaction["transactionAmount"]["amount"])
|
||||||
transaction["currency"] = transaction["transactionAmount"]["currency"]
|
transaction["currency"] = transaction["transactionAmount"]["currency"]
|
||||||
|
if state:
|
||||||
|
transaction["state"] = state
|
||||||
del transaction["transactionAmount"]
|
del transaction["transactionAmount"]
|
||||||
|
|
||||||
if transaction["remittanceInformationUnstructuredArray"]:
|
if transaction["remittanceInformationUnstructuredArray"]:
|
||||||
|
@ -289,7 +291,7 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
else:
|
else:
|
||||||
raise Exception(f"No way to get reference: {transaction}")
|
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.
|
Get all transactions for an account.
|
||||||
:param account_id: account to fetch transactions for
|
:param account_id: account to fetch transactions for
|
||||||
|
@ -298,9 +300,15 @@ class NordigenClient(BaseClient, AggregatorClient):
|
||||||
"""
|
"""
|
||||||
path = f"accounts/{account_id}/transactions"
|
path = f"accounts/{account_id}/transactions"
|
||||||
response = await self.call(path, schema="Transactions")
|
response = await self.call(path, schema="Transactions")
|
||||||
|
print("RESP", response["pending"])
|
||||||
parsed = response["booked"]
|
parsed = response["booked"]
|
||||||
self.normalise_transactions(parsed)
|
self.normalise_transactions(parsed, state="booked")
|
||||||
|
|
||||||
if process:
|
if process:
|
||||||
await self.process_transactions(parsed)
|
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
|
return parsed
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
{% get_last_invalidation 'core.Aggregator' as last %}
|
{% get_last_invalidation 'core.Aggregator' as last %}
|
||||||
{% include 'mixins/partials/notify.html' %}
|
{% include 'mixins/partials/notify.html' %}
|
||||||
{# cache 600 objects_banks_transactions request.user.id object_list type last #}
|
{# cache 600 objects_banks_transactions request.user.id object_list type last #}
|
||||||
|
|
||||||
<table
|
<table
|
||||||
class="table is-fullwidth is-hoverable"
|
class="table is-fullwidth is-hoverable"
|
||||||
hx-target="#{{ context_object_name }}-table"
|
hx-target="#{{ context_object_name }}-table"
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
<th>amount</th>
|
<th>amount</th>
|
||||||
<th>currency</th>
|
<th>currency</th>
|
||||||
<th>reference</th>
|
<th>reference</th>
|
||||||
|
<th>state</th>
|
||||||
</thead>
|
</thead>
|
||||||
{% for item in object_list %}
|
{% for item in object_list %}
|
||||||
<tr class="
|
<tr class="
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a
|
<a
|
||||||
class="has-text-grey"
|
class="has-text-grey"
|
||||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.transaction_id }}/');">
|
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.transaction_id }}');">
|
||||||
<span class="icon" data-tooltip="Copy to clipboard">
|
<span class="icon" data-tooltip="Copy to clipboard">
|
||||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
|
@ -50,6 +52,17 @@
|
||||||
<td>{{ item.amount }}</td>
|
<td>{{ item.amount }}</td>
|
||||||
<td>{{ item.currency }}</td>
|
<td>{{ item.currency }}</td>
|
||||||
<td>{{ item.reference }}</td>
|
<td>{{ item.reference }}</td>
|
||||||
|
<td>
|
||||||
|
{% if item.state == 'pending' %}
|
||||||
|
<span class="icon has-text-warning" data-tooltip="Pending">
|
||||||
|
<i class="fa-solid fa-hourglass" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
{% elif item.state == 'booked' %}
|
||||||
|
<span class="icon has-text-success" data-tooltip="Booked">
|
||||||
|
<i class="fa-solid fa-check" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -121,5 +121,5 @@ class BanksTransactions(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
run = synchronize_async_helper(NordigenClient(aggregator))
|
run = synchronize_async_helper(NordigenClient(aggregator))
|
||||||
transactions = synchronize_async_helper(run.get_transactions(account_id))
|
transactions = synchronize_async_helper(run.get_transactions(account_id, pending=True))
|
||||||
return transactions
|
return transactions
|
||||||
|
|
Loading…
Reference in New Issue